comparison gui/mplayer/gtk/common.c @ 23077:17bf4f4b0715

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