2 * This file is part of MPlayer.
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.
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.
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.
19 #include <gdk/gdkkeysyms.h>
22 #include "gtk_common.h"
24 void WidgetDestroy( GtkWidget
* widget
,GtkWidget
** widget_pointer
)
26 if ( !widget_pointer
) return;
27 gtk_widget_hide( *widget_pointer
);
28 gtk_widget_destroy( *widget_pointer
);
32 GtkWidget
* AddDialogFrame( GtkWidget
* parent
)
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 );
43 GtkWidget
* AddFrame( const char * title
,int type
,GtkWidget
* parent
,int add
)
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 );
56 GtkWidget
* AddLabel( const char * title
,GtkWidget
* parent
)
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 );
68 GtkWidget
* AddVBox( GtkWidget
* parent
,int type
)
71 vbox
=gtk_vbox_new( FALSE
,0 );
72 gtk_widget_set_name( vbox
,"vbox" );
73 gtk_widget_show( vbox
);
76 if ( type
) gtk_box_pack_start( GTK_BOX( parent
),vbox
,FALSE
,FALSE
,0 );
77 else gtk_container_add( GTK_CONTAINER( parent
),vbox
);
82 GtkWidget
* AddHBox( GtkWidget
* parent
,int type
)
85 hbox
=gtk_hbox_new( FALSE
,0 );
86 gtk_widget_set_name( hbox
,"hbox" );
87 gtk_widget_show( hbox
);
90 if ( type
) gtk_box_pack_start( GTK_BOX( parent
),hbox
,FALSE
,FALSE
,0 );
91 else gtk_container_add( GTK_CONTAINER( parent
),hbox
);
96 GtkWidget
* AddCheckButton( const char * title
, GtkWidget
* parent
)
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 );
106 GtkWidget
* AddRadioButton( const char * title
,GSList
** group
,GtkWidget
* parent
)
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 );
117 GtkWidget
* AddSpinButton( const char * title
,GtkAdjustment
* adj
,GtkWidget
* parent
)
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
);
132 GtkWidget
* AddButton( const char * title
,GtkWidget
* parent
)
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
);
142 GtkWidget
* AddHSeparator( GtkWidget
* parent
)
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 );
153 GtkWidget
* AddHButtonBox( GtkWidget
* parent
)
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 );
164 GtkWidget
* AddHScaler( GtkAdjustment
* adj
,GtkWidget
* parent
,int digit
)
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
);
176 GtkWidget
* AddVScaler( GtkAdjustment
* adj
,GtkWidget
* parent
,int digit
)
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
);
189 GtkWidget
* AddComboBox( GtkWidget
* parent
)
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 );