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