]> git.sesse.net Git - vlc/blob - modules/gui/pda/pda_callbacks.c
Disabled the preference menu, it is not filled in anyway.
[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.28 2004/02/13 10:09:46 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, char **ppsz_options, int i_size)
91 {
92     intf_thread_t *p_intf = GtkGetIntf( widget );
93     playlist_t    *p_playlist;
94     int           i_id , i_pos=0;
95     GtkTreeView   *p_tvplaylist = NULL;
96
97     p_playlist = (playlist_t *)
98              vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
99
100     if( p_playlist ==  NULL)
101     {   /* Bail out when VLC's playlist object is not found. */
102         return;
103     }
104
105     /* Add to playlist object. */
106     p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(widget), "tvPlaylist");
107     if (p_tvplaylist)
108     {
109         GtkTreeModel *p_play_model;
110         GtkTreeIter   p_play_iter;
111
112         p_play_model = gtk_tree_view_get_model(p_tvplaylist);
113
114         if (p_play_model)
115         {
116             int i;
117
118             /* Add a new row to the playlist treeview model */
119             gtk_list_store_append (GTK_LIST_STORE(p_play_model), &p_play_iter);
120             gtk_list_store_set (GTK_LIST_STORE(p_play_model), &p_play_iter,
121                                     0, name,   /* Add path to it !!! */
122                                     1, "no info",
123                                     2, p_playlist->i_size, /* Hidden index. */
124                                     -1 );
125
126             /* Add to VLC's playlist */
127 #if 0
128             if (p_intf->p_sys->b_autoplayfile)
129             {
130                 playlist_Add( p_playlist, (const char*)name, (const char**)ppsz_options, i_size,
131                               PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END);
132             }
133             else
134 #endif
135             {
136                 i_id = playlist_AddExt( p_playlist, (const char*)name,
137                               (const char*)name,
138                               PLAYLIST_APPEND, PLAYLIST_END,
139                               (mtime_t) 0,
140                               (const char **) ppsz_options, i_pos );
141             }
142
143             /* Cleanup memory */
144             for (i=0; i<i_size; i++)
145                 free(ppsz_options[i]);
146             free(ppsz_options);
147         }
148     }
149     vlc_object_release( p_playlist );
150 }
151
152 void PlaylistRebuildListStore( GtkListStore * p_list, playlist_t * p_playlist )
153 {
154     GtkTreeIter iter;
155     int         i_dummy;
156     gchar *     ppsz_text[2];
157 #if 0
158     GdkColor    red;
159     red.red     = 65535;
160     red.blue    = 0;
161     red.green   = 0;
162 #endif
163     vlc_mutex_lock( &p_playlist->object_lock );
164     for( i_dummy = 0; i_dummy < p_playlist->i_size ; i_dummy++ )
165     {
166         ppsz_text[0] = p_playlist->pp_items[i_dummy]->psz_name;
167         ppsz_text[1] = "no info";
168         gtk_list_store_append (p_list, &iter);
169         gtk_list_store_set (p_list, &iter,
170                             0, ppsz_text[0],
171                             1, ppsz_text[1],
172                             2, i_dummy, /* Hidden index */
173                             -1);
174     }
175     vlc_mutex_unlock( &p_playlist->object_lock );
176 }
177
178 /*****************************************************************
179  * Read directory helper function.
180  ****************************************************************/
181 void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
182 {
183     GtkTreeIter    iter;
184     struct dirent **pp_namelist;
185     struct passwd *p_pw;
186     struct group  *p_grp;
187     struct stat    st;
188     int n=-1, status=-1;
189
190     msg_Dbg(p_intf, "Changing to dir %s", psz_dir);
191     if (psz_dir)
192     {
193        status = chdir(psz_dir);
194        if (status<0)
195           msg_Dbg(p_intf, "permision denied" );
196     }
197     n = scandir(".", &pp_namelist, 0, alphasort);
198
199     if (n<0)
200         perror("scandir");
201     else
202     {
203         int i;
204         gchar *ppsz_text[4];
205
206         if (lstat("..", &st)==0)
207         {
208             /* user, group  */
209             p_pw  = getpwuid(st.st_uid);
210             p_grp = getgrgid(st.st_gid);
211
212             /* XXX : kludge temporaire pour yopy */
213             ppsz_text[0] = "..";
214             ppsz_text[1] = get_file_perms(st);
215             ppsz_text[2] = p_pw->pw_name;
216             ppsz_text[3] = p_grp->gr_name;
217
218             /* Add a new row to the model */
219             gtk_list_store_append (p_list, &iter);
220             gtk_list_store_set (p_list, &iter,
221                                 0, ppsz_text[0],
222                                 1, ppsz_text[1],
223                                 2, st.st_size,
224                                 3, ppsz_text[2],
225                                 4, ppsz_text[3],
226                                 -1);
227
228             if (ppsz_text[1]) free(ppsz_text[1]);
229         }
230             /* kludge */
231         for (i=0; i<n; i++)
232         {           
233             if ((pp_namelist[i]->d_name[0] != '.') &&
234                 (lstat(pp_namelist[i]->d_name, &st)==0))
235             {
236                 /* user, group  */
237                 p_pw  = getpwuid(st.st_uid);
238                 p_grp = getgrgid(st.st_gid);
239
240                 /* This is a list of strings. */
241                 ppsz_text[0] = pp_namelist[i]->d_name;
242                 ppsz_text[1] = get_file_perms(st);
243                 ppsz_text[2] = p_pw->pw_name;
244                 ppsz_text[3] = p_grp->gr_name;
245 #if 0
246                 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] );
247 #endif
248                 gtk_list_store_append (p_list, &iter);
249                 gtk_list_store_set (p_list, &iter,
250                                     0, ppsz_text[0],
251                                     1, ppsz_text[1],
252                                     2, st.st_size,
253                                     3, ppsz_text[2],
254                                     4, ppsz_text[3],
255                                     -1);
256
257                 if (ppsz_text[1]) free(ppsz_text[1]);
258             }
259         }
260         free(pp_namelist);
261     }
262 }
263
264 static char *get_file_perms(const struct stat st)
265 {
266     char  *psz_perm;
267
268     psz_perm = (char *) malloc(sizeof(char)*10);
269     strncpy( psz_perm, "----------", sizeof("----------"));
270
271     /* determine permission modes */
272     if (S_ISLNK(st.st_mode))
273         psz_perm[0]= 'l';
274     else if (S_ISDIR(st.st_mode))
275         psz_perm[0]= 'd';
276     else if (S_ISCHR(st.st_mode))
277         psz_perm[0]= 'c';
278     else if (S_ISBLK(st.st_mode))
279         psz_perm[0]= 'b';
280     else if (S_ISFIFO(st.st_mode))
281         psz_perm[0]= 'f';
282     else if (S_ISSOCK(st.st_mode))
283         psz_perm[0]= 's';
284     else if (S_ISREG(st.st_mode))
285         psz_perm[0]= '-';
286     else /* Unknown type is an error */
287         psz_perm[0]= '?';
288     /* Get file permissions */
289     /* User */
290     if (st.st_mode & S_IRUSR)
291         psz_perm[1]= 'r';
292     if (st.st_mode & S_IWUSR)
293         psz_perm[2]= 'w';
294     if (st.st_mode & S_IXUSR)
295     {
296         if (st.st_mode & S_ISUID)
297             psz_perm[3] = 's';
298         else
299             psz_perm[3]= 'x';
300     }
301     else if (st.st_mode & S_ISUID)
302         psz_perm[3] = 'S';
303     /* Group */
304     if (st.st_mode & S_IRGRP)
305         psz_perm[4]= 'r';
306     if (st.st_mode & S_IWGRP)
307         psz_perm[5]= 'w';
308     if (st.st_mode & S_IXGRP)
309     {
310         if (st.st_mode & S_ISGID)
311             psz_perm[6] = 's';
312         else
313             psz_perm[6]= 'x';
314     }
315     else if (st.st_mode & S_ISGID)
316         psz_perm[6] = 'S';
317     /* Other */
318     if (st.st_mode & S_IROTH)
319         psz_perm[7]= 'r';
320     if (st.st_mode & S_IWOTH)
321         psz_perm[8]= 'w';
322     if (st.st_mode & S_IXOTH)
323     {
324         // 'sticky' bit
325         if (st.st_mode &S_ISVTX)
326             psz_perm[9] = 't';
327         else
328             psz_perm[9]= 'x';
329     }
330     else if (st.st_mode &S_ISVTX)
331         psz_perm[9]= 'T';
332
333     return psz_perm;
334 }
335
336 /*
337  * Main interface callbacks
338  */
339
340 gboolean onPDADeleteEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data)
341 {
342     intf_thread_t *p_intf = GtkGetIntf( widget );
343
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 ... signaled" );
348
349     return TRUE;
350 }
351
352
353 void onRewind(GtkButton *button, 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 onPause(GtkButton *button, gpointer user_data)
365 {
366     intf_thread_t *p_intf = GtkGetIntf( button );
367
368     if (p_intf->p_sys->p_input != NULL)
369     {
370         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
371     }
372 }
373
374
375 void onPlay(GtkButton *button, gpointer user_data)
376 {
377     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) );
378     playlist_t *p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
379
380     if (p_playlist)
381     {
382         vlc_mutex_lock( &p_playlist->object_lock );
383         if (p_playlist->i_size)
384         {
385             vlc_mutex_unlock( &p_playlist->object_lock );
386             playlist_Play( p_playlist );
387             gdk_window_lower( p_intf->p_sys->p_window->window );
388         }
389         else
390         {
391             vlc_mutex_unlock( &p_playlist->object_lock );
392         }
393         vlc_object_release( p_playlist );
394     }
395 }
396
397
398 void onStop(GtkButton *button, gpointer user_data)
399 {
400     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) );
401     playlist_t *p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
402                                                        FIND_ANYWHERE );
403     if (p_playlist)
404     {
405         playlist_Stop( p_playlist );
406         vlc_object_release( p_playlist );
407         gdk_window_raise( p_intf->p_sys->p_window->window );
408     }
409 }
410
411
412 void onForward(GtkButton *button, gpointer user_data)
413 {
414     intf_thread_t *p_intf = GtkGetIntf( button );
415
416     if (p_intf->p_sys->p_input != NULL)
417     {
418         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
419     }
420 }
421
422
423 void onAbout(GtkButton *button, gpointer user_data)
424 {
425     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(button) );
426
427     // Toggle notebook
428     if (p_intf->p_sys->p_notebook)
429     {
430         gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
431         gtk_notebook_set_page(p_intf->p_sys->p_notebook,6);
432     }
433 }
434
435
436 gboolean SliderRelease(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
437 {
438     intf_thread_t *p_intf = GtkGetIntf( widget );
439
440     msg_Dbg( p_intf, "SliderButton Release" );
441     vlc_mutex_lock( &p_intf->change_lock );
442     p_intf->p_sys->b_slider_free = 1;
443     vlc_mutex_unlock( &p_intf->change_lock );
444
445     return TRUE;
446 }
447
448
449 gboolean SliderPress(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
450 {
451     intf_thread_t *p_intf = GtkGetIntf( widget );
452
453     msg_Dbg( p_intf, "SliderButton Press" );
454     vlc_mutex_lock( &p_intf->change_lock );
455     p_intf->p_sys->b_slider_free = 0;
456     vlc_mutex_unlock( &p_intf->change_lock );
457
458     return TRUE;
459 }
460
461 void SliderMove(GtkRange *range, GtkScrollType scroll, gpointer user_data)
462 {
463     intf_thread_t *p_intf = GtkGetIntf( range );
464     msg_Dbg( p_intf, "SliderButton Move" );
465 }
466
467
468 void addSelectedToPlaylist(GtkTreeModel *model, GtkTreePath *path,
469                            GtkTreeIter *iter, gpointer *userdata)
470 {
471     gchar *psz_filename;
472
473     gtk_tree_model_get(model, iter, 0, &psz_filename, -1);
474
475     PlaylistAddItem(GTK_WIDGET(userdata), psz_filename, 0, 0);
476 }
477
478 void onFileListRow(GtkTreeView *treeview, GtkTreePath *path,
479                    GtkTreeViewColumn *column, gpointer user_data)
480 {
481     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(treeview) );
482     GtkTreeSelection *p_selection = gtk_tree_view_get_selection(treeview);
483
484     if (gtk_tree_selection_count_selected_rows(p_selection) == 1)
485     {
486         struct stat   st;
487         GtkTreeModel *p_model;
488         GtkTreeIter   iter;
489         gchar        *psz_filename;
490
491         /* This might be a directory selection */
492         p_model = gtk_tree_view_get_model(treeview);
493         if (!p_model)
494         {
495             msg_Err(p_intf, "PDA: Filelist model contains a NULL pointer\n" );
496             return;
497         }
498         if (!gtk_tree_model_get_iter(p_model, &iter, path))
499         {
500             msg_Err( p_intf, "PDA: Could not get iter from model" );
501             return;
502         }
503
504         gtk_tree_model_get(p_model, &iter, 0, &psz_filename, -1);
505         if (stat((char*)psz_filename, &st)==0)
506         {
507             if (S_ISDIR(st.st_mode))
508             {
509                 GtkListStore *p_store = NULL;
510
511                 /* Get new directory listing */
512                 p_store = gtk_list_store_new (5,
513                                            G_TYPE_STRING,
514                                            G_TYPE_STRING,
515                                            G_TYPE_UINT64,
516                                            G_TYPE_STRING,
517                                            G_TYPE_STRING);
518                 if (p_store)
519                 {
520                     ReadDirectory(p_intf, p_store, psz_filename);
521
522                     /* Update TreeView with new model */
523                     gtk_tree_view_set_model(treeview, (GtkTreeModel*) p_store);
524                     g_object_unref(p_store);
525                 }
526             }
527         }
528     }
529 }
530
531 void onAddFileToPlaylist(GtkButton *button, gpointer user_data)
532 {
533     GtkTreeView       *p_treeview = NULL;
534
535     p_treeview = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvFileList");
536     if (p_treeview)
537     {
538         GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_treeview);
539
540         gtk_tree_selection_selected_foreach(p_selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) p_treeview);    
541     }
542 }
543
544
545 void NetworkBuildMRL(GtkEditable *editable, gpointer user_data)
546 {
547     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(editable) );
548     GtkSpinButton *p_networkPort = NULL;
549     GtkEntry      *p_entryMRL = NULL;
550     GtkEntry      *p_networkType = NULL;
551     GtkEntry      *p_networkAddress = NULL;
552     GtkEntry      *p_networkProtocol = NULL;
553     const gchar   *psz_mrlNetworkType;
554     const gchar   *psz_mrlAddress;
555     const gchar   *psz_mrlProtocol;
556     gint           i_mrlPort;
557     char           text[VLC_MAX_MRL];
558     int            i_pos = 0;
559
560     p_entryMRL = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryMRL" );
561
562     p_networkType     = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkType" );
563     p_networkAddress  = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkAddress" );
564     p_networkPort     = (GtkSpinButton*) lookup_widget( GTK_WIDGET(editable), "entryNetworkPort" );
565     p_networkProtocol = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkProtocolType" );
566
567     psz_mrlNetworkType = gtk_entry_get_text(GTK_ENTRY(p_networkType));
568     psz_mrlAddress     = gtk_entry_get_text(GTK_ENTRY(p_networkAddress));
569     i_mrlPort          = gtk_spin_button_get_value_as_int(p_networkPort);
570     psz_mrlProtocol    = gtk_entry_get_text(GTK_ENTRY(p_networkProtocol));
571
572     /* Build MRL from parts ;-) */
573     i_pos = snprintf( &text[0], VLC_MAX_MRL, "%s://", (char*)psz_mrlProtocol);
574     if (strncasecmp( (char*)psz_mrlNetworkType, "multicast",9)==0)
575     {
576         i_pos += snprintf( &text[i_pos], VLC_MAX_MRL - i_pos, "@" );
577     }
578     i_pos += snprintf( &text[i_pos], VLC_MAX_MRL - i_pos, "%s:%d", (char*)psz_mrlAddress, (int)i_mrlPort );
579
580     if (i_pos >= VLC_MAX_MRL)
581     {
582         text[VLC_MAX_MRL-1]='\0';
583         msg_Err( p_intf, "Media Resource Locator is truncated to: %s", text);
584     }
585
586     gtk_entry_set_text(p_entryMRL,text);
587 }
588
589 void onAddNetworkPlaylist(GtkButton *button, gpointer user_data)
590 {
591     GtkEntry     *p_mrl = NULL;
592     const gchar  *psz_mrl_name;
593
594     p_mrl = (GtkEntry*) lookup_widget(GTK_WIDGET(button),"entryMRL" );
595     if (p_mrl)
596     {
597         psz_mrl_name = gtk_entry_get_text(p_mrl);
598         if (psz_mrl_name != NULL)
599         {
600             PlaylistAddItem(GTK_WIDGET(button), (gchar *)psz_mrl_name, 0, 0);
601         }
602     }
603 }
604
605
606 void onAddCameraToPlaylist(GtkButton *button, gpointer user_data)
607 {
608     intf_thread_t *p_intf = GtkGetIntf( button );
609
610     GtkSpinButton *entryV4LChannel = NULL;
611     GtkSpinButton *entryV4LFrequency = NULL;
612     GtkSpinButton *entryV4LSampleRate = NULL;
613     GtkSpinButton *entryV4LQuality = NULL;
614     GtkSpinButton *entryV4LTuner = NULL;
615     gint    i_v4l_channel;
616     gint    i_v4l_frequency;
617     gint    i_v4l_samplerate;
618     gint    i_v4l_quality;
619     gint    i_v4l_tuner;
620
621     GtkEntry      *entryV4LVideoDevice = NULL;
622     GtkEntry      *entryV4LAudioDevice = NULL;
623     GtkEntry      *entryV4LNorm = NULL;
624     GtkEntry      *entryV4LSize = NULL;
625     GtkEntry      *entryV4LSoundDirection = NULL;
626     const gchar   *p_v4l_video_device;
627     const gchar   *p_v4l_audio_device;
628     const gchar   *p_v4l_norm;
629     const gchar   *p_v4l_size;
630     const gchar   *p_v4l_sound_direction;
631
632     /* MJPEG only */
633     GtkCheckButton *checkV4LMJPEG = NULL;
634     GtkSpinButton  *entryV4LDecimation = NULL;
635     gboolean        b_v4l_mjpeg;
636     gint            i_v4l_decimation;
637     /* end MJPEG only */
638
639     char **ppsz_options = NULL; /* list of options */
640     int  i_options=0;
641     char v4l_mrl[6];
642     int i_pos;
643     int i;
644
645     ppsz_options = (char **) malloc(11 *sizeof(char*));
646     if (ppsz_options == NULL)
647     {
648         msg_Err(p_intf, "No memory to allocate for v4l options.");
649         return;
650     }
651     for (i=0; i<11; i++)
652     {
653         ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char));
654         if (ppsz_options[i] == NULL)
655         {
656             msg_Err(p_intf, "No memory to allocate for v4l options string %i.", i);
657             for (i-=1; i>=0; i--)
658                 free(ppsz_options[i]);
659             free(ppsz_options);
660             return;
661         }
662     }
663
664     i_pos = snprintf( &v4l_mrl[0], 6, "v4l");
665     v4l_mrl[5]='\0';
666
667     entryV4LChannel    = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LChannel" );
668     entryV4LFrequency  = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LFrequency" );
669     entryV4LSampleRate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LSampleRate" );
670     entryV4LQuality    = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LQuality" );
671     entryV4LTuner      = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LTuner" );
672
673     entryV4LVideoDevice  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LVideoDevice" );
674     entryV4LAudioDevice  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LAudioDevice" );
675     entryV4LNorm  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LNorm" );
676     entryV4LSize  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSize" );
677     entryV4LSoundDirection  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSoundDirection" );
678
679     i_v4l_channel = gtk_spin_button_get_value_as_int(entryV4LChannel);
680     i_v4l_frequency = gtk_spin_button_get_value_as_int(entryV4LFrequency);
681     i_v4l_samplerate = gtk_spin_button_get_value_as_int(entryV4LSampleRate);
682     i_v4l_quality = gtk_spin_button_get_value_as_int(entryV4LQuality);
683     i_v4l_tuner = gtk_spin_button_get_value_as_int(entryV4LTuner);
684
685     p_v4l_video_device = gtk_entry_get_text(GTK_ENTRY(entryV4LVideoDevice));
686     p_v4l_audio_device = gtk_entry_get_text(GTK_ENTRY(entryV4LAudioDevice));
687     p_v4l_norm = gtk_entry_get_text(GTK_ENTRY(entryV4LNorm));
688     p_v4l_size  = gtk_entry_get_text(GTK_ENTRY(entryV4LSize));
689     p_v4l_sound_direction = gtk_entry_get_text(GTK_ENTRY(entryV4LSoundDirection));
690
691     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "%s", (char*)p_v4l_video_device );
692     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
693     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "adev=%s", (char*)p_v4l_audio_device );
694     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
695     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "norm=%s", (char*)p_v4l_norm );
696     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
697     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "size=%s", (char*)p_v4l_size );
698     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
699     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "%s", (char*)p_v4l_sound_direction );
700     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
701
702     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "channel=%d", (int)i_v4l_channel );
703     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
704     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "frequency=%d", (int)i_v4l_frequency );
705     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
706     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "samplerate=%d", (int)i_v4l_samplerate );
707     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
708     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "quality=%d", (int)i_v4l_quality );
709     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
710     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "tuner=%d", (int)i_v4l_tuner );
711     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
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
721         i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "mjpeg:%d", (int)i_v4l_decimation );
722         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
723     }
724     /* end MJPEG only */
725
726     PlaylistAddItem(GTK_WIDGET(button), (gchar*) &v4l_mrl, ppsz_options, i_options);
727 }
728
729
730 gboolean PlaylistEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data)
731 {
732     return FALSE;
733 }
734
735
736 void onPlaylistColumnsChanged(GtkTreeView *treeview, gpointer user_data)
737 {
738 }
739
740
741 gboolean onPlaylistRowSelected(GtkTreeView *treeview, gboolean start_editing, gpointer user_data)
742 {
743     return FALSE;
744 }
745
746
747 void onPlaylistRow(GtkTreeView *treeview, GtkTreePath *path,
748                    GtkTreeViewColumn *column, gpointer user_data)
749 {
750     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(treeview) );
751     GtkTreeSelection *p_selection = gtk_tree_view_get_selection(treeview);
752     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
753                                                        FIND_ANYWHERE );
754
755     if( p_playlist == NULL )
756     {
757         return; // FALSE;
758     }
759
760     if (gtk_tree_selection_count_selected_rows(p_selection) == 1)
761     {
762         GtkTreeModel *p_model;
763         GtkTreeIter   iter;
764         int           i_row;
765
766         /* This might be a directory selection */
767         p_model = gtk_tree_view_get_model(treeview);
768         if (!p_model)
769         {
770             msg_Err(p_intf, "PDA: Playlist model contains a NULL pointer\n" );
771             return;
772         }
773         if (!gtk_tree_model_get_iter(p_model, &iter, path))
774         {
775             msg_Err( p_intf, "PDA: Playlist could not get iter from model" );
776             return;
777         }
778
779         gtk_tree_model_get(p_model, &iter, 2, &i_row, -1);
780         playlist_Goto( p_playlist, i_row );
781     }
782     vlc_object_release( p_playlist );
783 }
784
785
786 void onUpdatePlaylist(GtkButton *button, gpointer user_data)
787 {
788     intf_thread_t *  p_intf = GtkGetIntf( button );
789     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
790                                                        FIND_ANYWHERE );
791     GtkTreeView *p_tvplaylist = NULL;
792
793     if( p_playlist == NULL )
794     {
795         return;
796     }
797
798     p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
799     if (p_tvplaylist)
800     {
801         GtkListStore *p_model = NULL;
802
803         /* Rebuild the playlist then. */
804         p_model = gtk_list_store_new (3,
805                     G_TYPE_STRING, /* Filename */
806                     G_TYPE_STRING, /* Time */
807                     G_TYPE_UINT);  /* Hidden field */
808         if (p_model)
809         {
810             PlaylistRebuildListStore(p_model, p_playlist);
811             gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_model));
812             g_object_unref(p_model);
813         }
814     }
815     vlc_object_release( p_playlist );
816 }
817
818 void deleteItemFromPlaylist(gpointer data, gpointer user_data)
819 {
820     gtk_tree_path_free((GtkTreePath*) data); // removing an item.
821 }
822
823 void onDeletePlaylist(GtkButton *button, gpointer user_data)
824 {
825     intf_thread_t *p_intf = GtkGetIntf( button );
826     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
827                                                        FIND_ANYWHERE );
828     GtkTreeView    *p_tvplaylist;
829
830     /* Delete an arbitrary item from the playlist */
831     p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvPlaylist" );
832     if (p_tvplaylist != NULL)
833     {
834         GList *p_rows = NULL;
835         GList *p_node;
836         GtkTreeModel *p_model = NULL;
837         GtkListStore *p_store = NULL;
838         GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_tvplaylist);
839
840         p_model = gtk_tree_view_get_model(p_tvplaylist);
841         if (p_model)
842         {
843             p_rows = gtk_tree_selection_get_selected_rows(p_selection, &p_model);
844
845             if( g_list_length( p_rows ) )
846             {
847                 /* reverse-sort so that we can delete from the furthest
848                  * to the closest item to delete...
849                  */
850                 p_rows = g_list_reverse( p_rows );
851             }
852     
853             for (p_node=p_rows; p_node!=NULL; p_node = p_node->next)
854             {
855                 GtkTreeIter iter;
856                 GtkTreePath *p_path = NULL;
857
858                 p_path = (GtkTreePath *)p_node->data;
859                 if (p_path)
860                 {
861                     if (gtk_tree_model_get_iter(p_model, &iter, p_path))
862                     {
863                         gint item;
864
865                         gtk_tree_model_get(p_model, &iter, 2, &item, -1);
866                         playlist_Delete(p_playlist, item);
867                     }
868                 }
869             }
870 #if 0 
871             g_list_foreach (p_rows, (GFunc*)gtk_tree_path_free, NULL);
872 #endif /* Testing the next line */
873             g_list_foreach (p_rows, deleteItemFromPlaylist, NULL);
874             g_list_free (p_rows);
875         }
876
877         /* Rebuild the playlist then. */
878         p_store = gtk_list_store_new (3,
879                     G_TYPE_STRING, /* Filename */
880                     G_TYPE_STRING, /* Time */
881                     G_TYPE_UINT);  /* Hidden field */
882         if (p_store)
883         {
884             PlaylistRebuildListStore(p_store, p_playlist);
885             gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_store));
886             g_object_unref(p_store);
887         }
888     }
889     vlc_object_release( p_playlist );
890 }
891
892
893 void onClearPlaylist(GtkButton *button, gpointer user_data)
894 {
895     intf_thread_t *p_intf = GtkGetIntf( button );
896     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
897                                                        FIND_ANYWHERE );
898     GtkTreeView    *p_tvplaylist;
899     int item;
900
901     if( p_playlist == NULL )
902     {
903         return;
904     }
905
906     for(item = p_playlist->i_size - 1; item >= 0 ;item-- )
907     {
908         playlist_Delete( p_playlist, item);
909     }
910     vlc_object_release( p_playlist );
911
912     // Remove all entries from the Playlist widget.
913     p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
914     if (p_tvplaylist)
915     {
916         GtkTreeModel *p_play_model;
917
918         p_play_model = gtk_tree_view_get_model(p_tvplaylist);
919         if (p_play_model)
920         {
921             gtk_list_store_clear(GTK_LIST_STORE(p_play_model));
922         }
923     }
924 }
925
926
927 void onPreferenceSave(GtkButton *button, gpointer user_data)
928 {
929 #if 0
930     intf_thread_t *p_intf = GtkGetIntf( button );
931
932     msg_Dbg(p_intf, "Preferences Save" );
933     config_SaveConfigFile( p_intf, NULL );
934 #endif
935 }
936
937
938 void onPreferenceApply(GtkButton *button, gpointer user_data)
939 {
940 #if 0
941     intf_thread_t *p_intf = GtkGetIntf( button );
942
943     msg_Dbg(p_intf, "Preferences Apply" );
944 #endif
945 }
946
947
948 void onPreferenceCancel(GtkButton *button, gpointer user_data)
949 {
950 #if 0
951     intf_thread_t *p_intf = GtkGetIntf( button );
952
953     msg_Dbg(p_intf, "Preferences Cancel" );
954     config_ResetAll( p_intf );
955     /* Cancel interface changes. */
956     config_SaveConfigFile( p_intf, NULL );
957 #endif
958 }
959
960
961 void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data)
962 {
963     intf_thread_t *p_intf = GtkGetIntf( button );
964
965     GtkEntry       *p_entryVideoCodec = NULL;
966     GtkSpinButton  *p_entryVideoBitrate = NULL;
967     GtkSpinButton  *p_entryVideoBitrateTolerance = NULL;
968     GtkSpinButton  *p_entryVideoKeyFrameInterval = NULL;
969     GtkCheckButton *p_checkVideoDeinterlace = NULL;
970     GtkEntry       *p_entryAudioCodec = NULL;
971     GtkSpinButton  *p_entryAudioBitrate = NULL;
972     const gchar    *p_video_codec;
973     gint            i_video_bitrate;
974     gint            i_video_bitrate_tolerance;
975     gint            i_video_keyframe_interval;
976     gboolean        b_video_deinterlace;
977     const gchar    *p_audio_codec;
978     gint            i_audio_bitrate;
979
980     GtkEntry       *p_entryStdAccess = NULL;
981     GtkEntry       *p_entryStdMuxer = NULL;
982     GtkEntry       *p_entryStdURL = NULL;
983     GtkEntry       *p_entryStdAnnounce = NULL;
984     GtkSpinButton  *p_entryStdTTL = NULL;
985     GtkCheckButton *p_checkSAP = NULL;
986     GtkCheckButton *p_checkSLP = NULL;
987     const gchar    *p_std_announce;
988     const gchar    *p_std_access;
989     const gchar    *p_std_muxer;
990     const gchar    *p_std_url;
991     gboolean        b_sap_announce;
992     gboolean        b_slp_announce;
993     gint            i_std_ttl;
994
995     char **ppsz_options = NULL; /* list of options */
996     int  i_options=0;
997     int  i;
998
999     gchar mrl[7];
1000     int   i_pos;
1001
1002     ppsz_options = (char **) malloc(3 *sizeof(char*));
1003     if (ppsz_options == NULL)
1004     {
1005         msg_Err(p_intf, "No memory to allocate for v4l options.");
1006         return;
1007     }
1008     for (i=0; i<3; i++)
1009     {
1010         ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char));
1011         if (ppsz_options[i] == NULL)
1012         {
1013             msg_Err(p_intf, "No memory to allocate for v4l options string %i.", i);
1014             for (i-=1; i>=0; i--)
1015                 free(ppsz_options[i]);
1016             free(ppsz_options);
1017             return;
1018         }
1019     }
1020
1021     i_pos = snprintf( &mrl[0], VLC_MAX_MRL, "sout");
1022     mrl[6] = '\0';
1023     /* option 1 */
1024     i_pos = snprintf( &ppsz_options[i_options][0], VLC_MAX_MRL, "sout='#transcode{");
1025     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1026
1027     p_entryVideoCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryVideoCodec" );
1028     p_entryVideoBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrate" );
1029     p_entryVideoBitrateTolerance = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrateTolerance" );
1030     p_entryVideoKeyFrameInterval = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoKeyFrameInterval" );
1031     
1032     p_video_codec = gtk_entry_get_text(GTK_ENTRY(p_entryVideoCodec));
1033     i_video_bitrate = gtk_spin_button_get_value_as_int(p_entryVideoBitrate);
1034     i_video_bitrate_tolerance = gtk_spin_button_get_value_as_int(p_entryVideoBitrateTolerance);
1035     i_video_keyframe_interval = gtk_spin_button_get_value_as_int(p_entryVideoKeyFrameInterval);
1036     
1037     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vcodec=%s,", (char*)p_video_codec );
1038     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1039     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vb=%d,", (int)i_video_bitrate );
1040     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1041     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vt=%d,", (int)i_video_bitrate_tolerance );
1042     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1043     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "keyint=%d,", (int)i_video_keyframe_interval );
1044     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1045
1046     p_checkVideoDeinterlace = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkVideoDeinterlace" );
1047     b_video_deinterlace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkVideoDeinterlace));
1048     if (b_video_deinterlace)
1049     {
1050         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "deinterlace," );
1051         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1052     }
1053     p_entryAudioCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAudioCodec" );
1054     p_entryAudioBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryAudioBitrate" );
1055
1056     p_audio_codec = gtk_entry_get_text(GTK_ENTRY(p_entryAudioCodec));
1057     i_audio_bitrate = gtk_spin_button_get_value_as_int(p_entryAudioBitrate);
1058
1059     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "acodec=%s,", (char*)p_audio_codec );
1060     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1061     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "ab=%d,", (int)i_audio_bitrate );
1062     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1063     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "channels=1}"/*, (int)i_audio_channels*/ );
1064     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1065
1066     /* option 2 */
1067     i_pos = 0;
1068     i_pos = snprintf( &ppsz_options[i_options++][i_pos], VLC_MAX_MRL - i_pos, "dst=" );
1069     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1070
1071     p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdAccess" );
1072     p_entryStdMuxer  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdMuxer" );
1073     p_entryStdURL = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdURL" );
1074     p_entryStdAnnounce = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAnnounceChannel" );
1075     p_entryStdTTL = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryStdTTL" );
1076
1077     p_std_access = gtk_entry_get_text(GTK_ENTRY(p_entryStdAccess));
1078     p_std_muxer = gtk_entry_get_text(GTK_ENTRY(p_entryStdMuxer));
1079     p_std_url = gtk_entry_get_text(GTK_ENTRY(p_entryStdURL));
1080     p_std_announce = gtk_entry_get_text(GTK_ENTRY(p_entryStdAnnounce));
1081     b_sap_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSAP));
1082     b_slp_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSLP));
1083
1084     if ( strncasecmp( (const char*)p_std_access, "display", 7 ) == 0)
1085     {
1086         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "%s,", (char*)p_std_access);
1087         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1088     }
1089     else
1090     {
1091         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "std{access=%s,", (char*)p_std_access);
1092         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1093         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "mux=%s,", (char*)p_std_muxer);
1094         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1095         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "url=%s", (char*)p_std_url);
1096         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1097
1098         if (strncasecmp( (const char*)p_std_access, "udp", 3)==0)
1099         {
1100             if (b_sap_announce)
1101             {
1102                 i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "sap=%s", (char*)p_std_announce);
1103                 if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1104             }
1105             if (b_slp_announce)
1106             {
1107                 i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "slp=%s", (char*)p_std_announce);
1108                 if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1109             }
1110         }
1111         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "}");
1112         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1113
1114         i_std_ttl = gtk_spin_button_get_value_as_int(p_entryStdTTL);
1115
1116         i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "ttl=%d", (int)i_std_ttl);
1117         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1118     }
1119
1120     PlaylistAddItem(GTK_WIDGET(button), (gchar*) &mrl, ppsz_options, i_options);
1121 }
1122
1123
1124
1125 void onEntryStdAccessChanged(GtkEditable *editable, gpointer user_data)
1126 {
1127     intf_thread_t *p_intf = GtkGetIntf( editable );
1128
1129     GtkCheckButton *p_checkSAP = NULL;
1130     GtkCheckButton *p_checkSLP = NULL;
1131     GtkEntry       *p_entryStdAccess = NULL;
1132     const gchar    *p_std_access = NULL;    
1133     gboolean        b_announce = FALSE;
1134
1135     p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryStdAccess" );
1136     p_checkSAP = (GtkCheckButton*) lookup_widget( GTK_WIDGET(editable), "checkSAP" );
1137     p_checkSLP = (GtkCheckButton*) lookup_widget( GTK_WIDGET(editable), "checkSLP" );
1138
1139     if ( (p_std_access == NULL) || (p_checkSAP == NULL) || (p_checkSLP == NULL))
1140     {
1141         msg_Err( p_intf, "Access, SAP and SLP widgets not found." );
1142         return;
1143     }
1144     p_std_access = gtk_entry_get_text(GTK_ENTRY(p_entryStdAccess));
1145
1146     b_announce = (strncasecmp( (const char*)p_std_access, "udp", 3) == 0);
1147     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_checkSAP), b_announce);
1148     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_checkSLP), b_announce);
1149 }
1150