Mercurial > mplayer.hg
annotate gui/mplayer/widgets.c @ 33524:7d5fd12b86e7
Add note on wsXFMM key definitions.
author | ib |
---|---|
date | Tue, 14 Jun 2011 14:39:26 +0000 |
parents | 645b0990ba4c |
children | 140525bcc32f |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <stdio.h> | |
21 | |
22 #include <sys/types.h> | |
23 #include <sys/stat.h> | |
24 #include <sys/wait.h> | |
25 #include <unistd.h> | |
26 #include <string.h> | |
27 #include <signal.h> | |
28 | |
29 #include <gdk/gdkprivate.h> | |
30 #include <gdk/gdkkeysyms.h> | |
31 #include <gdk/gdkx.h> | |
32 #include <gdk/gdk.h> | |
33 #include <gtk/gtk.h> | |
34 | |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
36 #include "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
37 #include "mp_msg.h" |
33465 | 38 #include "libvo/x11_common.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
39 |
23077 | 40 #include "widgets.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
41 #include "gui/app.h" |
33466 | 42 #include "gui/interface.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
43 #include "gui/wm/ws.h" |
23077 | 44 |
45 | |
46 #include "play.h" | |
47 #include "gtk/fs.h" | |
48 | |
49 GtkWidget * PopUpMenu = NULL; | |
50 | |
51 GtkWidget * WarningPixmap; | |
52 GtkWidget * ErrorPixmap; | |
53 | |
54 int gtkPopupMenu = 0; | |
55 int gtkPopupMenuParam = 0; | |
25962 | 56 int gtkInitialized = 0; |
23077 | 57 |
58 #include "gtk/sb.h" | |
59 #include "gtk/pl.h" | |
60 #include "gtk/fs.h" | |
61 #include "gtk/mb.h" | |
62 #include "gtk/about.h" | |
63 #include "gtk/opts.h" | |
30531
704903d34069
Rename gui/mplayer/gtk/menu.[ch] --> gui/mplayer/gtk/gtkmenu.[ch].
diego
parents:
29263
diff
changeset
|
64 #include "gtk/gtk_menu.h" |
26137
02a08fffb1dc
Rename url.c/url.h to the less generic gtk_url.c/gtk_url.h.
diego
parents:
25962
diff
changeset
|
65 #include "gtk/gtk_url.h" |
23077 | 66 #include "gtk/eq.h" |
67 | |
33484
4f940d7917f0
Provide a desktop icon of reasonable size (48x48) and quality.
ib
parents:
33466
diff
changeset
|
68 #include "pixmaps/mplayer.xpm" |
23077 | 69 |
70 // --- init & close gtk | |
71 | |
33508 | 72 static GdkPixmap * gdkIcon; |
73 static GdkBitmap * gdkIconMask; | |
23077 | 74 Pixmap guiIcon; |
75 Pixmap guiIconMask; | |
76 | |
77 void gtkInit( void ) | |
78 { | |
33465 | 79 int argc = 0; |
80 char *arg[3], **argv = arg; | |
81 | |
33466 | 82 arg[argc++] = GMPlayer; |
33465 | 83 |
84 if (mDisplayName) // MPlayer option '-display' was given | |
85 { | |
86 arg[argc++] = "--display"; // Pass corresponding command line arguments to GTK, | |
87 arg[argc++] = mDisplayName; // to open the requested display for the GUI, too. | |
88 } | |
89 | |
23077 | 90 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[widget] init GTK ...\n" ); |
27343 | 91 #ifdef CONFIG_GTK2 |
23077 | 92 gtk_disable_setlocale(); |
93 #endif | |
33465 | 94 gtk_init( &argc, &argv ); |
23077 | 95 // gdk_set_use_xshm( TRUE ); |
96 | |
97 { | |
98 GtkWidget * win; | |
99 win=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
100 | |
33508 | 101 if ( !gdkIcon ) |
102 gdkIcon=gdk_pixmap_colormap_create_from_xpm_d( win->window,gdk_colormap_get_system(),&gdkIconMask,&win->style->bg[GTK_STATE_NORMAL],(gchar **) mplayer_xpm ); | |
23077 | 103 |
33509 | 104 guiIcon=GDK_PIXMAP_XID( gdkIcon ); |
105 guiIconMask=GDK_PIXMAP_XID( gdkIconMask ); | |
23077 | 106 |
107 gtk_widget_destroy( win ); | |
108 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
109 |
25962 | 110 gtkInitialized=1; |
23077 | 111 } |
112 | |
113 void gtkAddIcon( GtkWidget * window ) | |
114 { wsSetIcon( gdk_display,GDK_WINDOW_XWINDOW( window->window ),guiIcon,guiIconMask ); } | |
115 | |
116 void gtkClearList( GtkWidget * list ) | |
117 { gtk_clist_clear( GTK_CLIST( list ) ); } | |
118 | |
119 int gtkFindCList( GtkWidget * list,char * item ) | |
120 { | |
33314 | 121 gint j; |
23077 | 122 gchar * tmpstr; |
33314 | 123 for( j=0;j<GTK_CLIST( list )->rows;j++ ) |
23077 | 124 { |
125 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr ); | |
126 if ( !strcmp( tmpstr,item ) ) return j; | |
127 } | |
128 return -1; | |
129 } | |
130 | |
131 void gtkSetDefaultToCList( GtkWidget * list,char * item ) | |
132 { | |
133 gint i; | |
134 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 ); | |
135 } | |
136 | |
137 void gtkEventHandling( void ) | |
138 { | |
139 int i; | |
140 for( i=0;i < 25;i++ ) gtk_main_iteration_do( 0 ); | |
141 } | |
142 | |
143 // --- funcs | |
144 | |
145 void gtkMessageBox( int type,const gchar * str ) | |
146 { | |
25962 | 147 if ( !gtkInitialized ) return; |
23077 | 148 ShowMessageBox( str ); |
149 gtk_label_set_text( GTK_LABEL( gtkMessageBoxText ),str ); | |
150 /* enable linewrapping by alex */ | |
151 // GTK_LABEL(gtkMessageBoxText)->max_width = 80; | |
152 if (strlen(str) > 80) | |
153 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE); | |
154 else | |
155 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE); | |
156 switch( type) | |
157 { | |
158 case GTK_MB_FATAL: | |
159 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_FatalError ); | |
160 gtk_widget_hide( WarningPixmap ); | |
161 gtk_widget_show( ErrorPixmap ); | |
162 break; | |
163 case GTK_MB_ERROR: | |
164 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Error ); | |
165 gtk_widget_hide( WarningPixmap ); | |
166 gtk_widget_show( ErrorPixmap ); | |
167 break; | |
168 case GTK_MB_WARNING: | |
169 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Warning ); | |
170 gtk_widget_show( WarningPixmap ); | |
171 gtk_widget_hide( ErrorPixmap ); | |
172 break; | |
173 } | |
174 gtk_widget_show( MessageBox ); | |
175 gtkSetLayer( MessageBox ); | |
176 if ( type == GTK_MB_FATAL ) | |
177 while ( MessageBox ) gtk_main_iteration_do( 0 ); | |
178 } | |
179 | |
180 void gtkSetLayer( GtkWidget * wdg ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
181 { |
23077 | 182 wsSetLayer( gdk_display,GDK_WINDOW_XWINDOW( wdg->window ),appMPlayer.subWindow.isFullScreen ); |
183 gtkActive( wdg ); | |
184 } | |
185 | |
186 void gtkActive( GtkWidget * wdg ) | |
187 { wsMoveTopWindow( gdk_display,GDK_WINDOW_XWINDOW( wdg->window )); } | |
188 | |
189 void gtkShow( int type,char * param ) | |
190 { | |
191 switch( type ) | |
192 { | |
193 case evEqualizer: | |
194 ShowEqualizer(); | |
195 gtkSetLayer( Equalizer ); | |
196 break; | |
197 case evSkinBrowser: | |
198 ShowSkinBrowser(); | |
199 // gtkClearList( SkinList ); | |
200 if ( gtkFillSkinList( sbMPlayerPrefixDir ) && | |
32847
12ae3b893c59
Remove support for skins directories using the obsolete name 'Skin'.
ib
parents:
32741
diff
changeset
|
201 gtkFillSkinList( sbMPlayerDirInHome ) ) |
23077 | 202 { |
203 gtkSetDefaultToCList( SkinList,param ); | |
204 gtk_clist_sort( GTK_CLIST( SkinList ) ); | |
205 gtk_widget_show( SkinBrowser ); | |
206 gtkSetLayer( SkinBrowser ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
207 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
208 else |
23077 | 209 { |
210 gtk_widget_destroy( SkinBrowser ); | |
211 gtkMessageBox( GTK_MB_ERROR,"Skin dirs not found ... Please install skins." ); | |
212 } | |
213 break; | |
214 case evPreferences: | |
215 ShowPreferences(); | |
216 break; | |
217 case evPlayList: | |
218 ShowPlayList(); | |
219 gtkSetLayer( PlayList ); | |
220 break; | |
221 case evLoad: | |
222 ShowFileSelect( fsVideoSelector,0 ); | |
223 gtkSetLayer( fsFileSelect ); | |
224 break; | |
225 case evFirstLoad: | |
226 ShowFileSelect( fsVideoSelector,0 ); | |
227 gtkSetLayer( fsFileSelect ); | |
228 break; | |
229 case evLoadSubtitle: | |
230 ShowFileSelect( fsSubtitleSelector,0 ); | |
231 gtkSetLayer( fsFileSelect ); | |
232 break; | |
233 case evLoadAudioFile: | |
234 ShowFileSelect( fsAudioSelector,0 ); | |
235 gtkSetLayer( fsFileSelect ); | |
236 break; | |
237 case evAbout: | |
238 ShowAboutBox(); | |
239 gtkSetLayer( About ); | |
240 break; | |
241 case evShowPopUpMenu: | |
242 gtkPopupMenu=evNone; | |
243 gtkPopupMenuParam=0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
244 if ( PopUpMenu ) |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
245 { |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
246 gtk_widget_hide( PopUpMenu ); |
23077 | 247 gtk_widget_destroy( PopUpMenu ); |
248 } | |
249 PopUpMenu=create_PopUpMenu(); | |
250 gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 ); | |
251 break; | |
252 case evHidePopUpMenu: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
253 if ( PopUpMenu ) |
23077 | 254 { |
255 gtk_widget_hide( PopUpMenu ); | |
256 gtk_widget_destroy( PopUpMenu ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
257 PopUpMenu=NULL; |
23077 | 258 } |
259 break; | |
260 case evPlayNetwork: | |
261 ShowURLDialogBox(); | |
262 gtkSetLayer( URL ); | |
263 break; | |
264 } | |
265 } |