X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fskins%2Fsrc%2Fskin_main.cpp;h=0ed57c2923ecc06e826076e4909a0d3d0bda9453;hb=ae65b15b7b26ece5daa69e3721225d7bd5c8cc98;hp=d0352d58f3fd3730aea72c440dff09baff2cdb44;hpb=4b62a0849ca7d65d5b64b88a6ef718c35baf2bb5;p=vlc diff --git a/modules/gui/skins/src/skin_main.cpp b/modules/gui/skins/src/skin_main.cpp index d0352d58f3..0ed57c2923 100644 --- a/modules/gui/skins/src/skin_main.cpp +++ b/modules/gui/skins/src/skin_main.cpp @@ -2,7 +2,7 @@ * skin-main.cpp: skins plugin for VLC ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: skin_main.cpp,v 1.36 2003/06/09 21:14:17 asmax Exp $ + * $Id: skin_main.cpp,v 1.47 2003/07/20 10:38:49 gbazin Exp $ * * Authors: Olivier Teulière * Emmanuel Puig @@ -28,17 +28,6 @@ #include #include -//--- GENERAL --------------------------------------------------------------- -#ifndef BASIC_SKINS -#ifdef WIN32 /* mingw32 hack */ -# undef Yield -# undef CreateDialog -#endif -/* Let vlc take care of the i18n stuff */ -#define WXINTL_NO_GETTEXT_MACRO -#include -#endif - //--- SKIN ------------------------------------------------------------------ #include "../os_api.h" #include "event.h" @@ -51,12 +40,9 @@ #include "skin_common.h" #include "dialogs.h" -#ifndef BASIC_SKINS -#include "../../wxwindows/wxwindows.h" -#endif - #ifdef X11_SKINS #include +#include #endif //--------------------------------------------------------------------------- @@ -102,7 +88,6 @@ static int Open ( vlc_object_t *p_this ) p_intf->pf_run = Run; - // Suscribe to messages bank p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); @@ -119,18 +104,47 @@ static int Open ( vlc_object_t *p_this ) p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); -#ifdef GTK2_SKINS - // Initialize GDK - int i_args = 3; - char *p_args[] = { "", "", "--sync", NULL }; - char **pp_args = p_args; - - gdk_init( &i_args, &pp_args ); - -#elif defined X11_SKINS +#if defined X11_SKINS // Initialize X11 - p_intf->p_sys->display = XOpenDisplay( NULL ); + Display *display = XOpenDisplay( NULL ); + p_intf->p_sys->display = display; vlc_mutex_init( p_intf, &p_intf->p_sys->xlock ); + // Fake window to receive broadcast events + Window root = DefaultRootWindow( display ); + p_intf->p_sys->mainWin = XCreateSimpleWindow( display, root, 0, 0, + 1, 1, 0, 0, 0 ); + XStoreName( display, p_intf->p_sys->mainWin, "VLC Media Player" ); + + // Load the vlc icon + int screen = DefaultScreen( display ); + Screen *screenptr = DefaultScreenOfDisplay( display ); + Visual *visual = DefaultVisualOfScreen( screenptr ); + imlib_context_set_display( display ); + imlib_context_set_visual( visual ); + imlib_context_set_drawable( root ); + imlib_context_set_colormap( DefaultColormap( display, screen ) ); + imlib_context_set_dither( 1 ); + imlib_context_set_blend( 1 ); + Imlib_Image img = imlib_load_image_immediately( DATA_PATH"/vlc32x32.png" ); + if( img == NULL ) + { + // for developers ;) + img = imlib_load_image_immediately( "./share/vlc32x32.png" ); + } + if( img == NULL ) + { + msg_Err( p_intf, "loading vlc icon failed" ); + p_intf->p_sys->iconPixmap = None; + p_intf->p_sys->iconMask = None; + } + else + { + imlib_context_set_image( img ); + imlib_render_pixmaps_for_whole_image( &p_intf->p_sys->iconPixmap, + &p_intf->p_sys->iconMask ); + imlib_free_image(); + } + #elif defined WIN32 // Interface thread id used to post broadcast messages @@ -189,6 +203,7 @@ static void Close ( vlc_object_t *p_this ) delete (OSTheme *)p_intf->p_sys->p_theme; #if defined X11_SKINS + XDestroyWindow( p_intf->p_sys->display, p_intf->p_sys->mainWin ); XCloseDisplay( p_intf->p_sys->display ); #endif @@ -218,12 +233,9 @@ static void Run( intf_thread_t *p_intf ) int a = OSAPI_GetTime(); -#ifndef BASIC_SKINS // Initialize the dialog boxes p_intf->p_sys->p_dialogs = new Dialogs( p_intf ); - if( !p_intf->p_sys->p_dialogs || - !p_intf->p_sys->p_dialogs->OpenDlg ) return; -#endif + if( !p_intf->p_sys->p_dialogs ) return; // Load a theme char *skin_last = config_GetPsz( p_intf, "skin_last" ); @@ -255,32 +267,16 @@ static void Run( intf_thread_t *p_intf ) if( !Loader->Load( user_skin ) && !Loader->Load( default_skin ) ) { #endif -#ifndef BASIC_SKINS - wxMutexGuiEnter(); - wxFileDialog dialog( NULL, - wxU(_("Open a skin file")), wxT(""), wxT(""), - wxT("Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|" - "All files|*.*"), wxOPEN ); - - if( dialog.ShowModal() == wxID_OK ) - { - // try to load selected file - if( ! Loader->Load( (string)dialog.GetPath().mb_str() ) ) - { - // He, he, what the hell is he doing ? - delete Loader; - wxMutexGuiLeave(); - return; - } - wxMutexGuiLeave(); - } - else -#endif + p_intf->p_sys->p_dialogs->ShowOpenSkin( 1 /* block */ ); + + // try to load selected file + if( !p_intf->p_sys->p_new_theme_file || + !Loader->Load( (string)p_intf->p_sys->p_new_theme_file ) ) { + // He, he, what the hell is he doing ? delete Loader; -#ifndef BASIC_SKINS - wxMutexGuiLeave(); -#endif + delete p_intf->p_sys->p_dialogs; + if( skin_last ) free( skin_last ); return; } } @@ -290,19 +286,17 @@ static void Run( intf_thread_t *p_intf ) p_intf->p_sys->p_theme->InitTheme(); p_intf->p_sys->p_theme->ShowTheme(); + if( skin_last ) free( skin_last ); delete Loader; msg_Dbg( p_intf, "Load theme time : %i ms", OSAPI_GetTime() - a ); - // Refresh the whole interface OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (int)true ); OSRun( p_intf ); -#ifndef BASIC_SKINS // clean up the dialog boxes delete p_intf->p_sys->p_dialogs; -#endif } //--------------------------------------------------------------------------- @@ -329,6 +323,7 @@ vlc_module_begin(); set_description( _("Skinnable Interface") ); set_capability( "interface", 30 ); set_callbacks( Open, Close ); + set_program( "svlc" ); vlc_module_end(); @@ -351,16 +346,6 @@ int SkinManage( intf_thread_t *p_intf ) p_intf->p_sys->p_input = NULL; } - OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (long)false ); - -#ifndef BASIC_SKINS //FIXME - // Update the log window - p_intf->p_sys->p_dialogs->MessagesDlg->UpdateLog(); - - // Update the file info window - p_intf->p_sys->p_dialogs->FileInfoDlg->UpdateFileInfo(); -#endif - //------------------------------------------------------------------------- if( p_intf->p_sys->p_input != NULL && !p_intf->p_sys->p_input->b_die ) { @@ -380,7 +365,6 @@ int SkinManage( intf_thread_t *p_intf ) p_intf->p_sys->p_theme->EvtBank->Get( "volume_refresh" ), (long)( volume * SLIDER_RANGE / AOUT_VOLUME_MAX ) ); - // Refresh slider // if( p_input->stream.b_seekable && p_intf->p_sys->b_playing ) if( p_input->stream.b_seekable )