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