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