annotate gui/ui/gtk/tools.c @ 34488:01c19d9b1e83

Print an error when streams behave in a way that the cache cannot handle.
author reimar
date Sun, 15 Jan 2012 12:38:38 +0000
parents d9b805602aa1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
1 /*
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
2 * This file is part of MPlayer.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
3 *
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
7 * (at your option) any later version.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
8 *
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
12 * GNU General Public License for more details.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
13 *
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License along
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
17 */
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
18
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
19 #include <gdk/gdkkeysyms.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
20 #include <gtk/gtk.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
21
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
22 #include "tools.h"
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
23
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
24 void WidgetDestroy( GtkWidget * widget,GtkWidget ** widget_pointer )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
25 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
26 if ( !widget_pointer ) return;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
27 gtk_widget_hide( *widget_pointer );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
28 gtk_widget_destroy( *widget_pointer );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
29 *widget_pointer=NULL;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
30 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
31
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
32 GtkWidget * AddDialogFrame( GtkWidget * parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
33 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
34 GtkWidget * frame;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
35 frame=AddFrame( NULL,GTK_SHADOW_IN,parent,1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
36 gtk_container_set_border_width( GTK_CONTAINER( frame ),1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
37 frame=AddFrame( NULL,GTK_SHADOW_NONE,frame,1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
38 frame=AddFrame( NULL,GTK_SHADOW_ETCHED_OUT,frame,1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
39 frame=AddFrame( NULL,GTK_SHADOW_NONE,frame,1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
40 return frame;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
41 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
42
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
43 GtkWidget * AddFrame( const char * title,int type,GtkWidget * parent,int add )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
44 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
45 GtkWidget * frame = NULL;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
46 frame=gtk_frame_new( title );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
47 gtk_widget_set_name( frame,"frame" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
48 gtk_widget_show( frame );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
49 gtk_frame_set_shadow_type( GTK_FRAME( frame ),type );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
50 if ( !parent ) return frame;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
51 if ( add ) gtk_container_add( GTK_CONTAINER( parent ),frame );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
52 else gtk_box_pack_start( GTK_BOX( parent ),frame,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
53 return frame;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
54 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
55
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
56 GtkWidget * AddLabel( const char * title,GtkWidget * parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
57 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
58 GtkWidget * label;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
59 label=gtk_label_new( title );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
60 gtk_widget_set_name( label,"label" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
61 gtk_widget_show( label );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
62 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),label,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
63 gtk_misc_set_alignment( GTK_MISC( label ),0,0.5 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
64 gtk_misc_set_padding( GTK_MISC( label ),4,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
65 return label;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
66 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
67
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
68 GtkWidget * AddVBox( GtkWidget * parent,int type )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
69 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
70 GtkWidget * vbox;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
71 vbox=gtk_vbox_new( FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
72 gtk_widget_set_name( vbox,"vbox" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
73 gtk_widget_show( vbox );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
74 if ( parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
75 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
76 if ( type ) gtk_box_pack_start( GTK_BOX( parent ),vbox,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
77 else gtk_container_add( GTK_CONTAINER( parent ),vbox );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
78 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
79 return vbox;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
80 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
81
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
82 GtkWidget * AddHBox( GtkWidget * parent,int type )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
83 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
84 GtkWidget * hbox;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
85 hbox=gtk_hbox_new( FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
86 gtk_widget_set_name( hbox,"hbox" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
87 gtk_widget_show( hbox );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
88 if ( parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
89 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
90 if ( type ) gtk_box_pack_start( GTK_BOX( parent ),hbox,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
91 else gtk_container_add( GTK_CONTAINER( parent ),hbox );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
92 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
93 return hbox;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
94 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
95
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
96 GtkWidget * AddCheckButton( const char * title, GtkWidget * parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
97 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
98 GtkWidget * CB;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
99 CB=gtk_check_button_new_with_label( title );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
100 gtk_widget_set_name( CB,"CB" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
101 gtk_widget_show( CB );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
102 gtk_box_pack_start( GTK_BOX( parent ),CB,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
103 return CB;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
104 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
105
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
106 GtkWidget * AddRadioButton( const char * title,GSList ** group,GtkWidget * parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
107 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
108 GtkWidget * RB;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
109 RB=gtk_radio_button_new_with_label( *group,title );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
110 *group=gtk_radio_button_group( GTK_RADIO_BUTTON( RB ) );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
111 gtk_widget_set_name( RB,"RB" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
112 gtk_widget_show( RB );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
113 gtk_box_pack_start( GTK_BOX( parent ),RB,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
114 return RB;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
115 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
116
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
117 GtkWidget * AddSpinButton( const char * title,GtkAdjustment * adj,GtkWidget * parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
118 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
119 GtkWidget * SB;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
120 GtkWidget * label;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
121 label=gtk_label_new( title );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
122 gtk_misc_set_alignment( GTK_MISC( label ),0,0.5 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
123 gtk_box_pack_start( GTK_BOX( parent ),label,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
124 gtk_widget_show( label );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
125 SB=gtk_spin_button_new( adj,0,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
126 gtk_widget_set_name( SB,"SB" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
127 gtk_box_pack_start( GTK_BOX( parent ),SB,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
128 gtk_widget_show( SB );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
129 return SB;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
130 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
131
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
132 GtkWidget * AddButton( const char * title,GtkWidget * parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
133 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
134 GtkWidget * B;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
135 B=gtk_button_new_with_label( title );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
136 gtk_widget_set_name( B,"B" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
137 gtk_widget_show( B );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
138 gtk_container_add( GTK_CONTAINER( parent ),B );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
139 return B;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
140 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
141
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
142 GtkWidget * AddHSeparator( GtkWidget * parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
143 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
144 GtkWidget * hseparator;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
145 hseparator=gtk_hseparator_new();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
146 gtk_widget_set_name( hseparator,"hseparator1" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
147 gtk_widget_show( hseparator );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
148 gtk_box_pack_start( GTK_BOX( parent ),hseparator,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
149 gtk_widget_set_usize( hseparator,-2,6 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
150 return hseparator;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
151 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
152
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
153 GtkWidget * AddHButtonBox( GtkWidget * parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
154 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
155 GtkWidget * hbuttonbox;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
156 hbuttonbox=gtk_hbutton_box_new();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
157 gtk_widget_set_name( hbuttonbox,"hbuttonbox" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
158 gtk_widget_show( hbuttonbox );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
159 gtk_box_pack_start( GTK_BOX( parent ),hbuttonbox,FALSE,FALSE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
160 gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox ),85,20 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
161 return hbuttonbox;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
162 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
163
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
164 GtkWidget * AddHScaler( GtkAdjustment * adj,GtkWidget * parent,int digit )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
165 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
166 GtkWidget * HS;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
167 HS=gtk_hscale_new( adj );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
168 gtk_widget_set_name( HS,"HS" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
169 gtk_widget_show( HS );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
170 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),HS,TRUE,TRUE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
171 gtk_scale_set_value_pos( GTK_SCALE( HS ),GTK_POS_RIGHT );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
172 gtk_scale_set_digits( GTK_SCALE( HS ),digit );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
173 return HS;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
174 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
175
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
176 GtkWidget * AddVScaler( GtkAdjustment * adj,GtkWidget * parent,int digit )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
177 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
178 GtkWidget * VS;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
179 VS=gtk_vscale_new( adj );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
180 gtk_widget_set_name( VS,"VS" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
181 gtk_widget_show( VS );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
182 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),VS,TRUE,TRUE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
183 // gtk_scale_set_value_pos( GTK_SCALE( VS ),GTK_POS_RIGHT );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
184 if ( digit == -1 ) gtk_scale_set_draw_value( GTK_SCALE( VS ),FALSE );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
185 else gtk_scale_set_digits( GTK_SCALE( VS ),digit );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
186 return VS;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
187 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
188
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
189 GtkWidget * AddComboBox( GtkWidget * parent )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
190 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
191 GtkWidget * CB;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
192 CB=gtk_combo_new();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
193 gtk_widget_set_name( CB,"CB" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
194 gtk_widget_show( CB );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
195 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),CB,TRUE,TRUE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
196 return CB;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
197 }