Merge lp:~bratsche/ido/scale-size into lp:ido/0.3
- scale-size
- Merge into trunk
Proposed by
Cody Russell
Status: | Merged |
---|---|
Merged at revision: | 46 |
Proposed branch: | lp:~bratsche/ido/scale-size |
Merge into: | lp:ido/0.3 |
Diff against target: |
310 lines (+99/-58) 3 files modified
example/menus.c (+3/-1) src/idoscalemenuitem.c (+93/-57) src/idoscalemenuitem.h (+3/-0) |
To merge this branch: | bzr merge lp:~bratsche/ido/scale-size |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Conor Curran (community) | Approve | ||
Review via email: mp+29992@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'example/menus.c' | |||
2 | --- example/menus.c 2010-07-13 14:45:22 +0000 | |||
3 | +++ example/menus.c 2010-07-15 13:49:44 +0000 | |||
4 | @@ -51,7 +51,9 @@ | |||
5 | 51 | menuitem = gtk_menu_item_new_with_label ("Open"); | 51 | menuitem = gtk_menu_item_new_with_label ("Open"); |
6 | 52 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); | 52 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); |
7 | 53 | 53 | ||
9 | 54 | menuitem = ido_scale_menu_item_new_with_range ("Volume", 65, 0, 100, 1); | 54 | menuitem = ido_scale_menu_item_new_with_range ("Volume", |
10 | 55 | IDO_RANGE_STYLE_DEFAULT, | ||
11 | 56 | 65, 0, 100, 1); | ||
12 | 55 | ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM (menuitem), IDO_SCALE_MENU_ITEM_STYLE_IMAGE); | 57 | ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM (menuitem), IDO_SCALE_MENU_ITEM_STYLE_IMAGE); |
13 | 56 | image = ido_scale_menu_item_get_primary_image (IDO_SCALE_MENU_ITEM (menuitem)); | 58 | image = ido_scale_menu_item_get_primary_image (IDO_SCALE_MENU_ITEM (menuitem)); |
14 | 57 | gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); | 59 | gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); |
15 | 58 | 60 | ||
16 | === modified file 'src/idoscalemenuitem.c' | |||
17 | --- src/idoscalemenuitem.c 2010-07-13 14:45:22 +0000 | |||
18 | +++ src/idoscalemenuitem.c 2010-07-15 13:49:44 +0000 | |||
19 | @@ -51,6 +51,9 @@ | |||
20 | 51 | static void ido_scale_menu_item_notify (IdoScaleMenuItem *item, | 51 | static void ido_scale_menu_item_notify (IdoScaleMenuItem *item, |
21 | 52 | GParamSpec *pspec, | 52 | GParamSpec *pspec, |
22 | 53 | gpointer user_data); | 53 | gpointer user_data); |
23 | 54 | static void update_packing (IdoScaleMenuItem *self, | ||
24 | 55 | IdoScaleMenuItemStyle style, | ||
25 | 56 | IdoScaleMenuItemStyle old_style); | ||
26 | 54 | 57 | ||
27 | 55 | struct _IdoScaleMenuItemPrivate { | 58 | struct _IdoScaleMenuItemPrivate { |
28 | 56 | GtkWidget *scale; | 59 | GtkWidget *scale; |
29 | @@ -66,6 +69,7 @@ | |||
30 | 66 | gboolean reverse_scroll; | 69 | gboolean reverse_scroll; |
31 | 67 | gboolean grabbed; | 70 | gboolean grabbed; |
32 | 68 | IdoScaleMenuItemStyle style; | 71 | IdoScaleMenuItemStyle style; |
33 | 72 | IdoRangeStyle range_style; | ||
34 | 69 | }; | 73 | }; |
35 | 70 | 74 | ||
36 | 71 | enum { | 75 | enum { |
37 | @@ -78,7 +82,8 @@ | |||
38 | 78 | PROP_0, | 82 | PROP_0, |
39 | 79 | PROP_ADJUSTMENT, | 83 | PROP_ADJUSTMENT, |
40 | 80 | PROP_REVERSE_SCROLL_EVENTS, | 84 | PROP_REVERSE_SCROLL_EVENTS, |
42 | 81 | PROP_STYLE | 85 | PROP_STYLE, |
43 | 86 | PROP_RANGE_STYLE | ||
44 | 82 | }; | 87 | }; |
45 | 83 | 88 | ||
46 | 84 | static guint signals[LAST_SIGNAL] = { 0 }; | 89 | static guint signals[LAST_SIGNAL] = { 0 }; |
47 | @@ -193,32 +198,87 @@ | |||
48 | 193 | } | 198 | } |
49 | 194 | 199 | ||
50 | 195 | static void | 200 | static void |
51 | 201 | ido_scale_menu_item_constructed (GObject *object) | ||
52 | 202 | { | ||
53 | 203 | IdoScaleMenuItem *self = IDO_SCALE_MENU_ITEM (object); | ||
54 | 204 | IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); | ||
55 | 205 | GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0)); | ||
56 | 206 | IdoRangeStyle range_style; | ||
57 | 207 | GtkWidget *hbox; | ||
58 | 208 | |||
59 | 209 | priv->adjustment = NULL; | ||
60 | 210 | |||
61 | 211 | g_object_get (self, | ||
62 | 212 | "range-style", &range_style, | ||
63 | 213 | NULL); | ||
64 | 214 | |||
65 | 215 | priv->scale = ido_range_new (adj, range_style); | ||
66 | 216 | g_object_ref (priv->scale); | ||
67 | 217 | gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE); | ||
68 | 218 | |||
69 | 219 | hbox = gtk_hbox_new (FALSE, 0); | ||
70 | 220 | |||
71 | 221 | priv->primary_image = gtk_image_new (); | ||
72 | 222 | g_signal_connect (priv->primary_image, "notify", | ||
73 | 223 | G_CALLBACK (ido_scale_menu_item_primary_image_notify), | ||
74 | 224 | self); | ||
75 | 225 | |||
76 | 226 | priv->secondary_image = gtk_image_new (); | ||
77 | 227 | g_signal_connect (priv->secondary_image, "notify", | ||
78 | 228 | G_CALLBACK (ido_scale_menu_item_secondary_image_notify), | ||
79 | 229 | self); | ||
80 | 230 | |||
81 | 231 | priv->primary_label = gtk_label_new (""); | ||
82 | 232 | priv->secondary_label = gtk_label_new (""); | ||
83 | 233 | |||
84 | 234 | priv->hbox = hbox; | ||
85 | 235 | |||
86 | 236 | update_packing (self, priv->style, priv->style); | ||
87 | 237 | |||
88 | 238 | g_signal_connect (self, "notify", | ||
89 | 239 | G_CALLBACK (ido_scale_menu_item_notify), | ||
90 | 240 | NULL); | ||
91 | 241 | |||
92 | 242 | gtk_container_add (GTK_CONTAINER (self), hbox); | ||
93 | 243 | } | ||
94 | 244 | |||
95 | 245 | static void | ||
96 | 196 | ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class) | 246 | ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class) |
97 | 197 | { | 247 | { |
98 | 198 | GObjectClass *gobject_class = G_OBJECT_CLASS (item_class); | 248 | GObjectClass *gobject_class = G_OBJECT_CLASS (item_class); |
99 | 199 | GtkObjectClass *object_class = GTK_OBJECT_CLASS (item_class); | 249 | GtkObjectClass *object_class = GTK_OBJECT_CLASS (item_class); |
100 | 200 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (item_class); | 250 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (item_class); |
101 | 201 | 251 | ||
103 | 202 | widget_class->button_press_event = ido_scale_menu_item_button_press_event; | 252 | widget_class->button_press_event = ido_scale_menu_item_button_press_event; |
104 | 203 | widget_class->button_release_event = ido_scale_menu_item_button_release_event; | 253 | widget_class->button_release_event = ido_scale_menu_item_button_release_event; |
109 | 204 | widget_class->motion_notify_event = ido_scale_menu_item_motion_notify_event; | 254 | widget_class->motion_notify_event = ido_scale_menu_item_motion_notify_event; |
110 | 205 | widget_class->scroll_event = ido_scale_menu_item_scroll_event; | 255 | widget_class->scroll_event = ido_scale_menu_item_scroll_event; |
111 | 206 | widget_class->state_changed = ido_scale_menu_item_state_changed; | 256 | widget_class->state_changed = ido_scale_menu_item_state_changed; |
112 | 207 | widget_class->size_allocate = ido_scale_menu_item_size_allocate; | 257 | widget_class->size_allocate = ido_scale_menu_item_size_allocate; |
113 | 208 | 258 | ||
114 | 259 | gobject_class->constructed = ido_scale_menu_item_constructed; | ||
115 | 209 | gobject_class->set_property = ido_scale_menu_item_set_property; | 260 | gobject_class->set_property = ido_scale_menu_item_set_property; |
116 | 210 | gobject_class->get_property = ido_scale_menu_item_get_property; | 261 | gobject_class->get_property = ido_scale_menu_item_get_property; |
117 | 211 | 262 | ||
118 | 212 | g_object_class_install_property (gobject_class, | 263 | g_object_class_install_property (gobject_class, |
119 | 213 | PROP_STYLE, | 264 | PROP_STYLE, |
123 | 214 | g_param_spec_enum ("range-style", | 265 | g_param_spec_enum ("accessory-style", |
124 | 215 | "Range style", | 266 | "Style of primary/secondary widgets", |
125 | 216 | "The style of the range", | 267 | "The style of the primary/secondary widgets", |
126 | 217 | IDO_TYPE_SCALE_MENU_ITEM_STYLE, | 268 | IDO_TYPE_SCALE_MENU_ITEM_STYLE, |
127 | 218 | IDO_SCALE_MENU_ITEM_STYLE_NONE, | 269 | IDO_SCALE_MENU_ITEM_STYLE_NONE, |
128 | 219 | G_PARAM_READWRITE)); | 270 | G_PARAM_READWRITE)); |
129 | 220 | 271 | ||
130 | 221 | g_object_class_install_property (gobject_class, | 272 | g_object_class_install_property (gobject_class, |
131 | 273 | PROP_RANGE_STYLE, | ||
132 | 274 | g_param_spec_enum ("range-style", | ||
133 | 275 | "Range style", | ||
134 | 276 | "Style of the range", | ||
135 | 277 | IDO_TYPE_RANGE_STYLE, | ||
136 | 278 | IDO_RANGE_STYLE_DEFAULT, | ||
137 | 279 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); | ||
138 | 280 | |||
139 | 281 | g_object_class_install_property (gobject_class, | ||
140 | 222 | PROP_ADJUSTMENT, | 282 | PROP_ADJUSTMENT, |
141 | 223 | g_param_spec_object ("adjustment", | 283 | g_param_spec_object ("adjustment", |
142 | 224 | "Adjustment", | 284 | "Adjustment", |
143 | @@ -259,11 +319,6 @@ | |||
144 | 259 | IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); | 319 | IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); |
145 | 260 | GtkContainer *container = GTK_CONTAINER (priv->hbox); | 320 | GtkContainer *container = GTK_CONTAINER (priv->hbox); |
146 | 261 | 321 | ||
147 | 262 | g_print ("%s %s %s\n", | ||
148 | 263 | G_OBJECT_TYPE_NAME (priv->primary_image), | ||
149 | 264 | G_OBJECT_TYPE_NAME (priv->scale), | ||
150 | 265 | G_OBJECT_TYPE_NAME (priv->secondary_image)); | ||
151 | 266 | |||
152 | 267 | if (style != old_style) | 322 | if (style != old_style) |
153 | 268 | { | 323 | { |
154 | 269 | switch (old_style) | 324 | switch (old_style) |
155 | @@ -319,40 +374,6 @@ | |||
156 | 319 | static void | 374 | static void |
157 | 320 | ido_scale_menu_item_init (IdoScaleMenuItem *self) | 375 | ido_scale_menu_item_init (IdoScaleMenuItem *self) |
158 | 321 | { | 376 | { |
159 | 322 | IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); | ||
160 | 323 | GtkWidget *hbox; | ||
161 | 324 | GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0)); | ||
162 | 325 | |||
163 | 326 | priv->adjustment = NULL; | ||
164 | 327 | |||
165 | 328 | priv->scale = ido_range_new (adj, IDO_RANGE_STYLE_SMALL); | ||
166 | 329 | g_object_ref (priv->scale); | ||
167 | 330 | gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE); | ||
168 | 331 | |||
169 | 332 | hbox = gtk_hbox_new (FALSE, 0); | ||
170 | 333 | |||
171 | 334 | priv->primary_image = gtk_image_new (); | ||
172 | 335 | g_signal_connect (priv->primary_image, "notify", | ||
173 | 336 | G_CALLBACK (ido_scale_menu_item_primary_image_notify), | ||
174 | 337 | self); | ||
175 | 338 | |||
176 | 339 | priv->secondary_image = gtk_image_new (); | ||
177 | 340 | g_signal_connect (priv->secondary_image, "notify", | ||
178 | 341 | G_CALLBACK (ido_scale_menu_item_secondary_image_notify), | ||
179 | 342 | self); | ||
180 | 343 | |||
181 | 344 | priv->primary_label = gtk_label_new (""); | ||
182 | 345 | priv->secondary_label = gtk_label_new (""); | ||
183 | 346 | |||
184 | 347 | priv->hbox = hbox; | ||
185 | 348 | |||
186 | 349 | update_packing (self, priv->style, priv->style); | ||
187 | 350 | |||
188 | 351 | g_signal_connect (self, "notify", | ||
189 | 352 | G_CALLBACK (ido_scale_menu_item_notify), | ||
190 | 353 | NULL); | ||
191 | 354 | |||
192 | 355 | gtk_container_add (GTK_CONTAINER (self), hbox); | ||
193 | 356 | } | 377 | } |
194 | 357 | 378 | ||
195 | 358 | static void | 379 | static void |
196 | @@ -378,6 +399,10 @@ | |||
197 | 378 | ido_scale_menu_item_set_style (menu_item, g_value_get_enum (value)); | 399 | ido_scale_menu_item_set_style (menu_item, g_value_get_enum (value)); |
198 | 379 | break; | 400 | break; |
199 | 380 | 401 | ||
200 | 402 | case PROP_RANGE_STYLE: | ||
201 | 403 | priv->range_style = g_value_get_enum (value); | ||
202 | 404 | break; | ||
203 | 405 | |||
204 | 381 | default: | 406 | default: |
205 | 382 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | 407 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
206 | 383 | break; | 408 | break; |
207 | @@ -392,11 +417,12 @@ | |||
208 | 392 | { | 417 | { |
209 | 393 | IdoScaleMenuItem *menu_item = IDO_SCALE_MENU_ITEM (object); | 418 | IdoScaleMenuItem *menu_item = IDO_SCALE_MENU_ITEM (object); |
210 | 394 | IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menu_item); | 419 | IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menu_item); |
212 | 395 | GtkAdjustment *adjustment = gtk_range_get_adjustment (GTK_RANGE (priv->scale)); | 420 | GtkAdjustment *adjustment; |
213 | 396 | 421 | ||
214 | 397 | switch (prop_id) | 422 | switch (prop_id) |
215 | 398 | { | 423 | { |
216 | 399 | case PROP_ADJUSTMENT: | 424 | case PROP_ADJUSTMENT: |
217 | 425 | adjustment = gtk_range_get_adjustment (GTK_RANGE (priv->scale)); | ||
218 | 400 | g_value_set_object (value, adjustment); | 426 | g_value_set_object (value, adjustment); |
219 | 401 | break; | 427 | break; |
220 | 402 | 428 | ||
221 | @@ -404,6 +430,10 @@ | |||
222 | 404 | g_value_set_boolean (value, priv->reverse_scroll); | 430 | g_value_set_boolean (value, priv->reverse_scroll); |
223 | 405 | break; | 431 | break; |
224 | 406 | 432 | ||
225 | 433 | case PROP_RANGE_STYLE: | ||
226 | 434 | g_value_set_enum (value, priv->range_style); | ||
227 | 435 | break; | ||
228 | 436 | |||
229 | 407 | default: | 437 | default: |
230 | 408 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | 438 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
231 | 409 | break; | 439 | break; |
232 | @@ -607,6 +637,7 @@ | |||
233 | 607 | /** | 637 | /** |
234 | 608 | * ido_scale_menu_item_new: | 638 | * ido_scale_menu_item_new: |
235 | 609 | * @label: the text of the new menu item. | 639 | * @label: the text of the new menu item. |
236 | 640 | * @size: The size style of the range. | ||
237 | 610 | * @adjustment: A #GtkAdjustment describing the slider value. | 641 | * @adjustment: A #GtkAdjustment describing the slider value. |
238 | 611 | * @returns: a new #IdoScaleMenuItem. | 642 | * @returns: a new #IdoScaleMenuItem. |
239 | 612 | * | 643 | * |
240 | @@ -614,16 +645,19 @@ | |||
241 | 614 | **/ | 645 | **/ |
242 | 615 | GtkWidget* | 646 | GtkWidget* |
243 | 616 | ido_scale_menu_item_new (const gchar *label, | 647 | ido_scale_menu_item_new (const gchar *label, |
244 | 648 | IdoRangeStyle range_style, | ||
245 | 617 | GtkAdjustment *adjustment) | 649 | GtkAdjustment *adjustment) |
246 | 618 | { | 650 | { |
247 | 619 | return g_object_new (IDO_TYPE_SCALE_MENU_ITEM, | 651 | return g_object_new (IDO_TYPE_SCALE_MENU_ITEM, |
249 | 620 | "adjustment", adjustment, | 652 | "adjustment", adjustment, |
250 | 653 | "range-style", range_style, | ||
251 | 621 | NULL); | 654 | NULL); |
252 | 622 | } | 655 | } |
253 | 623 | 656 | ||
254 | 624 | /** | 657 | /** |
255 | 625 | * ido_scale_menu_item_new_with_label: | 658 | * ido_scale_menu_item_new_with_label: |
256 | 626 | * @label: the text of the menu item. | 659 | * @label: the text of the menu item. |
257 | 660 | * @size: The size style of the range. | ||
258 | 627 | * @min: The minimum value of the slider. | 661 | * @min: The minimum value of the slider. |
259 | 628 | * @max: The maximum value of the slider. | 662 | * @max: The maximum value of the slider. |
260 | 629 | * @step: The step increment of the slider. | 663 | * @step: The step increment of the slider. |
261 | @@ -632,17 +666,19 @@ | |||
262 | 632 | * Creates a new #IdoScaleMenuItem containing a label. | 666 | * Creates a new #IdoScaleMenuItem containing a label. |
263 | 633 | **/ | 667 | **/ |
264 | 634 | GtkWidget* | 668 | GtkWidget* |
270 | 635 | ido_scale_menu_item_new_with_range (const gchar *label, | 669 | ido_scale_menu_item_new_with_range (const gchar *label, |
271 | 636 | gdouble value, | 670 | IdoRangeStyle range_style, |
272 | 637 | gdouble min, | 671 | gdouble value, |
273 | 638 | gdouble max, | 672 | gdouble min, |
274 | 639 | gdouble step) | 673 | gdouble max, |
275 | 674 | gdouble step) | ||
276 | 640 | { | 675 | { |
277 | 641 | GtkObject *adjustment = gtk_adjustment_new (value, min, max, step, 10 * step, 0); | 676 | GtkObject *adjustment = gtk_adjustment_new (value, min, max, step, 10 * step, 0); |
278 | 642 | 677 | ||
279 | 643 | return g_object_new (IDO_TYPE_SCALE_MENU_ITEM, | 678 | return g_object_new (IDO_TYPE_SCALE_MENU_ITEM, |
282 | 644 | "label", label, | 679 | "label", label, |
283 | 645 | "adjustment", adjustment, | 680 | "range-style", range_style, |
284 | 681 | "adjustment", adjustment, | ||
285 | 646 | NULL); | 682 | NULL); |
286 | 647 | } | 683 | } |
287 | 648 | 684 | ||
288 | 649 | 685 | ||
289 | === modified file 'src/idoscalemenuitem.h' | |||
290 | --- src/idoscalemenuitem.h 2010-07-13 14:45:22 +0000 | |||
291 | +++ src/idoscalemenuitem.h 2010-07-15 13:49:44 +0000 | |||
292 | @@ -27,6 +27,7 @@ | |||
293 | 27 | #define __IDO_SCALE_MENU_ITEM_H__ | 27 | #define __IDO_SCALE_MENU_ITEM_H__ |
294 | 28 | 28 | ||
295 | 29 | #include <gtk/gtkmenuitem.h> | 29 | #include <gtk/gtkmenuitem.h> |
296 | 30 | #include "idorange.h" | ||
297 | 30 | 31 | ||
298 | 31 | G_BEGIN_DECLS | 32 | G_BEGIN_DECLS |
299 | 32 | 33 | ||
300 | @@ -63,8 +64,10 @@ | |||
301 | 63 | 64 | ||
302 | 64 | GType ido_scale_menu_item_get_type (void) G_GNUC_CONST; | 65 | GType ido_scale_menu_item_get_type (void) G_GNUC_CONST; |
303 | 65 | GtkWidget *ido_scale_menu_item_new (const gchar *label, | 66 | GtkWidget *ido_scale_menu_item_new (const gchar *label, |
304 | 67 | IdoRangeStyle size, | ||
305 | 66 | GtkAdjustment *adjustment); | 68 | GtkAdjustment *adjustment); |
306 | 67 | GtkWidget *ido_scale_menu_item_new_with_range (const gchar *label, | 69 | GtkWidget *ido_scale_menu_item_new_with_range (const gchar *label, |
307 | 70 | IdoRangeStyle size, | ||
308 | 68 | gdouble value, | 71 | gdouble value, |
309 | 69 | gdouble min, | 72 | gdouble min, |
310 | 70 | gdouble max, | 73 | gdouble max, |