Mercurial > mplayer.hg
annotate gui/dialog/tools.c @ 36824:836563c39dac
Set the step increment for panscan to 0.1.
author | ib |
---|---|
date | Mon, 24 Feb 2014 11:28:34 +0000 |
parents | 92159376ad91 |
children |
rev | line source |
---|---|
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> | |
36024 | 21 #include <string.h> |
35526 | 22 |
23 #include "tools.h" | |
24 | |
36710 | 25 #include "help_mp.h" |
26 | |
27 /** | |
28 * @brief Perform a localization of the decimal mark. | |
29 * | |
30 * @param scale object which received the signal | |
31 * @param value value to format | |
32 * @param user_data user data set when the signal handler was connected | |
33 * | |
34 * @return allocated string representing value | |
35 * | |
36 * @note This function is necessary, because we have to run in the "C" locale. | |
37 */ | |
38 static gchar *scale_format_value (GtkScale *scale, gdouble value, gpointer user_data) | |
39 { | |
40 gchar *val, *p, *dm = MSGTR_GUI_DecimalMark; | |
41 | |
42 (void) user_data; | |
43 | |
44 val = g_strdup_printf("%0.*f", gtk_scale_get_digits(scale), value); | |
45 | |
46 p = val; | |
47 | |
48 while (p && *p && *dm) | |
49 { | |
50 if (*p == '.') *p = *dm; | |
51 | |
52 p++; | |
53 } | |
54 | |
55 return val; | |
56 } | |
57 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
58 GtkWidget * gtkAddDialogFrame( GtkWidget * parent ) |
35526 | 59 { |
60 GtkWidget * frame; | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
61 frame=gtkAddFrame( NULL,GTK_SHADOW_IN,parent,1 ); |
35526 | 62 gtk_container_set_border_width( GTK_CONTAINER( frame ),1 ); |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
63 frame=gtkAddFrame( NULL,GTK_SHADOW_NONE,frame,1 ); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
64 frame=gtkAddFrame( NULL,GTK_SHADOW_ETCHED_OUT,frame,1 ); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
65 frame=gtkAddFrame( NULL,GTK_SHADOW_NONE,frame,1 ); |
35526 | 66 return frame; |
67 } | |
68 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
69 GtkWidget * gtkAddFrame( const char * title,int type,GtkWidget * parent,int add ) |
35526 | 70 { |
71 GtkWidget * frame = NULL; | |
72 frame=gtk_frame_new( title ); | |
73 gtk_widget_show( frame ); | |
74 gtk_frame_set_shadow_type( GTK_FRAME( frame ),type ); | |
75 if ( !parent ) return frame; | |
76 if ( add ) gtk_container_add( GTK_CONTAINER( parent ),frame ); | |
77 else gtk_box_pack_start( GTK_BOX( parent ),frame,FALSE,FALSE,0 ); | |
78 return frame; | |
79 } | |
80 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
81 GtkWidget * gtkAddLabel( const char * title,GtkWidget * parent ) |
35526 | 82 { |
83 GtkWidget * label; | |
84 label=gtk_label_new( title ); | |
85 gtk_widget_show( label ); | |
86 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),label,FALSE,FALSE,0 ); | |
87 gtk_misc_set_alignment( GTK_MISC( label ),0,0.5 ); | |
88 gtk_misc_set_padding( GTK_MISC( label ),4,0 ); | |
89 return label; | |
90 } | |
91 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
92 GtkWidget * gtkAddVBox( GtkWidget * parent,int type ) |
35526 | 93 { |
94 GtkWidget * vbox; | |
95 vbox=gtk_vbox_new( FALSE,0 ); | |
96 gtk_widget_show( vbox ); | |
97 if ( parent ) | |
98 { | |
99 if ( type ) gtk_box_pack_start( GTK_BOX( parent ),vbox,FALSE,FALSE,0 ); | |
100 else gtk_container_add( GTK_CONTAINER( parent ),vbox ); | |
101 } | |
102 return vbox; | |
103 } | |
104 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
105 GtkWidget * gtkAddHBox( GtkWidget * parent,int type ) |
35526 | 106 { |
107 GtkWidget * hbox; | |
108 hbox=gtk_hbox_new( FALSE,0 ); | |
109 gtk_widget_show( hbox ); | |
110 if ( parent ) | |
111 { | |
112 if ( type ) gtk_box_pack_start( GTK_BOX( parent ),hbox,FALSE,FALSE,0 ); | |
113 else gtk_container_add( GTK_CONTAINER( parent ),hbox ); | |
114 } | |
115 return hbox; | |
116 } | |
117 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
118 GtkWidget * gtkAddCheckButton( const char * title, GtkWidget * parent ) |
35526 | 119 { |
120 GtkWidget * CB; | |
121 CB=gtk_check_button_new_with_label( title ); | |
122 gtk_widget_show( CB ); | |
123 gtk_box_pack_start( GTK_BOX( parent ),CB,FALSE,FALSE,0 ); | |
124 return CB; | |
125 } | |
126 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
127 GtkWidget * gtkAddRadioButton( const char * title,GSList ** group,GtkWidget * parent ) |
35526 | 128 { |
129 GtkWidget * RB; | |
130 RB=gtk_radio_button_new_with_label( *group,title ); | |
131 *group=gtk_radio_button_group( GTK_RADIO_BUTTON( RB ) ); | |
132 gtk_widget_show( RB ); | |
133 gtk_box_pack_start( GTK_BOX( parent ),RB,FALSE,FALSE,0 ); | |
134 return RB; | |
135 } | |
136 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
137 GtkWidget * gtkAddSpinButton( const char * title,GtkAdjustment * adj,GtkWidget * parent ) |
35526 | 138 { |
139 GtkWidget * SB; | |
140 GtkWidget * label; | |
141 label=gtk_label_new( title ); | |
142 gtk_misc_set_alignment( GTK_MISC( label ),0,0.5 ); | |
143 gtk_box_pack_start( GTK_BOX( parent ),label,FALSE,FALSE,0 ); | |
144 gtk_widget_show( label ); | |
145 SB=gtk_spin_button_new( adj,0,0 ); | |
146 gtk_box_pack_start( GTK_BOX( parent ),SB,FALSE,FALSE,0 ); | |
147 gtk_widget_show( SB ); | |
148 return SB; | |
149 } | |
150 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
151 GtkWidget * gtkAddButton( const char * title,GtkWidget * parent ) |
35526 | 152 { |
153 GtkWidget * B; | |
154 B=gtk_button_new_with_label( title ); | |
155 gtk_widget_show( B ); | |
156 gtk_container_add( GTK_CONTAINER( parent ),B ); | |
157 return B; | |
158 } | |
159 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
160 GtkWidget * gtkAddHSeparator( GtkWidget * parent ) |
35526 | 161 { |
162 GtkWidget * hseparator; | |
163 hseparator=gtk_hseparator_new(); | |
164 gtk_widget_show( hseparator ); | |
165 gtk_box_pack_start( GTK_BOX( parent ),hseparator,FALSE,FALSE,0 ); | |
166 gtk_widget_set_usize( hseparator,-2,6 ); | |
167 return hseparator; | |
168 } | |
169 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
170 GtkWidget * gtkAddHButtonBox( GtkWidget * parent ) |
35526 | 171 { |
172 GtkWidget * hbuttonbox; | |
173 hbuttonbox=gtk_hbutton_box_new(); | |
174 gtk_widget_show( hbuttonbox ); | |
175 gtk_box_pack_start( GTK_BOX( parent ),hbuttonbox,FALSE,FALSE,0 ); | |
176 gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox ),85,20 ); | |
177 return hbuttonbox; | |
178 } | |
179 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
180 GtkWidget * gtkAddHScale( GtkAdjustment * adj,GtkWidget * parent,int digit ) |
35526 | 181 { |
182 GtkWidget * HS; | |
183 HS=gtk_hscale_new( adj ); | |
184 gtk_widget_show( HS ); | |
185 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),HS,TRUE,TRUE,0 ); | |
186 gtk_scale_set_value_pos( GTK_SCALE( HS ),GTK_POS_RIGHT ); | |
187 gtk_scale_set_digits( GTK_SCALE( HS ),digit ); | |
36710 | 188 if (digit > 0) gtk_signal_connect(GTK_OBJECT(HS), "format-value", GTK_SIGNAL_FUNC(scale_format_value), NULL); |
35526 | 189 return HS; |
190 } | |
191 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
192 GtkWidget * gtkAddVScale( GtkAdjustment * adj,GtkWidget * parent,int digit ) |
35526 | 193 { |
194 GtkWidget * VS; | |
195 VS=gtk_vscale_new( adj ); | |
196 gtk_widget_show( VS ); | |
197 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),VS,TRUE,TRUE,0 ); | |
198 // gtk_scale_set_value_pos( GTK_SCALE( VS ),GTK_POS_RIGHT ); | |
199 if ( digit == -1 ) gtk_scale_set_draw_value( GTK_SCALE( VS ),FALSE ); | |
200 else gtk_scale_set_digits( GTK_SCALE( VS ),digit ); | |
36710 | 201 if (digit > 0) gtk_signal_connect(GTK_OBJECT(VS), "format-value", GTK_SIGNAL_FUNC(scale_format_value), NULL); |
35526 | 202 return VS; |
203 } | |
204 | |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36009
diff
changeset
|
205 GtkWidget * gtkAddCombo( GtkWidget * parent ) |
35526 | 206 { |
207 GtkWidget * CB; | |
208 CB=gtk_combo_new(); | |
209 gtk_widget_show( CB ); | |
210 if ( parent ) gtk_box_pack_start( GTK_BOX( parent ),CB,TRUE,TRUE,0 ); | |
211 return CB; | |
212 } | |
36024 | 213 |
214 int gtkFindInCList (GtkWidget *list, char *item) | |
215 { | |
216 gint j; | |
217 gchar *tmpstr; | |
218 | |
219 for (j = 0; j < GTK_CLIST(list)->rows; j++) | |
220 { | |
221 gtk_clist_get_text(GTK_CLIST(list), j, 0, &tmpstr); | |
222 | |
223 if (!strcmp(tmpstr, item)) return j; | |
224 } | |
225 | |
226 return -1; | |
227 } |