Use wxApp::OnExit() to cleanup the dialogs provider.
Added a "Miscellaneous" section to the menu. Added a "Switch interface" and "Add interface" entries to this menu.
* modules/gui/skins/src/*: dialog providers have object types of VLC_OBJECT_DIALOGS.
Don't forget to attach/detach the dialogs provider to its parent intf.
Work around a bug in imlib2 when we close the plugin.
* src/misc/objects.c, include/vlc_objects.h: added VLC_OBJECT_DIALOGS for dialogs providers.
* src/interface/interface.c, include/vlc_interface.h: added 2 object variables to switch/add interfaces on the fly (intf-switch and intf-add).
* interface, such as message output.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: vlc_interface.h,v 1.6 2003/09/18 17:54:02 zorglub Exp $
+ * $Id: vlc_interface.h,v 1.7 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
vlc_bool_t b_block;
/* Specific interfaces */
- intf_console_t * p_console; /** console */
- intf_sys_t * p_sys; /** system interface */
+ intf_console_t * p_console; /** console */
+ intf_sys_t * p_sys; /** system interface */
/** Interface module */
module_t * p_module;
vlc_mutex_t change_lock;
vlc_bool_t b_menu_change;
vlc_bool_t b_menu;
+
+ /* Provides the ability to switch an interface on the fly */
+ char *psz_switch_intf;
};
/*****************************************************************************
* vlc_objects.h: vlc_object_t definition.
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: vlc_objects.h,v 1.19 2003/10/08 21:01:07 gbazin Exp $
+ * $Id: vlc_objects.h,v 1.20 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
#define VLC_OBJECT_HTTPD (-12)
#define VLC_OBJECT_PACKETIZER (-13)
#define VLC_OBJECT_ENCODER (-14)
+#define VLC_OBJECT_DIALOGS (-15)
#define VLC_OBJECT_GENERIC (-666)
* dialogs.cpp: Handles all the different dialog boxes we provide.
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: dialogs.cpp,v 1.14 2003/09/05 15:55:30 asmax Exp $
+ * $Id: dialogs.cpp,v 1.15 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
b_popup_change = VLC_FALSE;
/* Allocate descriptor */
- p_provider = (intf_thread_t *)vlc_object_create( p_intf, VLC_OBJECT_INTF );
+ p_provider = (intf_thread_t *)vlc_object_create( p_intf,
+ VLC_OBJECT_DIALOGS );
if( p_provider == NULL )
{
msg_Err( p_intf, "out of memory" );
return;
}
+ /* Attach the dialogs provider to its parent interface */
+ vlc_object_attach( p_provider, p_intf );
+
/* Initialize dialogs provider
* (returns as soon as initialization is done) */
if( p_provider->pf_run ) p_provider->pf_run( p_provider );
{
if( p_provider && p_module )
{
+ /* Detach the dialogs provider from its parent interface */
+ vlc_object_detach( p_provider );
+
module_Unneed( p_provider, p_module );
vlc_object_destroy( p_provider );
}
* skin-main.cpp: skins plugin for VLC
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: skin_main.cpp,v 1.47 2003/07/20 10:38:49 gbazin Exp $
+ * $Id: skin_main.cpp,v 1.48 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
#if defined X11_SKINS
XDestroyWindow( p_intf->p_sys->display, p_intf->p_sys->mainWin );
- XCloseDisplay( p_intf->p_sys->display );
+
+ // There is a bug in imlib2 which prevents us from closing the display
+ // (__imlib_RenderImage() can free old GC with already closed display)
+ //XCloseDisplay( p_intf->p_sys->display );
#endif
// Unsuscribe to messages bank
* interface.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: interface.cpp,v 1.64 2003/10/08 12:18:50 zorglub Exp $
+ * $Id: interface.cpp,v 1.65 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
Prefs_Event,
Extra_Event,
+ Skins_Event,
SliderScroll_Event,
StopStream_Event,
#endif
UpdateAcceleratorTable();
+
+ /* Start timer */
+ timer = new Timer( p_intf, this );
}
Interface::~Interface()
{
delete p_intf->p_sys->p_wxwindow;
}
+
/* Clean up */
+ delete timer;
}
/*****************************************************************************
settings_menu->AppendCheckItem( Extra_Event, wxU(_("&Extended GUI") ),
wxU(_(EXTRA_PREFS)) );
-
/* Create the "Audio" menu */
p_audio_menu = new wxMenu;
b_audio_menu = 1;
p_navig_menu = new wxMenu;
b_navig_menu = 1;
+ /* Create the "Miscellaneous" menu */
+ p_misc_menu = new wxMenu;
+ b_misc_menu = 1;
+
/* Create the "Help" menu */
wxMenu *help_menu = new wxMenu;
help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
menubar->Append( p_audio_menu, wxU(_("&Audio")) );
menubar->Append( p_video_menu, wxU(_("&Video")) );
menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
+ menubar->Append( p_misc_menu, wxU(_("&Miscellaneous")) );
menubar->Append( help_menu, wxU(_("&Help")) );
/* Attach the menu bar to the frame */
}
else b_navig_menu = 1;
}
+ else if( event.GetEventObject() == p_misc_menu )
+ {
+ if( b_misc_menu )
+ {
+ p_misc_menu = MiscMenu( p_intf, this );
+
+ /* Work-around for buggy wxGTK */
+ wxMenu *menu = GetMenuBar()->GetMenu( 6 );
+ RecursiveDestroy( menu );
+ /* End work-around */
+
+ menu = GetMenuBar()->Replace( 6, p_misc_menu,
+ wxU(_("&Miscellaneous")));
+ if( menu ) delete menu;
+
+ b_misc_menu = 0;
+ }
+ else b_misc_menu = 1;
+ }
#else
p_audio_menu = AudioMenu( p_intf, this );
menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
if( menu ) delete menu;
+ p_misc_menu = MiscMenu( p_intf, this );
+ menu = GetMenuBar()->Replace( 6, p_misc_menu, wxU(_("&Miscellaneous")) );
+ if( menu ) delete menu;
#endif
}
void wxVolCtrl::Change( int i_volume )
{
- aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 );
+ aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
SetValue( i_volume );
SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
i_volume ) );
* menus.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: menus.cpp,v 1.20 2003/08/28 15:59:04 gbazin Exp $
+ * $Id: menus.cpp,v 1.21 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
AudioMenu_Events = wxID_HIGHEST + 2000,
VideoMenu_Events = wxID_HIGHEST + 3000,
NavigMenu_Events = wxID_HIGHEST + 4000,
- PopupMenu_Events = wxID_HIGHEST + 5000
+ MiscMenu_Events = wxID_HIGHEST + 5000,
+ PopupMenu_Events = wxID_HIGHEST + 6000
};
BEGIN_EVENT_TABLE(Menu, wxMenu)
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "deinterlace";
pi_objects[i++] = p_object->i_object_id;
+ ppsz_varnames[i] = "aspect-ratio";
+ pi_objects[i++] = p_object->i_object_id;
+ ppsz_varnames[i] = "crop";
+ pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "directx-on-top";
pi_objects[i++] = p_object->i_object_id;
vlc_object_release( p_object );
vlc_object_release( p_object );
}
+ /* Interface menu */
+ ppsz_varnames[i++] = NULL; /* Separator */
+ ppsz_varnames[i++] = _("Interface menu");
+ ppsz_varnames[i++] = NULL; /* Separator */
+
+ /* vlc_object_find is needed because of the dialogs provider case */
+ p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INTF,
+ FIND_PARENT );
+ if( p_object != NULL )
+ {
+ ppsz_varnames[i] = "intf-switch";
+ pi_objects[i++] = p_object->i_object_id;
+ ppsz_varnames[i] = "intf-add";
+ pi_objects[i++] = p_object->i_object_id;
+
+ vlc_object_release( p_object );
+ }
+
/* Build menu */
Menu popupmenu( p_intf, p_parent, i,
ppsz_varnames, pi_objects, PopupMenu_Events );
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "deinterlace";
pi_objects[i++] = p_object->i_object_id;
+ ppsz_varnames[i] = "aspect-ratio";
+ pi_objects[i++] = p_object->i_object_id;
+ ppsz_varnames[i] = "crop";
+ pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "directx-on-top";
pi_objects[i++] = p_object->i_object_id;
vlc_object_release( p_object );
ppsz_varnames, pi_objects, NavigMenu_Events );
}
+wxMenu *MiscMenu( intf_thread_t *_p_intf, wxWindow *p_parent )
+{
+ vlc_object_t *p_object;
+ char *ppsz_varnames[10];
+ int pi_objects[10];
+ int i = 0;
+
+ /* Initializations */
+ memset( pi_objects, 0, 4 * sizeof(int) );
+
+ p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INTF,
+ FIND_PARENT );
+ if( p_object != NULL )
+ {
+ ppsz_varnames[i] = "intf-switch";
+ pi_objects[i++] = p_object->i_object_id;
+ ppsz_varnames[i] = "intf-add";
+ pi_objects[i++] = p_object->i_object_id;
+ vlc_object_release( p_object );
+ }
+
+ /* Build menu */
+ return new Menu( _p_intf, p_parent, i,
+ ppsz_varnames, pi_objects, MiscMenu_Events );
+}
+
/*****************************************************************************
* Constructor.
*****************************************************************************/
* timer.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: timer.cpp,v 1.32 2003/09/07 22:53:09 fenrir Exp $
+ * $Id: timer.cpp,v 1.33 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
/* Take care of the volume */
audio_volume_t i_volume;
aout_VolumeGet( p_intf, &i_volume );
- p_main_interface->volctrl->SetValue( i_volume * 200 /
+ p_main_interface->volctrl->SetValue( i_volume * 200 * 2 /
AOUT_VOLUME_MAX );
p_main_interface->volctrl->SetToolTip(
wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
* wxwindows.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: wxwindows.cpp,v 1.33 2003/10/04 14:59:38 gbazin Exp $
+ * $Id: wxwindows.cpp,v 1.34 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
Instance( intf_thread_t *_p_intf );
bool OnInit();
+ int OnExit();
private:
intf_thread_t *p_intf;
MainInterface->Show( TRUE );
SetTopWindow( MainInterface );
-
- /* Start timer */
- new Timer( p_intf, MainInterface );
}
/* Creates the dialogs provider */
return TRUE;
}
+/*****************************************************************************
+ * Instance::OnExit: called when the interface execution stops
+ *****************************************************************************/
+int Instance::OnExit()
+{
+ if( p_intf->pf_show_dialog )
+ {
+ /* We need to manually clean up the dialogs class */
+ if( p_intf->p_sys->p_wxwindow ) delete p_intf->p_sys->p_wxwindow;
+ }
+ return 0;
+}
+
static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg,
intf_dialog_args_t *p_arg )
{
* wxwindows.h: private wxWindows interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: wxwindows.h,v 1.64 2003/10/08 19:40:42 gbazin Exp $
+ * $Id: wxwindows.h,v 1.65 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
vlc_bool_t b_video_menu;
wxMenu *p_navig_menu;
vlc_bool_t b_navig_menu;
+ wxMenu *p_misc_menu;
+ vlc_bool_t b_misc_menu;
};
/* Dialogs Provider */
wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
+wxMenu *MiscMenu( intf_thread_t *_p_intf, wxWindow *p_parent );
class MenuEvtHandler : public wxEvtHandler
{
* interface, such as command line.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: interface.c,v 1.106 2003/09/18 17:54:02 zorglub Exp $
+ * $Id: interface.c,v 1.107 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
* Local prototypes
*****************************************************************************/
static void Manager( intf_thread_t *p_intf );
+static void RunInterface( intf_thread_t *p_intf );
+
+static int SwitchIntfCallback( vlc_object_t *, char const *,
+ vlc_value_t , vlc_value_t , void * );
+static int AddIntfCallback( vlc_object_t *, char const *,
+ vlc_value_t , vlc_value_t , void * );
/*****************************************************************************
* intf_Create: prepare interface before main loop
return VLC_EGENERIC;
}
- p_intf->pf_run( p_intf );
+ RunInterface( p_intf );
p_intf->b_die = VLC_TRUE;
else
{
/* Run the interface in a separate thread */
- if( vlc_thread_create( p_intf, "interface", p_intf->pf_run,
+ if( vlc_thread_create( p_intf, "interface", RunInterface,
VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
{
msg_Err( p_intf, "cannot spawn interface thread" );
vlc_object_destroy( p_intf );
}
-/* Following functions are local */
-
+/* Following functions are local */
/*****************************************************************************
* Manager: helper thread for blocking interfaces
}
}
+/*****************************************************************************
+ * RunInterface: setups necessary data and give control to the interface
+ *****************************************************************************/
+static void RunInterface( intf_thread_t *p_intf )
+{
+ vlc_value_t val, text;
+
+ /* Variable used for interface switching */
+ p_intf->psz_switch_intf = NULL;
+ var_Create( p_intf, "intf-switch", VLC_VAR_STRING |
+ VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND );
+ text.psz_string = _("Switch interface");
+ var_Change( p_intf, "intf-switch", VLC_VAR_SETTEXT, &text, NULL );
+
+ val.psz_string = "skins"; text.psz_string = "Skins";
+ var_Change( p_intf, "intf-switch", VLC_VAR_ADDCHOICE, &val, &text );
+ val.psz_string = "wxwin"; text.psz_string = "wxWindows";
+ var_Change( p_intf, "intf-switch", VLC_VAR_ADDCHOICE, &val, &text );
+
+ var_AddCallback( p_intf, "intf-switch", SwitchIntfCallback, NULL );
+
+ /* Variable used for interface spawning */
+ var_Create( p_intf, "intf-add", VLC_VAR_STRING |
+ VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND );
+ text.psz_string = _("Add interface");
+ var_Change( p_intf, "intf-add", VLC_VAR_SETTEXT, &text, NULL );
+
+ val.psz_string = "rc"; text.psz_string = "Console";
+ var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text );
+ val.psz_string = "logger"; text.psz_string = "Debug logging";
+ var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text );
+ val.psz_string = "http"; text.psz_string = "HTTP remote control";
+ var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text );
+
+ var_AddCallback( p_intf, "intf-add", AddIntfCallback, NULL );
+
+ /* Give control to the interface */
+ p_intf->pf_run( p_intf );
+
+ /* Provide ability to switch the main interface on the fly */
+ while( p_intf->psz_switch_intf )
+ {
+ char *psz_intf = p_intf->psz_switch_intf;
+ p_intf->psz_switch_intf = NULL;
+ p_intf->b_die = VLC_FALSE;
+
+ /* Make sure the old interface is completely uninitialised */
+ module_Unneed( p_intf, p_intf->p_module );
+
+ p_intf->p_module = module_Need( p_intf, "interface", psz_intf );
+ free( psz_intf );
+
+ if( p_intf->p_module )
+ {
+ p_intf->pf_run( p_intf );
+ }
+ else break;
+ }
+}
+
+static int SwitchIntfCallback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ intf_thread_t *p_intf = (intf_thread_t *)p_this;
+
+ p_intf->psz_switch_intf =
+ malloc( strlen(newval.psz_string) + sizeof(",none") );
+ sprintf( p_intf->psz_switch_intf, "%s,none", newval.psz_string );
+ p_intf->b_die = VLC_TRUE;
+
+ return VLC_SUCCESS;
+}
+
+static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ intf_thread_t *p_intf;
+ char *psz_intf = malloc( strlen(newval.psz_string) + sizeof(",none") );
+
+ /* Try to create the interface */
+ sprintf( psz_intf, "%s,none", newval.psz_string );
+ p_intf = intf_Create( p_this, psz_intf );
+ free( psz_intf );
+ if( p_intf == NULL )
+ {
+ msg_Err( p_this, "interface \"%s\" initialization failed",
+ newval.psz_string );
+ return VLC_EGENERIC;
+ }
+
+ /* Try to run the interface */
+ p_intf->b_block = VLC_FALSE;
+ if( intf_RunThread( p_intf ) != VLC_SUCCESS )
+ {
+ vlc_object_detach( p_intf );
+ intf_Destroy( p_intf );
+ return VLC_EGENERIC;
+ }
+
+ return VLC_SUCCESS;
+}
* objects.c: vlc_object_t handling
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: objects.c,v 1.41 2003/10/08 21:01:07 gbazin Exp $
+ * $Id: objects.c,v 1.42 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
i_size = sizeof(intf_thread_t);
psz_type = "interface";
break;
+ case VLC_OBJECT_DIALOGS:
+ i_size = sizeof(intf_thread_t);
+ psz_type = "dialogs provider";
+ break;
case VLC_OBJECT_PLAYLIST:
i_size = sizeof(playlist_t);
psz_type = "playlist";
if( p_this->i_children )
{
- msg_Err( p_this, "cannot delete object with children" );
+ msg_Err( p_this, "cannot delete object (%i, %s) with children" ,
+ p_this->i_object_id, p_this->psz_object_name );
return;
}
if( p_this->p_parent )
{
- msg_Err( p_this, "cannot delete object with a parent" );
+ msg_Err( p_this, "cannot delete object (%i, %s) with a parent",
+ p_this->i_object_id, p_this->psz_object_name );
return;
}