Mercurial > mplayer.hg
annotate Gui/mplayer/widgets.c @ 6885:41cdd019d616
'swtiching to -ni' added
author | arpi |
---|---|
date | Sun, 04 Aug 2002 01:48:54 +0000 |
parents | ded48a755830 |
children | 138a7ff52a26 |
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" | |
21 #include "../events.h" | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
22 #include "../app.h" |
6651 | 23 #include "../wm/ws.h" |
24 | |
1693 | 25 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
26 #include "gtk/menu.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
27 #include "play.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
28 #include "gtk/fs.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
29 |
1693 | 30 #include "../../config.h" |
1884 | 31 #include "../../help_mp.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; |
6755 | 41 int gtkVisible = 0; |
1693 | 42 |
43 #include "gtk/sb.h" | |
44 #include "gtk/pl.h" | |
45 #include "gtk/fs.h" | |
46 #include "gtk/mb.h" | |
47 #include "gtk/about.h" | |
48 #include "gtk/opts.h" | |
2901 | 49 #include "gtk/menu.h" |
6298 | 50 #include "gtk/url.h" |
6627 | 51 #include "gtk/eq.h" |
1693 | 52 |
6651 | 53 #include "pixmaps/MPlayer_mini.xpm" |
54 | |
1693 | 55 // --- init & close gtk |
56 | |
6651 | 57 GdkPixmap * gtkIcon = NULL; |
58 GdkBitmap * gtkIconMask = NULL; | |
59 Pixmap guiIcon; | |
60 Pixmap guiIconMask; | |
61 | |
6218 | 62 void gtkInit( void ) |
1693 | 63 { |
5919 | 64 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[widget] init gtk ...\n" ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
65 gtk_set_locale(); |
6218 | 66 // gtk_init( &argc,&argv ); |
67 gtk_init( 0,NULL ); | |
6146 | 68 // gdk_set_use_xshm( TRUE ); |
6651 | 69 |
70 { | |
71 GtkWidget * win; | |
72 win=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
73 | |
74 if ( !gtkIcon ) | |
75 gtkIcon=gdk_pixmap_colormap_create_from_xpm_d( win->window,gdk_colormap_get_system(),>kIconMask,&win->style->bg[GTK_STATE_NORMAL],MPlayer_mini_xpm ); | |
76 | |
77 guiIcon=GDK_WINDOW_XWINDOW( gtkIcon ); | |
78 guiIconMask=GDK_WINDOW_XWINDOW( gtkIconMask ); | |
79 | |
80 gtk_widget_destroy( win ); | |
81 } | |
82 | |
5919 | 83 gtkInited=1; |
1693 | 84 } |
85 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
86 void gtkDone( void ) |
1693 | 87 { |
88 } | |
89 | |
6651 | 90 void gtkAddIcon( GtkWidget * window ) |
91 { | |
92 GdkWindowPrivate * win = (GdkWindowPrivate *)window->window; | |
93 wsSetIcon( gdk_display,win->xwindow,guiIcon,guiIconMask ); | |
94 } | |
95 | |
1693 | 96 void gtkClearList( GtkWidget * list ) |
97 { gtk_clist_clear( GTK_CLIST( list ) ); } | |
98 | |
99 int gtkFindCList( GtkWidget * list,char * item ) | |
100 { | |
101 gint j,t; | |
102 gchar * tmpstr; | |
103 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ ) | |
104 { | |
105 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr ); | |
106 if ( !strcmp( tmpstr,item ) ) return j; | |
107 } | |
108 return -1; | |
109 } | |
110 | |
111 void gtkSetDefaultToCList( GtkWidget * list,char * item ) | |
112 { | |
113 gint i; | |
114 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 ); | |
115 } | |
116 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
117 void gtkEventHandling( void ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
118 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
119 int i; |
6755 | 120 if ( gtkVisible > 0 ) |
121 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
|
122 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
123 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
124 // --- funcs |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
125 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
126 void gtkMessageBox( int type,gchar * str ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
127 { |
5919 | 128 if ( !gtkInited ) return; |
6146 | 129 ShowMessageBox( str ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
130 gtk_label_set_text( GTK_LABEL( gtkMessageBoxText ),str ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
131 switch( type) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
132 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
133 case GTK_MB_FATAL: |
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_FatalError ); |
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_ERROR: |
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_Error ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
140 gtk_widget_hide( WarningPixmap ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
141 gtk_widget_show( 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 case GTK_MB_WARNING: |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
144 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
|
145 gtk_widget_show( WarningPixmap ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
146 gtk_widget_hide( ErrorPixmap ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
147 break; |
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 gtk_widget_show( MessageBox ); |
6794 | 150 gtkSetLayer( MessageBox ); |
151 if ( type == GTK_MB_FATAL ) | |
152 while ( gtkVMessageBox ) gtk_main_iteration_do( 0 ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
153 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
154 |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
155 void gtkSetLayer( GtkWidget * wdg ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
156 { |
6651 | 157 GdkWindowPrivate * win = (GdkWindowPrivate *)wdg->window; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
158 wsSetLayer( gdk_display,win->xwindow,appMPlayer.subWindow.isFullScreen ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
159 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
160 |
6146 | 161 void gtkActive( GtkWidget * wdg ) |
162 { | |
6651 | 163 GdkWindowPrivate * win = (GdkWindowPrivate *)wdg->window; |
6146 | 164 wsMoveTopWindow( gdk_display,win->xwindow ); |
165 } | |
166 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
167 void gtkShow( int type,char * param ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
168 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
169 switch( type ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
170 { |
6627 | 171 case evEqualizer: |
172 ShowEqualizer(); | |
173 gtkSetLayer( Equalizer ); | |
174 break; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
175 case evSkinBrowser: |
6146 | 176 ShowSkinBrowser(); |
6044 | 177 // gtkClearList( SkinList ); |
178 if ( gtkFillSkinList( sbMPlayerPrefixDir ) && gtkFillSkinList( sbMPlayerDirInHome ) ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
179 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
180 gtkSetDefaultToCList( SkinList,param ); |
6651 | 181 gtk_clist_sort( GTK_CLIST( SkinList ) ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
182 gtk_widget_show( SkinBrowser ); |
6044 | 183 gtkSetLayer( SkinBrowser ); |
6222 | 184 } |
185 else | |
186 { | |
6854 | 187 gtk_widget_destroy( SkinBrowser ); gtkDecVisible(); |
6222 | 188 gtkMessageBox( GTK_MB_ERROR,"Skin dirs not found ... Please install skins." ); |
189 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
190 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
191 case evPreferences: |
6794 | 192 ShowPreferences(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
193 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
194 case evPlayList: |
6713 | 195 ShowPlayList(); |
196 gtkSetLayer( PlayList ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
197 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
198 case evLoad: |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6298
diff
changeset
|
199 ShowFileSelect( fsVideoSelector,0 ); |
6146 | 200 gtkSetLayer( fsFileSelect ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
201 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
202 case evFirstLoad: |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6298
diff
changeset
|
203 ShowFileSelect( fsVideoSelector,0 ); |
6146 | 204 gtkSetLayer( fsFileSelect ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
205 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
206 case evLoadSubtitle: |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6298
diff
changeset
|
207 ShowFileSelect( fsSubtitleSelector,0 ); |
6146 | 208 gtkSetLayer( fsFileSelect ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
209 break; |
6623 | 210 case evLoadAudioFile: |
211 ShowFileSelect( fsAudioSelector,0 ); | |
212 gtkSetLayer( fsFileSelect ); | |
213 break; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
214 case evAbout: |
6146 | 215 ShowAboutBox(); |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
216 gtkSetLayer( AboutBox ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
217 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
218 case evShowPopUpMenu: |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
219 gtkPopupMenu=evNone; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
220 gtkPopupMenuParam=0; |
6854 | 221 if ( PopUpMenu ) { gtk_widget_hide_on_delete( PopUpMenu ); gtkDecVisible(); } |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
222 PopUpMenu=create_PopUpMenu(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
223 gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 ); |
6854 | 224 gtkIncVisible(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
225 break; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
226 case evHidePopUpMenu: |
6794 | 227 if ( PopUpMenu ) { gtk_widget_hide_on_delete( PopUpMenu ); /*gtkVisible--;*/ PopUpMenu=NULL; } |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
228 break; |
6298 | 229 case evPlayNetwork: |
230 ShowURLDialogBox(); | |
6755 | 231 gtkSetLayer( URL ); |
6298 | 232 break; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
233 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4176
diff
changeset
|
234 } |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
235 |
6854 | 236 void gtkIncVisible( void ) { gtkVisible++; } |
237 void gtkDecVisible( void ) { if ( gtkVisible > 0 ) gtkVisible--; } | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5919
diff
changeset
|
238 |