23077
|
1
|
|
2 #include <stdlib.h>
|
|
3 #include <stdio.h>
|
|
4
|
|
5 #include <sys/types.h>
|
|
6 #include <sys/stat.h>
|
|
7 #include <sys/wait.h>
|
|
8 #include <unistd.h>
|
|
9 #include <string.h>
|
|
10 #include <signal.h>
|
|
11
|
|
12 #include <gdk/gdkprivate.h>
|
|
13 #include <gdk/gdkkeysyms.h>
|
|
14 #include <gdk/gdkx.h>
|
|
15 #include <gdk/gdk.h>
|
|
16 #include <gtk/gtk.h>
|
|
17
|
|
18 #include "widgets.h"
|
|
19 #include "app.h"
|
|
20 #include "wm/ws.h"
|
|
21
|
|
22
|
|
23 #include "gtk/menu.h"
|
|
24 #include "play.h"
|
|
25 #include "gtk/fs.h"
|
|
26
|
|
27 #include "../config.h"
|
|
28 #include "../help_mp.h"
|
|
29 #include "../mp_msg.h"
|
|
30
|
|
31 GtkWidget * PopUpMenu = NULL;
|
|
32
|
|
33 GtkWidget * WarningPixmap;
|
|
34 GtkWidget * ErrorPixmap;
|
|
35
|
|
36 int gtkPopupMenu = 0;
|
|
37 int gtkPopupMenuParam = 0;
|
|
38 int gtkInited = 0;
|
|
39
|
|
40 #include "gtk/sb.h"
|
|
41 #include "gtk/pl.h"
|
|
42 #include "gtk/fs.h"
|
|
43 #include "gtk/mb.h"
|
|
44 #include "gtk/about.h"
|
|
45 #include "gtk/opts.h"
|
|
46 #include "gtk/menu.h"
|
|
47 #include "gtk/url.h"
|
|
48 #include "gtk/eq.h"
|
|
49
|
|
50 #include "pixmaps/MPlayer_mini.xpm"
|
|
51
|
|
52 // --- init & close gtk
|
|
53
|
|
54 GdkPixmap * gtkIcon = NULL;
|
|
55 GdkBitmap * gtkIconMask = NULL;
|
|
56 Pixmap guiIcon;
|
|
57 Pixmap guiIconMask;
|
|
58
|
|
59 void gtkInit( void )
|
|
60 {
|
|
61 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[widget] init GTK ...\n" );
|
|
62 #ifdef HAVE_GTK2_GUI
|
|
63 gtk_disable_setlocale();
|
|
64 #endif
|
|
65 gtk_init( 0,NULL );
|
|
66 // gdk_set_use_xshm( TRUE );
|
|
67
|
|
68 {
|
|
69 GtkWidget * win;
|
|
70 win=gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
|
71
|
|
72 if ( !gtkIcon )
|
|
73 gtkIcon=gdk_pixmap_colormap_create_from_xpm_d( win->window,gdk_colormap_get_system(),>kIconMask,&win->style->bg[GTK_STATE_NORMAL],MPlayer_mini_xpm );
|
|
74
|
|
75 guiIcon=GDK_WINDOW_XWINDOW( gtkIcon );
|
|
76 guiIconMask=GDK_WINDOW_XWINDOW( gtkIconMask );
|
|
77
|
|
78 gtk_widget_destroy( win );
|
|
79 }
|
|
80
|
|
81 gtkInited=1;
|
|
82 }
|
|
83
|
|
84 void gtkAddIcon( GtkWidget * window )
|
|
85 { wsSetIcon( gdk_display,GDK_WINDOW_XWINDOW( window->window ),guiIcon,guiIconMask ); }
|
|
86
|
|
87 void gtkClearList( GtkWidget * list )
|
|
88 { gtk_clist_clear( GTK_CLIST( list ) ); }
|
|
89
|
|
90 int gtkFindCList( GtkWidget * list,char * item )
|
|
91 {
|
|
92 gint j,t;
|
|
93 gchar * tmpstr;
|
|
94 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ )
|
|
95 {
|
|
96 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
|
|
97 if ( !strcmp( tmpstr,item ) ) return j;
|
|
98 }
|
|
99 return -1;
|
|
100 }
|
|
101
|
|
102 void gtkSetDefaultToCList( GtkWidget * list,char * item )
|
|
103 {
|
|
104 gint i;
|
|
105 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
|
|
106 }
|
|
107
|
|
108 void gtkEventHandling( void )
|
|
109 {
|
|
110 int i;
|
|
111 for( i=0;i < 25;i++ ) gtk_main_iteration_do( 0 );
|
|
112 }
|
|
113
|
|
114 // --- funcs
|
|
115
|
|
116 void gtkMessageBox( int type,const gchar * str )
|
|
117 {
|
|
118 if ( !gtkInited ) return;
|
|
119 ShowMessageBox( str );
|
|
120 gtk_label_set_text( GTK_LABEL( gtkMessageBoxText ),str );
|
|
121 /* enable linewrapping by alex */
|
|
122 // GTK_LABEL(gtkMessageBoxText)->max_width = 80;
|
|
123 if (strlen(str) > 80)
|
|
124 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE);
|
|
125 else
|
|
126 gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE);
|
|
127 switch( type)
|
|
128 {
|
|
129 case GTK_MB_FATAL:
|
|
130 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_FatalError );
|
|
131 gtk_widget_hide( WarningPixmap );
|
|
132 gtk_widget_show( ErrorPixmap );
|
|
133 break;
|
|
134 case GTK_MB_ERROR:
|
|
135 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Error );
|
|
136 gtk_widget_hide( WarningPixmap );
|
|
137 gtk_widget_show( ErrorPixmap );
|
|
138 break;
|
|
139 case GTK_MB_WARNING:
|
|
140 gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Warning );
|
|
141 gtk_widget_show( WarningPixmap );
|
|
142 gtk_widget_hide( ErrorPixmap );
|
|
143 break;
|
|
144 }
|
|
145 gtk_widget_show( MessageBox );
|
|
146 gtkSetLayer( MessageBox );
|
|
147 if ( type == GTK_MB_FATAL )
|
|
148 while ( MessageBox ) gtk_main_iteration_do( 0 );
|
|
149 }
|
|
150
|
|
151 void gtkSetLayer( GtkWidget * wdg )
|
|
152 {
|
|
153 wsSetLayer( gdk_display,GDK_WINDOW_XWINDOW( wdg->window ),appMPlayer.subWindow.isFullScreen );
|
|
154 gtkActive( wdg );
|
|
155 }
|
|
156
|
|
157 void gtkActive( GtkWidget * wdg )
|
|
158 { wsMoveTopWindow( gdk_display,GDK_WINDOW_XWINDOW( wdg->window )); }
|
|
159
|
|
160 void gtkShow( int type,char * param )
|
|
161 {
|
|
162 switch( type )
|
|
163 {
|
|
164 case evEqualizer:
|
|
165 ShowEqualizer();
|
|
166 gtkSetLayer( Equalizer );
|
|
167 break;
|
|
168 case evSkinBrowser:
|
|
169 ShowSkinBrowser();
|
|
170 // gtkClearList( SkinList );
|
|
171 if ( gtkFillSkinList( sbMPlayerPrefixDir ) &&
|
|
172 gtkFillSkinList( sbMPlayerPrefixDir_obsolete ) &&
|
|
173 gtkFillSkinList( sbMPlayerDirInHome ) &&
|
|
174 gtkFillSkinList( sbMPlayerDirInHome_obsolete ) )
|
|
175 {
|
|
176 gtkSetDefaultToCList( SkinList,param );
|
|
177 gtk_clist_sort( GTK_CLIST( SkinList ) );
|
|
178 gtk_widget_show( SkinBrowser );
|
|
179 gtkSetLayer( SkinBrowser );
|
|
180 }
|
|
181 else
|
|
182 {
|
|
183 gtk_widget_destroy( SkinBrowser );
|
|
184 gtkMessageBox( GTK_MB_ERROR,"Skin dirs not found ... Please install skins." );
|
|
185 }
|
|
186 break;
|
|
187 case evPreferences:
|
|
188 ShowPreferences();
|
|
189 break;
|
|
190 case evPlayList:
|
|
191 ShowPlayList();
|
|
192 gtkSetLayer( PlayList );
|
|
193 break;
|
|
194 case evLoad:
|
|
195 ShowFileSelect( fsVideoSelector,0 );
|
|
196 gtkSetLayer( fsFileSelect );
|
|
197 break;
|
|
198 case evFirstLoad:
|
|
199 ShowFileSelect( fsVideoSelector,0 );
|
|
200 gtkSetLayer( fsFileSelect );
|
|
201 break;
|
|
202 case evLoadSubtitle:
|
|
203 ShowFileSelect( fsSubtitleSelector,0 );
|
|
204 gtkSetLayer( fsFileSelect );
|
|
205 break;
|
|
206 case evLoadAudioFile:
|
|
207 ShowFileSelect( fsAudioSelector,0 );
|
|
208 gtkSetLayer( fsFileSelect );
|
|
209 break;
|
|
210 case evAbout:
|
|
211 ShowAboutBox();
|
|
212 gtkSetLayer( About );
|
|
213 break;
|
|
214 case evShowPopUpMenu:
|
|
215 gtkPopupMenu=evNone;
|
|
216 gtkPopupMenuParam=0;
|
|
217 if ( PopUpMenu )
|
|
218 {
|
|
219 gtk_widget_hide( PopUpMenu );
|
|
220 gtk_widget_destroy( PopUpMenu );
|
|
221 }
|
|
222 PopUpMenu=create_PopUpMenu();
|
|
223 gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 );
|
|
224 break;
|
|
225 case evHidePopUpMenu:
|
|
226 if ( PopUpMenu )
|
|
227 {
|
|
228 gtk_widget_hide( PopUpMenu );
|
|
229 gtk_widget_destroy( PopUpMenu );
|
|
230 PopUpMenu=NULL;
|
|
231 }
|
|
232 break;
|
|
233 case evPlayNetwork:
|
|
234 ShowURLDialogBox();
|
|
235 gtkSetLayer( URL );
|
|
236 break;
|
|
237 }
|
|
238 }
|