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