Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/sb.c @ 4818:3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
author | pontscho |
---|---|
date | Sat, 23 Feb 2002 15:12:55 +0000 |
parents | 6e21fbb41a2b |
children | 436cf6ef67fd |
rev | line source |
---|---|
2901 | 1 |
2 #include <sys/stat.h> | |
3 #include <glob.h> | |
4 #include <unistd.h> | |
2985 | 5 #include <string.h> |
6 #include <stdlib.h> | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
7 #include <stdio.h> |
2901 | 8 |
9 #include "sb.h" | |
10 #include "../../events.h" | |
11 #include "../../../config.h" | |
12 #include "../../../help_mp.h" | |
13 | |
14 #include "../widgets.h" | |
15 #include "../app.h" | |
16 | |
17 GtkWidget * SkinList; | |
18 char * sbSelectedSkin=NULL; | |
19 char * sbMPlayerDirInHome=NULL; | |
20 char * sbMPlayerPrefixDir=NULL; | |
21 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
22 char * gtkOldSkin; |
2901 | 23 |
24 int gtkFillSkinList( gchar * mdir ) | |
25 { | |
26 gchar * str[2]; | |
27 gchar * tmp; | |
28 int i; | |
29 glob_t gg; | |
30 struct stat fs; | |
31 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
32 gtkOldSkin=strdup( skinName ); |
2901 | 33 if ( ( str[0]=(char *)calloc( 1,7 ) ) == NULL ) |
34 { | |
35 gtkMessageBox( GTK_MB_FATAL,MSGTR_SKINBROWSER_NotEnoughMemory ); | |
36 return 0; | |
37 } | |
38 str[1]=""; | |
39 strcpy( str[0],"default" ); | |
40 if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str ); | |
41 free( str[0] ); | |
42 | |
43 glob( mdir,GLOB_NOSORT,NULL,&gg ); | |
44 for( i=0;i<gg.gl_pathc;i++ ) | |
45 { | |
46 if ( !strcmp( gg.gl_pathv[i],"." ) || !strcmp( gg.gl_pathv[i],".." ) ) continue; | |
47 stat( gg.gl_pathv[i],&fs ); | |
48 if ( S_ISDIR( fs.st_mode ) ) | |
49 { | |
50 tmp=strrchr( gg.gl_pathv[i],'/' ); tmp++; | |
51 if ( !strcmp( tmp,"default" ) ) continue; | |
52 if ( ( str[0]=(char *)malloc( strlen( tmp ) + 1 ) ) == NULL ) { gtkMessageBox( GTK_MB_FATAL,MSGTR_SKINBROWSER_NotEnoughMemory ); return 0; } | |
53 strcpy( str[0],tmp ); | |
54 if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str ); | |
55 free( str[0] ); | |
56 } | |
57 } | |
58 globfree( &gg ); | |
59 return 1; | |
60 } | |
61 | |
62 void on_SkinBrowser_destroy( GtkObject * object,gpointer user_data ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
63 { gtk_widget_hide( SkinBrowser ); } |
2901 | 64 |
65 void on_SkinBrowser_Cancel( GtkObject * object,gpointer user_data ) | |
66 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
67 ChangeSkin( skinName ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
68 gtk_widget_hide( SkinBrowser ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
69 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
70 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
71 void on_SkinBrowser_Ok( GtkObject * object,gpointer user_data ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
72 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
73 ChangeSkin( sbSelectedSkin ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
74 if ( skinName ) free( skinName ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
75 skinName=strdup( sbSelectedSkin ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
76 gtk_widget_hide( SkinBrowser ); |
2901 | 77 } |
78 | |
79 void on_SkinList_select_row( GtkCList * clist,gint row,gint column,GdkEvent * bevent,gpointer user_data ) | |
80 { | |
81 gtk_clist_get_text( clist,row,0,&sbSelectedSkin ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
82 ChangeSkin( sbSelectedSkin ); |
2901 | 83 if( !bevent ) return; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
84 if( bevent->type == GDK_2BUTTON_PRESS ) gtk_widget_hide( SkinBrowser ); |
2901 | 85 } |
86 | |
87 GtkWidget * create_SkinBrowser( void ) | |
88 { | |
89 GtkWidget * SkinBrowser; | |
90 GtkWidget * frame5; | |
91 GtkWidget * frame6; | |
92 GtkWidget * frame7; | |
93 GtkWidget * frame8; | |
94 GtkWidget * vbox5; | |
95 GtkWidget * label; | |
96 GtkWidget * hseparator4; | |
97 GtkWidget * scrolledwindow1; | |
98 GtkWidget * label2; | |
99 GtkWidget * hseparator5; | |
100 GtkWidget * hbuttonbox4; | |
101 GtkWidget * Cancel; | |
102 GtkWidget * Ok; | |
103 GtkAccelGroup * accel_group; | |
104 | |
105 accel_group = gtk_accel_group_new (); | |
106 | |
107 SkinBrowser=gtk_window_new( GTK_WINDOW_DIALOG ); | |
108 gtk_widget_set_name( SkinBrowser,MSGTR_SkinBrowser ); | |
109 gtk_object_set_data( GTK_OBJECT( SkinBrowser ),MSGTR_SkinBrowser,SkinBrowser ); | |
110 gtk_widget_set_usize( SkinBrowser,256,320 ); | |
111 gtk_container_set_border_width( GTK_CONTAINER( SkinBrowser ),1 ); | |
112 // GTK_WIDGET_SET_FLAGS( SkinBrowser,GTK_CAN_FOCUS ); | |
113 GTK_WIDGET_SET_FLAGS( SkinBrowser,GTK_CAN_DEFAULT ); | |
114 gtk_widget_set_events( SkinBrowser,GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK ); | |
115 gtk_window_set_title( GTK_WINDOW( SkinBrowser ),MSGTR_SkinBrowser ); | |
116 gtk_window_set_position( GTK_WINDOW( SkinBrowser ),GTK_WIN_POS_CENTER ); | |
117 gtk_window_set_policy( GTK_WINDOW( SkinBrowser ),FALSE,FALSE,TRUE ); | |
118 | |
119 frame5=gtk_frame_new( NULL ); | |
120 gtk_widget_set_name( frame5,"frame5" ); | |
121 gtk_widget_ref( frame5 ); | |
122 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"frame5",frame5, | |
123 ( GtkDestroyNotify ) gtk_widget_unref ); | |
124 gtk_widget_show( frame5 ); | |
125 gtk_container_add( GTK_CONTAINER( SkinBrowser ),frame5 ); | |
126 gtk_frame_set_shadow_type( GTK_FRAME( frame5 ),GTK_SHADOW_IN ); | |
127 | |
128 frame6=gtk_frame_new( NULL ); | |
129 gtk_widget_set_name( frame6,"frame6" ); | |
130 gtk_widget_ref( frame6 ); | |
131 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"frame6",frame6, | |
132 ( GtkDestroyNotify ) gtk_widget_unref ); | |
133 gtk_widget_show( frame6 ); | |
134 gtk_container_add( GTK_CONTAINER( frame5 ),frame6 ); | |
135 gtk_frame_set_shadow_type( GTK_FRAME( frame6 ),GTK_SHADOW_NONE ); | |
136 | |
137 frame7=gtk_frame_new( NULL ); | |
138 gtk_widget_set_name( frame7,"frame7" ); | |
139 gtk_widget_ref( frame7 ); | |
140 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"frame7",frame7, | |
141 ( GtkDestroyNotify ) gtk_widget_unref ); | |
142 gtk_widget_show( frame7 ); | |
143 gtk_container_add( GTK_CONTAINER( frame6 ),frame7 ); | |
144 gtk_frame_set_shadow_type( GTK_FRAME( frame7 ),GTK_SHADOW_ETCHED_OUT ); | |
145 | |
146 frame8=gtk_frame_new( NULL ); | |
147 gtk_widget_set_name( frame8,"frame8" ); | |
148 gtk_widget_ref( frame8 ); | |
149 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"frame8",frame8, | |
150 ( GtkDestroyNotify ) gtk_widget_unref ); | |
151 gtk_widget_show( frame8 ); | |
152 gtk_container_add( GTK_CONTAINER( frame7 ),frame8 ); | |
153 gtk_frame_set_shadow_type( GTK_FRAME( frame8 ),GTK_SHADOW_NONE ); | |
154 | |
155 vbox5=gtk_vbox_new( FALSE,0 ); | |
156 gtk_widget_set_name( vbox5,"vbox5" ); | |
157 gtk_widget_ref( vbox5 ); | |
158 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"vbox5",vbox5, | |
159 ( GtkDestroyNotify ) gtk_widget_unref ); | |
160 gtk_widget_show( vbox5 ); | |
161 gtk_container_add( GTK_CONTAINER( frame8 ),vbox5 ); | |
162 | |
3587 | 163 label=gtk_label_new( MSGTR_SKIN_LABEL ); |
2901 | 164 gtk_widget_set_name( label,"label" ); |
165 gtk_widget_ref( label ); | |
166 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"label",label, | |
167 ( GtkDestroyNotify ) gtk_widget_unref ); | |
168 gtk_widget_show( label ); | |
169 gtk_box_pack_start( GTK_BOX( vbox5 ),label,FALSE,FALSE,0 ); | |
170 gtk_label_set_justify( GTK_LABEL( label ),GTK_JUSTIFY_RIGHT ); | |
171 gtk_misc_set_alignment( GTK_MISC( label ),7.45058e-09,7.45058e-09 ); | |
172 | |
173 hseparator4=gtk_hseparator_new(); | |
174 gtk_widget_set_name( hseparator4,"hseparator4" ); | |
175 gtk_widget_ref( hseparator4 ); | |
176 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"hseparator4",hseparator4, | |
177 ( GtkDestroyNotify ) gtk_widget_unref ); | |
178 gtk_widget_show( hseparator4 ); | |
179 gtk_box_pack_start( GTK_BOX( vbox5 ),hseparator4,FALSE,TRUE,0 ); | |
180 gtk_widget_set_usize( hseparator4,-2,5 ); | |
181 | |
182 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); | |
183 gtk_widget_set_name( scrolledwindow1,"scrolledwindow1" ); | |
184 gtk_widget_ref( scrolledwindow1 ); | |
185 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"scrolledwindow1",scrolledwindow1, | |
186 ( GtkDestroyNotify ) gtk_widget_unref ); | |
187 gtk_widget_show( scrolledwindow1 ); | |
188 gtk_box_pack_start( GTK_BOX( vbox5 ),scrolledwindow1,TRUE,TRUE,0 ); | |
189 gtk_container_set_border_width( GTK_CONTAINER( scrolledwindow1 ),2 ); | |
190 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
191 | |
192 SkinList=gtk_clist_new( 1 ); | |
193 gtk_widget_set_name( SkinList,"SkinList" ); | |
194 gtk_widget_ref( SkinList ); | |
195 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"SkinList",SkinList, | |
196 ( GtkDestroyNotify ) gtk_widget_unref ); | |
197 gtk_widget_show( SkinList ); | |
198 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),SkinList ); | |
199 gtk_clist_set_column_width( GTK_CLIST( SkinList ),0,80 ); | |
200 gtk_clist_set_selection_mode( GTK_CLIST( SkinList ),GTK_SELECTION_SINGLE ); | |
201 gtk_clist_column_titles_hide( GTK_CLIST( SkinList ) ); | |
202 gtk_clist_set_shadow_type( GTK_CLIST( SkinList ),GTK_SHADOW_ETCHED_OUT ); | |
203 | |
204 label2=gtk_label_new( "label2" ); | |
205 gtk_widget_set_name( label2,"label2" ); | |
206 gtk_widget_ref( label2 ); | |
207 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"label2",label2,(GtkDestroyNotify)gtk_widget_unref ); | |
208 gtk_widget_show( label2 ); | |
209 gtk_clist_set_column_widget( GTK_CLIST( SkinList ),0,label2 ); | |
210 | |
211 hseparator5=gtk_hseparator_new(); | |
212 gtk_widget_set_name( hseparator5,"hseparator5" ); | |
213 gtk_widget_ref( hseparator5 ); | |
214 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"hseparator5",hseparator5,(GtkDestroyNotify)gtk_widget_unref ); | |
215 gtk_widget_show( hseparator5 ); | |
216 gtk_box_pack_start( GTK_BOX( vbox5 ),hseparator5,FALSE,TRUE,0 ); | |
217 gtk_widget_set_usize( hseparator5,-2,9 ); | |
218 | |
219 hbuttonbox4=gtk_hbutton_box_new(); | |
220 gtk_widget_set_name( hbuttonbox4,"hbuttonbox4" ); | |
221 gtk_widget_ref( hbuttonbox4 ); | |
222 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"hbuttonbox4",hbuttonbox4,(GtkDestroyNotify)gtk_widget_unref ); | |
3587 | 223 gtk_widget_set_usize( hbuttonbox4,-2,25 ); |
2901 | 224 gtk_widget_show( hbuttonbox4 ); |
225 gtk_box_pack_start( GTK_BOX( vbox5 ),hbuttonbox4,FALSE,TRUE,0 ); | |
226 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox4 ),GTK_BUTTONBOX_END ); | |
3587 | 227 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox4 ),5 ); |
228 gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox4 ),75,0 ); | |
2901 | 229 |
230 Ok=gtk_button_new_with_label( MSGTR_Ok ); | |
231 gtk_widget_set_name( Ok,MSGTR_Ok ); | |
232 gtk_widget_ref( Ok ); | |
233 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),MSGTR_Ok,Ok,(GtkDestroyNotify)gtk_widget_unref ); | |
234 gtk_widget_show( Ok ); | |
235 gtk_container_add( GTK_CONTAINER( hbuttonbox4 ),Ok ); | |
3587 | 236 gtk_widget_set_usize( Ok,-2,22 ); |
2901 | 237 gtk_widget_add_accelerator( Ok,"released",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); |
238 | |
239 Cancel=gtk_button_new_with_label( MSGTR_Cancel ); | |
240 gtk_widget_set_name( Cancel,MSGTR_Cancel ); | |
241 gtk_widget_ref( Cancel ); | |
242 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),MSGTR_Cancel,Cancel,(GtkDestroyNotify)gtk_widget_unref ); | |
243 gtk_widget_show( Cancel ); | |
244 gtk_container_add( GTK_CONTAINER( hbuttonbox4 ),Cancel ); | |
3587 | 245 gtk_widget_set_usize( Cancel,-2,22 ); |
2901 | 246 gtk_widget_add_accelerator( Cancel,"released",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); |
247 | |
248 gtk_signal_connect( GTK_OBJECT( SkinBrowser ),"destroy",GTK_SIGNAL_FUNC( on_SkinBrowser_destroy ),NULL ); | |
249 gtk_signal_connect( GTK_OBJECT( SkinList ),"select_row",GTK_SIGNAL_FUNC( on_SkinList_select_row ),NULL ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
250 gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( on_SkinBrowser_Ok ),NULL ); |
2901 | 251 gtk_signal_connect( GTK_OBJECT( Cancel ),"released",GTK_SIGNAL_FUNC( on_SkinBrowser_Cancel ),NULL ); |
252 | |
253 if ( ( sbMPlayerDirInHome=(char *)calloc( 1,strlen( skinDirInHome ) + 4 ) ) != NULL ) | |
254 { strcpy( sbMPlayerDirInHome,skinDirInHome ); strcat( sbMPlayerDirInHome,"/*" ); } | |
255 if ( ( sbMPlayerPrefixDir=(char *)calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL ) | |
256 { strcpy( sbMPlayerPrefixDir,skinMPlayerDir ); strcat( sbMPlayerPrefixDir,"/*" ); } | |
257 | |
258 gtk_window_add_accel_group( GTK_WINDOW( SkinBrowser ),accel_group ); | |
259 gtk_widget_grab_focus( SkinList ); | |
260 | |
261 return SkinBrowser; | |
262 } |