Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/sb.c @ 22109:95e936ac33cd
Fix vqscale description to match at least somewhat the code.
author | reimar |
---|---|
date | Sun, 04 Feb 2007 13:38:41 +0000 |
parents | 86350b4b8203 |
children | 8e6182a75006 |
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" | |
8299 | 10 #include "common.h" |
11 | |
17144 | 12 #include "../app.h" |
13 #include "../../config.h" | |
14 #include "../../help_mp.h" | |
2901 | 15 |
16 #include "../widgets.h" | |
17144 | 17 #include "app.h" |
2901 | 18 |
8299 | 19 GtkWidget * SkinList = NULL; |
2901 | 20 char * sbSelectedSkin=NULL; |
17974
9a5a62f480e6
Rename the default GUI skins directory from 'Skin' to 'skins', keeping
diego
parents:
17144
diff
changeset
|
21 /* FIXME: Eventually remove the obsolete directory names. */ |
2901 | 22 char * sbMPlayerDirInHome=NULL; |
17974
9a5a62f480e6
Rename the default GUI skins directory from 'Skin' to 'skins', keeping
diego
parents:
17144
diff
changeset
|
23 char * sbMPlayerDirInHome_obsolete=NULL; |
2901 | 24 char * sbMPlayerPrefixDir=NULL; |
17974
9a5a62f480e6
Rename the default GUI skins directory from 'Skin' to 'skins', keeping
diego
parents:
17144
diff
changeset
|
25 char * sbMPlayerPrefixDir_obsolete=NULL; |
2901 | 26 |
18066
2ee39341b7a6
fix segfault in the skin browser when sbSelectedSkin gets dereferenced before setting, when no skin is selected in the skin list upon opening the browser,
gpoirier
parents:
17974
diff
changeset
|
27 char * gtkOldSkin=NULL; |
2ee39341b7a6
fix segfault in the skin browser when sbSelectedSkin gets dereferenced before setting, when no skin is selected in the skin list upon opening the browser,
gpoirier
parents:
17974
diff
changeset
|
28 static char * prev=NULL; |
2901 | 29 |
8299 | 30 GtkWidget * SkinBrowser = NULL; |
6146 | 31 |
32 void ShowSkinBrowser( void ) | |
33 { | |
8299 | 34 if ( SkinBrowser ) gtkActive( SkinBrowser ); |
6146 | 35 else SkinBrowser=create_SkinBrowser(); |
36 } | |
37 | |
38 void HideSkinBrowser( void ) | |
39 { | |
8299 | 40 if ( !SkinBrowser ) return; |
41 gtk_widget_hide( SkinBrowser ); | |
6146 | 42 gtk_widget_destroy( SkinBrowser ); |
8299 | 43 SkinBrowser=NULL; |
6146 | 44 } |
45 | |
2901 | 46 int gtkFillSkinList( gchar * mdir ) |
47 { | |
48 gchar * str[2]; | |
49 gchar * tmp; | |
50 int i; | |
51 glob_t gg; | |
52 struct stat fs; | |
53 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
54 gtkOldSkin=strdup( skinName ); |
5690 | 55 prev=gtkOldSkin; |
8977 | 56 |
57 str[0]="default"; | |
2901 | 58 str[1]=""; |
59 if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str ); | |
60 | |
61 glob( mdir,GLOB_NOSORT,NULL,&gg ); | |
8299 | 62 for( i=0;i<(int)gg.gl_pathc;i++ ) |
2901 | 63 { |
64 if ( !strcmp( gg.gl_pathv[i],"." ) || !strcmp( gg.gl_pathv[i],".." ) ) continue; | |
65 stat( gg.gl_pathv[i],&fs ); | |
66 if ( S_ISDIR( fs.st_mode ) ) | |
67 { | |
68 tmp=strrchr( gg.gl_pathv[i],'/' ); tmp++; | |
69 if ( !strcmp( tmp,"default" ) ) continue; | |
8977 | 70 str[0]=tmp; |
2901 | 71 if ( gtkFindCList( SkinList,str[0] ) == -1 ) gtk_clist_append( GTK_CLIST( SkinList ),str ); |
72 } | |
73 } | |
74 globfree( &gg ); | |
75 return 1; | |
76 } | |
77 | |
8299 | 78 static void prButton( GtkObject * object,gpointer user_data ) |
2901 | 79 { |
18066
2ee39341b7a6
fix segfault in the skin browser when sbSelectedSkin gets dereferenced before setting, when no skin is selected in the skin list upon opening the browser,
gpoirier
parents:
17974
diff
changeset
|
80 if ( sbSelectedSkin ) |
2ee39341b7a6
fix segfault in the skin browser when sbSelectedSkin gets dereferenced before setting, when no skin is selected in the skin list upon opening the browser,
gpoirier
parents:
17974
diff
changeset
|
81 { |
2ee39341b7a6
fix segfault in the skin browser when sbSelectedSkin gets dereferenced before setting, when no skin is selected in the skin list upon opening the browser,
gpoirier
parents:
17974
diff
changeset
|
82 switch ( (int)user_data ) |
2ee39341b7a6
fix segfault in the skin browser when sbSelectedSkin gets dereferenced before setting, when no skin is selected in the skin list upon opening the browser,
gpoirier
parents:
17974
diff
changeset
|
83 { |
2ee39341b7a6
fix segfault in the skin browser when sbSelectedSkin gets dereferenced before setting, when no skin is selected in the skin list upon opening the browser,
gpoirier
parents:
17974
diff
changeset
|
84 case 0: // cancel |
8299 | 85 if ( strcmp( sbSelectedSkin,gtkOldSkin ) ) ChangeSkin( gtkOldSkin ); |
86 break; | |
87 case 1: // ok | |
88 ChangeSkin( sbSelectedSkin ); | |
89 if ( skinName ) free( skinName ); | |
90 skinName=strdup( sbSelectedSkin ); | |
91 break; | |
92 } | |
18066
2ee39341b7a6
fix segfault in the skin browser when sbSelectedSkin gets dereferenced before setting, when no skin is selected in the skin list upon opening the browser,
gpoirier
parents:
17974
diff
changeset
|
93 } |
6146 | 94 HideSkinBrowser(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
95 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3587
diff
changeset
|
96 |
8299 | 97 static void on_SkinList_select_row( GtkCList * clist,gint row,gint column,GdkEvent * bevent,gpointer user_data ) |
2901 | 98 { |
99 gtk_clist_get_text( clist,row,0,&sbSelectedSkin ); | |
5690 | 100 if ( strcmp( prev,sbSelectedSkin ) ) |
101 { | |
102 prev=sbSelectedSkin; | |
103 ChangeSkin( sbSelectedSkin ); | |
6222 | 104 gtkActive( SkinBrowser ); |
5690 | 105 } |
2901 | 106 if( !bevent ) return; |
5690 | 107 if( bevent->type == GDK_2BUTTON_PRESS ) |
108 { | |
109 if ( skinName ) free( skinName ); | |
110 skinName=strdup( sbSelectedSkin ); | |
6146 | 111 HideSkinBrowser(); |
5690 | 112 } |
2901 | 113 } |
114 | |
115 GtkWidget * create_SkinBrowser( void ) | |
116 { | |
117 GtkWidget * vbox5; | |
118 GtkWidget * scrolledwindow1; | |
119 GtkWidget * hbuttonbox4; | |
120 GtkWidget * Cancel; | |
121 GtkWidget * Ok; | |
122 GtkAccelGroup * accel_group; | |
123 | |
124 accel_group = gtk_accel_group_new (); | |
125 | |
8043 | 126 SkinBrowser=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
2901 | 127 gtk_widget_set_name( SkinBrowser,MSGTR_SkinBrowser ); |
128 gtk_object_set_data( GTK_OBJECT( SkinBrowser ),MSGTR_SkinBrowser,SkinBrowser ); | |
129 gtk_widget_set_usize( SkinBrowser,256,320 ); | |
130 gtk_container_set_border_width( GTK_CONTAINER( SkinBrowser ),1 ); | |
131 GTK_WIDGET_SET_FLAGS( SkinBrowser,GTK_CAN_DEFAULT ); | |
132 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 ); | |
133 gtk_window_set_title( GTK_WINDOW( SkinBrowser ),MSGTR_SkinBrowser ); | |
134 gtk_window_set_position( GTK_WINDOW( SkinBrowser ),GTK_WIN_POS_CENTER ); | |
135 gtk_window_set_policy( GTK_WINDOW( SkinBrowser ),FALSE,FALSE,TRUE ); | |
8299 | 136 gtk_window_set_wmclass( GTK_WINDOW( SkinBrowser ),"SkinBrowser","MPlayer" ); |
6651 | 137 |
138 gtk_widget_realize( SkinBrowser ); | |
139 gtkAddIcon( SkinBrowser ); | |
2901 | 140 |
8299 | 141 vbox5=AddVBox( AddDialogFrame( SkinBrowser ),0 ); |
142 AddLabel( MSGTR_SKIN_LABEL,vbox5 ); | |
143 AddHSeparator( vbox5 ); | |
2901 | 144 |
145 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); | |
146 gtk_widget_set_name( scrolledwindow1,"scrolledwindow1" ); | |
147 gtk_widget_ref( scrolledwindow1 ); | |
6146 | 148 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"scrolledwindow1",scrolledwindow1,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 149 gtk_widget_show( scrolledwindow1 ); |
150 gtk_box_pack_start( GTK_BOX( vbox5 ),scrolledwindow1,TRUE,TRUE,0 ); | |
151 gtk_container_set_border_width( GTK_CONTAINER( scrolledwindow1 ),2 ); | |
152 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
153 | |
154 SkinList=gtk_clist_new( 1 ); | |
155 gtk_widget_set_name( SkinList,"SkinList" ); | |
156 gtk_widget_ref( SkinList ); | |
6146 | 157 gtk_object_set_data_full( GTK_OBJECT( SkinBrowser ),"SkinList",SkinList,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 158 gtk_widget_show( SkinList ); |
159 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),SkinList ); | |
160 gtk_clist_set_column_width( GTK_CLIST( SkinList ),0,80 ); | |
161 gtk_clist_set_selection_mode( GTK_CLIST( SkinList ),GTK_SELECTION_SINGLE ); | |
162 gtk_clist_column_titles_hide( GTK_CLIST( SkinList ) ); | |
163 gtk_clist_set_shadow_type( GTK_CLIST( SkinList ),GTK_SHADOW_ETCHED_OUT ); | |
164 | |
8299 | 165 AddHSeparator( vbox5 ); |
2901 | 166 |
8299 | 167 hbuttonbox4=AddHButtonBox( vbox5 ); |
168 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox4 ),GTK_BUTTONBOX_SPREAD ); | |
169 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox4 ),10 ); | |
2901 | 170 |
8299 | 171 Ok=AddButton( MSGTR_Ok,hbuttonbox4 ); |
172 Cancel=AddButton( MSGTR_Cancel,hbuttonbox4 ); | |
2901 | 173 |
8299 | 174 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); |
175 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
2901 | 176 |
8719
dc27303ae528
correct widget destroy event handler (thank for D J Hawkey Jr <hawkeyd@visi.com>)
pontscho
parents:
8299
diff
changeset
|
177 gtk_signal_connect( GTK_OBJECT( SkinBrowser ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&SkinBrowser ); |
2901 | 178 gtk_signal_connect( GTK_OBJECT( SkinList ),"select_row",GTK_SIGNAL_FUNC( on_SkinList_select_row ),NULL ); |
8299 | 179 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)1 ); |
180 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void *)0 ); | |
2901 | 181 |
19061
86350b4b8203
drops casts from void * on malloc/calloc from the gui code
reynaldo
parents:
18066
diff
changeset
|
182 if ( ( sbMPlayerDirInHome_obsolete=calloc( 1,strlen( skinDirInHome_obsolete ) + 4 ) ) != NULL ) |
17974
9a5a62f480e6
Rename the default GUI skins directory from 'Skin' to 'skins', keeping
diego
parents:
17144
diff
changeset
|
183 { strcpy( sbMPlayerDirInHome_obsolete,skinDirInHome_obsolete ); strcat( sbMPlayerDirInHome_obsolete,"/*" ); } |
19061
86350b4b8203
drops casts from void * on malloc/calloc from the gui code
reynaldo
parents:
18066
diff
changeset
|
184 if ( ( sbMPlayerDirInHome=calloc( 1,strlen( skinDirInHome ) + 4 ) ) != NULL ) |
2901 | 185 { strcpy( sbMPlayerDirInHome,skinDirInHome ); strcat( sbMPlayerDirInHome,"/*" ); } |
19061
86350b4b8203
drops casts from void * on malloc/calloc from the gui code
reynaldo
parents:
18066
diff
changeset
|
186 if ( ( sbMPlayerPrefixDir_obsolete=calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL ) |
17974
9a5a62f480e6
Rename the default GUI skins directory from 'Skin' to 'skins', keeping
diego
parents:
17144
diff
changeset
|
187 { strcpy( sbMPlayerPrefixDir_obsolete,skinMPlayerDir ); strcat( sbMPlayerPrefixDir_obsolete,"/*" ); } |
19061
86350b4b8203
drops casts from void * on malloc/calloc from the gui code
reynaldo
parents:
18066
diff
changeset
|
188 if ( ( sbMPlayerPrefixDir=calloc( 1,strlen( skinMPlayerDir ) + 4 ) ) != NULL ) |
2901 | 189 { strcpy( sbMPlayerPrefixDir,skinMPlayerDir ); strcat( sbMPlayerPrefixDir,"/*" ); } |
190 | |
191 gtk_window_add_accel_group( GTK_WINDOW( SkinBrowser ),accel_group ); | |
192 gtk_widget_grab_focus( SkinList ); | |
193 | |
194 return SkinBrowser; | |
195 } |