]> git.sesse.net Git - vlc/blob - modules/gui/pda/pda_callbacks.c
PDA Interface:
[vlc] / modules / gui / pda / pda_callbacks.c
1 /*****************************************************************************
2  * pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
3  *****************************************************************************
4  * Copyright (C) 2000, 2001 VideoLAN
5  * $Id: pda_callbacks.c,v 1.15 2003/11/21 09:23:49 jpsaman Exp $
6  *
7  * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <sys/types.h>                                              /* off_t */
28 #include <stdlib.h>
29 #include <vlc/vlc.h>
30 #include <vlc/intf.h>
31 #include <vlc/vout.h>
32
33 #include <stdio.h>
34 #include <string.h>
35 #include <dirent.h>
36 #include <sys/stat.h>
37 #include <unistd.h>
38 #include <pwd.h>
39 #include <grp.h>
40
41 #ifdef HAVE_CONFIG_H
42 #  include <config.h>
43 #endif
44
45 #include <gtk/gtk.h>
46
47 #include "pda_callbacks.h"
48 #include "pda_interface.h"
49 #include "pda_support.h"
50 #include "pda.h"
51
52 #define VLC_MAX_MRL     256
53
54 static char *get_file_perms(struct stat st);
55
56 /*****************************************************************************
57  * Useful function to retrieve p_intf
58  ****************************************************************************/
59 void * E_(__GtkGetIntf)( GtkWidget * widget )
60 {
61     void *p_data;
62
63     if( GTK_IS_MENU_ITEM( widget ) )
64     {
65         /* Look for a GTK_MENU */
66         while( widget->parent && !GTK_IS_MENU( widget ) )
67         {
68             widget = widget->parent;
69         }
70
71         /* Maybe this one has the data */
72         p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
73         if( p_data )
74         {
75             return p_data;
76         }
77
78         /* Otherwise, the parent widget has it */
79         widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
80     }
81
82     /* We look for the top widget */
83     widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) );
84
85     p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
86
87     return p_data;
88 }
89
90 void PlaylistAddItem(GtkWidget *widget, gchar *name)
91 {
92     GtkTreeView  *p_tvplaylist = NULL;
93
94     /* Add to playlist object. */
95     p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(widget), "tvPlaylist");
96     if (p_tvplaylist)
97     {
98         GtkTreeModel *p_play_model;
99         GtkTreeIter   p_play_iter;
100
101         p_play_model = gtk_tree_view_get_model(p_tvplaylist);
102
103         if (p_play_model)
104         {
105             /* Add a new row to the playlist treeview model */
106             gtk_list_store_append (GTK_LIST_STORE(p_play_model), &p_play_iter);
107             gtk_list_store_set (GTK_LIST_STORE(p_play_model), &p_play_iter,
108                                     0, name,   /* Add path to it !!! */
109                                     1, "no info",
110                                     -1 );
111         }
112     }
113 }
114
115 void PlaylistRebuildListStore( GtkListStore * p_list, playlist_t * p_playlist )
116 {
117     GtkTreeIter iter;
118     int         i_dummy;
119     gchar *     ppsz_text[2];
120     GdkColor    red;
121     red.red     = 65535;
122     red.blue    = 0;
123     red.green   = 0;
124
125     vlc_mutex_lock( &p_playlist->object_lock );
126     for( i_dummy = p_playlist->i_size ; i_dummy-- ; )
127     {
128         ppsz_text[0] = p_playlist->pp_items[i_dummy]->psz_name;
129         ppsz_text[1] = "no info";
130         gtk_list_store_append (p_list, &iter);
131         gtk_list_store_set (p_list, &iter,
132                             0, ppsz_text[0],
133                             1, ppsz_text[1],
134                             -1);
135     }
136     vlc_mutex_unlock( &p_playlist->object_lock );
137 }
138
139 #if 0
140 void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
141 {
142     intf_thread_t *p_intf = GtkGetIntf( widget );
143     playlist_t   *p_playlist;
144
145     p_playlist = (playlist_t *)
146              vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
147
148     if( p_playlist ==  NULL)
149     {
150         return;
151     }
152
153     if( p_playlist )
154     {
155         if (p_intf->p_sys->b_autoplayfile)
156         {
157             playlist_Add( p_playlist, (char*)psz_url, 0, 0,
158                           PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END);
159         }
160         else
161         {
162             playlist_Add( p_playlist, (char*)psz_url, 0, 0,
163                           PLAYLIST_APPEND, PLAYLIST_END );
164         }
165         vlc_object_release(  p_playlist );
166
167         PlaylistAddItem(GTK_WIDGET(widget), psz_url);
168     }
169 }
170 #endif
171
172 /*****************************************************************
173  * Read directory helper function.
174  ****************************************************************/
175 void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
176 {
177     GtkTreeIter    iter;
178     struct dirent **namelist;
179     struct passwd *pw;
180     struct group  *grp;
181     struct stat    st;
182     int n=-1, status=-1;
183
184     msg_Dbg(p_intf, "Changing to dir %s", psz_dir);
185     if (psz_dir)
186     {
187        status = chdir(psz_dir);
188        if (status<0)
189           msg_Dbg(p_intf, "permision denied" );
190     }
191     n = scandir(".", &namelist, 0, alphasort);
192
193     if (n<0)
194         perror("scandir");
195     else
196     {
197         int i;
198         gchar *ppsz_text[4];
199
200         if (lstat("..", &st)==0)
201         {
202             /* user, group  */
203             pw  = getpwuid(st.st_uid);
204             grp = getgrgid(st.st_gid);
205
206             /* XXX : kludge temporaire pour yopy */
207             ppsz_text[0] = "..";
208             ppsz_text[1] = get_file_perms(st);
209             ppsz_text[2] = pw->pw_name;
210             ppsz_text[3] = grp->gr_name;
211
212             /* Add a new row to the model */
213             gtk_list_store_append (p_list, &iter);
214             gtk_list_store_set (p_list, &iter,
215                                 0, ppsz_text[0],
216                                 1, ppsz_text[1],
217                                 2, st.st_size,
218                                 3, ppsz_text[2],
219                                 4, ppsz_text[3],
220                                 -1);
221
222             if (ppsz_text[1]) free(ppsz_text[1]);
223         }
224             /* kludge */
225         for (i=0; i<n; i++)
226         {           
227             if ((namelist[i]->d_name[0] != '.') &&
228                 (lstat(namelist[i]->d_name, &st)==0))
229             {
230                 /* user, group  */
231                 pw  = getpwuid(st.st_uid);
232                 grp = getgrgid(st.st_gid);
233
234                 /* This is a list of strings. */
235                 ppsz_text[0] = namelist[i]->d_name;
236                 ppsz_text[1] = get_file_perms(st);
237                 ppsz_text[2] = pw->pw_name;
238                 ppsz_text[3] = grp->gr_name;
239 #if 0
240                 msg_Dbg(p_intf, "(%d) file: %s permission: %s user: %s group: %s", i, ppsz_text[0], ppsz_text[1], ppsz_text[2], ppsz_text[3] );
241 #endif
242                 gtk_list_store_append (p_list, &iter);
243                 gtk_list_store_set (p_list, &iter,
244                                     0, ppsz_text[0],
245                                     1, ppsz_text[1],
246                                     2, st.st_size,
247                                     3, ppsz_text[2],
248                                     4, ppsz_text[3],
249                                     -1);
250
251                 if (ppsz_text[1]) free(ppsz_text[1]);
252             }
253         }
254         free(namelist);
255     }
256 }
257
258 static char *get_file_perms(const struct stat st)
259 {
260     char  *perm;
261
262     perm = (char *) malloc(sizeof(char)*10);
263     strncpy( perm, "----------", sizeof("----------"));
264
265     /* determine permission modes */
266     if (S_ISLNK(st.st_mode))
267         perm[0]= 'l';
268     else if (S_ISDIR(st.st_mode))
269         perm[0]= 'd';
270     else if (S_ISCHR(st.st_mode))
271         perm[0]= 'c';
272     else if (S_ISBLK(st.st_mode))
273         perm[0]= 'b';
274     else if (S_ISFIFO(st.st_mode))
275         perm[0]= 'f';
276     else if (S_ISSOCK(st.st_mode))
277         perm[0]= 's';
278     else if (S_ISREG(st.st_mode))
279         perm[0]= '-';
280     else /* Unknown type is an error */
281         perm[0]= '?';
282     /* Get file permissions */
283     /* User */
284     if (st.st_mode & S_IRUSR)
285         perm[1]= 'r';
286     if (st.st_mode & S_IWUSR)
287         perm[2]= 'w';
288     if (st.st_mode & S_IXUSR)
289     {
290         if (st.st_mode & S_ISUID)
291             perm[3] = 's';
292         else
293             perm[3]= 'x';
294     }
295     else if (st.st_mode & S_ISUID)
296         perm[3] = 'S';
297     /* Group */
298     if (st.st_mode & S_IRGRP)
299         perm[4]= 'r';
300     if (st.st_mode & S_IWGRP)
301         perm[5]= 'w';
302     if (st.st_mode & S_IXGRP)
303     {
304         if (st.st_mode & S_ISGID)
305             perm[6] = 's';
306         else
307             perm[6]= 'x';
308     }
309     else if (st.st_mode & S_ISGID)
310         perm[6] = 'S';
311     /* Other */
312     if (st.st_mode & S_IROTH)
313         perm[7]= 'r';
314     if (st.st_mode & S_IWOTH)
315         perm[8]= 'w';
316     if (st.st_mode & S_IXOTH)
317     {
318         // 'sticky' bit
319         if (st.st_mode &S_ISVTX)
320             perm[9] = 't';
321         else
322             perm[9]= 'x';
323     }
324     else if (st.st_mode &S_ISVTX)
325         perm[9]= 'T';
326
327     return perm;
328 }
329
330 /*
331  * Main interface callbacks
332  */
333
334 gboolean
335 onPDADeleteEvent                       (GtkWidget       *widget,
336                                         GdkEvent        *event,
337                                         gpointer         user_data)
338 {
339     intf_thread_t *p_intf = GtkGetIntf( widget );
340
341     msg_Dbg( p_intf, "about to exit vlc ... " );
342     vlc_mutex_lock( &p_intf->change_lock );
343     p_intf->p_vlc->b_die = VLC_TRUE;
344     vlc_mutex_unlock( &p_intf->change_lock );
345     msg_Dbg( p_intf, "about to exit vlc ... signalled" );
346
347     return TRUE;
348 }
349
350
351 void
352 onRewind                               (GtkButton       *button,
353                                         gpointer         user_data)
354 {
355     intf_thread_t *  p_intf = GtkGetIntf( button );
356
357     if (p_intf->p_sys->p_input != NULL)
358     {
359         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
360     }
361 }
362
363
364 void
365 onPause                                (GtkButton       *button,
366                                         gpointer         user_data)
367 {
368     intf_thread_t *  p_intf = GtkGetIntf( button );
369
370     if (p_intf->p_sys->p_input != NULL)
371     {
372         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
373     }
374 }
375
376
377 void
378 onPlay                                 (GtkButton       *button,
379                                         gpointer         user_data)
380 {
381     intf_thread_t *  p_intf = GtkGetIntf( GTK_WIDGET( button ) );
382     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
383
384     if (p_playlist)
385     {
386         vlc_mutex_lock( &p_playlist->object_lock );
387         if (p_playlist->i_size)
388         {
389             vlc_mutex_unlock( &p_playlist->object_lock );
390             playlist_Play( p_playlist );
391         }
392         else
393         {
394             vlc_mutex_unlock( &p_playlist->object_lock );
395         }
396         vlc_object_release( p_playlist );
397     }
398 }
399
400
401 void
402 onStop                                 (GtkButton       *button,
403                                         gpointer         user_data)
404 {
405     intf_thread_t *  p_intf = GtkGetIntf( GTK_WIDGET( button ) );
406     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
407                                                        FIND_ANYWHERE );
408     if (p_playlist)
409     {
410         playlist_Stop( p_playlist );
411         vlc_object_release( p_playlist );
412     }
413 }
414
415
416 void
417 onForward                              (GtkButton       *button,
418                                         gpointer         user_data)
419 {
420     intf_thread_t *p_intf = GtkGetIntf( button );
421
422     if (p_intf->p_sys->p_input != NULL)
423     {
424         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
425     }
426 }
427
428
429 void
430 onAbout                                (GtkButton       *button,
431                                         gpointer         user_data)
432 {
433     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(button) );
434
435     // Toggle notebook
436     if (p_intf->p_sys->p_notebook)
437     {
438         gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
439         gtk_notebook_set_page(p_intf->p_sys->p_notebook,6);
440     }
441 }
442
443
444 gboolean
445 SliderRelease                          (GtkWidget       *widget,
446                                         GdkEventButton  *event,
447                                         gpointer         user_data)
448 {
449     intf_thread_t *p_intf = GtkGetIntf( widget );
450
451     vlc_mutex_lock( &p_intf->change_lock );
452     p_intf->p_sys->b_slider_free = 1;
453     vlc_mutex_unlock( &p_intf->change_lock );
454
455     return TRUE;
456 }
457
458
459 gboolean
460 SliderPress                            (GtkWidget       *widget,
461                                         GdkEventButton  *event,
462                                         gpointer         user_data)
463 {
464     intf_thread_t *p_intf = GtkGetIntf( widget );
465
466     vlc_mutex_lock( &p_intf->change_lock );
467     p_intf->p_sys->b_slider_free = 0;
468     vlc_mutex_unlock( &p_intf->change_lock );
469
470     return TRUE;
471 }
472
473 void addSelectedToPlaylist(GtkTreeModel *model,
474                                GtkTreePath *path,
475                                GtkTreeIter *iter,
476                                gpointer *userdata)
477 {
478     gchar *filename;
479
480     gtk_tree_model_get(model, iter, 0, &filename, -1);
481
482     PlaylistAddItem(GTK_WIDGET(userdata), filename);
483 }
484
485 void
486 onFileListRow                          (GtkTreeView     *treeview,
487                                         GtkTreePath     *path,
488                                         GtkTreeViewColumn *column,
489                                         gpointer         user_data)
490 {
491     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(treeview) );
492     GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
493
494     if (gtk_tree_selection_count_selected_rows(selection) == 1)
495     {
496         struct stat   st;
497         GtkTreeModel *model;
498         GtkTreeIter   iter;
499         gchar        *filename;
500
501         /* This might be a directory selection */
502         model = gtk_tree_view_get_model(treeview);
503         if (!model)
504             msg_Err(p_intf, "PDA: Filelist model contains a NULL pointer\n" );
505
506         if (path == NULL )
507         {
508 #if 0
509             GList* list;
510
511             list = gtk_tree_selection_get_selected_rows(selection,model);
512             if (g_list_length(list) == 1)
513             {
514                 filename = (gchar *) g_list_nth_data(list,0);
515                 msg_Dbg(p_intf, "PDA: filename = %s", (gchar*) filename );
516                 PlaylistAddItem(GTK_WIDGET(treeview), filename);
517             }
518             g_list_foreach (list, gtk_tree_path_free, NULL);
519             g_list_free (list);
520 #endif
521         }
522         else
523         {
524             if (!gtk_tree_model_get_iter(model, &iter, path))
525                 msg_Err( p_intf, "PDA: Could not get iter from model" );
526
527             gtk_tree_model_get(model, &iter, 0, &filename, -1);
528
529             if (stat((char*)filename, &st)==0)
530             {
531                 if (S_ISDIR(st.st_mode))
532                 {
533                     GtkListStore *p_model = NULL;
534
535                     /* Get new directory listing */
536                     p_model = gtk_list_store_new (5,
537                                                G_TYPE_STRING,
538                                                G_TYPE_STRING,
539                                                G_TYPE_UINT64,
540                                                G_TYPE_STRING,
541                                                G_TYPE_STRING);
542                     if (p_model)
543                     {
544                         ReadDirectory(p_intf, p_model, filename);
545
546                         /* Update TreeView with new model */
547                         gtk_tree_view_set_model(treeview, (GtkTreeModel*) p_model);
548                         g_object_unref(p_model);
549                     }
550                 }
551                 else
552                 {
553                     gtk_tree_selection_selected_foreach(selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
554                 }
555             }
556         }
557     }
558     else
559     {
560         gtk_tree_selection_selected_foreach(selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
561     }
562 }
563
564 void
565 onAddFileToPlaylist                    (GtkButton       *button,
566                                         gpointer         user_data)
567 {
568     GtkTreeView       *treeview = NULL;
569
570     treeview = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvFileList");
571     if (treeview)
572     {
573         onFileListRow(treeview, NULL, NULL, NULL );
574     }
575 }
576
577
578 void
579 NetworkBuildMRL                        (GtkEditable     *editable,
580                                         gpointer         user_data)
581 {
582     GtkSpinButton *networkPort = NULL;
583     GtkEntry      *entryMRL = NULL;
584     GtkEntry      *networkType = NULL;
585     GtkEntry      *networkAddress = NULL;
586     GtkEntry      *networkProtocol = NULL;
587     const gchar   *mrlNetworkType;
588     const gchar   *mrlAddress;
589     const gchar   *mrlProtocol;
590     gint           mrlPort;
591     char           text[VLC_MAX_MRL];
592     int            pos = 0;
593
594     entryMRL = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryMRL" );
595
596     networkType     = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkType" );
597     networkAddress  = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkAddress" );
598     networkPort     = (GtkSpinButton*) lookup_widget( GTK_WIDGET(editable), "entryNetworkPort" );
599     networkProtocol = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkProtocolType" );
600
601     mrlNetworkType = gtk_entry_get_text(GTK_ENTRY(networkType));
602     mrlAddress     = gtk_entry_get_text(GTK_ENTRY(networkAddress));
603     mrlPort        = gtk_spin_button_get_value_as_int(networkPort);
604     mrlProtocol    = gtk_entry_get_text(GTK_ENTRY(networkProtocol));
605
606     /* Build MRL from parts ;-) */
607     pos = snprintf( &text[0], VLC_MAX_MRL, "%s://", (char*)mrlProtocol);
608     if (strncasecmp( (char*)mrlNetworkType, "multicast",9)==0)
609     {
610         pos += snprintf( &text[pos], VLC_MAX_MRL - pos, "@" );
611     }
612     pos += snprintf( &text[pos], VLC_MAX_MRL - pos, "%s:%d", (char*)mrlAddress, (int)mrlPort );
613
614     if (pos >= VLC_MAX_MRL)
615         text[VLC_MAX_MRL-1]='\0';
616
617     gtk_entry_set_text(entryMRL,text);
618 }
619
620 void
621 onAddNetworkPlaylist                   (GtkButton       *button,
622                                         gpointer         user_data)
623 {
624     GtkEntry     *p_mrl = NULL;
625     const gchar  *mrl_name;
626
627     p_mrl = (GtkEntry*) lookup_widget(GTK_WIDGET(button),"entryMRL" );
628     if (p_mrl)
629     {
630         mrl_name = gtk_entry_get_text(p_mrl);
631
632         PlaylistAddItem(GTK_WIDGET(button), (gchar *)mrl_name);
633     }
634 }
635
636
637 void
638 onAddCameraToPlaylist                  (GtkButton       *button,
639                                         gpointer         user_data)
640 {
641     intf_thread_t *p_intf = GtkGetIntf( button );
642
643     GtkSpinButton *entryV4LChannel = NULL;
644     GtkSpinButton *entryV4LFrequency = NULL;
645     GtkSpinButton *entryV4LSampleRate = NULL;
646     GtkSpinButton *entryV4LQuality = NULL;
647     GtkSpinButton *entryV4LTuner = NULL;
648     gint    i_v4l_channel;
649     gint    i_v4l_frequency;
650     gint    i_v4l_samplerate;
651     gint    i_v4l_quality;
652     gint    i_v4l_tuner;
653
654     GtkEntry      *entryV4LVideoDevice = NULL;
655     GtkEntry      *entryV4LAudioDevice = NULL;
656     GtkEntry      *entryV4LNorm = NULL;
657     GtkEntry      *entryV4LSize = NULL;
658     GtkEntry      *entryV4LSoundDirection = NULL;
659     const gchar   *p_v4l_video_device;
660     const gchar   *p_v4l_audio_device;
661     const gchar   *p_v4l_norm;
662     const gchar   *p_v4l_size;
663     const gchar   *p_v4l_sound_direction;
664
665     /* MJPEG only */
666     GtkCheckButton *checkV4LMJPEG = NULL;
667     GtkSpinButton  *entryV4LDecimation = NULL;
668     gboolean        b_v4l_mjpeg;
669     gint            i_v4l_decimation;
670     /* end MJPEG only */
671
672     char v4l_mrl[VLC_MAX_MRL];
673     int pos;
674
675     pos = snprintf( &v4l_mrl[0], VLC_MAX_MRL, "v4l://");
676
677     entryV4LChannel    = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LChannel" );
678     entryV4LFrequency  = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LFrequency" );
679     entryV4LSampleRate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LSampleRate" );
680     entryV4LQuality    = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LQuality" );
681     entryV4LTuner      = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LTuner" );
682
683     entryV4LVideoDevice  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LVideoDevice" );
684     entryV4LAudioDevice  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LAudioDevice" );
685     entryV4LNorm  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LNorm" );
686     entryV4LSize  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSize" );
687     entryV4LSoundDirection  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSoundDirection" );
688
689     i_v4l_channel = gtk_spin_button_get_value_as_int(entryV4LChannel);
690     i_v4l_frequency = gtk_spin_button_get_value_as_int(entryV4LFrequency);
691     i_v4l_samplerate = gtk_spin_button_get_value_as_int(entryV4LSampleRate);
692     i_v4l_quality = gtk_spin_button_get_value_as_int(entryV4LQuality);
693     i_v4l_tuner = gtk_spin_button_get_value_as_int(entryV4LTuner);
694
695     p_v4l_video_device = gtk_entry_get_text(GTK_ENTRY(entryV4LVideoDevice));
696     p_v4l_audio_device = gtk_entry_get_text(GTK_ENTRY(entryV4LAudioDevice));
697     p_v4l_norm = gtk_entry_get_text(GTK_ENTRY(entryV4LNorm));
698     p_v4l_size  = gtk_entry_get_text(GTK_ENTRY(entryV4LSize));
699     p_v4l_sound_direction = gtk_entry_get_text(GTK_ENTRY(entryV4LSoundDirection));
700
701     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":%s", (char*)p_v4l_video_device );
702     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":adev=%s", (char*)p_v4l_audio_device );
703     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":norm=%s", (char*)p_v4l_norm );
704     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":size=%s", (char*)p_v4l_size );
705     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":%s", (char*)p_v4l_sound_direction );
706
707     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":channel=%d", (int)i_v4l_channel );
708     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":frequency=%d", (int)i_v4l_frequency );
709     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":samplerate=%d", (int)i_v4l_samplerate );
710     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":quality=%d", (int)i_v4l_quality );
711     pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":tuner=%d", (int)i_v4l_tuner );
712
713     /* MJPEG only */
714     checkV4LMJPEG      = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkV4LMJPEG" );
715     b_v4l_mjpeg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkV4LMJPEG));
716     if (b_v4l_mjpeg)
717     {
718         entryV4LDecimation = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LDecimation" );
719         i_v4l_decimation = gtk_spin_button_get_value_as_int(entryV4LDecimation);
720         pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":mjpeg:%d", (int)i_v4l_decimation );
721     }
722     /* end MJPEG only */
723
724     if (pos >= VLC_MAX_MRL)
725     {
726         v4l_mrl[VLC_MAX_MRL-1]='\0';
727         msg_Err(p_intf, "Media Resource Locator is truncated to: %s", v4l_mrl);
728     }
729
730     PlaylistAddItem(GTK_WIDGET(button), (gchar*) &v4l_mrl);
731 }
732
733
734 gboolean
735 PlaylistEvent                          (GtkWidget       *widget,
736                                         GdkEvent        *event,
737                                         gpointer         user_data)
738 {
739     return FALSE;
740 }
741
742
743 void
744 onPlaylistColumnsChanged               (GtkTreeView     *treeview,
745                                         gpointer         user_data)
746 {
747 }
748
749
750 gboolean
751 onPlaylistRowSelected                  (GtkTreeView     *treeview,
752                                         gboolean         start_editing,
753                                         gpointer         user_data)
754 {
755     return FALSE;
756 }
757
758
759 void
760 onPlaylistRow                          (GtkTreeView     *treeview,
761                                         GtkTreePath     *path,
762                                         GtkTreeViewColumn *column,
763                                         gpointer         user_data)
764 {
765 }
766
767
768 void
769 onUpdatePlaylist                       (GtkButton       *button,
770                                         gpointer         user_data)
771 {
772
773 }
774
775
776 void
777 onDeletePlaylist                       (GtkButton       *button,
778                                         gpointer         user_data)
779 {
780
781 }
782
783
784 void
785 onClearPlaylist                        (GtkButton       *button,
786                                         gpointer         user_data)
787 {
788     intf_thread_t *p_intf = GtkGetIntf( button );
789
790     msg_Dbg(p_intf, "Clear playlist" );
791 }
792
793
794 void
795 onPreferenceSave                       (GtkButton       *button,
796                                         gpointer         user_data)
797 {
798     intf_thread_t *p_intf = GtkGetIntf( button );
799
800     msg_Dbg(p_intf, "Preferences Save" );
801 }
802
803
804 void
805 onPreferenceApply                      (GtkButton       *button,
806                                         gpointer         user_data)
807 {
808     intf_thread_t *p_intf = GtkGetIntf( button );
809
810     msg_Dbg(p_intf, "Preferences Apply" );
811 }
812
813
814 void
815 onPreferenceCancel                     (GtkButton       *button,
816                                         gpointer         user_data)
817 {
818     intf_thread_t *p_intf = GtkGetIntf( button );
819
820     msg_Dbg(p_intf, "Preferences Cancel" );
821 }
822
823
824 void
825 onAddTranscodeToPlaylist               (GtkButton       *button,
826                                         gpointer         user_data)
827 {
828     intf_thread_t *p_intf = GtkGetIntf( button );
829
830     GtkEntry       *entryVideoCodec = NULL;
831     GtkSpinButton  *entryVideoBitrate = NULL;
832     GtkSpinButton  *entryVideoBitrateTolerance = NULL;
833     GtkSpinButton  *entryVideoKeyFrameInterval = NULL;
834     GtkCheckButton *checkVideoDeinterlace = NULL;
835     GtkEntry       *entryAudioCodec = NULL;
836     GtkSpinButton  *entryAudioBitrate = NULL;
837     const gchar    *p_video_codec;
838     gint            i_video_bitrate;
839     gint            i_video_bitrate_tolerance;
840     gint            i_video_keyframe_interval;
841     gboolean        b_video_deinterlace;
842     const gchar    *p_audio_codec;
843     gint            i_audio_bitrate;
844
845     GtkEntry       *entryStdAccess = NULL;
846     GtkEntry       *entryStdMuxer = NULL;
847     GtkEntry       *entryStdURL = NULL;
848     GtkSpinButton  *entryStdTTL = NULL;
849     const gchar    *p_std_access;
850     const gchar    *p_std_muxer;
851     const gchar    *p_std_url;
852     gint            i_std_ttl;
853
854     gchar mrl[VLC_MAX_MRL];
855     int   pos;
856
857     pos = snprintf( &mrl[0], VLC_MAX_MRL, "--sout '#transcode{");
858
859     entryVideoCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryVideoCodec" );
860     entryVideoBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrate" );
861     entryVideoBitrateTolerance = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrateTolerance" );
862     entryVideoKeyFrameInterval = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoKeyFrameInterval" );
863     
864     p_video_codec = gtk_entry_get_text(GTK_ENTRY(entryVideoCodec));
865     i_video_bitrate = gtk_spin_button_get_value_as_int(entryVideoBitrate);
866     i_video_bitrate_tolerance = gtk_spin_button_get_value_as_int(entryVideoBitrateTolerance);
867     i_video_keyframe_interval = gtk_spin_button_get_value_as_int(entryVideoKeyFrameInterval);
868     
869     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "vcodec=%s,", (char*)p_video_codec );
870     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "vb=%d,", (int)i_video_bitrate );
871     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "vt=%d,", (int)i_video_bitrate_tolerance );
872     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "keyint=%d,", (int)i_video_keyframe_interval );
873
874     checkVideoDeinterlace = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkVideoDeinterlace" );
875     b_video_deinterlace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkVideoDeinterlace));
876     if (b_video_deinterlace)
877     {
878         pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "deinterlace," );
879     }
880     entryAudioCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAudioCodec" );
881     entryAudioBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryAudioBitrate" );
882
883     p_audio_codec = gtk_entry_get_text(GTK_ENTRY(entryAudioCodec));
884     i_audio_bitrate = gtk_spin_button_get_value_as_int(entryAudioBitrate);
885
886     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "acodec=%s,", (char*)p_audio_codec );
887     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "ab=%d", (int)i_audio_bitrate );
888
889     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "}:std{" );
890
891     entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdAccess" );
892     entryStdMuxer  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdMuxer" );
893     entryStdURL = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdURL" );
894     entryStdTTL = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryStdTTL" );
895
896     p_std_access = gtk_entry_get_text(GTK_ENTRY(entryStdAccess));
897     p_std_muxer = gtk_entry_get_text(GTK_ENTRY(entryStdMuxer));
898     p_std_url = gtk_entry_get_text(GTK_ENTRY(entryStdURL));
899
900     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "access=%s,", (char*)p_std_access);
901     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "mux=%s,", (char*)p_std_muxer);
902     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "url=%s", (char*)p_std_url);
903     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "}'");
904
905     i_std_ttl = gtk_spin_button_get_value_as_int(entryStdTTL);
906
907     pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, " --ttl=%d", (int)i_std_ttl);
908
909     if (pos >= VLC_MAX_MRL)
910     {
911         mrl[VLC_MAX_MRL-1]='\0';
912         msg_Err(p_intf, "Media Resource Locator is truncated to: %s", mrl );
913     }
914
915     PlaylistAddItem(GTK_WIDGET(button), (gchar*) &mrl);
916 }
917
918