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