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