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 <gdk/gdkkeysyms.h>
|
|
20 #include <gtk/gtk.h>
|
|
21
|
|
22 #include "tools.h"
|
|
23
|
|
24 void WidgetDestroy( GtkWidget * widget,GtkWidget ** widget_pointer )
|
|
25 {
|
|
26 if ( !widget_pointer ) return;
|
|
27 gtk_widget_hide( *widget_pointer );
|
|
28 gtk_widget_destroy( *widget_pointer );
|
|
29 *widget_pointer=NULL;
|
|
30 }
|
|
31
|
|
32 GtkWidget * AddDialogFrame( GtkWidget * parent )
|
|
33 {
|
|
34 GtkWidget * frame;
|
|
35 frame=AddFrame( NULL,GTK_SHADOW_IN,parent,1 );
|
|
36 gtk_container_set_border_width( GTK_CONTAINER( frame ),1 );
|
|
37 frame=AddFrame( NULL,GTK_SHADOW_NONE,frame,1 );
|
|
38 frame=AddFrame( NULL,GTK_SHADOW_ETCHED_OUT,frame,1 );
|
|
39 frame=AddFrame( NULL,GTK_SHADOW_NONE,frame,1 );
|
|
40 return frame;
|
|
41 }
|
|
42
|
|
43 GtkWidget * AddFrame( const char * title,int type,GtkWidget * parent,int add )
|
|
44 {
|
|
45 GtkWidget * frame = NULL;
|
|
46 frame=gtk_frame_new( title );
|
|
47 gtk_widget_set_name( frame,"frame" );
|
|
48 gtk_widget_show( frame );
|
|
49 gtk_frame_set_shadow_type( GTK_FRAME( frame ),type );
|
|
50 if ( !parent ) return frame;
|
|
51 if ( add ) gtk_container_add( GTK_CONTAINER( parent ),frame );
|
|
52 else gtk_box_pack_start( GTK_BOX( parent ),frame,FALSE,FALSE,0 );
|
|
53 return frame;
|
|
54 }
|
|
55
|
|
56 GtkWidget * AddLabel( const char * title,GtkWidget * parent )
|
|
57 {
|
|
58 GtkWidget * label;
|
|
59 label=gtk_label_new( title );
|
|
60 gtk_widget_set_name( label,"label" );
|
|
61 gtk_widget_show( label );
|
|
62 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),label,FALSE,FALSE,0 );
|
|
63 gtk_misc_set_alignment( GTK_MISC( label ),0,0.5 );
|
|
64 gtk_misc_set_padding( GTK_MISC( label ),4,0 );
|
|
65 return label;
|
|
66 }
|
|
67
|
|
68 GtkWidget * AddVBox( GtkWidget * parent,int type )
|
|
69 {
|
|
70 GtkWidget * vbox;
|
|
71 vbox=gtk_vbox_new( FALSE,0 );
|
|
72 gtk_widget_set_name( vbox,"vbox" );
|
|
73 gtk_widget_show( vbox );
|
|
74 if ( parent )
|
|
75 {
|
|
76 if ( type ) gtk_box_pack_start( GTK_BOX( parent ),vbox,FALSE,FALSE,0 );
|
|
77 else gtk_container_add( GTK_CONTAINER( parent ),vbox );
|
|
78 }
|
|
79 return vbox;
|
|
80 }
|
|
81
|
|
82 GtkWidget * AddHBox( GtkWidget * parent,int type )
|
|
83 {
|
|
84 GtkWidget * hbox;
|
|
85 hbox=gtk_hbox_new( FALSE,0 );
|
|
86 gtk_widget_set_name( hbox,"hbox" );
|
|
87 gtk_widget_show( hbox );
|
|
88 if ( parent )
|
|
89 {
|
|
90 if ( type ) gtk_box_pack_start( GTK_BOX( parent ),hbox,FALSE,FALSE,0 );
|
|
91 else gtk_container_add( GTK_CONTAINER( parent ),hbox );
|
|
92 }
|
|
93 return hbox;
|
|
94 }
|
|
95
|
|
96 GtkWidget * AddCheckButton( const char * title, GtkWidget * parent )
|
|
97 {
|
|
98 GtkWidget * CB;
|
|
99 CB=gtk_check_button_new_with_label( title );
|
|
100 gtk_widget_set_name( CB,"CB" );
|
|
101 gtk_widget_show( CB );
|
|
102 gtk_box_pack_start( GTK_BOX( parent ),CB,FALSE,FALSE,0 );
|
|
103 return CB;
|
|
104 }
|
|
105
|
|
106 GtkWidget * AddRadioButton( const char * title,GSList ** group,GtkWidget * parent )
|
|
107 {
|
|
108 GtkWidget * RB;
|
|
109 RB=gtk_radio_button_new_with_label( *group,title );
|
|
110 *group=gtk_radio_button_group( GTK_RADIO_BUTTON( RB ) );
|
|
111 gtk_widget_set_name( RB,"RB" );
|
|
112 gtk_widget_show( RB );
|
|
113 gtk_box_pack_start( GTK_BOX( parent ),RB,FALSE,FALSE,0 );
|
|
114 return RB;
|
|
115 }
|
|
116
|
|
117 GtkWidget * AddSpinButton( const char * title,GtkAdjustment * adj,GtkWidget * parent )
|
|
118 {
|
|
119 GtkWidget * SB;
|
|
120 GtkWidget * label;
|
|
121 label=gtk_label_new( title );
|
|
122 gtk_misc_set_alignment( GTK_MISC( label ),0,0.5 );
|
|
123 gtk_box_pack_start( GTK_BOX( parent ),label,FALSE,FALSE,0 );
|
|
124 gtk_widget_show( label );
|
|
125 SB=gtk_spin_button_new( adj,0,0 );
|
|
126 gtk_widget_set_name( SB,"SB" );
|
|
127 gtk_box_pack_start( GTK_BOX( parent ),SB,FALSE,FALSE,0 );
|
|
128 gtk_widget_show( SB );
|
|
129 return SB;
|
|
130 }
|
|
131
|
|
132 GtkWidget * AddButton( const char * title,GtkWidget * parent )
|
|
133 {
|
|
134 GtkWidget * B;
|
|
135 B=gtk_button_new_with_label( title );
|
|
136 gtk_widget_set_name( B,"B" );
|
|
137 gtk_widget_show( B );
|
|
138 gtk_container_add( GTK_CONTAINER( parent ),B );
|
|
139 return B;
|
|
140 }
|
|
141
|
|
142 GtkWidget * AddHSeparator( GtkWidget * parent )
|
|
143 {
|
|
144 GtkWidget * hseparator;
|
|
145 hseparator=gtk_hseparator_new();
|
|
146 gtk_widget_set_name( hseparator,"hseparator1" );
|
|
147 gtk_widget_show( hseparator );
|
|
148 gtk_box_pack_start( GTK_BOX( parent ),hseparator,FALSE,FALSE,0 );
|
|
149 gtk_widget_set_usize( hseparator,-2,6 );
|
|
150 return hseparator;
|
|
151 }
|
|
152
|
|
153 GtkWidget * AddHButtonBox( GtkWidget * parent )
|
|
154 {
|
|
155 GtkWidget * hbuttonbox;
|
|
156 hbuttonbox=gtk_hbutton_box_new();
|
|
157 gtk_widget_set_name( hbuttonbox,"hbuttonbox" );
|
|
158 gtk_widget_show( hbuttonbox );
|
|
159 gtk_box_pack_start( GTK_BOX( parent ),hbuttonbox,FALSE,FALSE,0 );
|
|
160 gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox ),85,20 );
|
|
161 return hbuttonbox;
|
|
162 }
|
|
163
|
|
164 GtkWidget * AddHScaler( GtkAdjustment * adj,GtkWidget * parent,int digit )
|
|
165 {
|
|
166 GtkWidget * HS;
|
|
167 HS=gtk_hscale_new( adj );
|
|
168 gtk_widget_set_name( HS,"HS" );
|
|
169 gtk_widget_show( HS );
|
|
170 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),HS,TRUE,TRUE,0 );
|
|
171 gtk_scale_set_value_pos( GTK_SCALE( HS ),GTK_POS_RIGHT );
|
|
172 gtk_scale_set_digits( GTK_SCALE( HS ),digit );
|
|
173 return HS;
|
|
174 }
|
|
175
|
|
176 GtkWidget * AddVScaler( GtkAdjustment * adj,GtkWidget * parent,int digit )
|
|
177 {
|
|
178 GtkWidget * VS;
|
|
179 VS=gtk_vscale_new( adj );
|
|
180 gtk_widget_set_name( VS,"VS" );
|
|
181 gtk_widget_show( VS );
|
|
182 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),VS,TRUE,TRUE,0 );
|
|
183 // gtk_scale_set_value_pos( GTK_SCALE( VS ),GTK_POS_RIGHT );
|
|
184 if ( digit == -1 ) gtk_scale_set_draw_value( GTK_SCALE( VS ),FALSE );
|
|
185 else gtk_scale_set_digits( GTK_SCALE( VS ),digit );
|
|
186 return VS;
|
|
187 }
|
|
188
|
|
189 GtkWidget * AddComboBox( GtkWidget * parent )
|
|
190 {
|
|
191 GtkWidget * CB;
|
|
192 CB=gtk_combo_new();
|
|
193 gtk_widget_set_name( CB,"CB" );
|
|
194 gtk_widget_show( CB );
|
|
195 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),CB,TRUE,TRUE,0 );
|
|
196 return CB;
|
|
197 }
|