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