]> git.sesse.net Git - vlc/blob - modules/gui/skins/gtk2/gtk2_event.cpp
* GTK2 events work even better
[vlc] / modules / gui / skins / gtk2 / gtk2_event.cpp
1 /*****************************************************************************
2  * gtk2_event.cpp: GTK2 implementation of the Event class
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: gtk2_event.cpp,v 1.7 2003/04/15 20:54:58 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
30 //--- VLC -------------------------------------------------------------------
31 #include <vlc/intf.h>
32
33 //--- SKIN ------------------------------------------------------------------
34 #include "os_api.h"
35 #include "event.h"
36 #include "os_event.h"
37 #include "window.h"
38 #include "os_window.h"
39 #include "theme.h"
40 #include "os_theme.h"
41 #include "skin_common.h"
42
43
44 //---------------------------------------------------------------------------
45 //   VLC Event
46 //---------------------------------------------------------------------------
47 GTK2Event::GTK2Event( intf_thread_t *p_intf, string Desc, string shortcut )
48     : Event( p_intf, Desc, shortcut )
49 {
50     gWnd = NULL;
51 }
52 //---------------------------------------------------------------------------
53 GTK2Event::GTK2Event( intf_thread_t *p_intf, GdkWindow *gwnd, unsigned int msg,
54     unsigned int par1, long par2 ) : Event( p_intf, msg, par1, par2 )
55 {
56     gWnd = gwnd;
57 }
58 //---------------------------------------------------------------------------
59 GTK2Event::GTK2Event( intf_thread_t *p_intf, Window *win, unsigned int msg,
60     unsigned int par1, long par2 ) : Event( p_intf, msg, par1, par2 )
61 {
62     gWnd = ( (GTK2Window *)win )->GetHandle();
63 }
64 //---------------------------------------------------------------------------
65 GTK2Event::~GTK2Event()
66 {
67 }
68 //---------------------------------------------------------------------------
69 bool GTK2Event::SendEvent()
70 {
71     if( Message != VLC_NOTHING )
72     {
73         // Find window matching with gwnd
74         list<Window *>::const_iterator win;
75         for( win = p_intf->p_sys->p_theme->WindowList.begin();
76              win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
77         {
78             // If it is the correct window
79             if( gWnd == ( (GTK2Window *)(*win) )->GetHandle() )
80             {
81                 OSAPI_PostMessage( *win, Message, Param1, Param2 );
82                 PostSynchroMessage();
83                 return true;
84             }
85         }
86         OSAPI_PostMessage( NULL, Message, Param1, Param2 );
87         return true;
88     }
89
90     return false;
91 }
92 //---------------------------------------------------------------------------
93 bool GTK2Event::IsEqual( Event *evt )
94 {
95 /*    GTK2Event *WinEvt = (GTK2Event *)evt;
96     return( WinEvt->GetWindow() == hWnd   && WinEvt->GetMessage() == Message &&
97             WinEvt->GetParam1() == Param1 && WinEvt->GetParam2()  == Param2 );*/
98 }
99 //---------------------------------------------------------------------------
100 void GTK2Event::CreateOSEvent( string para1, string para2, string para3 )
101 {
102     // Find Parameters
103     switch( Message )
104     {
105         case WINDOW_MOVE:
106             gWnd = GetWindowFromName( para1 );
107             break;
108
109         case WINDOW_CLOSE:
110             gWnd = GetWindowFromName( para1 );
111             break;
112
113         case WINDOW_OPEN:
114             gWnd = GetWindowFromName( para1 );
115             break;
116
117     }
118 }
119 //---------------------------------------------------------------------------
120 GdkWindow *GTK2Event::GetWindowFromName( string name )
121 {
122     GTK2Window *win = (GTK2Window *)
123         p_intf->p_sys->p_theme->GetWindow( name );
124
125     if( win == NULL )
126     {
127         return NULL;
128     }
129     else
130     {
131         return win->GetHandle();
132     }
133 }
134 //---------------------------------------------------------------------------
135
136 #endif