]> git.sesse.net Git - vlc/blob - modules/gui/skins/gtk2/gtk2_theme.cpp
517eeffb8ff0554a598a3c62cd0c93d97ec558f9
[vlc] / modules / gui / skins / gtk2 / gtk2_theme.cpp
1 /*****************************************************************************
2  * gtk2_theme.cpp: GTK2 implementation of the Theme class
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: gtk2_theme.cpp,v 1.11 2003/04/15 16:42:02 karibu Exp $
6  *
7  * Authors: Cyril Deguet     <asmax@videolan.org>
8  *
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.
13  *
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.
18  *
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,
22  * USA.
23  *****************************************************************************/
24
25 #if !defined WIN32
26
27 //--- GTK2 -----------------------------------------------------------------
28 #include <gdk/gdk.h>
29 #include <gdk-pixbuf/gdk-pixbuf.h>
30
31 //--- VLC -------------------------------------------------------------------
32 #include <vlc/intf.h>
33
34 //--- SKIN ------------------------------------------------------------------
35 #include "os_api.h"
36 #include "banks.h"
37 #include "window.h"
38 #include "os_window.h"
39 #include "event.h"
40 #include "os_event.h"
41 #include "theme.h"
42 #include "os_theme.h"
43 #include "dialog.h"
44 #include "os_dialog.h"
45 #include "vlcproc.h"
46 #include "skin_common.h"
47
48
49 //---------------------------------------------------------------------------
50 void SkinManage( intf_thread_t *p_intf );
51
52
53 //---------------------------------------------------------------------------
54 // THEME
55 //---------------------------------------------------------------------------
56 GTK2Theme::GTK2Theme( intf_thread_t *_p_intf ) : Theme( _p_intf )
57 {
58 /*
59     // Get instance handle
60     hinst = GetModuleHandle( NULL );
61
62     // Create window class
63     WNDCLASS SkinWindow;
64
65     SkinWindow.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
66     SkinWindow.lpfnWndProc = (WNDPROC) GTK2Proc;
67     SkinWindow.lpszClassName = "SkinWindow";
68     SkinWindow.lpszMenuName = NULL;
69     SkinWindow.cbClsExtra = 0;
70     SkinWindow.cbWndExtra = 0;
71     SkinWindow.hbrBackground = HBRUSH (COLOR_WINDOW);
72     SkinWindow.hCursor = LoadCursor( NULL , IDC_ARROW );
73     SkinWindow.hIcon = LoadIcon( hinst, "VLC_ICON" );
74     SkinWindow.hInstance = hinst;
75
76     if( !RegisterClass( &SkinWindow ) )
77     {
78         WNDCLASS wndclass;
79
80         // Check why it failed. If it's because the class already exists
81         // then fine, otherwise return with an error.
82         if( !GetClassInfo( hinst, "SkinWindow", &wndclass ) )
83         {
84             msg_Err( p_intf, "Cannot register window class" );
85             return;
86         }
87     }
88 */
89     //Initialize value
90     ParentWindow = NULL;
91
92 }
93
94 //---------------------------------------------------------------------------
95 GTK2Theme::~GTK2Theme()
96 {/*
97     // Unregister the window class if needed
98     WNDCLASS wndclass;
99     if( GetClassInfo( hinst, "SkinWindow", &wndclass ) )
100     {
101         UnregisterClass( "SkinWindow", hinst );
102     }
103     if( GetClassInfo( hinst, "LogWindow", &wndclass ) )
104     {
105         UnregisterClass( "LogWindow", hinst );
106     }
107     if( GetClassInfo( hinst, "ParentWindow", &wndclass ) )
108     {
109         UnregisterClass( "ParentWindow", hinst );
110     }
111
112     // Delete tray icon if exists
113     if( ShowInTray )
114     {
115         Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
116     }
117
118     // Destroy parent window
119     if( ParentWindow )
120     {
121         DestroyWindow( ParentWindow );
122     }*/
123 }
124 //---------------------------------------------------------------------------
125 void GTK2Theme::OnLoadTheme()
126 {/*
127     // Create window class
128     WNDCLASS ParentClass;
129     ParentClass.style = CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS;
130     ParentClass.lpfnWndProc = (WNDPROC) GTK2Proc;
131     ParentClass.lpszClassName = "ParentWindow";
132     ParentClass.lpszMenuName = NULL;
133     ParentClass.cbClsExtra = 0;
134     ParentClass.cbWndExtra = 0;
135     ParentClass.hbrBackground = HBRUSH (COLOR_WINDOW);
136     ParentClass.hCursor = LoadCursor( NULL , IDC_ARROW );
137     ParentClass.hIcon = LoadIcon( hinst, "VLC_ICON" );
138     ParentClass.hInstance = hinst;
139
140     // register class and check it
141     if( !RegisterClass( &ParentClass ) )
142     {
143         WNDCLASS wndclass;
144
145         // Check why it failed. If it's because the class already exists
146         // then fine, otherwise return with an error.
147         if( !GetClassInfo( hinst, "ParentWindow", &wndclass ) )
148         {
149             msg_Err( p_intf, "Cannot register window class" );
150             return;
151         }
152     }
153
154     // Create Window
155     ParentWindow = CreateWindowEx( WS_EX_LAYERED|WS_EX_TOOLWINDOW,
156         "ParentWindow", "VLC Media Player",
157         WS_SYSMENU,
158         0, 0, 0, 0, 0, 0, hinst, NULL );
159
160     // Store with it a pointer to the interface thread
161     SetWindowLongPtr( ParentWindow, GWLP_USERDATA, (LONG_PTR)p_intf );
162     ShowWindow( ParentWindow, SW_SHOW );
163
164     // System tray icon
165     TrayIcon.cbSize = sizeof( PNOTIFYICONDATA );\r
166     TrayIcon.hWnd = ParentWindow;\r
167     TrayIcon.uID = 42;\r
168     TrayIcon.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE;\r
169     TrayIcon.uCallbackMessage = WM_RBUTTONDOWN;\r
170     TrayIcon.hIcon = LoadIcon( hinst, "VLC_ICON" );
171     strcpy( TrayIcon.szTip, "VLC Media Player" );
172
173     // Remove default entries from system menu popup
174     SysMenu = GetSystemMenu( ParentWindow, false );
175     RemoveMenu( SysMenu, SC_RESTORE,  MF_BYCOMMAND );
176     RemoveMenu( SysMenu, SC_MOVE,     MF_BYCOMMAND );
177     RemoveMenu( SysMenu, SC_SIZE,     MF_BYCOMMAND );
178     RemoveMenu( SysMenu, SC_MINIMIZE, MF_BYCOMMAND );
179     RemoveMenu( SysMenu, SC_MAXIMIZE, MF_BYCOMMAND );
180     RemoveMenu( SysMenu, SC_CLOSE,    MF_BYCOMMAND );
181     RemoveMenu( SysMenu, 0,           MF_BYPOSITION );
182
183     // The create menu
184     CreateSystemMenu();
185 */
186     // Set the parent window attributes
187     GdkWindowAttr attr;
188     attr.title = "VLC Media Player";
189     attr.event_mask = GDK_ALL_EVENTS_MASK;
190     attr.x = 0;
191     attr.y = 0;
192     attr.width = 0;
193     attr.height = 0;
194     attr.window_type = GDK_WINDOW_TOPLEVEL;
195     attr.wclass = GDK_INPUT_ONLY;
196     attr.override_redirect = FALSE;
197     
198     gint mask = GDK_WA_TITLE|GDK_WA_X|GDK_WA_Y|GDK_WA_NOREDIR;
199     
200     // Create the parent window
201     ParentWindow = gdk_window_new( NULL, &attr, mask);
202
203 //    gdk_window_show( ParentWindow );
204 }
205 //---------------------------------------------------------------------------
206 void GTK2Theme::AddSystemMenu( string name, Event *event )
207 {/*
208     if( name == "SEPARATOR" )
209     {
210         AppendMenu( SysMenu, MF_SEPARATOR, 0, NULL );
211     }
212     else
213     {
214         AppendMenu( SysMenu, MF_STRING, (unsigned int)event,
215                     (char *)name.c_str() );
216     }*/
217 }
218 //---------------------------------------------------------------------------
219 void GTK2Theme::ChangeClientWindowName( string name )
220 {/*
221     SetWindowText( ParentWindow, name.c_str() );*/
222 }
223 //---------------------------------------------------------------------------
224 void GTK2Theme::AddWindow( string name, int x, int y, bool visible,
225     int fadetime, int alpha, int movealpha, bool dragdrop )
226 {/*
227     HWND hwnd;
228
229     hwnd = CreateWindowEx( WS_EX_LAYERED|WS_EX_TOOLWINDOW,
230         "SkinWindow", name.c_str(), WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT,
231         0, 0, ParentWindow, 0, hinst, NULL );
232
233     if( !hwnd )
234     {
235         msg_Err( p_intf, "CreateWindow failed" );
236         return;
237     }
238
239     SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR)p_intf );
240
241     WindowList.push_back( (Window *)new OSWindow( p_intf, hwnd, x, y, visible,
242         fadetime, alpha, movealpha, dragdrop ) ) ;*/
243
244     GdkWindowAttr attr;
245     attr.event_mask = GDK_ALL_EVENTS_MASK;
246     attr.width = 0;
247     attr.height = 0;
248     attr.window_type = GDK_WINDOW_TOPLEVEL;
249     attr.wclass = GDK_INPUT_OUTPUT;
250     attr.override_redirect = TRUE;
251     
252     gint mask = GDK_WA_NOREDIR;
253     
254     // Create the window
255     GdkWindow *gwnd = gdk_window_new( NULL, &attr, mask );
256     if( !gwnd )
257     {
258         msg_Err( p_intf, "CreateWindow failed" );
259         return;
260     }
261     
262     gdk_window_show( gwnd );
263     
264     WindowList.push_back( (Window *)new OSWindow( p_intf, gwnd, x, y, visible,
265         fadetime, alpha, movealpha, dragdrop ) ) ;
266
267 }
268 //---------------------------------------------------------------------------
269 /*HWND GTK2Theme::GetLogHandle()
270 {
271     if( Log != NULL )
272         return ( (GTK2LogWindow *)Log )->GetWindow();
273     else
274         return NULL;
275 }*/
276 //---------------------------------------------------------------------------
277 void GTK2Theme::ChangeTray()
278 {/*
279     if( ShowInTray )
280     {
281         Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
282         ShowInTray = false;
283     }
284     else
285     {
286         Shell_NotifyIcon( NIM_ADD, &TrayIcon );
287         ShowInTray = true;
288     }*/
289 }
290 //---------------------------------------------------------------------------
291 void GTK2Theme::ChangeTaskbar()
292 {/*
293     if( ShowInTaskbar )
294     {
295         ShowWindow( ParentWindow, SW_HIDE );
296         SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
297                           WS_EX_LAYERED|WS_EX_TOOLWINDOW );
298         ShowWindow( ParentWindow, SW_SHOW );
299         ShowInTaskbar = false;
300     }
301     else
302     {
303         ShowWindow( ParentWindow, SW_HIDE );
304         SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
305                           WS_EX_LAYERED|WS_EX_APPWINDOW );
306         ShowWindow( ParentWindow, SW_SHOW );
307         ShowInTaskbar = true;
308     }*/
309 }
310 //---------------------------------------------------------------------------
311
312 #endif