Mercurial > mplayer.hg
annotate gui/mplayer/gtk/sb.c @ 27298:0de5b595d2ae
Remove "en" from list of all man page languages when generating man page
installation rules from a pattern. There is a separate rule for English above.
author | diego |
---|---|
date | Sat, 19 Jul 2008 11:32:33 +0000 |
parents | b0a7b35b78d2 |
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 <sys/stat.h> | |
20 #include <glob.h> | |
21 #include <unistd.h> | |
22 #include <string.h> | |
23 #include <stdlib.h> | |
24 #include <stdio.h> | |
25 | |
26203 | 26 #include "config.h" |
23077 | 27 #include "sb.h" |
25601
8a0adeba5910
Rename common.[ch] to gtk_common.[ch], there are too many files by that name.
diego
parents:
23077
diff
changeset
|
28 #include "gtk_common.h" |
23077 | 29 |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26362
diff
changeset
|
30 #include "gui/app.h" |
23077 | 31 #include "help_mp.h" |
32 | |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
33 #include "gui/mplayer/widgets.h" |
23077 | 34 |
35 GtkWidget * SkinList = NULL; | |
36 char * sbSelectedSkin=NULL; | |
37 /* FIXME: Eventually remove the obsolete directory names. */ | |
38 char * sbMPlayerDirInHome=NULL; | |
39 char * sbMPlayerDirInHome_obsolete=NULL; | |
40 char * sbMPlayerPrefixDir=NULL; | |
41 char * sbMPlayerPrefixDir_obsolete=NULL; | |
42 | |
43 char * gtkOldSkin=NULL; | |
44 static char * prev=NULL; | |
45 | |
46 GtkWidget * SkinBrowser = NULL; | |
47 | |
48 void ShowSkinBrowser( void ) | |
49 { | |
50 if ( SkinBrowser ) gtkActive( SkinBrowser ); | |
51 else SkinBrowser=create_SkinBrowser(); | |
52 } | |
53 | |
54 void HideSkinBrowser( void ) | |
55 { | |
56 if ( !SkinBrowser ) return; | |
57 gtk_widget_hide( SkinBrowser ); | |
58 gtk_widget_destroy( SkinBrowser ); | |
59 SkinBrowser=NULL; | |
60 } | |
61 | |
62 int gtkFillSkinList( gchar * mdir ) | |
63 { | |
64 gchar * str[2]; | |
65 gchar * tmp; | |
66 int i; | |
67 glob_t gg; | |
68 struct stat fs; | |
69 | |
70 gtkOldSkin=strdup( skinName ); | |
71 prev=gtkOldSkin; | |
72 | |
73 str[0]="default"; | |
74 str[1]=""; | |
75 if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str ); | |
76 | |
77 glob( mdir,GLOB_NOSORT,NULL,&gg ); | |
78 for( i=0;i<(int)gg.gl_pathc;i++ ) | |
79 { | |
80 if ( !strcmp( gg.gl_pathv[i],"." ) || !strcmp( gg.gl_pathv[i],".." ) ) continue; | |
81 stat( gg.gl_pathv[i],&fs ); | |
82 if ( S_ISDIR( fs.st_mode ) ) | |
83 { | |
84 tmp=strrchr( gg.gl_pathv[i],'/' ); tmp++; | |
85 if ( !strcmp( tmp,"default" ) ) continue; | |
86 str[0]=tmp; | |
87 if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str ); | |
88 } | |
89 } | |
90 globfree( &gg ); | |
91 return 1; | |
92 } | |
93 | |
94 static void prButton( GtkObject * object,gpointer user_data ) | |
95 { | |
96 if ( sbSelectedSkin ) | |
97 { | |
98 switch ( (int)user_data ) | |
99 { | |
100 case 0: // cancel | |
101 if ( strcmp( sbSelectedSkin,gtkOldSkin ) ) ChangeSkin( gtkOldSkin ); | |
102 break; | |
103 case 1: // ok | |
104 ChangeSkin( sbSelectedSkin ); | |
105 if ( skinName ) free( skinName ); | |
106 skinName=strdup( sbSelectedSkin ); | |
107 break; | |
108 } | |
109 } | |
110 HideSkinBrowser(); | |
111 } | |
112 | |
113 static void on_SkinList_select_row( GtkCList * clist,gint row,gint column,GdkEvent * bevent,gpointer user_data ) | |
114 { | |
115 gtk_clist_get_text( clist,row,0,&sbSelectedSkin ); | |
116 if ( strcmp( prev,sbSelectedSkin ) ) | |
117 { | |
118 prev=sbSelectedSkin; | |
119 ChangeSkin( sbSelectedSkin ); | |
120 gtkActive( SkinBrowser ); | |
121 } | |
122 if( !bevent ) return; | |
123 if( bevent->type == GDK_2BUTTON_PRESS ) | |
124 { | |
125 if ( skinName ) free( skinName ); | |
126 skinName=strdup( sbSelectedSkin ); | |
127 HideSkinBrowser(); | |
128 } | |
129 } | |
130 | |
131 GtkWidget * create_SkinBrowser( void ) | |
132 { | |
133 GtkWidget * vbox5; | |
134 GtkWidget * scrolledwindow1; | |
135 GtkWidget * hbuttonbox4; | |
136 GtkWidget * Cancel; | |
137 GtkWidget * Ok; | |
138 GtkAccelGroup * accel_group; | |
139 | |
140 accel_group = gtk_accel_group_new (); | |
141 | |
142 SkinBrowser=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
143 gtk_widget_set_name( SkinBrowser,MSGTR_SkinBrowser ); | |
144 gtk_object_set_data( GTK_OBJECT( SkinBrowser ),MSGTR_SkinBrowser,SkinBrowser ); | |
145 gtk_widget_set_usize( SkinBrowser,256,320 ); | |
146 gtk_container_set_border_width( GTK_CONTAINER( SkinBrowser ),1 ); | |
147 GTK_WIDGET_SET_FLAGS( SkinBrowser,GTK_CAN_DEFAULT ); | |
148 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 ); | |
149 gtk_window_set_title( GTK_WINDOW( SkinBrowser ),MSGTR_SkinBrowser ); | |
150 gtk_window_set_position( GTK_WINDOW( SkinBrowser ),GTK_WIN_POS_CENTER ); | |
151 gtk_window_set_policy( GTK_WINDOW( SkinBrowser ),FALSE,FALSE,TRUE ); | |
152 gtk_window_set_wmclass( GTK_WINDOW( SkinBrowser ),"SkinBrowser","MPlayer" ); | |
153 | |
154 gtk_widget_realize( SkinBrowser ); | |
155 gtkAddIcon( SkinBrowser ); | |
156 | |
157 vbox5=AddVBox( AddDialogFrame( SkinBrowser ),0 ); | |
158 AddLabel( MSGTR_SKIN_LABEL,vbox5 ); | |
159 AddHSeparator( vbox5 ); | |
160 | |
161 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); | |
162 gtk_widget_set_name( scrolledwindow1,"scrolledwindow1" ); | |
163 gtk_widget_ref( scrolledwindow1 ); | |
164 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"scrolledwindow1",scrolledwindow1,(GtkDestroyNotify)gtk_widget_unref ); | |
165 gtk_widget_show( scrolledwindow1 ); | |
166 gtk_box_pack_start( GTK_BOX( vbox5 ),scrolledwindow1,TRUE,TRUE,0 ); | |
167 gtk_container_set_border_width( GTK_CONTAINER( scrolledwindow1 ),2 ); | |
168 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
169 | |
170 SkinList=gtk_clist_new( 1 ); | |
171 gtk_widget_set_name( SkinList,"SkinList" ); | |
172 gtk_widget_ref( SkinList ); | |
173 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"SkinList",SkinList,(GtkDestroyNotify)gtk_widget_unref ); | |
174 gtk_widget_show( SkinList ); | |
175 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),SkinList ); | |
176 gtk_clist_set_column_width( GTK_CLIST( SkinList ),0,80 ); | |
177 gtk_clist_set_selection_mode( GTK_CLIST( SkinList ),GTK_SELECTION_SINGLE ); | |
178 gtk_clist_column_titles_hide( GTK_CLIST( SkinList ) ); | |
179 gtk_clist_set_shadow_type( GTK_CLIST( SkinList ),GTK_SHADOW_ETCHED_OUT ); | |
180 | |
181 AddHSeparator( vbox5 ); | |
182 | |
183 hbuttonbox4=AddHButtonBox( vbox5 ); | |
184 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox4 ),GTK_BUTTONBOX_SPREAD ); | |
185 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox4 ),10 ); | |
186 | |
187 Ok=AddButton( MSGTR_Ok,hbuttonbox4 ); | |
188 Cancel=AddButton( MSGTR_Cancel,hbuttonbox4 ); | |
189 | |
190 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
191 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
192 | |
193 gtk_signal_connect( GTK_OBJECT( SkinBrowser ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&SkinBrowser ); | |
194 gtk_signal_connect( GTK_OBJECT( SkinList ),"select_row",GTK_SIGNAL_FUNC( on_SkinList_select_row ),NULL ); | |
195 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)1 ); | |
196 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)0 ); | |
197 | |
198 if ( ( sbMPlayerDirInHome_obsolete=calloc( 1,strlen( skinDirInHome_obsolete ) + 4 ) ) != NULL ) | |
199 { strcpy( sbMPlayerDirInHome_obsolete,skinDirInHome_obsolete ); strcat( sbMPlayerDirInHome_obsolete,"/*" ); } | |
200 if ( ( sbMPlayerDirInHome=calloc( 1,strlen( skinDirInHome ) + 4 ) ) != NULL ) | |
201 { strcpy( sbMPlayerDirInHome,skinDirInHome ); strcat( sbMPlayerDirInHome,"/*" ); } | |
202 if ( ( sbMPlayerPrefixDir_obsolete=calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL ) | |
203 { strcpy( sbMPlayerPrefixDir_obsolete,skinMPlayerDir ); strcat( sbMPlayerPrefixDir_obsolete,"/*" ); } | |
204 if ( ( sbMPlayerPrefixDir=calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL ) | |
205 { strcpy( sbMPlayerPrefixDir,skinMPlayerDir ); strcat( sbMPlayerPrefixDir,"/*" ); } | |
206 | |
207 gtk_window_add_accel_group( GTK_WINDOW( SkinBrowser ),accel_group ); | |
208 gtk_widget_grab_focus( SkinList ); | |
209 | |
210 return SkinBrowser; | |
211 } |