]> 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.22 2003/12/06 22:41:40 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         }
384         else
385         {
386             vlc_mutex_unlock( &p_playlist->object_lock );
387         }
388         vlc_object_release( p_playlist );
389     }
390 }
391
392
393 void onStop(GtkButton *button, gpointer user_data)
394 {
395     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) );
396     playlist_t *p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
397                                                        FIND_ANYWHERE );
398     if (p_playlist)
399     {
400         playlist_Stop( p_playlist );
401         vlc_object_release( p_playlist );
402     }
403 }
404
405
406 void onForward(GtkButton *button, gpointer user_data)
407 {
408     intf_thread_t *p_intf = GtkGetIntf( button );
409
410     if (p_intf->p_sys->p_input != NULL)
411     {
412         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
413     }
414 }
415
416
417 void onAbout(GtkButton *button, gpointer user_data)
418 {
419     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(button) );
420
421     // Toggle notebook
422     if (p_intf->p_sys->p_notebook)
423     {
424         gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
425         gtk_notebook_set_page(p_intf->p_sys->p_notebook,6);
426     }
427 }
428
429
430 gboolean SliderRelease(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
431 {
432     intf_thread_t *p_intf = GtkGetIntf( widget );
433
434     msg_Dbg( p_intf, "SliderButton Release" );
435     vlc_mutex_lock( &p_intf->change_lock );
436     p_intf->p_sys->b_slider_free = 1;
437     vlc_mutex_unlock( &p_intf->change_lock );
438
439     return TRUE;
440 }
441
442
443 gboolean SliderPress(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
444 {
445     intf_thread_t *p_intf = GtkGetIntf( widget );
446
447     msg_Dbg( p_intf, "SliderButton Press" );
448     vlc_mutex_lock( &p_intf->change_lock );
449     p_intf->p_sys->b_slider_free = 0;
450     vlc_mutex_unlock( &p_intf->change_lock );
451
452     return TRUE;
453 }
454
455 void SliderMove(GtkRange *range, GtkScrollType scroll, gpointer user_data)
456 {
457     intf_thread_t *p_intf = GtkGetIntf( range );
458     msg_Dbg( p_intf, "SliderButton Move" );
459 }
460
461
462 void addSelectedToPlaylist(GtkTreeModel *model, GtkTreePath *path,
463                            GtkTreeIter *iter, gpointer *userdata)
464 {
465     gchar *psz_filename;
466
467     gtk_tree_model_get(model, iter, 0, &psz_filename, -1);
468
469     PlaylistAddItem(GTK_WIDGET(userdata), psz_filename, 0, 0);
470 }
471
472 void onFileListRow(GtkTreeView *treeview, GtkTreePath *path,
473                    GtkTreeViewColumn *column, gpointer user_data)
474 {
475     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(treeview) );
476     GtkTreeSelection *p_selection = gtk_tree_view_get_selection(treeview);
477
478     if (gtk_tree_selection_count_selected_rows(p_selection) == 1)
479     {
480         struct stat   st;
481         GtkTreeModel *p_model;
482         GtkTreeIter   iter;
483         gchar        *psz_filename;
484
485         /* This might be a directory selection */
486         p_model = gtk_tree_view_get_model(treeview);
487         if (!p_model)
488         {
489             msg_Err(p_intf, "PDA: Filelist model contains a NULL pointer\n" );
490             return;
491         }
492         if (!gtk_tree_model_get_iter(p_model, &iter, path))
493         {
494             msg_Err( p_intf, "PDA: Could not get iter from model" );
495             return;
496         }
497
498         gtk_tree_model_get(p_model, &iter, 0, &psz_filename, -1);
499         if (stat((char*)psz_filename, &st)==0)
500         {
501             if (S_ISDIR(st.st_mode))
502             {
503                 GtkListStore *p_store = NULL;
504
505                 /* Get new directory listing */
506                 p_store = gtk_list_store_new (5,
507                                            G_TYPE_STRING,
508                                            G_TYPE_STRING,
509                                            G_TYPE_UINT64,
510                                            G_TYPE_STRING,
511                                            G_TYPE_STRING);
512                 if (p_store)
513                 {
514                     ReadDirectory(p_intf, p_store, psz_filename);
515
516                     /* Update TreeView with new model */
517                     gtk_tree_view_set_model(treeview, (GtkTreeModel*) p_store);
518                     g_object_unref(p_store);
519                 }
520             }
521             else
522             {
523                 gtk_tree_selection_selected_foreach(p_selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
524             }
525         }
526     }
527     else
528     {
529         gtk_tree_selection_selected_foreach(p_selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
530     }
531 }
532
533 void onAddFileToPlaylist(GtkButton *button, gpointer user_data)
534 {
535     GtkTreeView       *p_treeview = NULL;
536
537     p_treeview = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvFileList");
538     if (p_treeview)
539     {
540         GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_treeview);
541
542         gtk_tree_selection_selected_foreach(p_selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) p_treeview);    
543     }
544 }
545
546
547 void NetworkBuildMRL(GtkEditable *editable, gpointer user_data)
548 {
549     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(editable) );
550     GtkSpinButton *p_networkPort = NULL;
551     GtkEntry      *p_entryMRL = NULL;
552     GtkEntry      *p_networkType = NULL;
553     GtkEntry      *p_networkAddress = NULL;
554     GtkEntry      *p_networkProtocol = NULL;
555     const gchar   *psz_mrlNetworkType;
556     const gchar   *psz_mrlAddress;
557     const gchar   *psz_mrlProtocol;
558     gint           i_mrlPort;
559     char           text[VLC_MAX_MRL];
560     int            i_pos = 0;
561
562     p_entryMRL = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryMRL" );
563
564     p_networkType     = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkType" );
565     p_networkAddress  = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkAddress" );
566     p_networkPort     = (GtkSpinButton*) lookup_widget( GTK_WIDGET(editable), "entryNetworkPort" );
567     p_networkProtocol = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkProtocolType" );
568
569     psz_mrlNetworkType = gtk_entry_get_text(GTK_ENTRY(p_networkType));
570     psz_mrlAddress     = gtk_entry_get_text(GTK_ENTRY(p_networkAddress));
571     i_mrlPort          = gtk_spin_button_get_value_as_int(p_networkPort);
572     psz_mrlProtocol    = gtk_entry_get_text(GTK_ENTRY(p_networkProtocol));
573
574     /* Build MRL from parts ;-) */
575     i_pos = snprintf( &text[0], VLC_MAX_MRL, "%s://", (char*)psz_mrlProtocol);
576     if (strncasecmp( (char*)psz_mrlNetworkType, "multicast",9)==0)
577     {
578         i_pos += snprintf( &text[i_pos], VLC_MAX_MRL - i_pos, "@" );
579     }
580     i_pos += snprintf( &text[i_pos], VLC_MAX_MRL - i_pos, "%s:%d", (char*)psz_mrlAddress, (int)i_mrlPort );
581
582     if (i_pos >= VLC_MAX_MRL)
583     {
584         text[VLC_MAX_MRL-1]='\0';
585         msg_Err( p_intf, "Media Resource Locator is truncated to: %s", text);
586     }
587
588     gtk_entry_set_text(p_entryMRL,text);
589 }
590
591 void onAddNetworkPlaylist(GtkButton *button, gpointer user_data)
592 {
593     GtkEntry     *p_mrl = NULL;
594     const gchar  *psz_mrl_name;
595
596     p_mrl = (GtkEntry*) lookup_widget(GTK_WIDGET(button),"entryMRL" );
597     if (p_mrl)
598     {
599         psz_mrl_name = gtk_entry_get_text(p_mrl);
600         if (psz_mrl_name != NULL)
601         {
602             PlaylistAddItem(GTK_WIDGET(button), (gchar *)psz_mrl_name, 0, 0);
603         }
604     }
605 }
606
607
608 void onAddCameraToPlaylist(GtkButton *button, gpointer user_data)
609 {
610     intf_thread_t *p_intf = GtkGetIntf( button );
611
612     GtkSpinButton *entryV4LChannel = NULL;
613     GtkSpinButton *entryV4LFrequency = NULL;
614     GtkSpinButton *entryV4LSampleRate = NULL;
615     GtkSpinButton *entryV4LQuality = NULL;
616     GtkSpinButton *entryV4LTuner = NULL;
617     gint    i_v4l_channel;
618     gint    i_v4l_frequency;
619     gint    i_v4l_samplerate;
620     gint    i_v4l_quality;
621     gint    i_v4l_tuner;
622
623     GtkEntry      *entryV4LVideoDevice = NULL;
624     GtkEntry      *entryV4LAudioDevice = NULL;
625     GtkEntry      *entryV4LNorm = NULL;
626     GtkEntry      *entryV4LSize = NULL;
627     GtkEntry      *entryV4LSoundDirection = NULL;
628     const gchar   *p_v4l_video_device;
629     const gchar   *p_v4l_audio_device;
630     const gchar   *p_v4l_norm;
631     const gchar   *p_v4l_size;
632     const gchar   *p_v4l_sound_direction;
633
634     /* MJPEG only */
635     GtkCheckButton *checkV4LMJPEG = NULL;
636     GtkSpinButton  *entryV4LDecimation = NULL;
637     gboolean        b_v4l_mjpeg;
638     gint            i_v4l_decimation;
639     /* end MJPEG only */
640
641     char **ppsz_options = NULL; /* list of options */
642     int  i_options=0;
643     char v4l_mrl[6];
644     int i_pos;
645     int i;
646
647     ppsz_options = (char **) malloc(11 *sizeof(char*));
648     if (ppsz_options == NULL)
649     {
650         msg_Err(p_intf, "No memory to allocate for v4l options.");
651         return;
652     }
653     for (i=0; i<11; i++)
654     {
655         ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char));
656         if (ppsz_options[i] == NULL)
657         {
658             msg_Err(p_intf, "No memory to allocate for v4l options string %i.", i);
659             for (i-=1; i>=0; i--)
660                 free(ppsz_options[i]);
661             free(ppsz_options);
662             return;
663         }
664     }
665
666     i_pos = snprintf( &v4l_mrl[0], 6, "v4l");
667     v4l_mrl[5]='\0'; 
668
669     entryV4LChannel    = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LChannel" );
670     entryV4LFrequency  = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LFrequency" );
671     entryV4LSampleRate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LSampleRate" );
672     entryV4LQuality    = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LQuality" );
673     entryV4LTuner      = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LTuner" );
674
675     entryV4LVideoDevice  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LVideoDevice" );
676     entryV4LAudioDevice  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LAudioDevice" );
677     entryV4LNorm  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LNorm" );
678     entryV4LSize  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSize" );
679     entryV4LSoundDirection  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSoundDirection" );
680
681     i_v4l_channel = gtk_spin_button_get_value_as_int(entryV4LChannel);
682     i_v4l_frequency = gtk_spin_button_get_value_as_int(entryV4LFrequency);
683     i_v4l_samplerate = gtk_spin_button_get_value_as_int(entryV4LSampleRate);
684     i_v4l_quality = gtk_spin_button_get_value_as_int(entryV4LQuality);
685     i_v4l_tuner = gtk_spin_button_get_value_as_int(entryV4LTuner);
686
687     p_v4l_video_device = gtk_entry_get_text(GTK_ENTRY(entryV4LVideoDevice));
688     p_v4l_audio_device = gtk_entry_get_text(GTK_ENTRY(entryV4LAudioDevice));
689     p_v4l_norm = gtk_entry_get_text(GTK_ENTRY(entryV4LNorm));
690     p_v4l_size  = gtk_entry_get_text(GTK_ENTRY(entryV4LSize));
691     p_v4l_sound_direction = gtk_entry_get_text(GTK_ENTRY(entryV4LSoundDirection));
692
693     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "%s", (char*)p_v4l_video_device );
694     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
695     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "adev=%s", (char*)p_v4l_audio_device );
696     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
697     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "norm=%s", (char*)p_v4l_norm );
698     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
699     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "size=%s", (char*)p_v4l_size );
700     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
701     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "%s", (char*)p_v4l_sound_direction );
702     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
703
704     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "channel=%d", (int)i_v4l_channel );
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, "frequency=%d", (int)i_v4l_frequency );
707     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
708     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "samplerate=%d", (int)i_v4l_samplerate );
709     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
710     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "quality=%d", (int)i_v4l_quality );
711     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
712     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "tuner=%d", (int)i_v4l_tuner );
713     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
714
715     /* MJPEG only */
716     checkV4LMJPEG      = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkV4LMJPEG" );
717     b_v4l_mjpeg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkV4LMJPEG));
718     if (b_v4l_mjpeg)
719     {
720         entryV4LDecimation = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LDecimation" );
721         i_v4l_decimation = gtk_spin_button_get_value_as_int(entryV4LDecimation);
722
723         i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "mjpeg:%d", (int)i_v4l_decimation );
724         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
725     }
726     /* end MJPEG only */
727
728     PlaylistAddItem(GTK_WIDGET(button), (gchar*) &v4l_mrl, ppsz_options, i_options);
729 }
730
731
732 gboolean PlaylistEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data)
733 {
734     return FALSE;
735 }
736
737
738 void onPlaylistColumnsChanged(GtkTreeView *treeview, gpointer user_data)
739 {
740 }
741
742
743 gboolean onPlaylistRowSelected(GtkTreeView *treeview, gboolean start_editing, gpointer user_data)
744 {
745     return FALSE;
746 }
747
748
749 void onPlaylistRow(GtkTreeView *treeview, GtkTreePath *path,
750                    GtkTreeViewColumn *column, gpointer user_data)
751 {
752 }
753
754
755 void onUpdatePlaylist(GtkButton *button, gpointer user_data)
756 {
757     intf_thread_t *  p_intf = GtkGetIntf( button );
758     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
759                                                        FIND_ANYWHERE );
760     GtkTreeView *p_tvplaylist = NULL;
761
762     if( p_playlist == NULL )
763     {
764         return;
765     }
766
767     p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
768     if (p_tvplaylist)
769     {
770         GtkListStore *p_model = NULL;
771
772         /* Rebuild the playlist then. */
773         p_model = gtk_list_store_new (3,
774                     G_TYPE_STRING, /* Filename */
775                     G_TYPE_STRING, /* Time */
776                     G_TYPE_UINT);  /* Hidden field */
777         if (p_model)
778         {
779             PlaylistRebuildListStore(p_model, p_playlist);
780             gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_model));
781             g_object_unref(p_model);
782         }
783     }
784     vlc_object_release( p_playlist );
785 }
786
787 void onDeletePlaylist(GtkButton *button, gpointer user_data)
788 {
789     intf_thread_t *p_intf = GtkGetIntf( button );
790     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
791                                                        FIND_ANYWHERE );
792     GtkTreeView    *p_tvplaylist;
793
794     /* Delete an arbitrary item from the playlist */
795     p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvPlaylist" );
796     if (p_tvplaylist != NULL)
797     {
798         GList *p_rows = NULL;
799         GList *p_node;
800         GtkTreeModel *p_model = NULL;
801         GtkListStore *p_store = NULL;
802         GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_tvplaylist);
803
804         p_model = gtk_tree_view_get_model(p_tvplaylist);
805         if (p_model)
806         {
807             p_rows = gtk_tree_selection_get_selected_rows(p_selection, &p_model);
808
809             if( g_list_length( p_rows ) )
810             {
811                 /* reverse-sort so that we can delete from the furthest
812                  * to the closest item to delete...
813                  */
814                 p_rows = g_list_reverse( p_rows );
815             }
816     
817             for (p_node=p_rows; p_node!=NULL; p_node = p_node->next)
818             {
819                 GtkTreeIter iter;
820                 GtkTreePath *p_path = NULL;
821
822                 p_path = (GtkTreePath *)p_node->data;
823                 if (p_path)
824                 {
825                     if (gtk_tree_model_get_iter(p_model, &iter, p_path))
826                     {
827                         gint item;
828
829                         gtk_tree_model_get(p_model, &iter, 2, &item, -1);
830                         playlist_Delete(p_playlist, item);
831                     }
832                 }
833             }
834             g_list_foreach (p_rows, (GFunc*)gtk_tree_path_free, NULL);
835             g_list_free (p_rows);
836         }
837
838         /* Rebuild the playlist then. */
839         p_store = gtk_list_store_new (3,
840                     G_TYPE_STRING, /* Filename */
841                     G_TYPE_STRING, /* Time */
842                     G_TYPE_UINT);  /* Hidden field */
843         if (p_store)
844         {
845             PlaylistRebuildListStore(p_store, p_playlist);
846             gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_store));
847             g_object_unref(p_store);
848         }
849     }
850     vlc_object_release( p_playlist );
851 }
852
853
854 void onClearPlaylist(GtkButton *button, gpointer user_data)
855 {
856     intf_thread_t *p_intf = GtkGetIntf( button );
857     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
858                                                        FIND_ANYWHERE );
859     GtkTreeView    *p_tvplaylist;
860     int item;
861
862     if( p_playlist == NULL )
863     {
864         return;
865     }
866
867     for(item = p_playlist->i_size - 1; item >= 0 ;item-- )
868     {
869         playlist_Delete( p_playlist, item);
870     }
871     vlc_object_release( p_playlist );
872
873     // Remove all entries from the Playlist widget.
874     p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
875     if (p_tvplaylist)
876     {
877         GtkTreeModel *p_play_model;
878
879         p_play_model = gtk_tree_view_get_model(p_tvplaylist);
880         if (p_play_model)
881         {
882             gtk_list_store_clear(GTK_LIST_STORE(p_play_model));
883         }
884     }
885 }
886
887
888 void onPreferenceSave(GtkButton *button, gpointer user_data)
889 {
890 #if 0
891     intf_thread_t *p_intf = GtkGetIntf( button );
892
893     msg_Dbg(p_intf, "Preferences Save" );
894     config_SaveConfigFile( p_intf, NULL );
895 #endif
896 }
897
898
899 void onPreferenceApply(GtkButton *button, gpointer user_data)
900 {
901 #if 0
902     intf_thread_t *p_intf = GtkGetIntf( button );
903
904     msg_Dbg(p_intf, "Preferences Apply" );
905 #endif
906 }
907
908
909 void onPreferenceCancel(GtkButton *button, gpointer user_data)
910 {
911 #if 0
912     intf_thread_t *p_intf = GtkGetIntf( button );
913
914     msg_Dbg(p_intf, "Preferences Cancel" );
915     config_ResetAll( p_intf );
916     /* Cancel interface changes. */
917     config_SaveConfigFile( p_intf, NULL );
918 #endif
919 }
920
921
922 void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data)
923 {
924     intf_thread_t *p_intf = GtkGetIntf( button );
925
926     GtkEntry       *p_entryVideoCodec = NULL;
927     GtkSpinButton  *p_entryVideoBitrate = NULL;
928     GtkSpinButton  *p_entryVideoBitrateTolerance = NULL;
929     GtkSpinButton  *p_entryVideoKeyFrameInterval = NULL;
930     GtkCheckButton *p_checkVideoDeinterlace = NULL;
931     GtkEntry       *p_entryAudioCodec = NULL;
932     GtkSpinButton  *p_entryAudioBitrate = NULL;
933     const gchar    *p_video_codec;
934     gint            i_video_bitrate;
935     gint            i_video_bitrate_tolerance;
936     gint            i_video_keyframe_interval;
937     gboolean        b_video_deinterlace;
938     const gchar    *p_audio_codec;
939     gint            i_audio_bitrate;
940
941     GtkEntry       *p_entryStdAccess = NULL;
942     GtkEntry       *p_entryStdMuxer = NULL;
943     GtkEntry       *p_entryStdURL = NULL;
944     GtkEntry       *p_entryStdAnnounce = NULL;
945     GtkSpinButton  *p_entryStdTTL = NULL;
946     GtkCheckButton *p_checkSAP = NULL;
947     GtkCheckButton *p_checkSLP = NULL;
948     const gchar    *p_std_announce;
949     const gchar    *p_std_access;
950     const gchar    *p_std_muxer;
951     const gchar    *p_std_url;
952     gboolean        b_sap_announce;
953     gboolean        b_slp_announce;
954     gint            i_std_ttl;
955
956     char **ppsz_options = NULL; /* list of options */
957     int  i_options=0;
958     int  i;
959
960     gchar mrl[7];
961     int   i_pos;
962
963     ppsz_options = (char **) malloc(3 *sizeof(char*));
964     if (ppsz_options == NULL)
965     {
966         msg_Err(p_intf, "No memory to allocate for v4l options.");
967         return;
968     }
969     for (i=0; i<3; i++)
970     {
971         ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char));
972         if (ppsz_options[i] == NULL)
973         {
974             msg_Err(p_intf, "No memory to allocate for v4l options string %i.", i);
975             for (i-=1; i>=0; i--)
976                 free(ppsz_options[i]);
977             free(ppsz_options);
978             return;
979         }
980     }
981
982     i_pos = snprintf( &mrl[0], VLC_MAX_MRL, "sout");
983     mrl[6] = '\0';
984     /* option 1 */
985     i_pos = snprintf( &ppsz_options[i_options][0], VLC_MAX_MRL, "sout='#transcode{");
986     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
987
988     p_entryVideoCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryVideoCodec" );
989     p_entryVideoBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrate" );
990     p_entryVideoBitrateTolerance = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrateTolerance" );
991     p_entryVideoKeyFrameInterval = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoKeyFrameInterval" );
992     
993     p_video_codec = gtk_entry_get_text(GTK_ENTRY(p_entryVideoCodec));
994     i_video_bitrate = gtk_spin_button_get_value_as_int(p_entryVideoBitrate);
995     i_video_bitrate_tolerance = gtk_spin_button_get_value_as_int(p_entryVideoBitrateTolerance);
996     i_video_keyframe_interval = gtk_spin_button_get_value_as_int(p_entryVideoKeyFrameInterval);
997     
998     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vcodec=%s,", (char*)p_video_codec );
999     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1000     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vb=%d,", (int)i_video_bitrate );
1001     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1002     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vt=%d,", (int)i_video_bitrate_tolerance );
1003     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1004     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "keyint=%d,", (int)i_video_keyframe_interval );
1005     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1006
1007     p_checkVideoDeinterlace = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkVideoDeinterlace" );
1008     b_video_deinterlace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkVideoDeinterlace));
1009     if (b_video_deinterlace)
1010     {
1011         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "deinterlace," );
1012         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1013     }
1014     p_entryAudioCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAudioCodec" );
1015     p_entryAudioBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryAudioBitrate" );
1016
1017     p_audio_codec = gtk_entry_get_text(GTK_ENTRY(p_entryAudioCodec));
1018     i_audio_bitrate = gtk_spin_button_get_value_as_int(p_entryAudioBitrate);
1019
1020     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "acodec=%s,", (char*)p_audio_codec );
1021     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1022     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "ab=%d,", (int)i_audio_bitrate );
1023     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1024     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "channels=1}"/*, (int)i_audio_channels*/ );
1025     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1026
1027     /* option 2 */
1028     i_pos = 0;
1029     i_pos = snprintf( &ppsz_options[i_options++][i_pos], VLC_MAX_MRL - i_pos, "dst=" );
1030     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1031
1032     p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdAccess" );
1033     p_entryStdMuxer  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdMuxer" );
1034     p_entryStdURL = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdURL" );
1035     p_entryStdAnnounce = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAnnounceChannel" );
1036     p_entryStdTTL = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryStdTTL" );
1037
1038     p_std_access = gtk_entry_get_text(GTK_ENTRY(p_entryStdAccess));
1039     p_std_muxer = gtk_entry_get_text(GTK_ENTRY(p_entryStdMuxer));
1040     p_std_url = gtk_entry_get_text(GTK_ENTRY(p_entryStdURL));
1041     p_std_announce = gtk_entry_get_text(GTK_ENTRY(p_entryStdAnnounce));
1042     b_sap_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSAP));
1043     b_slp_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSLP));
1044
1045     if ( strncasecmp( (const char*)p_std_access, "display", 7 ) == 0)
1046     {
1047         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "%s,", (char*)p_std_access);
1048         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1049     }
1050     else
1051     {
1052         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "std{access=%s,", (char*)p_std_access);
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, "mux=%s,", (char*)p_std_muxer);
1055         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1056         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "url=%s", (char*)p_std_url);
1057         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1058
1059         if (strncasecmp( (const char*)p_std_access, "udp", 3)==0)
1060         {
1061             if (b_sap_announce)
1062             {
1063                 i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "sap=%s", (char*)p_std_announce);
1064                 if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1065             }
1066             if (b_slp_announce)
1067             {
1068                 i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "slp=%s", (char*)p_std_announce);
1069                 if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1070             }
1071         }
1072         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "}");
1073         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1074
1075         i_std_ttl = gtk_spin_button_get_value_as_int(p_entryStdTTL);
1076
1077         i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "ttl=%d", (int)i_std_ttl);
1078         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1079     }
1080
1081     PlaylistAddItem(GTK_WIDGET(button), (gchar*) &mrl, ppsz_options, i_options);
1082 }
1083
1084
1085
1086 void onEntryStdAccessChanged(GtkEditable *editable, gpointer user_data)
1087 {
1088     intf_thread_t *p_intf = GtkGetIntf( editable );
1089
1090     GtkCheckButton *p_checkSAP = NULL;
1091     GtkCheckButton *p_checkSLP = NULL;
1092     GtkEntry       *p_entryStdAccess = NULL;
1093     const gchar    *p_std_access = NULL;    
1094     gboolean        b_announce = FALSE;
1095
1096     p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryStdAccess" );
1097     p_checkSAP = (GtkCheckButton*) lookup_widget( GTK_WIDGET(editable), "checkSAP" );
1098     p_checkSLP = (GtkCheckButton*) lookup_widget( GTK_WIDGET(editable), "checkSLP" );
1099
1100     if ( (p_std_access == NULL) || (p_checkSAP == NULL) || (p_checkSLP == NULL))
1101     {
1102         msg_Err( p_intf, "Access, SAP and SLP widgets not found." );
1103         return;
1104     }
1105     p_std_access = gtk_entry_get_text(GTK_ENTRY(p_entryStdAccess));
1106
1107     b_announce = (strncasecmp( (const char*)p_std_access, "udp", 3) == 0);
1108     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_checkSAP), b_announce);
1109     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_checkSLP), b_announce);
1110 }
1111