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