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