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.18 2003/11/30 10:26:19 jpsaman Exp $
7 * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
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.
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.
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 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <sys/types.h> /* off_t */
47 #include "pda_callbacks.h"
48 #include "pda_interface.h"
49 #include "pda_support.h"
52 #define VLC_MAX_MRL 256
54 static char *get_file_perms(struct stat st);
56 /*****************************************************************************
57 * Useful function to retrieve p_intf
58 ****************************************************************************/
59 void * E_(__GtkGetIntf)( GtkWidget * widget )
63 if( GTK_IS_MENU_ITEM( widget ) )
65 /* Look for a GTK_MENU */
66 while( widget->parent && !GTK_IS_MENU( widget ) )
68 widget = widget->parent;
71 /* Maybe this one has the data */
72 p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
78 /* Otherwise, the parent widget has it */
79 widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
82 /* We look for the top widget */
83 widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) );
85 p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
90 void PlaylistAddItem(GtkWidget *widget, gchar *name)
92 intf_thread_t *p_intf = GtkGetIntf( widget );
93 playlist_t *p_playlist;
94 GtkTreeView *p_tvplaylist = NULL;
96 p_playlist = (playlist_t *)
97 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
99 if( p_playlist == NULL)
100 { /* Bail out when VLC's playlist object is not found. */
104 /* Add to playlist object. */
105 p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(widget), "tvPlaylist");
108 GtkTreeModel *p_play_model;
109 GtkTreeIter p_play_iter;
111 p_play_model = gtk_tree_view_get_model(p_tvplaylist);
115 /* Add a new row to the playlist treeview model */
116 gtk_list_store_append (GTK_LIST_STORE(p_play_model), &p_play_iter);
117 gtk_list_store_set (GTK_LIST_STORE(p_play_model), &p_play_iter,
118 0, name, /* Add path to it !!! */
120 2, p_playlist->i_size, /* Hidden index. */
123 msg_Dbg( p_intf, "Adding files to playlist ...");
124 /* Add to VLC's playlist */
126 if (p_intf->p_sys->b_autoplayfile)
128 playlist_Add( p_playlist, (const char*)name, 0, 0,
129 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END);
134 playlist_Add( p_playlist, (const char*)name, 0, 0,
135 PLAYLIST_APPEND, PLAYLIST_END );
137 msg_Dbg( p_intf, "done");
140 vlc_object_release( p_playlist );
143 void PlaylistRebuildListStore( GtkListStore * p_list, playlist_t * p_playlist )
147 gchar * ppsz_text[2];
153 vlc_mutex_lock( &p_playlist->object_lock );
154 for( i_dummy = 0; i_dummy < p_playlist->i_size ; i_dummy++ )
156 ppsz_text[0] = p_playlist->pp_items[i_dummy]->psz_name;
157 ppsz_text[1] = "no info";
158 gtk_list_store_append (p_list, &iter);
159 gtk_list_store_set (p_list, &iter,
162 2, i_dummy, /* Hidden index */
165 vlc_mutex_unlock( &p_playlist->object_lock );
168 /*****************************************************************
169 * Read directory helper function.
170 ****************************************************************/
171 void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
174 struct dirent **namelist;
180 msg_Dbg(p_intf, "Changing to dir %s", psz_dir);
183 status = chdir(psz_dir);
185 msg_Dbg(p_intf, "permision denied" );
187 n = scandir(".", &namelist, 0, alphasort);
196 if (lstat("..", &st)==0)
199 pw = getpwuid(st.st_uid);
200 grp = getgrgid(st.st_gid);
202 /* XXX : kludge temporaire pour yopy */
204 ppsz_text[1] = get_file_perms(st);
205 ppsz_text[2] = pw->pw_name;
206 ppsz_text[3] = grp->gr_name;
208 /* Add a new row to the model */
209 gtk_list_store_append (p_list, &iter);
210 gtk_list_store_set (p_list, &iter,
218 if (ppsz_text[1]) free(ppsz_text[1]);
223 if ((namelist[i]->d_name[0] != '.') &&
224 (lstat(namelist[i]->d_name, &st)==0))
227 pw = getpwuid(st.st_uid);
228 grp = getgrgid(st.st_gid);
230 /* This is a list of strings. */
231 ppsz_text[0] = namelist[i]->d_name;
232 ppsz_text[1] = get_file_perms(st);
233 ppsz_text[2] = pw->pw_name;
234 ppsz_text[3] = grp->gr_name;
236 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] );
238 gtk_list_store_append (p_list, &iter);
239 gtk_list_store_set (p_list, &iter,
247 if (ppsz_text[1]) free(ppsz_text[1]);
254 static char *get_file_perms(const struct stat st)
258 perm = (char *) malloc(sizeof(char)*10);
259 strncpy( perm, "----------", sizeof("----------"));
261 /* determine permission modes */
262 if (S_ISLNK(st.st_mode))
264 else if (S_ISDIR(st.st_mode))
266 else if (S_ISCHR(st.st_mode))
268 else if (S_ISBLK(st.st_mode))
270 else if (S_ISFIFO(st.st_mode))
272 else if (S_ISSOCK(st.st_mode))
274 else if (S_ISREG(st.st_mode))
276 else /* Unknown type is an error */
278 /* Get file permissions */
280 if (st.st_mode & S_IRUSR)
282 if (st.st_mode & S_IWUSR)
284 if (st.st_mode & S_IXUSR)
286 if (st.st_mode & S_ISUID)
291 else if (st.st_mode & S_ISUID)
294 if (st.st_mode & S_IRGRP)
296 if (st.st_mode & S_IWGRP)
298 if (st.st_mode & S_IXGRP)
300 if (st.st_mode & S_ISGID)
305 else if (st.st_mode & S_ISGID)
308 if (st.st_mode & S_IROTH)
310 if (st.st_mode & S_IWOTH)
312 if (st.st_mode & S_IXOTH)
315 if (st.st_mode &S_ISVTX)
320 else if (st.st_mode &S_ISVTX)
327 * Main interface callbacks
331 onPDADeleteEvent (GtkWidget *widget,
335 intf_thread_t *p_intf = GtkGetIntf( widget );
337 msg_Dbg( p_intf, "about to exit vlc ... " );
338 vlc_mutex_lock( &p_intf->change_lock );
339 p_intf->p_vlc->b_die = VLC_TRUE;
340 vlc_mutex_unlock( &p_intf->change_lock );
341 msg_Dbg( p_intf, "about to exit vlc ... signalled" );
348 onRewind (GtkButton *button,
351 intf_thread_t * p_intf = GtkGetIntf( button );
353 if (p_intf->p_sys->p_input != NULL)
355 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
361 onPause (GtkButton *button,
364 intf_thread_t * p_intf = GtkGetIntf( button );
366 if (p_intf->p_sys->p_input != NULL)
368 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
374 onPlay (GtkButton *button,
377 intf_thread_t * p_intf = GtkGetIntf( GTK_WIDGET( button ) );
378 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
382 vlc_mutex_lock( &p_playlist->object_lock );
383 if (p_playlist->i_size)
385 vlc_mutex_unlock( &p_playlist->object_lock );
386 playlist_Play( p_playlist );
390 vlc_mutex_unlock( &p_playlist->object_lock );
392 vlc_object_release( p_playlist );
398 onStop (GtkButton *button,
401 intf_thread_t * p_intf = GtkGetIntf( GTK_WIDGET( button ) );
402 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
406 playlist_Stop( p_playlist );
407 vlc_object_release( p_playlist );
413 onForward (GtkButton *button,
416 intf_thread_t *p_intf = GtkGetIntf( button );
418 if (p_intf->p_sys->p_input != NULL)
420 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
426 onAbout (GtkButton *button,
429 intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(button) );
432 if (p_intf->p_sys->p_notebook)
434 gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
435 gtk_notebook_set_page(p_intf->p_sys->p_notebook,6);
441 SliderRelease (GtkWidget *widget,
442 GdkEventButton *event,
445 intf_thread_t *p_intf = GtkGetIntf( widget );
447 vlc_mutex_lock( &p_intf->change_lock );
448 p_intf->p_sys->b_slider_free = 1;
449 vlc_mutex_unlock( &p_intf->change_lock );
456 SliderPress (GtkWidget *widget,
457 GdkEventButton *event,
460 intf_thread_t *p_intf = GtkGetIntf( widget );
462 vlc_mutex_lock( &p_intf->change_lock );
463 p_intf->p_sys->b_slider_free = 0;
464 vlc_mutex_unlock( &p_intf->change_lock );
469 void addSelectedToPlaylist(GtkTreeModel *model,
476 gtk_tree_model_get(model, iter, 0, &filename, -1);
478 PlaylistAddItem(GTK_WIDGET(userdata), filename);
482 onFileListRow (GtkTreeView *treeview,
484 GtkTreeViewColumn *column,
487 intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(treeview) );
488 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
490 if (gtk_tree_selection_count_selected_rows(selection) == 1)
497 /* This might be a directory selection */
498 model = gtk_tree_view_get_model(treeview);
501 msg_Err(p_intf, "PDA: Filelist model contains a NULL pointer\n" );
504 if (!gtk_tree_model_get_iter(model, &iter, path))
506 msg_Err( p_intf, "PDA: Could not get iter from model" );
510 gtk_tree_model_get(model, &iter, 0, &filename, -1);
511 if (stat((char*)filename, &st)==0)
513 if (S_ISDIR(st.st_mode))
515 GtkListStore *p_model = NULL;
517 /* Get new directory listing */
518 p_model = gtk_list_store_new (5,
526 ReadDirectory(p_intf, p_model, filename);
528 /* Update TreeView with new model */
529 gtk_tree_view_set_model(treeview, (GtkTreeModel*) p_model);
530 g_object_unref(p_model);
535 gtk_tree_selection_selected_foreach(selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
541 gtk_tree_selection_selected_foreach(selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
546 onAddFileToPlaylist (GtkButton *button,
549 GtkTreeView *treeview = NULL;
551 treeview = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvFileList");
554 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
556 gtk_tree_selection_selected_foreach(selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
562 NetworkBuildMRL (GtkEditable *editable,
565 GtkSpinButton *networkPort = NULL;
566 GtkEntry *entryMRL = NULL;
567 GtkEntry *networkType = NULL;
568 GtkEntry *networkAddress = NULL;
569 GtkEntry *networkProtocol = NULL;
570 const gchar *mrlNetworkType;
571 const gchar *mrlAddress;
572 const gchar *mrlProtocol;
574 char text[VLC_MAX_MRL];
577 entryMRL = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryMRL" );
579 networkType = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkType" );
580 networkAddress = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkAddress" );
581 networkPort = (GtkSpinButton*) lookup_widget( GTK_WIDGET(editable), "entryNetworkPort" );
582 networkProtocol = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkProtocolType" );
584 mrlNetworkType = gtk_entry_get_text(GTK_ENTRY(networkType));
585 mrlAddress = gtk_entry_get_text(GTK_ENTRY(networkAddress));
586 mrlPort = gtk_spin_button_get_value_as_int(networkPort);
587 mrlProtocol = gtk_entry_get_text(GTK_ENTRY(networkProtocol));
589 /* Build MRL from parts ;-) */
590 pos = snprintf( &text[0], VLC_MAX_MRL, "%s://", (char*)mrlProtocol);
591 if (strncasecmp( (char*)mrlNetworkType, "multicast",9)==0)
593 pos += snprintf( &text[pos], VLC_MAX_MRL - pos, "@" );
595 pos += snprintf( &text[pos], VLC_MAX_MRL - pos, "%s:%d", (char*)mrlAddress, (int)mrlPort );
597 if (pos >= VLC_MAX_MRL)
598 text[VLC_MAX_MRL-1]='\0';
600 gtk_entry_set_text(entryMRL,text);
604 onAddNetworkPlaylist (GtkButton *button,
607 GtkEntry *p_mrl = NULL;
608 const gchar *mrl_name;
610 p_mrl = (GtkEntry*) lookup_widget(GTK_WIDGET(button),"entryMRL" );
613 mrl_name = gtk_entry_get_text(p_mrl);
615 PlaylistAddItem(GTK_WIDGET(button), (gchar *)mrl_name);
621 onAddCameraToPlaylist (GtkButton *button,
624 intf_thread_t *p_intf = GtkGetIntf( button );
626 GtkSpinButton *entryV4LChannel = NULL;
627 GtkSpinButton *entryV4LFrequency = NULL;
628 GtkSpinButton *entryV4LSampleRate = NULL;
629 GtkSpinButton *entryV4LQuality = NULL;
630 GtkSpinButton *entryV4LTuner = NULL;
632 gint i_v4l_frequency;
633 gint i_v4l_samplerate;
637 GtkEntry *entryV4LVideoDevice = NULL;
638 GtkEntry *entryV4LAudioDevice = NULL;
639 GtkEntry *entryV4LNorm = NULL;
640 GtkEntry *entryV4LSize = NULL;
641 GtkEntry *entryV4LSoundDirection = NULL;
642 const gchar *p_v4l_video_device;
643 const gchar *p_v4l_audio_device;
644 const gchar *p_v4l_norm;
645 const gchar *p_v4l_size;
646 const gchar *p_v4l_sound_direction;
649 GtkCheckButton *checkV4LMJPEG = NULL;
650 GtkSpinButton *entryV4LDecimation = NULL;
651 gboolean b_v4l_mjpeg;
652 gint i_v4l_decimation;
655 char v4l_mrl[VLC_MAX_MRL];
658 pos = snprintf( &v4l_mrl[0], VLC_MAX_MRL, "v4l://");
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" );
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" );
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);
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));
684 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":%s", (char*)p_v4l_video_device );
685 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":adev=%s", (char*)p_v4l_audio_device );
686 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":norm=%s", (char*)p_v4l_norm );
687 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":size=%s", (char*)p_v4l_size );
688 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":%s", (char*)p_v4l_sound_direction );
690 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":channel=%d", (int)i_v4l_channel );
691 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":frequency=%d", (int)i_v4l_frequency );
692 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":samplerate=%d", (int)i_v4l_samplerate );
693 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":quality=%d", (int)i_v4l_quality );
694 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":tuner=%d", (int)i_v4l_tuner );
697 checkV4LMJPEG = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkV4LMJPEG" );
698 b_v4l_mjpeg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkV4LMJPEG));
701 entryV4LDecimation = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LDecimation" );
702 i_v4l_decimation = gtk_spin_button_get_value_as_int(entryV4LDecimation);
703 pos += snprintf( &v4l_mrl[pos], VLC_MAX_MRL - pos, ":mjpeg:%d", (int)i_v4l_decimation );
707 if (pos >= VLC_MAX_MRL)
709 v4l_mrl[VLC_MAX_MRL-1]='\0';
710 msg_Err(p_intf, "Media Resource Locator is truncated to: %s", v4l_mrl);
713 PlaylistAddItem(GTK_WIDGET(button), (gchar*) &v4l_mrl);
718 PlaylistEvent (GtkWidget *widget,
727 onPlaylistColumnsChanged (GtkTreeView *treeview,
734 onPlaylistRowSelected (GtkTreeView *treeview,
735 gboolean start_editing,
743 onPlaylistRow (GtkTreeView *treeview,
745 GtkTreeViewColumn *column,
752 onUpdatePlaylist (GtkButton *button,
755 intf_thread_t * p_intf = GtkGetIntf( button );
756 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
758 GtkTreeView *p_tvplaylist = NULL;
760 if( p_playlist == NULL )
765 p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
768 GtkListStore *p_model = NULL;
770 /* Rebuild the playlist then. */
771 p_model = gtk_list_store_new (3,
772 G_TYPE_STRING, /* Filename */
773 G_TYPE_STRING, /* Time */
774 G_TYPE_UINT); /* Hidden field */
777 PlaylistRebuildListStore(p_model, p_playlist);
778 msg_Dbg(p_intf, "Adding new model to Playlist" );
779 gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_model));
780 g_object_unref(p_model);
783 vlc_object_release( p_playlist );
787 onDeletePlaylist (GtkButton *button,
790 intf_thread_t *p_intf = GtkGetIntf( button );
791 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
793 GtkTreeView *p_tvplaylist;
795 /* Delete an arbitrary item from the playlist */
796 msg_Dbg(p_intf, "Delete playlist item ... " );
797 p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvPlaylist" );
798 if (p_tvplaylist != NULL)
800 GList *p_rows = NULL;
802 GtkTreeModel *p_model = NULL;
803 GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_tvplaylist);
805 p_model = gtk_tree_view_get_model(p_tvplaylist);
808 p_rows = gtk_tree_selection_get_selected_rows(p_selection, &p_model);
810 if( g_list_length( p_rows ) )
812 /* reverse-sort so that we can delete from the furthest
813 * to the closest item to delete...
815 p_rows = g_list_reverse( p_rows );
818 for (p_node=p_rows; p_node!=NULL; p_node = p_node->next)
821 GtkTreePath *p_path = NULL;
823 p_path = (GtkTreePath *)p_node->data;
826 if (gtk_tree_model_get_iter(p_model, &iter, p_path))
831 gtk_tree_model_get(p_model, &iter, 0, &p_filename, -1);
832 gtk_tree_model_get(p_model, &iter, 2, &item, -1);
833 msg_Dbg(p_intf, "Deleting %d %s", item, p_filename);
834 playlist_Delete(p_playlist, item);
839 g_list_foreach (p_rows, gtk_tree_path_free, NULL);
840 g_list_free (p_rows);
843 /* Rebuild the playlist then. */
844 p_model = gtk_list_store_new (3,
845 G_TYPE_STRING, /* Filename */
846 G_TYPE_STRING, /* Time */
847 G_TYPE_UINT); /* Hidden field */
850 PlaylistRebuildListStore(GTK_LIST_STORE(p_model), p_playlist);
851 msg_Dbg(p_intf, "Adding new model to Playlist" );
852 gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_model));
853 g_object_unref(p_model);
856 vlc_object_release( p_playlist );
858 msg_Dbg(p_intf, "Delete playlist item ... done" );
863 onClearPlaylist (GtkButton *button,
866 intf_thread_t *p_intf = GtkGetIntf( button );
867 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
869 GtkTreeView *p_tvplaylist;
872 if( p_playlist == NULL )
877 for(item = p_playlist->i_size - 1; item >= 0 ;item-- )
879 playlist_Delete( p_playlist, item);
881 vlc_object_release( p_playlist );
883 // Remove all entries from the Playlist widget.
884 p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
887 GtkTreeModel *p_play_model;
889 p_play_model = gtk_tree_view_get_model(p_tvplaylist);
892 gtk_list_store_clear(GTK_LIST_STORE(p_play_model));
899 onPreferenceSave (GtkButton *button,
902 intf_thread_t *p_intf = GtkGetIntf( button );
904 msg_Dbg(p_intf, "Preferences Save" );
909 onPreferenceApply (GtkButton *button,
912 intf_thread_t *p_intf = GtkGetIntf( button );
914 msg_Dbg(p_intf, "Preferences Apply" );
919 onPreferenceCancel (GtkButton *button,
922 intf_thread_t *p_intf = GtkGetIntf( button );
924 msg_Dbg(p_intf, "Preferences Cancel" );
929 onAddTranscodeToPlaylist (GtkButton *button,
932 intf_thread_t *p_intf = GtkGetIntf( button );
934 GtkEntry *entryVideoCodec = NULL;
935 GtkSpinButton *entryVideoBitrate = NULL;
936 GtkSpinButton *entryVideoBitrateTolerance = NULL;
937 GtkSpinButton *entryVideoKeyFrameInterval = NULL;
938 GtkCheckButton *checkVideoDeinterlace = NULL;
939 GtkEntry *entryAudioCodec = NULL;
940 GtkSpinButton *entryAudioBitrate = NULL;
941 const gchar *p_video_codec;
942 gint i_video_bitrate;
943 gint i_video_bitrate_tolerance;
944 gint i_video_keyframe_interval;
945 gboolean b_video_deinterlace;
946 const gchar *p_audio_codec;
947 gint i_audio_bitrate;
949 GtkEntry *entryStdAccess = NULL;
950 GtkEntry *entryStdMuxer = NULL;
951 GtkEntry *entryStdURL = NULL;
952 GtkSpinButton *entryStdTTL = NULL;
953 const gchar *p_std_access;
954 const gchar *p_std_muxer;
955 const gchar *p_std_url;
958 gchar mrl[VLC_MAX_MRL];
961 pos = snprintf( &mrl[0], VLC_MAX_MRL, "--sout '#transcode{");
963 entryVideoCodec = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryVideoCodec" );
964 entryVideoBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrate" );
965 entryVideoBitrateTolerance = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrateTolerance" );
966 entryVideoKeyFrameInterval = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoKeyFrameInterval" );
968 p_video_codec = gtk_entry_get_text(GTK_ENTRY(entryVideoCodec));
969 i_video_bitrate = gtk_spin_button_get_value_as_int(entryVideoBitrate);
970 i_video_bitrate_tolerance = gtk_spin_button_get_value_as_int(entryVideoBitrateTolerance);
971 i_video_keyframe_interval = gtk_spin_button_get_value_as_int(entryVideoKeyFrameInterval);
973 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "vcodec=%s,", (char*)p_video_codec );
974 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "vb=%d,", (int)i_video_bitrate );
975 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "vt=%d,", (int)i_video_bitrate_tolerance );
976 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "keyint=%d,", (int)i_video_keyframe_interval );
978 checkVideoDeinterlace = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkVideoDeinterlace" );
979 b_video_deinterlace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkVideoDeinterlace));
980 if (b_video_deinterlace)
982 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "deinterlace," );
984 entryAudioCodec = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAudioCodec" );
985 entryAudioBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryAudioBitrate" );
987 p_audio_codec = gtk_entry_get_text(GTK_ENTRY(entryAudioCodec));
988 i_audio_bitrate = gtk_spin_button_get_value_as_int(entryAudioBitrate);
990 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "acodec=%s,", (char*)p_audio_codec );
991 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "ab=%d", (int)i_audio_bitrate );
993 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "}:std{" );
995 entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdAccess" );
996 entryStdMuxer = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdMuxer" );
997 entryStdURL = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdURL" );
998 entryStdTTL = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryStdTTL" );
1000 p_std_access = gtk_entry_get_text(GTK_ENTRY(entryStdAccess));
1001 p_std_muxer = gtk_entry_get_text(GTK_ENTRY(entryStdMuxer));
1002 p_std_url = gtk_entry_get_text(GTK_ENTRY(entryStdURL));
1004 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "access=%s,", (char*)p_std_access);
1005 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "mux=%s,", (char*)p_std_muxer);
1006 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "url=%s", (char*)p_std_url);
1007 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, "}'");
1009 i_std_ttl = gtk_spin_button_get_value_as_int(entryStdTTL);
1011 pos += snprintf( &mrl[pos], VLC_MAX_MRL - pos, " --ttl=%d", (int)i_std_ttl);
1013 if (pos >= VLC_MAX_MRL)
1015 mrl[VLC_MAX_MRL-1]='\0';
1016 msg_Err(p_intf, "Media Resource Locator is truncated to: %s", mrl );
1019 PlaylistAddItem(GTK_WIDGET(button), (gchar*) &mrl);