Mercurial > mplayer.hg
annotate gui/ui/gtk/skinbrowser.c @ 34962:8446e92c7bc2
Fix dependency generation with current FFmpeg.
author | cehoyos |
---|---|
date | Sun, 29 Jul 2012 19:50:30 +0000 |
parents | a650895d50a5 |
children | 4d7adee0a7ba |
rev | line source |
---|---|
33572 | 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 */ | |
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 | |
26 #include "config.h" | |
27 #include "skinbrowser.h" | |
28 #include "tools.h" | |
29 | |
30 #include "gui/app.h" | |
33749 | 31 #include "gui/cfg.h" |
32 #include "gui/skin/skin.h" | |
33572 | 33 #include "help_mp.h" |
34 | |
35 #include "gui/ui/widgets.h" | |
36 | |
37 GtkWidget * SkinList = NULL; | |
38 char * sbSelectedSkin=NULL; | |
39 char * sbMPlayerDirInHome=NULL; | |
40 char * sbMPlayerPrefixDir=NULL; | |
41 | |
42 char * gtkOldSkin=NULL; | |
43 static char * prev=NULL; | |
44 | |
45 GtkWidget * SkinBrowser = NULL; | |
46 | |
47 void ShowSkinBrowser( void ) | |
48 { | |
49 if ( SkinBrowser ) gtkActive( SkinBrowser ); | |
50 else SkinBrowser=create_SkinBrowser(); | |
51 } | |
52 | |
53 static void HideSkinBrowser( void ) | |
54 { | |
55 if ( !SkinBrowser ) return; | |
56 gtk_widget_hide( SkinBrowser ); | |
57 gtk_widget_destroy( SkinBrowser ); | |
58 SkinBrowser=NULL; | |
59 } | |
60 | |
61 int gtkFillSkinList( gchar * mdir ) | |
62 { | |
63 gchar * str[2]; | |
64 gchar * tmp; | |
65 int i; | |
66 glob_t gg; | |
67 struct stat fs; | |
68 | |
69 gtkOldSkin=strdup( skinName ); | |
70 prev=gtkOldSkin; | |
71 | |
72 str[0]="default"; | |
73 str[1]=""; | |
74 if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str ); | |
75 | |
76 glob( mdir,GLOB_NOSORT,NULL,&gg ); | |
77 for( i=0;i<(int)gg.gl_pathc;i++ ) | |
78 { | |
79 if ( !strcmp( gg.gl_pathv[i],"." ) || !strcmp( gg.gl_pathv[i],".." ) ) continue; | |
80 stat( gg.gl_pathv[i],&fs ); | |
81 if ( S_ISDIR( fs.st_mode ) ) | |
82 { | |
83 tmp=strrchr( gg.gl_pathv[i],'/' ); tmp++; | |
84 if ( !strcmp( tmp,"default" ) ) continue; | |
85 str[0]=tmp; | |
86 if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str ); | |
87 } | |
88 } | |
89 globfree( &gg ); | |
90 return 1; | |
91 } | |
92 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
33749
diff
changeset
|
93 static void prButton( GtkButton * button,gpointer user_data ) |
33572 | 94 { |
95 if ( sbSelectedSkin ) | |
96 { | |
97 switch ( (int)user_data ) | |
98 { | |
99 case 0: // cancel | |
100 if ( strcmp( sbSelectedSkin,gtkOldSkin ) ) uiChangeSkin( gtkOldSkin ); | |
101 break; | |
102 case 1: // ok | |
103 uiChangeSkin( sbSelectedSkin ); // NOTE TO MYSELF: skin already changed! | |
104 free( skinName ); | |
105 skinName=strdup( sbSelectedSkin ); | |
106 break; | |
107 } | |
108 } | |
109 HideSkinBrowser(); | |
110 } | |
111 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
33749
diff
changeset
|
112 static void on_SkinList_select_row( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) |
33572 | 113 { |
114 gtk_clist_get_text( clist,row,0,&sbSelectedSkin ); | |
115 if ( strcmp( prev,sbSelectedSkin ) ) | |
116 { | |
117 prev=sbSelectedSkin; | |
118 uiChangeSkin( sbSelectedSkin ); | |
119 gtkActive( SkinBrowser ); | |
120 } | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
33749
diff
changeset
|
121 if( !event ) return; |
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
33749
diff
changeset
|
122 if( event->type == GDK_2BUTTON_PRESS ) |
33572 | 123 { |
124 free( skinName ); | |
125 skinName=strdup( sbSelectedSkin ); | |
126 HideSkinBrowser(); | |
127 } | |
128 } | |
129 | |
130 GtkWidget * create_SkinBrowser( void ) | |
131 { | |
132 GtkWidget * vbox5; | |
133 GtkWidget * scrolledwindow1; | |
134 GtkWidget * hbuttonbox4; | |
135 GtkWidget * Cancel; | |
136 GtkWidget * Ok; | |
137 GtkAccelGroup * accel_group; | |
138 | |
139 accel_group = gtk_accel_group_new (); | |
140 | |
141 SkinBrowser=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
142 gtk_widget_set_name( SkinBrowser,MSGTR_SkinBrowser ); | |
143 gtk_object_set_data( GTK_OBJECT( SkinBrowser ),MSGTR_SkinBrowser,SkinBrowser ); | |
144 gtk_widget_set_usize( SkinBrowser,256,320 ); | |
145 gtk_container_set_border_width( GTK_CONTAINER( SkinBrowser ),1 ); | |
146 GTK_WIDGET_SET_FLAGS( SkinBrowser,GTK_CAN_DEFAULT ); | |
147 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 ); | |
148 gtk_window_set_title( GTK_WINDOW( SkinBrowser ),MSGTR_SkinBrowser ); | |
149 gtk_window_set_position( GTK_WINDOW( SkinBrowser ),GTK_WIN_POS_CENTER ); | |
150 gtk_window_set_policy( GTK_WINDOW( SkinBrowser ),FALSE,FALSE,TRUE ); | |
151 gtk_window_set_wmclass( GTK_WINDOW( SkinBrowser ),"SkinBrowser","MPlayer" ); | |
152 | |
153 gtk_widget_realize( SkinBrowser ); | |
154 gtkAddIcon( SkinBrowser ); | |
155 | |
156 vbox5=AddVBox( AddDialogFrame( SkinBrowser ),0 ); | |
157 AddLabel( MSGTR_SKIN_LABEL,vbox5 ); | |
158 AddHSeparator( vbox5 ); | |
159 | |
160 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); | |
161 gtk_widget_set_name( scrolledwindow1,"scrolledwindow1" ); | |
162 gtk_widget_ref( scrolledwindow1 ); | |
163 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"scrolledwindow1",scrolledwindow1,(GtkDestroyNotify)gtk_widget_unref ); | |
164 gtk_widget_show( scrolledwindow1 ); | |
165 gtk_box_pack_start( GTK_BOX( vbox5 ),scrolledwindow1,TRUE,TRUE,0 ); | |
166 gtk_container_set_border_width( GTK_CONTAINER( scrolledwindow1 ),2 ); | |
167 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
168 | |
169 SkinList=gtk_clist_new( 1 ); | |
170 gtk_widget_set_name( SkinList,"SkinList" ); | |
171 gtk_widget_ref( SkinList ); | |
172 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"SkinList",SkinList,(GtkDestroyNotify)gtk_widget_unref ); | |
173 gtk_widget_show( SkinList ); | |
174 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),SkinList ); | |
175 gtk_clist_set_column_width( GTK_CLIST( SkinList ),0,80 ); | |
176 gtk_clist_set_selection_mode( GTK_CLIST( SkinList ),GTK_SELECTION_SINGLE ); | |
177 gtk_clist_column_titles_hide( GTK_CLIST( SkinList ) ); | |
178 gtk_clist_set_shadow_type( GTK_CLIST( SkinList ),GTK_SHADOW_ETCHED_OUT ); | |
179 | |
180 AddHSeparator( vbox5 ); | |
181 | |
182 hbuttonbox4=AddHButtonBox( vbox5 ); | |
183 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox4 ),GTK_BUTTONBOX_SPREAD ); | |
184 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox4 ),10 ); | |
185 | |
186 Ok=AddButton( MSGTR_Ok,hbuttonbox4 ); | |
187 Cancel=AddButton( MSGTR_Cancel,hbuttonbox4 ); | |
188 | |
189 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
190 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
191 | |
192 gtk_signal_connect( GTK_OBJECT( SkinBrowser ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&SkinBrowser ); | |
193 gtk_signal_connect( GTK_OBJECT( SkinList ),"select_row",GTK_SIGNAL_FUNC( on_SkinList_select_row ),NULL ); | |
194 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)1 ); | |
195 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)0 ); | |
196 | |
197 if ( ( sbMPlayerDirInHome=calloc( 1,strlen( skinDirInHome ) + 4 ) ) != NULL ) | |
198 { strcpy( sbMPlayerDirInHome,skinDirInHome ); strcat( sbMPlayerDirInHome,"/*" ); } | |
199 if ( ( sbMPlayerPrefixDir=calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL ) | |
200 { strcpy( sbMPlayerPrefixDir,skinMPlayerDir ); strcat( sbMPlayerPrefixDir,"/*" ); } | |
201 | |
202 gtk_window_add_accel_group( GTK_WINDOW( SkinBrowser ),accel_group ); | |
203 gtk_widget_grab_focus( SkinList ); | |
204 | |
205 return SkinBrowser; | |
206 } |