From: Jean-Paul Saman Date: Mon, 30 Sep 2002 20:37:13 +0000 (+0000) Subject: Familiar Linux Gtk+ based interface backported from vlc-0.5.0 cvs. This is not a... X-Git-Tag: 0.4.6.1~91 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=e11f39d7b06831a7ab76a2f3a695cbd452528764;hp=c36ab258859443600501610378a119d7a8294ef6;p=vlc Familiar Linux Gtk+ based interface backported from vlc-0.5.0 cvs. This is not a working version, it segfaults open selecting a directory. --- diff --git a/plugins/familiar/Makefile b/plugins/familiar/Makefile new file mode 100644 index 0000000000..f81918f22c --- /dev/null +++ b/plugins/familiar/Makefile @@ -0,0 +1 @@ +familiar_SOURCES = familiar.c familiar_interface.c familiar_support.c familiar_callbacks.c diff --git a/plugins/familiar/familiar.c b/plugins/familiar/familiar.c new file mode 100644 index 0000000000..fb0ad8dfb2 --- /dev/null +++ b/plugins/familiar/familiar.c @@ -0,0 +1,243 @@ +/***************************************************************************** + * familiar.c : familiar plugin for vlc + ***************************************************************************** + * Copyright (C) 2002 VideoLAN + * $Id: familiar.c,v 1.8.2.1 2002/09/30 20:37:13 jpsaman Exp $ + * + * Authors: Jean-Paul Saman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include /* malloc(), free() */ +#include /* ENOMEM */ +#include /* strerror() */ +#include + +#include + +#include + +#include "stream_control.h" +#include "input_ext-intf.h" + +#include "interface.h" +#include "intf_playlist.h" + +#include "video.h" +#include "video_output.h" + +#include "familiar_callbacks.h" +#include "familiar_interface.h" +#include "familiar_support.h" +#include "familiar.h" + +/***************************************************************************** + * g_atexit: kludge to avoid the Gtk+ thread to segfault at exit + ***************************************************************************** + * gtk_init() makes several calls to g_atexit() which calls atexit() to + * register tidying callbacks to be called at program exit. Since the Gtk+ + * plugin is likely to be unloaded at program exit, we have to export this + * symbol to intercept the g_atexit() calls. Talk about crude hack. + *****************************************************************************/ +void g_atexit( GVoidFunc func ) +{ + intf_thread_t *p_intf = p_main->p_intf; + int i_dummy; + + for( i_dummy = 0; + i_dummy < MAX_ATEXIT && p_intf->p_sys->pf_callback[i_dummy] != NULL; + i_dummy++ ) + { + ; + } + + if( i_dummy >= MAX_ATEXIT - 1 ) + { + intf_ErrMsg( "too many atexit() callbacks to register" ); + return; + } + + p_intf->p_sys->pf_callback[i_dummy] = func; + p_intf->p_sys->pf_callback[i_dummy + 1] = NULL; +} + +/***************************************************************************** + * Local prototypes. + *****************************************************************************/ +static void intf_getfunctions ( function_list_t * p_function_list ); +static int Open ( intf_thread_t *p_intf ); +static void Close ( intf_thread_t *p_intf ); +static void Run ( intf_thread_t * ); + +/***************************************************************************** + * Module descriptor + *****************************************************************************/ +MODULE_CONFIG_START +ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL ) +MODULE_CONFIG_STOP + +MODULE_INIT_START + SET_DESCRIPTION( _("Familiar Linux Gtk+ interface module") ) +#ifndef WIN32 + if( getenv( "DISPLAY" ) == NULL ) + { + ADD_CAPABILITY( INTF, 10 ) + } + else +#endif + { + ADD_CAPABILITY( INTF, 70 ) + } +MODULE_INIT_STOP + +MODULE_ACTIVATE_START + intf_getfunctions( &p_module->p_functions->intf ); +MODULE_ACTIVATE_STOP + +MODULE_DEACTIVATE_START +MODULE_DEACTIVATE_STOP + +/***************************************************************************** + * Functions exported as capabilities. They are declared as static so that + * we don't pollute the namespace too much. + *****************************************************************************/ +static void intf_getfunctions( function_list_t * p_function_list ) +{ + p_function_list->functions.intf.pf_open = Open; + p_function_list->functions.intf.pf_close = Close; + p_function_list->functions.intf.pf_run = Run; +} + +/***************************************************************************** + * Open: initialize and create window + *****************************************************************************/ +static int Open( intf_thread_t *p_intf ) +{ + /* Allocate instance and initialize some members */ + p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); + if( p_intf->p_sys == NULL ) + { + intf_ErrMsg( "out of memory" ); + return (1); + } + + /* Initialize Gtk+ thread */ + p_intf->p_sys->b_autoplayfile = 1; + + /* Initialize Gtk+ thread */ + p_intf->p_sys->p_input = NULL; + p_intf->pf_run = Run; + + return (0); +} + +/***************************************************************************** + * Close: destroy interface window + *****************************************************************************/ +static void Close( intf_thread_t *p_intf ) +{ + if( p_intf->p_sys->p_input ) + { +// vlc_object_release( p_intf->p_sys->p_input ); + } + + /* Destroy structure */ + free( p_intf->p_sys ); +} + +/***************************************************************************** + * Run: Gtk+ thread + ***************************************************************************** + * this part of the interface is in a separate thread so that we can call + * gtk_main() from within it without annoying the rest of the program. + *****************************************************************************/ +static void Run( intf_thread_t *p_intf ) +{ + /* gtk_init needs to know the command line. We don't care, so we + * give it an empty one */ + char *p_args[] = { "" }; + char **pp_args = p_args; + int i_args = 1; + int i_dummy = 0; + + /* Initialize Gtk+ */ + gtk_set_locale (); + + /* gtk_init will register stuff with g_atexit, so we need to take + * the global lock if we want to be able to intercept the calls */ + gtk_init( &i_args, &pp_args ); + + /* Create some useful widgets that will certainly be used */ +// FIXME: magic path + add_pixmap_directory("share"); + + p_intf->p_sys->p_window = create_familiar(); + if (p_intf->p_sys->p_window == NULL) + { + intf_ErrMsg( "unable to create familiar interface" ); + } + + /* Set the title of the main window */ + gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window), + VOUT_TITLE " (Familiar Linux interface)"); + + p_intf->p_sys->p_notebook = GTK_NOTEBOOK( gtk_object_get_data( + GTK_OBJECT( p_intf->p_sys->p_window ), "notebook" ) ); +// gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_notebook) ); + + p_intf->p_sys->p_progess = GTK_PROGRESS_BAR( gtk_object_get_data( + GTK_OBJECT( p_intf->p_sys->p_window ), "progress" ) ); + gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_progess) ); + + p_intf->p_sys->p_clist = GTK_CLIST( gtk_object_get_data( + GTK_OBJECT( p_intf->p_sys->p_window ), "clistmedia" ) ); + gtk_clist_set_column_visibility (GTK_CLIST (p_intf->p_sys->p_clist), 2, FALSE); + gtk_clist_set_column_visibility (GTK_CLIST (p_intf->p_sys->p_clist), 3, FALSE); + gtk_clist_set_column_visibility (GTK_CLIST (p_intf->p_sys->p_clist), 4, FALSE); + gtk_clist_column_titles_show (GTK_CLIST (p_intf->p_sys->p_clist)); + + /* Store p_intf to keep an eye on it */ + gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window), + "p_intf", p_intf ); + /* Show the control window */ + gtk_widget_show( p_intf->p_sys->p_window ); + ReadDirectory(p_intf->p_sys->p_clist, "."); + + /* Sleep to avoid using all CPU - since some interfaces needs to access + * keyboard events, a 100ms delay is a good compromise */ +// i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, GtkManage, p_intf ); + + /* Enter Gtk mode */ + gtk_main(); + + intf_ErrMsg( "@@@ Run exiting interface" ); + + /* Remove the timeout */ + gtk_timeout_remove( i_dummy ); + gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) ); + + /* Launch stored callbacks */ + for( i_dummy = 0; + i_dummy < MAX_ATEXIT && p_intf->p_sys->pf_callback[i_dummy] != NULL; + i_dummy++ ) + { + p_intf->p_sys->pf_callback[i_dummy](); + } +} + diff --git a/plugins/familiar/familiar.glade b/plugins/familiar/familiar.glade new file mode 100644 index 0000000000..325e285cb3 --- /dev/null +++ b/plugins/familiar/familiar.glade @@ -0,0 +1,557 @@ + + + + + Familiar + familiar + + + ../../share + C + False + True + True + False + False + + + + GtkWindow + familiar + 240 + 320 + + delete_event + on_familiar_delete_event + Wed, 21 Aug 2002 19:12:40 GMT + + vlc (familiar) + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + True + True + + + GtkVBox + vbox + False + 0 + + + GtkToolbar + toolbar + 112 + 16 + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_ICONS + 5 + GTK_TOOLBAR_SPACE_EMPTY + GTK_RELIEF_NORMAL + True + + 0 + True + True + + + + GtkButton + Toolbar:button + toolbar_open + Open file + + clicked + on_toolbar_open_clicked + Wed, 24 Jul 2002 18:28:31 GMT + + + familiar-openb16x16.xpm + + + + GtkButton + Toolbar:button + toolbar_preferences + Preferences + + clicked + on_toolbar_preferences_clicked + Wed, 24 Jul 2002 18:29:05 GMT + + + familiar-preferencesb16x16.xpm + + + + GtkButton + Toolbar:button + toolbar_rewind + Rewind stream + + clicked + on_toolbar_rewind_clicked + Wed, 24 Jul 2002 18:28:45 GMT + + + familiar-rewindb16x16.xpm + + True + + + + + GtkButton + Toolbar:button + toolbar_pause + Pause stream + + clicked + on_toolbar_pause_clicked + Wed, 24 Jul 2002 18:28:58 GMT + + + familiar-pauseb16x16.xpm + + + + GtkButton + Toolbar:button + toolbar_play + Play stream + + clicked + on_toolbar_play_clicked + Wed, 24 Jul 2002 18:29:12 GMT + + + familiar-playb16x16.xpm + + + + GtkButton + Toolbar:button + toolbar_stop + Stop stream + + clicked + on_toolbar_stop_clicked + Wed, 24 Jul 2002 18:29:18 GMT + + + familiar-stopb16x16.xpm + + + + GtkButton + Toolbar:button + toolbar_forward + Forward stream + + clicked + on_toolbar_forward_clicked + Wed, 24 Jul 2002 18:29:25 GMT + + + familiar-forwardb16x16.xpm + + + + GtkButton + Toolbar:button + toolbar_about + About + + clicked + on_toolbar_about_clicked + Wed, 24 Jul 2002 18:29:31 GMT + + + vlc16x16.xpm + + True + + + + + + GtkProgressBar + progress + 0 + 0 + 100 + GTK_PROGRESS_CONTINUOUS + GTK_PROGRESS_LEFT_TO_RIGHT + True + False + %P %% + 0.5 + 0.5 + + 0 + False + False + + + + + GtkNotebook + notebook + True + True + True + GTK_POS_TOP + False + 2 + 2 + False + + 0 + True + True + + + + GtkFixed + fixedMedia + + + GtkLabel + labelUrl + 4 + 8 + 38 + 18 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkCombo + comboURL + 40 + 4 + 185 + 24 + False + True + False + True + False + file:// +ftp:// +http:// +udp://:1234 +udpstream://@:1234 + + + + GtkEntry + GtkCombo:entry + comboURL-entry + True + + changed + on_comboURL-entry_changed + Thu, 01 Aug 2002 19:37:06 GMT + + True + True + 0 + file:// + + + + + GtkScrolledWindow + scrolledwindow1 + 0 + 32 + 240 + 208 + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkCList + clistmedia + True + + select_row + on_clistmedia_select_row + Sun, 18 Aug 2002 19:40:44 GMT + + + click_column + on_clistmedia_click_column + Sun, 18 Aug 2002 19:41:06 GMT + + 5 + 123,80,80,80,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + labelname + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + labeltype + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + labelsize + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + labeluid + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + labelgid + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + + GtkLabel + Notebook:tab + media + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkFixed + fixedPreferences + + + GtkButton + buttonSave + 8 + 216 + 54 + 24 + True + + GTK_RELIEF_NORMAL + + + + GtkButton + buttonApply + 64 + 216 + 54 + 24 + True + + GTK_RELIEF_NORMAL + + + + GtkButton + buttonCancel + 176 + 216 + 54 + 24 + True + + GTK_RELIEF_NORMAL + + + + GtkCheckButton + cbautoplay + 8 + 8 + 216 + 24 + True + + toggled + on_cbautoplay_toggled + Sun, 18 Aug 2002 20:00:52 GMT + + + True + True + + + + + GtkLabel + Notebook:tab + preferences + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkFixed + fixedAbout + + + GtkPixmap + logo + 8 + 0 + 50 + 50 + vlc32x32.xpm + 0.5 + 0.5 + 0 + 0 + True + + + + GtkLabel + labelVlc + 64 + 8 + 120 + 40 + + GTK_JUSTIFY_CENTER + True + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + labelCopyright + 16 + 56 + 200 + 18 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + labelAuthors + 16 + 80 + 200 + 40 + + GTK_JUSTIFY_CENTER + True + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + labelAbout + 16 + 128 + 200 + 70 + + GTK_JUSTIFY_LEFT + True + 0.5 + 0.5 + 0 + 0 + + + + + GtkLabel + Notebook:tab + about + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + diff --git a/plugins/familiar/familiar.h b/plugins/familiar/familiar.h new file mode 100644 index 0000000000..b80625b2b8 --- /dev/null +++ b/plugins/familiar/familiar.h @@ -0,0 +1,52 @@ +/***************************************************************************** + * familiar.h: private Gtk+ interface description + ***************************************************************************** + * Copyright (C) 1999, 2000 VideoLAN + * $Id: familiar.h,v 1.6.2.1 2002/09/30 20:37:13 jpsaman Exp $ + * + * Authors: Jean-Paul Saman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#define MAX_ATEXIT 10 + +/***************************************************************************** + * intf_sys_t: description and status of Gtk+ interface + *****************************************************************************/ +typedef struct intf_sys_s +{ + /* windows and widgets */ + GtkWidget * p_window; /* main window */ + GtkNotebook * p_notebook; + GtkProgressBar * p_progess; + GtkCList * p_clist; + + boolean_t b_autoplayfile; + + /* The input thread */ + input_thread_t * p_input; + + /* XXX: Ugly kludge, see gtk.c */ + void ( *pf_callback[MAX_ATEXIT] ) ( void ); +} intf_sys_t; + +/***************************************************************************** + * Useful macro + ****************************************************************************/ +#define GtkGetIntf( widget ) __GtkGetIntf( GTK_WIDGET( widget ) ) +void * __GtkGetIntf( GtkWidget * ); + + diff --git a/plugins/familiar/familiar_callbacks.c b/plugins/familiar/familiar_callbacks.c new file mode 100644 index 0000000000..62dce7b2dd --- /dev/null +++ b/plugins/familiar/familiar_callbacks.c @@ -0,0 +1,501 @@ +/***************************************************************************** + * callbacks.c : Callbacks for the Familiar Linux Gtk+ plugin. + ***************************************************************************** + * Copyright (C) 2000, 2001 VideoLAN + * $Id: familiar_callbacks.c,v 1.6.2.1 2002/09/30 20:37:13 jpsaman Exp $ + * + * Authors: Jean-Paul Saman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include /* off_t */ +#include + +#include +#include +#include +#include +#include + +#include + +#include "stream_control.h" +#include "input_ext-intf.h" + +#include "interface.h" +#include "intf_playlist.h" + +#include "video.h" +#include "video_output.h" + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "familiar_callbacks.h" +#include "familiar_interface.h" +#include "familiar_support.h" +#include "familiar.h" + +/*#include "netutils.h"*/ + +static void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url ); +static char* get_file_perm(const char *path); + +/***************************************************************************** + * Useful function to retrieve p_intf + ****************************************************************************/ +void * __GtkGetIntf( GtkWidget * widget ) +{ + void *p_data; + + if( GTK_IS_MENU_ITEM( widget ) ) + { + /* Look for a GTK_MENU */ + while( widget->parent && !GTK_IS_MENU( widget ) ) + { + widget = widget->parent; + } + + /* Maybe this one has the data */ + p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" ); + if( p_data ) + { + return p_data; + } + + /* Otherwise, the parent widget has it */ + widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) ); + } + + /* We look for the top widget */ + widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) ); + + p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" ); + + return p_data; +} + +/***************************************************************************** + * Helper functions for URL changes in Media and Preferences notebook pages. + ****************************************************************************/ +static void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url ) +{ + intf_thread_t *p_intf = GtkGetIntf( widget ); + + g_print( "%s\n",psz_url ); + intf_ErrMsg( "@@@ MediaURLOpenChanged" ); + if( p_intf->p_sys->p_input != NULL ) + { + input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); + p_main->p_playlist->b_stopped = 0; + } + else + { + vlc_mutex_lock( &p_main->p_playlist->change_lock ); + + if( p_main->p_playlist->b_stopped ) + { + if( p_main->p_playlist->i_size ) + { + vlc_mutex_unlock( &p_main->p_playlist->change_lock ); + intf_PlaylistJumpto( p_main->p_playlist, + p_main->p_playlist->i_index ); + } + } + else + { + vlc_mutex_unlock( &p_main->p_playlist->change_lock ); + } + } +} + +/***************************************************************** + * Read directory helper function. + ****************************************************************/ +void ReadDirectory( GtkCList *clist, char *psz_dir ) +{ +// intf_thread_t *p_intf = GtkGetIntf( clist ); + struct dirent **namelist; + int n,i; + + intf_ErrMsg( "@@@ ReadDirectory - Enter" ); + g_print( "%s\n",psz_dir ); + if (psz_dir) + chdir(psz_dir); + n = scandir(".", &namelist, 0, NULL); + + if (n<0) + perror("scandir"); + else + { + gchar *ppsz_text[2]; + + gtk_clist_freeze( clist ); + gtk_clist_clear( clist ); + + g_print( "dir entries: %d\n",n ); + for (i=0; id_name; + ppsz_text[1] = get_file_perm(namelist[i]->d_name); + g_print( "%s %s\n",ppsz_text[0],ppsz_text[1] ); + if (strcmp(ppsz_text[1],"") == 0) + intf_ErrMsg("File system error unknown filetype encountered."); + gtk_clist_insert( clist, i, ppsz_text ); + g_print( "%s\n",ppsz_text[0] ); + free(namelist[i]); + } + free(namelist); + gtk_clist_thaw( clist ); + } + intf_ErrMsg( "@@@ ReadDirectory - Exit" ); +} + +static char* get_file_perm(const char *path) +{ + struct stat st; + char *perm; + + perm = (char *) malloc(sizeof(char)*10); + strncpy( perm, "----------", sizeof("----------")); + if (lstat(path, &st)==0) + { + if (S_ISLNK(st.st_mode)) + perm[0]= 'l'; + else if (S_ISDIR(st.st_mode)) + perm[0]= 'd'; + else if (S_ISCHR(st.st_mode)) + perm[0]= 'c'; + else if (S_ISBLK(st.st_mode)) + perm[0]= 'b'; + else if (S_ISFIFO(st.st_mode)) + perm[0]= 'f'; + else if (S_ISSOCK(st.st_mode)) + perm[0]= 's'; + else if (S_ISREG(st.st_mode)) + perm[0]= '-'; + else /* Unknown type is an error */ + perm[0]= '?'; + /* Get file permissions */ + /* User */ + if (st.st_mode & S_IRUSR) + perm[1]= 'r'; + if (st.st_mode & S_IWUSR) + perm[2]= 'w'; + if (st.st_mode & S_IXUSR) + { + if (st.st_mode & S_ISUID) + perm[3] = 's'; + else + perm[3]= 'x'; + } + else if (st.st_mode & S_ISUID) + perm[3] = 'S'; + /* Group */ + if (st.st_mode & S_IRGRP) + perm[4]= 'r'; + if (st.st_mode & S_IWGRP) + perm[5]= 'w'; + if (st.st_mode & S_IXGRP) + { + if (st.st_mode & S_ISGID) + perm[6] = 's'; + else + perm[6]= 'x'; + } + else if (st.st_mode & S_ISGID) + perm[6] = 'S'; + /* Other */ + if (st.st_mode & S_IROTH) + perm[7]= 'r'; + if (st.st_mode & S_IWOTH) + perm[8]= 'w'; + if (st.st_mode & S_IXOTH) + { + // 'sticky' bit + if (st.st_mode &S_ISVTX) + perm[9] = 't'; + else + perm[9]= 'x'; + } + else if (st.st_mode &S_ISVTX) + perm[9]= 'T'; + } + return perm; +} + +/* + * Main interface callbacks + */ + +gboolean GtkExit( GtkWidget *widget, + gpointer user_data ) +{ + intf_thread_t *p_intf = GtkGetIntf( widget ); + + vlc_mutex_lock( &p_intf->change_lock ); + p_intf->b_die = 1; + vlc_mutex_unlock( &p_intf->change_lock ); + + return TRUE; +} + +void +on_toolbar_open_clicked (GtkButton *button, + gpointer user_data) +{ + intf_thread_t *p_intf = GtkGetIntf( button ); + + gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) ); + gdk_window_raise( p_intf->p_sys->p_window->window ); + if (p_intf->p_sys->p_clist) + ReadDirectory(p_intf->p_sys->p_clist, "."); +} + + +void +on_toolbar_preferences_clicked (GtkButton *button, + gpointer user_data) +{ + intf_thread_t *p_intf = GtkGetIntf( button ); + + gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) ); + gdk_window_raise( p_intf->p_sys->p_window->window ); +} + + +void +on_toolbar_rewind_clicked (GtkButton *button, + gpointer user_data) +{ + intf_thread_t * p_intf = GtkGetIntf( button ); + + if( p_intf->p_sys->p_input ) + { + input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER ); + } +} + + +void +on_toolbar_pause_clicked (GtkButton *button, + gpointer user_data) +{ + intf_thread_t * p_intf = GtkGetIntf( button ); + + if( p_intf->p_sys->p_input ) + { + input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE ); + } +} + + +void +on_toolbar_play_clicked (GtkButton *button, + gpointer user_data) +{ + intf_thread_t * p_intf = GtkGetIntf( button ); + + if( p_intf->p_sys->p_input == NULL ) + { + gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) ); + gdk_window_raise( p_intf->p_sys->p_window->window ); + /* Display open page */ + } + + /* If the playlist is empty, open a file requester instead */ + vlc_mutex_lock( &p_main->p_playlist->change_lock ); + if( p_main->p_playlist->i_size ) + { + vlc_mutex_unlock( &p_main->p_playlist->change_lock ); + input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); + p_main->p_playlist->b_stopped = 0; + gdk_window_lower( p_intf->p_sys->p_window->window ); + } + else + { + vlc_mutex_lock( &p_main->p_playlist->change_lock ); + + if( p_main->p_playlist->b_stopped ) + { + if( p_main->p_playlist->i_size ) + { + vlc_mutex_unlock( &p_main->p_playlist->change_lock ); + intf_PlaylistJumpto( p_main->p_playlist, + p_main->p_playlist->i_index ); + } + else + { + vlc_mutex_unlock( &p_main->p_playlist->change_lock ); + /* simulate on open button click */ + on_toolbar_open_clicked(button,user_data); + } + } + else + { + vlc_mutex_unlock( &p_main->p_playlist->change_lock ); + } + + } +} + + +void +on_toolbar_stop_clicked (GtkButton *button, + gpointer user_data) +{ + intf_thread_t * p_intf = GtkGetIntf( button ); + + if( p_intf->p_sys->p_input != NULL ) + { + /* end playing item */ + p_intf->p_sys->p_input->b_eof = 1; + + /* update playlist */ + vlc_mutex_lock( &p_main->p_playlist->change_lock ); + + p_main->p_playlist->i_index--; + p_main->p_playlist->b_stopped = 1; + + vlc_mutex_unlock( &p_main->p_playlist->change_lock ); + gdk_window_raise( p_intf->p_sys->p_window->window ); + } +} + + +void +on_toolbar_forward_clicked (GtkButton *button, + gpointer user_data) +{ + intf_thread_t * p_intf = GtkGetIntf( button ); + + if( p_intf->p_sys->p_input ) + { + input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER ); + } +} + + +void +on_toolbar_about_clicked (GtkButton *button, + gpointer user_data) +{ + intf_thread_t *p_intf = GtkGetIntf( button ); + + // Toggle notebook + if (p_intf->p_sys->p_notebook) + { +/* if ( gtk_get_data( GTK_WIDGET(p_intf->p_sys->p_notebook), "visible" ) ) + * gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_notebook) ); + * else + */ gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) ); + } + gdk_window_raise( p_intf->p_sys->p_window->window ); +} + + +void +on_comboURL_entry_changed (GtkEditable *editable, + gpointer user_data) +{ + intf_thread_t * p_intf = GtkGetIntf( editable ); + gchar * psz_url; + + if (p_intf->p_sys->b_autoplayfile == 1) + { + psz_url = gtk_entry_get_text(GTK_ENTRY(editable)); + MediaURLOpenChanged( GTK_WIDGET(editable), psz_url ); + } +} + +void +on_clistmedia_click_column (GtkCList *clist, + gint column, + gpointer user_data) +{ + static GtkSortType sort_type = GTK_SORT_ASCENDING; + + // Should sort on column + switch(sort_type) + { + case GTK_SORT_ASCENDING: + sort_type = GTK_SORT_DESCENDING; + break; + case GTK_SORT_DESCENDING: + sort_type = GTK_SORT_ASCENDING; + break; + } + gtk_clist_freeze( clist ); + gtk_clist_set_sort_type( clist, sort_type ); + gtk_clist_sort( clist ); + gtk_clist_thaw( clist ); +} + + +void +on_clistmedia_select_row (GtkCList *clist, + gint row, + gint column, + GdkEvent *event, + gpointer user_data) +{ + gchar *text[2]; + gint ret; + struct stat st; + + ret = gtk_clist_get_text (clist, row, 0, text); + if (ret) + { + if (lstat((char*)text[0], &st)==0) + { + if (S_ISDIR(st.st_mode)) + ReadDirectory(clist, text[0]); + else + MediaURLOpenChanged(GTK_WIDGET(clist), text[0]); + } + } +} + + +void +on_cbautoplay_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + intf_thread_t * p_intf = GtkGetIntf( togglebutton ); + + if (p_intf->p_sys->b_autoplayfile == 1) + p_intf->p_sys->b_autoplayfile = 0; + else + p_intf->p_sys->b_autoplayfile = 1; +} + + +gboolean +on_familiar_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data) +{ + GtkExit( GTK_WIDGET( widget ), user_data ); + return TRUE; +} + diff --git a/plugins/familiar/familiar_callbacks.h b/plugins/familiar/familiar_callbacks.h new file mode 100644 index 0000000000..b6a4791845 --- /dev/null +++ b/plugins/familiar/familiar_callbacks.h @@ -0,0 +1,87 @@ +/***************************************************************************** + * callbacks.h : familiar plugin for vlc + ***************************************************************************** + * Copyright (C) 2002 VideoLAN + * $Id: familiar_callbacks.h,v 1.7.2.1 2002/09/30 20:37:13 jpsaman Exp $ + * + * Authors: Jean-Paul Saman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include + +gboolean GtkExit ( GtkWidget *, gpointer ); + +void ReadDirectory(GtkCList *clist, char *psz_dir); + +void +on_toolbar_open_clicked (GtkButton *button, + gpointer user_data); + +void +on_toolbar_preferences_clicked (GtkButton *button, + gpointer user_data); + +void +on_toolbar_rewind_clicked (GtkButton *button, + gpointer user_data); + +void +on_toolbar_pause_clicked (GtkButton *button, + gpointer user_data); + +void +on_toolbar_play_clicked (GtkButton *button, + gpointer user_data); + +void +on_toolbar_stop_clicked (GtkButton *button, + gpointer user_data); + +void +on_toolbar_forward_clicked (GtkButton *button, + gpointer user_data); + +void +on_toolbar_about_clicked (GtkButton *button, + gpointer user_data); + +void +on_comboURL_entry_changed (GtkEditable *editable, + gpointer user_data); + + +void +on_clistmedia_click_column (GtkCList *clist, + gint column, + gpointer user_data); + +void +on_clistmedia_select_row (GtkCList *clist, + gint row, + gint column, + GdkEvent *event, + gpointer user_data); + +void +on_cbautoplay_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + + +gboolean +on_familiar_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data); diff --git a/plugins/familiar/familiar_interface.c b/plugins/familiar/familiar_interface.c new file mode 100644 index 0000000000..6bb59ec440 --- /dev/null +++ b/plugins/familiar/familiar_interface.c @@ -0,0 +1,498 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include +#include + +#include "familiar_callbacks.h" +#include "familiar_interface.h" +#include "familiar_support.h" + +GtkWidget* +create_familiar (void) +{ + GtkWidget *familiar; + GtkWidget *vbox; + GtkWidget *toolbar; + GtkWidget *tmp_toolbar_icon; + GtkWidget *toolbar_open; + GtkWidget *toolbar_preferences; + GtkWidget *toolbar_rewind; + GtkWidget *toolbar_pause; + GtkWidget *toolbar_play; + GtkWidget *toolbar_stop; + GtkWidget *toolbar_forward; + GtkWidget *toolbar_about; + GtkWidget *progress; + GtkWidget *notebook; + GtkWidget *fixedMedia; + GtkWidget *labelUrl; + GtkWidget *comboURL; + GList *comboURL_items = NULL; + GtkWidget *comboURL_entry; + GtkWidget *scrolledwindow1; + GtkWidget *clistmedia; + GtkWidget *labelname; + GtkWidget *labeltype; + GtkWidget *labelsize; + GtkWidget *labeluid; + GtkWidget *labelgid; + GtkWidget *media; + GtkWidget *fixedPreferences; + GtkWidget *buttonSave; + GtkWidget *buttonApply; + GtkWidget *buttonCancel; + GtkWidget *cbautoplay; + GtkWidget *preferences; + GtkWidget *fixedAbout; + GtkWidget *logo; + GtkWidget *labelVlc; + GtkWidget *labelCopyright; + GtkWidget *labelAuthors; + GtkWidget *labelAbout; + GtkWidget *about; + + familiar = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_widget_set_name (familiar, "familiar"); + gtk_object_set_data (GTK_OBJECT (familiar), "familiar", familiar); + gtk_widget_set_usize (familiar, 240, 320); + gtk_window_set_title (GTK_WINDOW (familiar), _("vlc (familiar)")); + gtk_window_set_policy (GTK_WINDOW (familiar), TRUE, TRUE, TRUE); + + vbox = gtk_vbox_new (FALSE, 0); + gtk_widget_set_name (vbox, "vbox"); + gtk_widget_ref (vbox); + gtk_object_set_data_full (GTK_OBJECT (familiar), "vbox", vbox, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox); + gtk_container_add (GTK_CONTAINER (familiar), vbox); + + toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); + gtk_widget_set_name (toolbar, "toolbar"); + gtk_widget_ref (toolbar); + gtk_object_set_data_full (GTK_OBJECT (familiar), "toolbar", toolbar, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (toolbar); + gtk_box_pack_start (GTK_BOX (vbox), toolbar, TRUE, TRUE, 0); + gtk_widget_set_usize (toolbar, 112, 16); + + tmp_toolbar_icon = create_pixmap (familiar, "familiar-openb16x16.xpm"); + toolbar_open = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + _("Open"), + _("Open file"), NULL, + tmp_toolbar_icon, NULL, NULL); + gtk_widget_set_name (toolbar_open, "toolbar_open"); + gtk_widget_ref (toolbar_open); + gtk_object_set_data_full (GTK_OBJECT (familiar), "toolbar_open", toolbar_open, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (toolbar_open); + + tmp_toolbar_icon = create_pixmap (familiar, "familiar-preferencesb16x16.xpm"); + toolbar_preferences = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + _("Preferences"), + _("Preferences"), NULL, + tmp_toolbar_icon, NULL, NULL); + gtk_widget_set_name (toolbar_preferences, "toolbar_preferences"); + gtk_widget_ref (toolbar_preferences); + gtk_object_set_data_full (GTK_OBJECT (familiar), "toolbar_preferences", toolbar_preferences, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (toolbar_preferences); + + gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); + + tmp_toolbar_icon = create_pixmap (familiar, "familiar-rewindb16x16.xpm"); + toolbar_rewind = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + _("Rewind"), + _("Rewind stream"), NULL, + tmp_toolbar_icon, NULL, NULL); + gtk_widget_set_name (toolbar_rewind, "toolbar_rewind"); + gtk_widget_ref (toolbar_rewind); + gtk_object_set_data_full (GTK_OBJECT (familiar), "toolbar_rewind", toolbar_rewind, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (toolbar_rewind); + + tmp_toolbar_icon = create_pixmap (familiar, "familiar-pauseb16x16.xpm"); + toolbar_pause = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + _("Pause"), + _("Pause stream"), NULL, + tmp_toolbar_icon, NULL, NULL); + gtk_widget_set_name (toolbar_pause, "toolbar_pause"); + gtk_widget_ref (toolbar_pause); + gtk_object_set_data_full (GTK_OBJECT (familiar), "toolbar_pause", toolbar_pause, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (toolbar_pause); + + tmp_toolbar_icon = create_pixmap (familiar, "familiar-playb16x16.xpm"); + toolbar_play = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + _("Play"), + _("Play stream"), NULL, + tmp_toolbar_icon, NULL, NULL); + gtk_widget_set_name (toolbar_play, "toolbar_play"); + gtk_widget_ref (toolbar_play); + gtk_object_set_data_full (GTK_OBJECT (familiar), "toolbar_play", toolbar_play, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (toolbar_play); + + tmp_toolbar_icon = create_pixmap (familiar, "familiar-stopb16x16.xpm"); + toolbar_stop = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + _("Stop"), + _("Stop stream"), NULL, + tmp_toolbar_icon, NULL, NULL); + gtk_widget_set_name (toolbar_stop, "toolbar_stop"); + gtk_widget_ref (toolbar_stop); + gtk_object_set_data_full (GTK_OBJECT (familiar), "toolbar_stop", toolbar_stop, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (toolbar_stop); + + tmp_toolbar_icon = create_pixmap (familiar, "familiar-forwardb16x16.xpm"); + toolbar_forward = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + _("Forward"), + _("Forward stream"), NULL, + tmp_toolbar_icon, NULL, NULL); + gtk_widget_set_name (toolbar_forward, "toolbar_forward"); + gtk_widget_ref (toolbar_forward); + gtk_object_set_data_full (GTK_OBJECT (familiar), "toolbar_forward", toolbar_forward, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (toolbar_forward); + + gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); + + tmp_toolbar_icon = create_pixmap (familiar, "vlc16x16.xpm"); + toolbar_about = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + _("About"), + _("About"), NULL, + tmp_toolbar_icon, NULL, NULL); + gtk_widget_set_name (toolbar_about, "toolbar_about"); + gtk_widget_ref (toolbar_about); + gtk_object_set_data_full (GTK_OBJECT (familiar), "toolbar_about", toolbar_about, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (toolbar_about); + + progress = gtk_progress_bar_new (); + gtk_widget_set_name (progress, "progress"); + gtk_widget_ref (progress); + gtk_object_set_data_full (GTK_OBJECT (familiar), "progress", progress, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (progress); + gtk_box_pack_start (GTK_BOX (vbox), progress, FALSE, FALSE, 0); + gtk_progress_set_activity_mode (GTK_PROGRESS (progress), TRUE); + + notebook = gtk_notebook_new (); + gtk_widget_set_name (notebook, "notebook"); + gtk_widget_ref (notebook); + gtk_object_set_data_full (GTK_OBJECT (familiar), "notebook", notebook, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (notebook); + gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0); + + fixedMedia = gtk_fixed_new (); + gtk_widget_set_name (fixedMedia, "fixedMedia"); + gtk_widget_ref (fixedMedia); + gtk_object_set_data_full (GTK_OBJECT (familiar), "fixedMedia", fixedMedia, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (fixedMedia); + gtk_container_add (GTK_CONTAINER (notebook), fixedMedia); + + labelUrl = gtk_label_new (_("URL:")); + gtk_widget_set_name (labelUrl, "labelUrl"); + gtk_widget_ref (labelUrl); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labelUrl", labelUrl, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labelUrl); + gtk_fixed_put (GTK_FIXED (fixedMedia), labelUrl, 4, 8); + gtk_widget_set_uposition (labelUrl, 4, 8); + gtk_widget_set_usize (labelUrl, 38, 18); + + comboURL = gtk_combo_new (); + gtk_widget_set_name (comboURL, "comboURL"); + gtk_widget_ref (comboURL); + gtk_object_set_data_full (GTK_OBJECT (familiar), "comboURL", comboURL, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (comboURL); + gtk_fixed_put (GTK_FIXED (fixedMedia), comboURL, 40, 4); + gtk_widget_set_uposition (comboURL, 40, 4); + gtk_widget_set_usize (comboURL, 185, 24); + comboURL_items = g_list_append (comboURL_items, (gpointer) _("file://")); + comboURL_items = g_list_append (comboURL_items, (gpointer) _("ftp://")); + comboURL_items = g_list_append (comboURL_items, (gpointer) _("http://")); + comboURL_items = g_list_append (comboURL_items, (gpointer) _("udp://:1234")); + comboURL_items = g_list_append (comboURL_items, (gpointer) _("udpstream://@:1234")); + gtk_combo_set_popdown_strings (GTK_COMBO (comboURL), comboURL_items); + g_list_free (comboURL_items); + + comboURL_entry = GTK_COMBO (comboURL)->entry; + gtk_widget_set_name (comboURL_entry, "comboURL_entry"); + gtk_widget_ref (comboURL_entry); + gtk_object_set_data_full (GTK_OBJECT (familiar), "comboURL_entry", comboURL_entry, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (comboURL_entry); + gtk_entry_set_text (GTK_ENTRY (comboURL_entry), _("file://")); + + scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_set_name (scrolledwindow1, "scrolledwindow1"); + gtk_widget_ref (scrolledwindow1); + gtk_object_set_data_full (GTK_OBJECT (familiar), "scrolledwindow1", scrolledwindow1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (scrolledwindow1); + gtk_fixed_put (GTK_FIXED (fixedMedia), scrolledwindow1, 0, 32); + gtk_widget_set_uposition (scrolledwindow1, 0, 32); + gtk_widget_set_usize (scrolledwindow1, 240, 208); + + clistmedia = gtk_clist_new (5); + gtk_widget_set_name (clistmedia, "clistmedia"); + gtk_widget_ref (clistmedia); + gtk_object_set_data_full (GTK_OBJECT (familiar), "clistmedia", clistmedia, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (clistmedia); + gtk_container_add (GTK_CONTAINER (scrolledwindow1), clistmedia); + gtk_clist_set_column_width (GTK_CLIST (clistmedia), 0, 123); + gtk_clist_set_column_width (GTK_CLIST (clistmedia), 1, 80); + gtk_clist_set_column_width (GTK_CLIST (clistmedia), 2, 80); + gtk_clist_set_column_width (GTK_CLIST (clistmedia), 3, 80); + gtk_clist_set_column_width (GTK_CLIST (clistmedia), 4, 80); + gtk_clist_column_titles_show (GTK_CLIST (clistmedia)); + + labelname = gtk_label_new (_("Name")); + gtk_widget_set_name (labelname, "labelname"); + gtk_widget_ref (labelname); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labelname", labelname, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labelname); + gtk_clist_set_column_widget (GTK_CLIST (clistmedia), 0, labelname); + + labeltype = gtk_label_new (_("Type")); + gtk_widget_set_name (labeltype, "labeltype"); + gtk_widget_ref (labeltype); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labeltype", labeltype, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labeltype); + gtk_clist_set_column_widget (GTK_CLIST (clistmedia), 1, labeltype); + + labelsize = gtk_label_new (_("Size")); + gtk_widget_set_name (labelsize, "labelsize"); + gtk_widget_ref (labelsize); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labelsize", labelsize, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labelsize); + gtk_clist_set_column_widget (GTK_CLIST (clistmedia), 2, labelsize); + + labeluid = gtk_label_new (_("User")); + gtk_widget_set_name (labeluid, "labeluid"); + gtk_widget_ref (labeluid); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labeluid", labeluid, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labeluid); + gtk_clist_set_column_widget (GTK_CLIST (clistmedia), 3, labeluid); + + labelgid = gtk_label_new (_("Group")); + gtk_widget_set_name (labelgid, "labelgid"); + gtk_widget_ref (labelgid); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labelgid", labelgid, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labelgid); + gtk_clist_set_column_widget (GTK_CLIST (clistmedia), 4, labelgid); + + media = gtk_label_new (_("Media")); + gtk_widget_set_name (media, "media"); + gtk_widget_ref (media); + gtk_object_set_data_full (GTK_OBJECT (familiar), "media", media, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (media); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 0), media); + + fixedPreferences = gtk_fixed_new (); + gtk_widget_set_name (fixedPreferences, "fixedPreferences"); + gtk_widget_ref (fixedPreferences); + gtk_object_set_data_full (GTK_OBJECT (familiar), "fixedPreferences", fixedPreferences, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (fixedPreferences); + gtk_container_add (GTK_CONTAINER (notebook), fixedPreferences); + + buttonSave = gtk_button_new_with_label (_("Save")); + gtk_widget_set_name (buttonSave, "buttonSave"); + gtk_widget_ref (buttonSave); + gtk_object_set_data_full (GTK_OBJECT (familiar), "buttonSave", buttonSave, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (buttonSave); + gtk_fixed_put (GTK_FIXED (fixedPreferences), buttonSave, 8, 216); + gtk_widget_set_uposition (buttonSave, 8, 216); + gtk_widget_set_usize (buttonSave, 54, 24); + + buttonApply = gtk_button_new_with_label (_("Apply")); + gtk_widget_set_name (buttonApply, "buttonApply"); + gtk_widget_ref (buttonApply); + gtk_object_set_data_full (GTK_OBJECT (familiar), "buttonApply", buttonApply, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (buttonApply); + gtk_fixed_put (GTK_FIXED (fixedPreferences), buttonApply, 64, 216); + gtk_widget_set_uposition (buttonApply, 64, 216); + gtk_widget_set_usize (buttonApply, 54, 24); + + buttonCancel = gtk_button_new_with_label (_("Cancel")); + gtk_widget_set_name (buttonCancel, "buttonCancel"); + gtk_widget_ref (buttonCancel); + gtk_object_set_data_full (GTK_OBJECT (familiar), "buttonCancel", buttonCancel, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (buttonCancel); + gtk_fixed_put (GTK_FIXED (fixedPreferences), buttonCancel, 176, 216); + gtk_widget_set_uposition (buttonCancel, 176, 216); + gtk_widget_set_usize (buttonCancel, 54, 24); + + cbautoplay = gtk_check_button_new_with_label (_("Automatically play file.")); + gtk_widget_set_name (cbautoplay, "cbautoplay"); + gtk_widget_ref (cbautoplay); + gtk_object_set_data_full (GTK_OBJECT (familiar), "cbautoplay", cbautoplay, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (cbautoplay); + gtk_fixed_put (GTK_FIXED (fixedPreferences), cbautoplay, 8, 8); + gtk_widget_set_uposition (cbautoplay, 8, 8); + gtk_widget_set_usize (cbautoplay, 216, 24); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbautoplay), TRUE); + + preferences = gtk_label_new (_("Preference")); + gtk_widget_set_name (preferences, "preferences"); + gtk_widget_ref (preferences); + gtk_object_set_data_full (GTK_OBJECT (familiar), "preferences", preferences, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (preferences); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 1), preferences); + + fixedAbout = gtk_fixed_new (); + gtk_widget_set_name (fixedAbout, "fixedAbout"); + gtk_widget_ref (fixedAbout); + gtk_object_set_data_full (GTK_OBJECT (familiar), "fixedAbout", fixedAbout, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (fixedAbout); + gtk_container_add (GTK_CONTAINER (notebook), fixedAbout); + + logo = create_pixmap (familiar, "vlc32x32.xpm"); + gtk_widget_set_name (logo, "logo"); + gtk_widget_ref (logo); + gtk_object_set_data_full (GTK_OBJECT (familiar), "logo", logo, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (logo); + gtk_fixed_put (GTK_FIXED (fixedAbout), logo, 8, 0); + gtk_widget_set_uposition (logo, 8, 0); + gtk_widget_set_usize (logo, 50, 50); + + labelVlc = gtk_label_new (_("VideoLAN Client\n for familiar Linux")); + gtk_widget_set_name (labelVlc, "labelVlc"); + gtk_widget_ref (labelVlc); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labelVlc", labelVlc, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labelVlc); + gtk_fixed_put (GTK_FIXED (fixedAbout), labelVlc, 64, 8); + gtk_widget_set_uposition (labelVlc, 64, 8); + gtk_widget_set_usize (labelVlc, 120, 40); + gtk_label_set_line_wrap (GTK_LABEL (labelVlc), TRUE); + + labelCopyright = gtk_label_new (_("(c) 2002, the VideoLAN Team")); + gtk_widget_set_name (labelCopyright, "labelCopyright"); + gtk_widget_ref (labelCopyright); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labelCopyright", labelCopyright, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labelCopyright); + gtk_fixed_put (GTK_FIXED (fixedAbout), labelCopyright, 16, 56); + gtk_widget_set_uposition (labelCopyright, 16, 56); + gtk_widget_set_usize (labelCopyright, 200, 18); + + labelAuthors = gtk_label_new (_("Authors: The VideoLAN Team, http://www.videolan.org")); + gtk_widget_set_name (labelAuthors, "labelAuthors"); + gtk_widget_ref (labelAuthors); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labelAuthors", labelAuthors, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labelAuthors); + gtk_fixed_put (GTK_FIXED (fixedAbout), labelAuthors, 16, 80); + gtk_widget_set_uposition (labelAuthors, 16, 80); + gtk_widget_set_usize (labelAuthors, 200, 40); + gtk_label_set_line_wrap (GTK_LABEL (labelAuthors), TRUE); + + labelAbout = gtk_label_new (_("The VideoLAN Client is a MPEG, MPEG 2, MP3, DivX player, that accepts input from local or network sources.")); + gtk_widget_set_name (labelAbout, "labelAbout"); + gtk_widget_ref (labelAbout); + gtk_object_set_data_full (GTK_OBJECT (familiar), "labelAbout", labelAbout, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (labelAbout); + gtk_fixed_put (GTK_FIXED (fixedAbout), labelAbout, 16, 128); + gtk_widget_set_uposition (labelAbout, 16, 128); + gtk_widget_set_usize (labelAbout, 200, 70); + gtk_label_set_justify (GTK_LABEL (labelAbout), GTK_JUSTIFY_LEFT); + gtk_label_set_line_wrap (GTK_LABEL (labelAbout), TRUE); + + about = gtk_label_new (_("About")); + gtk_widget_set_name (about, "about"); + gtk_widget_ref (about); + gtk_object_set_data_full (GTK_OBJECT (familiar), "about", about, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (about); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 2), about); + + gtk_signal_connect (GTK_OBJECT (familiar), "delete_event", + GTK_SIGNAL_FUNC (on_familiar_delete_event), + NULL); + gtk_signal_connect (GTK_OBJECT (toolbar_open), "clicked", + GTK_SIGNAL_FUNC (on_toolbar_open_clicked), + NULL); + gtk_signal_connect (GTK_OBJECT (toolbar_preferences), "clicked", + GTK_SIGNAL_FUNC (on_toolbar_preferences_clicked), + NULL); + gtk_signal_connect (GTK_OBJECT (toolbar_rewind), "clicked", + GTK_SIGNAL_FUNC (on_toolbar_rewind_clicked), + NULL); + gtk_signal_connect (GTK_OBJECT (toolbar_pause), "clicked", + GTK_SIGNAL_FUNC (on_toolbar_pause_clicked), + NULL); + gtk_signal_connect (GTK_OBJECT (toolbar_play), "clicked", + GTK_SIGNAL_FUNC (on_toolbar_play_clicked), + NULL); + gtk_signal_connect (GTK_OBJECT (toolbar_stop), "clicked", + GTK_SIGNAL_FUNC (on_toolbar_stop_clicked), + NULL); + gtk_signal_connect (GTK_OBJECT (toolbar_forward), "clicked", + GTK_SIGNAL_FUNC (on_toolbar_forward_clicked), + NULL); + gtk_signal_connect (GTK_OBJECT (toolbar_about), "clicked", + GTK_SIGNAL_FUNC (on_toolbar_about_clicked), + NULL); + gtk_signal_connect (GTK_OBJECT (comboURL_entry), "changed", + GTK_SIGNAL_FUNC (on_comboURL_entry_changed), + NULL); + gtk_signal_connect (GTK_OBJECT (clistmedia), "select_row", + GTK_SIGNAL_FUNC (on_clistmedia_select_row), + NULL); + gtk_signal_connect (GTK_OBJECT (clistmedia), "click_column", + GTK_SIGNAL_FUNC (on_clistmedia_click_column), + NULL); + gtk_signal_connect (GTK_OBJECT (cbautoplay), "toggled", + GTK_SIGNAL_FUNC (on_cbautoplay_toggled), + NULL); + + return familiar; +} + diff --git a/plugins/familiar/familiar_interface.h b/plugins/familiar/familiar_interface.h new file mode 100644 index 0000000000..27a3bcf646 --- /dev/null +++ b/plugins/familiar/familiar_interface.h @@ -0,0 +1,5 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +GtkWidget* create_familiar (void); diff --git a/plugins/familiar/familiar_support.c b/plugins/familiar/familiar_support.c new file mode 100644 index 0000000000..22ca9310d0 --- /dev/null +++ b/plugins/familiar/familiar_support.c @@ -0,0 +1,162 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include + +#include "familiar_support.h" + +/* This is an internally used function to check if a pixmap file exists. */ +static gchar* check_file_exists (const gchar *directory, + const gchar *filename); + +/* This is an internally used function to create pixmaps. */ +static GtkWidget* create_dummy_pixmap (GtkWidget *widget); + +GtkWidget* +lookup_widget (GtkWidget *widget, + const gchar *widget_name) +{ + GtkWidget *parent, *found_widget; + + for (;;) + { + if (GTK_IS_MENU (widget)) + parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); + else + parent = widget->parent; + if (parent == NULL) + break; + widget = parent; + } + + found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget), + widget_name); + if (!found_widget) + g_warning ("Widget not found: %s", widget_name); + return found_widget; +} + +/* This is a dummy pixmap we use when a pixmap can't be found. */ +static char *dummy_pixmap_xpm[] = { +/* columns rows colors chars-per-pixel */ +"1 1 1 1", +" c None", +/* pixels */ +" " +}; + +/* This is an internally used function to create pixmaps. */ +static GtkWidget* +create_dummy_pixmap (GtkWidget *widget) +{ + GdkColormap *colormap; + GdkPixmap *gdkpixmap; + GdkBitmap *mask; + GtkWidget *pixmap; + + colormap = gtk_widget_get_colormap (widget); + gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, + NULL, dummy_pixmap_xpm); + if (gdkpixmap == NULL) + g_error ("Couldn't create replacement pixmap."); + pixmap = gtk_pixmap_new (gdkpixmap, mask); + gdk_pixmap_unref (gdkpixmap); + gdk_bitmap_unref (mask); + return pixmap; +} + +static GList *pixmaps_directories = NULL; + +/* Use this function to set the directory containing installed pixmaps. */ +void +add_pixmap_directory (const gchar *directory) +{ + pixmaps_directories = g_list_prepend (pixmaps_directories, + g_strdup (directory)); +} + +/* This is an internally used function to create pixmaps. */ +GtkWidget* +create_pixmap (GtkWidget *widget, + const gchar *filename) +{ + gchar *found_filename = NULL; + GdkColormap *colormap; + GdkPixmap *gdkpixmap; + GdkBitmap *mask; + GtkWidget *pixmap; + GList *elem; + + if (!filename || !filename[0]) + return create_dummy_pixmap (widget); + + /* We first try any pixmaps directories set by the application. */ + elem = pixmaps_directories; + while (elem) + { + found_filename = check_file_exists ((gchar*)elem->data, filename); + if (found_filename) + break; + elem = elem->next; + } + + /* If we haven't found the pixmap, try the source directory. */ + if (!found_filename) + { + found_filename = check_file_exists ("../../share", filename); + } + + if (!found_filename) + { + g_warning (_("Couldn't find pixmap file: %s"), filename); + return create_dummy_pixmap (widget); + } + + colormap = gtk_widget_get_colormap (widget); + gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, + NULL, found_filename); + if (gdkpixmap == NULL) + { + g_warning (_("Error loading pixmap file: %s"), found_filename); + g_free (found_filename); + return create_dummy_pixmap (widget); + } + g_free (found_filename); + pixmap = gtk_pixmap_new (gdkpixmap, mask); + gdk_pixmap_unref (gdkpixmap); + gdk_bitmap_unref (mask); + return pixmap; +} + +/* This is an internally used function to check if a pixmap file exists. */ +static gchar* +check_file_exists (const gchar *directory, + const gchar *filename) +{ + gchar *full_filename; + struct stat s; + gint status; + + full_filename = (gchar*) g_malloc (strlen (directory) + 1 + + strlen (filename) + 1); + strcpy (full_filename, directory); + strcat (full_filename, G_DIR_SEPARATOR_S); + strcat (full_filename, filename); + + status = stat (full_filename, &s); + if (status == 0 && S_ISREG (s.st_mode)) + return full_filename; + g_free (full_filename); + return NULL; +} + diff --git a/plugins/familiar/familiar_support.h b/plugins/familiar/familiar_support.h new file mode 100644 index 0000000000..931bc5ad04 --- /dev/null +++ b/plugins/familiar/familiar_support.h @@ -0,0 +1,61 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +/* + * Standard gettext macros. + */ +#ifdef ENABLE_NLS +# include +# undef _ +# define _(String) dgettext (PACKAGE, String) +# ifdef gettext_noop +# define N_(String) gettext_noop (String) +# else +# define N_(String) (String) +# endif +#else +# define textdomain(String) (String) +# define gettext(String) (String) +# define dgettext(Domain,Message) (Message) +# define dcgettext(Domain,Message,Type) (Message) +# define bindtextdomain(Domain,Directory) (Domain) +# define _(String) (String) +# define N_(String) (String) +#endif + + +/* + * Public Functions. + */ + +/* + * This function returns a widget in a component created by Glade. + * Call it with the toplevel widget in the component (i.e. a window/dialog), + * or alternatively any widget in the component, and the name of the widget + * you want returned. + */ +GtkWidget* lookup_widget (GtkWidget *widget, + const gchar *widget_name); + +/* get_widget() is deprecated. Use lookup_widget instead. */ +#define get_widget lookup_widget + +/* Use this function to set the directory containing installed pixmaps. */ +void add_pixmap_directory (const gchar *directory); + + +/* + * Private Functions. + */ + +/* This is used to create the pixmaps in the interface. */ +GtkWidget* create_pixmap (GtkWidget *widget, + const gchar *filename); +