Mercurial > mplayer.hg
annotate gui/mplayer/widgets.c @ 33527:9f0812ccc421
Cosmetic: Adjust indent.
author | ib |
---|---|
date | Tue, 14 Jun 2011 17:53:40 +0000 |
parents | 140525bcc32f |
children | 6f20f2a42b76 |
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 | |
72 Pixmap guiIcon; | |
73 Pixmap guiIconMask; | |
74 | |
75 void gtkInit( void ) | |
76 { | |
33465 | 77 int argc = 0; |
78 char *arg[3], **argv = arg; | |
33526 | 79 GdkPixmap *gdkIcon; |
80 GdkBitmap *gdkIconMask; | |
33465 | 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 | |
33527 | 97 gdkIcon=gdk_pixmap_colormap_create_from_xpm_d( NULL,gdk_colormap_get_system(),&gdkIconMask,NULL,(gchar **) mplayer_xpm ); |
23077 | 98 |
33526 | 99 // start up GTK which realizes the pixmaps |
100 gtk_main_iteration_do(FALSE); | |
23077 | 101 |
33527 | 102 guiIcon=GDK_PIXMAP_XID( gdkIcon ); |
103 guiIconMask=GDK_PIXMAP_XID( gdkIconMask ); | |
23077 | 104 |
25962 | 105 gtkInitialized=1; |
23077 | 106 } |
107 | |
108 void gtkAddIcon( GtkWidget * window ) | |
109 { wsSetIcon( gdk_display,GDK_WINDOW_XWINDOW( window->window ),guiIcon,guiIconMask ); } | |
110 | |
111 void gtkClearList( GtkWidget * list ) | |
112 { gtk_clist_clear( GTK_CLIST( list ) ); } | |
113 | |
114 int gtkFindCList( GtkWidget * list,char * item ) | |
115 { | |
33314 | 116 gint j; |
23077 | 117 gchar * tmpstr; |
33314 | 118 for( j=0;j<GTK_CLIST( list )->rows;j++ ) |
23077 | 119 { |
120 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr ); | |
121 if ( !strcmp( tmpstr,item ) ) return j; | |
122 } | |
123 return -1; | |
124 } | |
125 | |
126 void gtkSetDefaultToCList( GtkWidget * list,char * item ) | |
127 { | |
128 gint i; | |
129 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 ); | |
130 } | |
131 | |
132 void gtkEventHandling( void ) | |
133 { | |
134 int i; | |
135 for( i=0;i < 25;i++ ) gtk_main_iteration_do( 0 ); | |
136 } | |
137 | |
138 // --- funcs | |
139 | |
140 void gtkMessageBox( int type,const gchar * str ) | |
141 { | |
25962 | 142 if ( !gtkInitialized ) return; |
23077 | 143 ShowMessageBox( str ); |
144 gtk_label_set_text( GTK_LABEL( gtkMessageBoxText ),str ); | |
145 /* enable linewrapping by alex */ | |
146 // GTK_LABEL(gtkMessageBoxText)->max_width = 80; | |
147 if (strlen(str) > 80) | |
148 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE); | |
149 else | |
150 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE); | |
151 switch( type) | |
152 { | |
153 case GTK_MB_FATAL: | |
154 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_FatalError ); | |
155 gtk_widget_hide( WarningPixmap ); | |
156 gtk_widget_show( ErrorPixmap ); | |
157 break; | |
158 case GTK_MB_ERROR: | |
159 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Error ); | |
160 gtk_widget_hide( WarningPixmap ); | |
161 gtk_widget_show( ErrorPixmap ); | |
162 break; | |
163 case GTK_MB_WARNING: | |
164 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Warning ); | |
165 gtk_widget_show( WarningPixmap ); | |
166 gtk_widget_hide( ErrorPixmap ); | |
167 break; | |
168 } | |
169 gtk_widget_show( MessageBox ); | |
170 gtkSetLayer( MessageBox ); | |
171 if ( type == GTK_MB_FATAL ) | |
172 while ( MessageBox ) gtk_main_iteration_do( 0 ); | |
173 } | |
174 | |
175 void gtkSetLayer( GtkWidget * wdg ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
176 { |
23077 | 177 wsSetLayer( gdk_display,GDK_WINDOW_XWINDOW( wdg->window ),appMPlayer.subWindow.isFullScreen ); |
178 gtkActive( wdg ); | |
179 } | |
180 | |
181 void gtkActive( GtkWidget * wdg ) | |
182 { wsMoveTopWindow( gdk_display,GDK_WINDOW_XWINDOW( wdg->window )); } | |
183 | |
184 void gtkShow( int type,char * param ) | |
185 { | |
186 switch( type ) | |
187 { | |
188 case evEqualizer: | |
189 ShowEqualizer(); | |
190 gtkSetLayer( Equalizer ); | |
191 break; | |
192 case evSkinBrowser: | |
193 ShowSkinBrowser(); | |
194 // gtkClearList( SkinList ); | |
195 if ( gtkFillSkinList( sbMPlayerPrefixDir ) && | |
32847
12ae3b893c59
Remove support for skins directories using the obsolete name 'Skin'.
ib
parents:
32741
diff
changeset
|
196 gtkFillSkinList( sbMPlayerDirInHome ) ) |
23077 | 197 { |
198 gtkSetDefaultToCList( SkinList,param ); | |
199 gtk_clist_sort( GTK_CLIST( SkinList ) ); | |
200 gtk_widget_show( SkinBrowser ); | |
201 gtkSetLayer( SkinBrowser ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
202 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
203 else |
23077 | 204 { |
205 gtk_widget_destroy( SkinBrowser ); | |
206 gtkMessageBox( GTK_MB_ERROR,"Skin dirs not found ... Please install skins." ); | |
207 } | |
208 break; | |
209 case evPreferences: | |
210 ShowPreferences(); | |
211 break; | |
212 case evPlayList: | |
213 ShowPlayList(); | |
214 gtkSetLayer( PlayList ); | |
215 break; | |
216 case evLoad: | |
217 ShowFileSelect( fsVideoSelector,0 ); | |
218 gtkSetLayer( fsFileSelect ); | |
219 break; | |
220 case evFirstLoad: | |
221 ShowFileSelect( fsVideoSelector,0 ); | |
222 gtkSetLayer( fsFileSelect ); | |
223 break; | |
224 case evLoadSubtitle: | |
225 ShowFileSelect( fsSubtitleSelector,0 ); | |
226 gtkSetLayer( fsFileSelect ); | |
227 break; | |
228 case evLoadAudioFile: | |
229 ShowFileSelect( fsAudioSelector,0 ); | |
230 gtkSetLayer( fsFileSelect ); | |
231 break; | |
232 case evAbout: | |
233 ShowAboutBox(); | |
234 gtkSetLayer( About ); | |
235 break; | |
236 case evShowPopUpMenu: | |
237 gtkPopupMenu=evNone; | |
238 gtkPopupMenuParam=0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
239 if ( PopUpMenu ) |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
240 { |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
241 gtk_widget_hide( PopUpMenu ); |
23077 | 242 gtk_widget_destroy( PopUpMenu ); |
243 } | |
244 PopUpMenu=create_PopUpMenu(); | |
245 gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 ); | |
246 break; | |
247 case evHidePopUpMenu: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
248 if ( PopUpMenu ) |
23077 | 249 { |
250 gtk_widget_hide( PopUpMenu ); | |
251 gtk_widget_destroy( PopUpMenu ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
252 PopUpMenu=NULL; |
23077 | 253 } |
254 break; | |
255 case evPlayNetwork: | |
256 ShowURLDialogBox(); | |
257 gtkSetLayer( URL ); | |
258 break; | |
259 } | |
260 } |