Mercurial > mplayer.hg
annotate gui/mplayer/widgets.c @ 32955:e12d6cd72b75
Go without gtk functions.
Normal string function are sufficient to handle item->text,
there is no need to use gtk functions.
author | ib |
---|---|
date | Mon, 07 Mar 2011 20:27:29 +0000 |
parents | 12ae3b893c59 |
children | d30987a7e6cf |
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" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
38 |
23077 | 39 #include "widgets.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
40 #include "gui/app.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
41 #include "gui/wm/ws.h" |
23077 | 42 |
43 | |
44 #include "play.h" | |
45 #include "gtk/fs.h" | |
46 | |
47 GtkWidget * PopUpMenu = NULL; | |
48 | |
49 GtkWidget * WarningPixmap; | |
50 GtkWidget * ErrorPixmap; | |
51 | |
52 int gtkPopupMenu = 0; | |
53 int gtkPopupMenuParam = 0; | |
25962 | 54 int gtkInitialized = 0; |
23077 | 55 |
56 #include "gtk/sb.h" | |
57 #include "gtk/pl.h" | |
58 #include "gtk/fs.h" | |
59 #include "gtk/mb.h" | |
60 #include "gtk/about.h" | |
61 #include "gtk/opts.h" | |
30531
704903d34069
Rename gui/mplayer/gtk/menu.[ch] --> gui/mplayer/gtk/gtkmenu.[ch].
diego
parents:
29263
diff
changeset
|
62 #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
|
63 #include "gtk/gtk_url.h" |
23077 | 64 #include "gtk/eq.h" |
65 | |
66 #include "pixmaps/MPlayer_mini.xpm" | |
67 | |
68 // --- init & close gtk | |
69 | |
70 GdkPixmap * gtkIcon = NULL; | |
71 GdkBitmap * gtkIconMask = NULL; | |
72 Pixmap guiIcon; | |
73 Pixmap guiIconMask; | |
74 | |
75 void gtkInit( void ) | |
76 { | |
77 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[widget] init GTK ...\n" ); | |
27343 | 78 #ifdef CONFIG_GTK2 |
23077 | 79 gtk_disable_setlocale(); |
80 #endif | |
81 gtk_init( 0,NULL ); | |
82 // gdk_set_use_xshm( TRUE ); | |
83 | |
84 { | |
85 GtkWidget * win; | |
86 win=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
87 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
88 if ( !gtkIcon ) |
32741 | 89 gtkIcon=gdk_pixmap_colormap_create_from_xpm_d( win->window,gdk_colormap_get_system(),>kIconMask,&win->style->bg[GTK_STATE_NORMAL],(gchar **) MPlayer_mini_xpm ); |
23077 | 90 |
91 guiIcon=GDK_WINDOW_XWINDOW( gtkIcon ); | |
92 guiIconMask=GDK_WINDOW_XWINDOW( gtkIconMask ); | |
93 | |
94 gtk_widget_destroy( win ); | |
95 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
96 |
25962 | 97 gtkInitialized=1; |
23077 | 98 } |
99 | |
100 void gtkAddIcon( GtkWidget * window ) | |
101 { wsSetIcon( gdk_display,GDK_WINDOW_XWINDOW( window->window ),guiIcon,guiIconMask ); } | |
102 | |
103 void gtkClearList( GtkWidget * list ) | |
104 { gtk_clist_clear( GTK_CLIST( list ) ); } | |
105 | |
106 int gtkFindCList( GtkWidget * list,char * item ) | |
107 { | |
108 gint j,t; | |
109 gchar * tmpstr; | |
110 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ ) | |
111 { | |
112 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr ); | |
113 if ( !strcmp( tmpstr,item ) ) return j; | |
114 } | |
115 return -1; | |
116 } | |
117 | |
118 void gtkSetDefaultToCList( GtkWidget * list,char * item ) | |
119 { | |
120 gint i; | |
121 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 ); | |
122 } | |
123 | |
124 void gtkEventHandling( void ) | |
125 { | |
126 int i; | |
127 for( i=0;i < 25;i++ ) gtk_main_iteration_do( 0 ); | |
128 } | |
129 | |
130 // --- funcs | |
131 | |
132 void gtkMessageBox( int type,const gchar * str ) | |
133 { | |
25962 | 134 if ( !gtkInitialized ) return; |
23077 | 135 ShowMessageBox( str ); |
136 gtk_label_set_text( GTK_LABEL( gtkMessageBoxText ),str ); | |
137 /* enable linewrapping by alex */ | |
138 // GTK_LABEL(gtkMessageBoxText)->max_width = 80; | |
139 if (strlen(str) > 80) | |
140 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE); | |
141 else | |
142 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE); | |
143 switch( type) | |
144 { | |
145 case GTK_MB_FATAL: | |
146 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_FatalError ); | |
147 gtk_widget_hide( WarningPixmap ); | |
148 gtk_widget_show( ErrorPixmap ); | |
149 break; | |
150 case GTK_MB_ERROR: | |
151 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Error ); | |
152 gtk_widget_hide( WarningPixmap ); | |
153 gtk_widget_show( ErrorPixmap ); | |
154 break; | |
155 case GTK_MB_WARNING: | |
156 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Warning ); | |
157 gtk_widget_show( WarningPixmap ); | |
158 gtk_widget_hide( ErrorPixmap ); | |
159 break; | |
160 } | |
161 gtk_widget_show( MessageBox ); | |
162 gtkSetLayer( MessageBox ); | |
163 if ( type == GTK_MB_FATAL ) | |
164 while ( MessageBox ) gtk_main_iteration_do( 0 ); | |
165 } | |
166 | |
167 void gtkSetLayer( GtkWidget * wdg ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
168 { |
23077 | 169 wsSetLayer( gdk_display,GDK_WINDOW_XWINDOW( wdg->window ),appMPlayer.subWindow.isFullScreen ); |
170 gtkActive( wdg ); | |
171 } | |
172 | |
173 void gtkActive( GtkWidget * wdg ) | |
174 { wsMoveTopWindow( gdk_display,GDK_WINDOW_XWINDOW( wdg->window )); } | |
175 | |
176 void gtkShow( int type,char * param ) | |
177 { | |
178 switch( type ) | |
179 { | |
180 case evEqualizer: | |
181 ShowEqualizer(); | |
182 gtkSetLayer( Equalizer ); | |
183 break; | |
184 case evSkinBrowser: | |
185 ShowSkinBrowser(); | |
186 // gtkClearList( SkinList ); | |
187 if ( gtkFillSkinList( sbMPlayerPrefixDir ) && | |
32847
12ae3b893c59
Remove support for skins directories using the obsolete name 'Skin'.
ib
parents:
32741
diff
changeset
|
188 gtkFillSkinList( sbMPlayerDirInHome ) ) |
23077 | 189 { |
190 gtkSetDefaultToCList( SkinList,param ); | |
191 gtk_clist_sort( GTK_CLIST( SkinList ) ); | |
192 gtk_widget_show( SkinBrowser ); | |
193 gtkSetLayer( SkinBrowser ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
194 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
195 else |
23077 | 196 { |
197 gtk_widget_destroy( SkinBrowser ); | |
198 gtkMessageBox( GTK_MB_ERROR,"Skin dirs not found ... Please install skins." ); | |
199 } | |
200 break; | |
201 case evPreferences: | |
202 ShowPreferences(); | |
203 break; | |
204 case evPlayList: | |
205 ShowPlayList(); | |
206 gtkSetLayer( PlayList ); | |
207 break; | |
208 case evLoad: | |
209 ShowFileSelect( fsVideoSelector,0 ); | |
210 gtkSetLayer( fsFileSelect ); | |
211 break; | |
212 case evFirstLoad: | |
213 ShowFileSelect( fsVideoSelector,0 ); | |
214 gtkSetLayer( fsFileSelect ); | |
215 break; | |
216 case evLoadSubtitle: | |
217 ShowFileSelect( fsSubtitleSelector,0 ); | |
218 gtkSetLayer( fsFileSelect ); | |
219 break; | |
220 case evLoadAudioFile: | |
221 ShowFileSelect( fsAudioSelector,0 ); | |
222 gtkSetLayer( fsFileSelect ); | |
223 break; | |
224 case evAbout: | |
225 ShowAboutBox(); | |
226 gtkSetLayer( About ); | |
227 break; | |
228 case evShowPopUpMenu: | |
229 gtkPopupMenu=evNone; | |
230 gtkPopupMenuParam=0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
231 if ( PopUpMenu ) |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
232 { |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
233 gtk_widget_hide( PopUpMenu ); |
23077 | 234 gtk_widget_destroy( PopUpMenu ); |
235 } | |
236 PopUpMenu=create_PopUpMenu(); | |
237 gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 ); | |
238 break; | |
239 case evHidePopUpMenu: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
240 if ( PopUpMenu ) |
23077 | 241 { |
242 gtk_widget_hide( PopUpMenu ); | |
243 gtk_widget_destroy( PopUpMenu ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27343
diff
changeset
|
244 PopUpMenu=NULL; |
23077 | 245 } |
246 break; | |
247 case evPlayNetwork: | |
248 ShowURLDialogBox(); | |
249 gtkSetLayer( URL ); | |
250 break; | |
251 } | |
252 } |