1 /*****************************************************************************
2 * gtk2_theme.cpp: GTK2 implementation of the Theme class
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: gtk2_theme.cpp,v 1.25 2003/04/28 12:00:13 asmax Exp $
7 * Authors: Cyril Deguet <asmax@videolan.org>
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,
23 *****************************************************************************/
27 //--- GTK2 -----------------------------------------------------------------
29 #include <gdk-pixbuf/gdk-pixbuf.h>
32 //--- VLC -------------------------------------------------------------------
35 //--- SKIN ------------------------------------------------------------------
36 #include "../os_api.h"
37 #include "../src/banks.h"
38 #include "../src/window.h"
39 #include "../os_window.h"
40 #include "../src/event.h"
41 #include "../os_event.h"
42 #include "../src/theme.h"
43 #include "../os_theme.h"
44 #include "../src/vlcproc.h"
45 #include "../src/skin_common.h"
48 //---------------------------------------------------------------------------
49 void SkinManage( intf_thread_t *p_intf );
52 //---------------------------------------------------------------------------
54 //---------------------------------------------------------------------------
55 GTK2Theme::GTK2Theme( intf_thread_t *_p_intf ) : Theme( _p_intf )
61 //---------------------------------------------------------------------------
62 GTK2Theme::~GTK2Theme()
64 // Unregister the window class if needed
66 if( GetClassInfo( hinst, "SkinWindow", &wndclass ) )
68 UnregisterClass( "SkinWindow", hinst );
70 if( GetClassInfo( hinst, "ParentWindow", &wndclass ) )
72 UnregisterClass( "ParentWindow", hinst );
75 // Delete tray icon if exists
78 Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
81 // Destroy parent window
84 gdk_window_destroy( ParentWindow );
87 //---------------------------------------------------------------------------
88 void GTK2Theme::OnLoadTheme()
93 // Set the parent window attributes
95 attr.title = "VLC Media Player";
96 attr.event_mask = GDK_ALL_EVENTS_MASK;
101 attr.window_type = GDK_WINDOW_TOPLEVEL;
102 attr.wclass = GDK_INPUT_ONLY;
103 attr.override_redirect = FALSE;
105 gint mask = GDK_WA_TITLE|GDK_WA_X|GDK_WA_Y|GDK_WA_NOREDIR;
107 // Create the parent window
108 ParentWindow = gdk_window_new( NULL, &attr, mask);
111 msg_Err( p_intf, "gdk_window_new failed" );
115 Display *display = XOpenDisplay( NULL );
116 Window root = DefaultRootWindow( display );
118 //---------------------------------------------------------------------------
119 void GTK2Theme::AddSystemMenu( string name, Event *event )
121 if( name == "SEPARATOR" )
123 AppendMenu( SysMenu, MF_SEPARATOR, 0, NULL );
127 AppendMenu( SysMenu, MF_STRING, (unsigned int)event,
128 (char *)name.c_str() );
131 //---------------------------------------------------------------------------
132 void GTK2Theme::ChangeClientWindowName( string name )
134 SetWindowText( ParentWindow, name.c_str() );*/
136 //---------------------------------------------------------------------------
137 void GTK2Theme::AddWindow( string name, int x, int y, bool visible,
138 int fadetime, int alpha, int movealpha, bool dragdrop )
141 attr.title = (gchar *)name.c_str();
142 attr.event_mask = GDK_ALL_EVENTS_MASK;
145 attr.window_type = GDK_WINDOW_TOPLEVEL;
146 attr.wclass = GDK_INPUT_OUTPUT;
147 attr.override_redirect = FALSE;
149 gint mask = GDK_WA_NOREDIR;
152 GdkWindow *gwnd = gdk_window_new( NULL, &attr, mask );
155 msg_Err( p_intf, "gdk_window_new failed" );
159 gdk_window_set_decorations( gwnd, (GdkWMDecoration)0 );
161 gdk_window_show( gwnd );
163 WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, gwnd, x, y, visible,
164 fadetime, alpha, movealpha, dragdrop, name ) ) ;
167 //---------------------------------------------------------------------------
168 void GTK2Theme::ChangeTray()
172 Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
177 Shell_NotifyIcon( NIM_ADD, &TrayIcon );
181 //---------------------------------------------------------------------------
182 void GTK2Theme::ChangeTaskbar()
186 ShowWindow( ParentWindow, SW_HIDE );
187 SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
188 WS_EX_LAYERED|WS_EX_TOOLWINDOW );
189 ShowWindow( ParentWindow, SW_SHOW );
190 ShowInTaskbar = false;
194 ShowWindow( ParentWindow, SW_HIDE );
195 SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
196 WS_EX_LAYERED|WS_EX_APPWINDOW );
197 ShowWindow( ParentWindow, SW_SHOW );
198 ShowInTaskbar = true;
201 //---------------------------------------------------------------------------