Mercurial > mplayer.hg
annotate Gui/mplayer/widgets.c @ 20347:c1f610e507ed
fix "typo"
author | kraymer |
---|---|
date | Sun, 22 Oct 2006 12:21:29 +0000 |
parents | 273bdef43012 |
children | df66b39a57b5 |
rev | line source |
---|---|
1693 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
4 | |
5 #include <sys/types.h> | |
6 #include <sys/stat.h> | |
1700 | 7 #include <sys/wait.h> |
1693 | 8 #include <unistd.h> |
9 #include <string.h> | |
10 #include <signal.h> | |
11 | |
4176
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
12 #include <gdk/gdkprivate.h> |
1693 | 13 #include <gdk/gdkkeysyms.h> |
6651 | 14 #include <gdk/gdkx.h> |
4176
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
15 #include <gdk/gdk.h> |
1693 | 16 #include <gtk/gtk.h> |
17 | |
18 #include "widgets.h" | |
19 | |
20 #include "./mplayer.h" | |
17144 | 21 #include "app.h" |
22 #include "wm/ws.h" | |
6651 | 23 |
1693 | 24 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
25 #include "gtk/menu.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
26 #include "play.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
27 #include "gtk/fs.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
28 |
17144 | 29 #include "../config.h" |
30 #include "../help_mp.h" | |
31 #include "../mp_msg.h" | |
1693 | 32 |
4950 | 33 GtkWidget * PopUpMenu = NULL; |
1693 | 34 |
1925 | 35 GtkWidget * WarningPixmap; |
36 GtkWidget * ErrorPixmap; | |
37 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
38 int gtkPopupMenu = 0; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
39 int gtkPopupMenuParam = 0; |
5919 | 40 int gtkInited = 0; |
1693 | 41 |
42 #include "gtk/sb.h" | |
43 #include "gtk/pl.h" | |
44 #include "gtk/fs.h" | |
45 #include "gtk/mb.h" | |
46 #include "gtk/about.h" | |
47 #include "gtk/opts.h" | |
2901 | 48 #include "gtk/menu.h" |
6298 | 49 #include "gtk/url.h" |
6627 | 50 #include "gtk/eq.h" |
1693 | 51 |
6651 | 52 #include "pixmaps/MPlayer_mini.xpm" |
53 | |
1693 | 54 // --- init & close gtk |
55 | |
6651 | 56 GdkPixmap * gtkIcon = NULL; |
57 GdkBitmap * gtkIconMask = NULL; | |
58 Pixmap guiIcon; | |
59 Pixmap guiIconMask; | |
60 | |
6218 | 61 void gtkInit( void ) |
1693 | 62 { |
14156 | 63 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[widget] init GTK ...\n" ); |
6218 | 64 gtk_init( 0,NULL ); |
6146 | 65 // gdk_set_use_xshm( TRUE ); |
6651 | 66 |
67 { | |
68 GtkWidget * win; | |
69 win=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
70 | |
71 if ( !gtkIcon ) | |
72 gtkIcon=gdk_pixmap_colormap_create_from_xpm_d( win->window,gdk_colormap_get_system(),>kIconMask,&win->style->bg[GTK_STATE_NORMAL],MPlayer_mini_xpm ); | |
73 | |
74 guiIcon=GDK_WINDOW_XWINDOW( gtkIcon ); | |
75 guiIconMask=GDK_WINDOW_XWINDOW( gtkIconMask ); | |
76 | |
77 gtk_widget_destroy( win ); | |
78 } | |
79 | |
5919 | 80 gtkInited=1; |
1693 | 81 } |
82 | |
6651 | 83 void gtkAddIcon( GtkWidget * window ) |
8043 | 84 { wsSetIcon( gdk_display,GDK_WINDOW_XWINDOW( window->window ),guiIcon,guiIconMask ); } |
6651 | 85 |
1693 | 86 void gtkClearList( GtkWidget * list ) |
87 { gtk_clist_clear( GTK_CLIST( list ) ); } | |
88 | |
89 int gtkFindCList( GtkWidget * list,char * item ) | |
90 { | |
91 gint j,t; | |
92 gchar * tmpstr; | |
93 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ ) | |
94 { | |
95 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr ); | |
96 if ( !strcmp( tmpstr,item ) ) return j; | |
97 } | |
98 return -1; | |
99 } | |
100 | |
101 void gtkSetDefaultToCList( GtkWidget * list,char * item ) | |
102 { | |
103 gint i; | |
104 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 ); | |
105 } | |
106 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
107 void gtkEventHandling( void ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
108 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
109 int i; |
6903 | 110 for( i=0;i < 25;i++ ) gtk_main_iteration_do( 0 ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
111 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
112 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
113 // --- funcs |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
114 |
19081
273bdef43012
Mark several string parameters that are not modified in the function as const.
diego
parents:
17974
diff
changeset
|
115 void gtkMessageBox( int type,const gchar * str ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
116 { |
5919 | 117 if ( !gtkInited ) return; |
6146 | 118 ShowMessageBox( str ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
119 gtk_label_set_text( GTK_LABEL( gtkMessageBoxText ),str ); |
7198 | 120 /* enable linewrapping by alex */ |
121 // GTK_LABEL(gtkMessageBoxText)->max_width = 80; | |
122 if (strlen(str) > 80) | |
123 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE); | |
124 else | |
125 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
126 switch( type) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
127 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
128 case GTK_MB_FATAL: |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
129 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_FatalError ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
130 gtk_widget_hide( WarningPixmap ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
131 gtk_widget_show( ErrorPixmap ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
132 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
133 case GTK_MB_ERROR: |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
134 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Error ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
135 gtk_widget_hide( WarningPixmap ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
136 gtk_widget_show( ErrorPixmap ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
137 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
138 case GTK_MB_WARNING: |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
139 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Warning ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
140 gtk_widget_show( WarningPixmap ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
141 gtk_widget_hide( ErrorPixmap ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
142 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
143 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
144 gtk_widget_show( MessageBox ); |
6794 | 145 gtkSetLayer( MessageBox ); |
146 if ( type == GTK_MB_FATAL ) | |
8299 | 147 while ( MessageBox ) gtk_main_iteration_do( 0 ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
148 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
149 |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
150 void gtkSetLayer( GtkWidget * wdg ) |
8864 | 151 { |
152 wsSetLayer( gdk_display,GDK_WINDOW_XWINDOW( wdg->window ),appMPlayer.subWindow.isFullScreen ); | |
153 gtkActive( wdg ); | |
154 } | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
155 |
6146 | 156 void gtkActive( GtkWidget * wdg ) |
8043 | 157 { wsMoveTopWindow( gdk_display,GDK_WINDOW_XWINDOW( wdg->window )); } |
6146 | 158 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
159 void gtkShow( int type,char * param ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
160 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
161 switch( type ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
162 { |
6627 | 163 case evEqualizer: |
164 ShowEqualizer(); | |
165 gtkSetLayer( Equalizer ); | |
166 break; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
167 case evSkinBrowser: |
6146 | 168 ShowSkinBrowser(); |
6044 | 169 // gtkClearList( SkinList ); |
17974
9a5a62f480e6
Rename the default GUI skins directory from 'Skin' to 'skins', keeping
diego
parents:
17772
diff
changeset
|
170 if ( gtkFillSkinList( sbMPlayerPrefixDir ) && |
9a5a62f480e6
Rename the default GUI skins directory from 'Skin' to 'skins', keeping
diego
parents:
17772
diff
changeset
|
171 gtkFillSkinList( sbMPlayerPrefixDir_obsolete ) && |
9a5a62f480e6
Rename the default GUI skins directory from 'Skin' to 'skins', keeping
diego
parents:
17772
diff
changeset
|
172 gtkFillSkinList( sbMPlayerDirInHome ) && |
9a5a62f480e6
Rename the default GUI skins directory from 'Skin' to 'skins', keeping
diego
parents:
17772
diff
changeset
|
173 gtkFillSkinList( sbMPlayerDirInHome_obsolete ) ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
174 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
175 gtkSetDefaultToCList( SkinList,param ); |
6651 | 176 gtk_clist_sort( GTK_CLIST( SkinList ) ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
177 gtk_widget_show( SkinBrowser ); |
6044 | 178 gtkSetLayer( SkinBrowser ); |
6222 | 179 } |
180 else | |
181 { | |
6903 | 182 gtk_widget_destroy( SkinBrowser ); |
6222 | 183 gtkMessageBox( GTK_MB_ERROR,"Skin dirs not found ... Please install skins." ); |
184 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
185 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
186 case evPreferences: |
6794 | 187 ShowPreferences(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
188 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
189 case evPlayList: |
6713 | 190 ShowPlayList(); |
191 gtkSetLayer( PlayList ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
192 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
193 case evLoad: |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6298
diff
changeset
|
194 ShowFileSelect( fsVideoSelector,0 ); |
6146 | 195 gtkSetLayer( fsFileSelect ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
196 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
197 case evFirstLoad: |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6298
diff
changeset
|
198 ShowFileSelect( fsVideoSelector,0 ); |
6146 | 199 gtkSetLayer( fsFileSelect ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
200 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
201 case evLoadSubtitle: |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6298
diff
changeset
|
202 ShowFileSelect( fsSubtitleSelector,0 ); |
6146 | 203 gtkSetLayer( fsFileSelect ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
204 break; |
6623 | 205 case evLoadAudioFile: |
206 ShowFileSelect( fsAudioSelector,0 ); | |
207 gtkSetLayer( fsFileSelect ); | |
208 break; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
209 case evAbout: |
6146 | 210 ShowAboutBox(); |
8299 | 211 gtkSetLayer( About ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
212 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
213 case evShowPopUpMenu: |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
214 gtkPopupMenu=evNone; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
215 gtkPopupMenuParam=0; |
8973 | 216 if ( PopUpMenu ) |
217 { | |
218 gtk_widget_hide( PopUpMenu ); | |
219 gtk_widget_destroy( PopUpMenu ); | |
220 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
221 PopUpMenu=create_PopUpMenu(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
222 gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
223 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
224 case evHidePopUpMenu: |
8973 | 225 if ( PopUpMenu ) |
226 { | |
227 gtk_widget_hide( PopUpMenu ); | |
228 gtk_widget_destroy( PopUpMenu ); | |
229 PopUpMenu=NULL; | |
230 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
231 break; |
6298 | 232 case evPlayNetwork: |
233 ShowURLDialogBox(); | |
6755 | 234 gtkSetLayer( URL ); |
6298 | 235 break; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
236 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
237 } |