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 | menuitem = gtk_menu_item_new_with_label ("Open"); |
6 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); |
7 | |
8 | - menuitem = ido_scale_menu_item_new_with_range ("Volume", 65, 0, 100, 1); |
9 | + menuitem = ido_scale_menu_item_new_with_range ("Volume", |
10 | + IDO_RANGE_STYLE_DEFAULT, |
11 | + 65, 0, 100, 1); |
12 | ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM (menuitem), IDO_SCALE_MENU_ITEM_STYLE_IMAGE); |
13 | image = ido_scale_menu_item_get_primary_image (IDO_SCALE_MENU_ITEM (menuitem)); |
14 | gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); |
15 | |
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 | static void ido_scale_menu_item_notify (IdoScaleMenuItem *item, |
21 | GParamSpec *pspec, |
22 | gpointer user_data); |
23 | +static void update_packing (IdoScaleMenuItem *self, |
24 | + IdoScaleMenuItemStyle style, |
25 | + IdoScaleMenuItemStyle old_style); |
26 | |
27 | struct _IdoScaleMenuItemPrivate { |
28 | GtkWidget *scale; |
29 | @@ -66,6 +69,7 @@ |
30 | gboolean reverse_scroll; |
31 | gboolean grabbed; |
32 | IdoScaleMenuItemStyle style; |
33 | + IdoRangeStyle range_style; |
34 | }; |
35 | |
36 | enum { |
37 | @@ -78,7 +82,8 @@ |
38 | PROP_0, |
39 | PROP_ADJUSTMENT, |
40 | PROP_REVERSE_SCROLL_EVENTS, |
41 | - PROP_STYLE |
42 | + PROP_STYLE, |
43 | + PROP_RANGE_STYLE |
44 | }; |
45 | |
46 | static guint signals[LAST_SIGNAL] = { 0 }; |
47 | @@ -193,32 +198,87 @@ |
48 | } |
49 | |
50 | static void |
51 | +ido_scale_menu_item_constructed (GObject *object) |
52 | +{ |
53 | + IdoScaleMenuItem *self = IDO_SCALE_MENU_ITEM (object); |
54 | + IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); |
55 | + GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0)); |
56 | + IdoRangeStyle range_style; |
57 | + GtkWidget *hbox; |
58 | + |
59 | + priv->adjustment = NULL; |
60 | + |
61 | + g_object_get (self, |
62 | + "range-style", &range_style, |
63 | + NULL); |
64 | + |
65 | + priv->scale = ido_range_new (adj, range_style); |
66 | + g_object_ref (priv->scale); |
67 | + gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE); |
68 | + |
69 | + hbox = gtk_hbox_new (FALSE, 0); |
70 | + |
71 | + priv->primary_image = gtk_image_new (); |
72 | + g_signal_connect (priv->primary_image, "notify", |
73 | + G_CALLBACK (ido_scale_menu_item_primary_image_notify), |
74 | + self); |
75 | + |
76 | + priv->secondary_image = gtk_image_new (); |
77 | + g_signal_connect (priv->secondary_image, "notify", |
78 | + G_CALLBACK (ido_scale_menu_item_secondary_image_notify), |
79 | + self); |
80 | + |
81 | + priv->primary_label = gtk_label_new (""); |
82 | + priv->secondary_label = gtk_label_new (""); |
83 | + |
84 | + priv->hbox = hbox; |
85 | + |
86 | + update_packing (self, priv->style, priv->style); |
87 | + |
88 | + g_signal_connect (self, "notify", |
89 | + G_CALLBACK (ido_scale_menu_item_notify), |
90 | + NULL); |
91 | + |
92 | + gtk_container_add (GTK_CONTAINER (self), hbox); |
93 | +} |
94 | + |
95 | +static void |
96 | ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class) |
97 | { |
98 | GObjectClass *gobject_class = G_OBJECT_CLASS (item_class); |
99 | GtkObjectClass *object_class = GTK_OBJECT_CLASS (item_class); |
100 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (item_class); |
101 | |
102 | - widget_class->button_press_event = ido_scale_menu_item_button_press_event; |
103 | + widget_class->button_press_event = ido_scale_menu_item_button_press_event; |
104 | widget_class->button_release_event = ido_scale_menu_item_button_release_event; |
105 | - widget_class->motion_notify_event = ido_scale_menu_item_motion_notify_event; |
106 | - widget_class->scroll_event = ido_scale_menu_item_scroll_event; |
107 | - widget_class->state_changed = ido_scale_menu_item_state_changed; |
108 | - widget_class->size_allocate = ido_scale_menu_item_size_allocate; |
109 | + widget_class->motion_notify_event = ido_scale_menu_item_motion_notify_event; |
110 | + widget_class->scroll_event = ido_scale_menu_item_scroll_event; |
111 | + widget_class->state_changed = ido_scale_menu_item_state_changed; |
112 | + widget_class->size_allocate = ido_scale_menu_item_size_allocate; |
113 | |
114 | + gobject_class->constructed = ido_scale_menu_item_constructed; |
115 | gobject_class->set_property = ido_scale_menu_item_set_property; |
116 | gobject_class->get_property = ido_scale_menu_item_get_property; |
117 | |
118 | g_object_class_install_property (gobject_class, |
119 | PROP_STYLE, |
120 | - g_param_spec_enum ("range-style", |
121 | - "Range style", |
122 | - "The style of the range", |
123 | + g_param_spec_enum ("accessory-style", |
124 | + "Style of primary/secondary widgets", |
125 | + "The style of the primary/secondary widgets", |
126 | IDO_TYPE_SCALE_MENU_ITEM_STYLE, |
127 | IDO_SCALE_MENU_ITEM_STYLE_NONE, |
128 | G_PARAM_READWRITE)); |
129 | |
130 | g_object_class_install_property (gobject_class, |
131 | + PROP_RANGE_STYLE, |
132 | + g_param_spec_enum ("range-style", |
133 | + "Range style", |
134 | + "Style of the range", |
135 | + IDO_TYPE_RANGE_STYLE, |
136 | + IDO_RANGE_STYLE_DEFAULT, |
137 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
138 | + |
139 | + g_object_class_install_property (gobject_class, |
140 | PROP_ADJUSTMENT, |
141 | g_param_spec_object ("adjustment", |
142 | "Adjustment", |
143 | @@ -259,11 +319,6 @@ |
144 | IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); |
145 | GtkContainer *container = GTK_CONTAINER (priv->hbox); |
146 | |
147 | - g_print ("%s %s %s\n", |
148 | - G_OBJECT_TYPE_NAME (priv->primary_image), |
149 | - G_OBJECT_TYPE_NAME (priv->scale), |
150 | - G_OBJECT_TYPE_NAME (priv->secondary_image)); |
151 | - |
152 | if (style != old_style) |
153 | { |
154 | switch (old_style) |
155 | @@ -319,40 +374,6 @@ |
156 | static void |
157 | ido_scale_menu_item_init (IdoScaleMenuItem *self) |
158 | { |
159 | - IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); |
160 | - GtkWidget *hbox; |
161 | - GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0)); |
162 | - |
163 | - priv->adjustment = NULL; |
164 | - |
165 | - priv->scale = ido_range_new (adj, IDO_RANGE_STYLE_SMALL); |
166 | - g_object_ref (priv->scale); |
167 | - gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE); |
168 | - |
169 | - hbox = gtk_hbox_new (FALSE, 0); |
170 | - |
171 | - priv->primary_image = gtk_image_new (); |
172 | - g_signal_connect (priv->primary_image, "notify", |
173 | - G_CALLBACK (ido_scale_menu_item_primary_image_notify), |
174 | - self); |
175 | - |
176 | - priv->secondary_image = gtk_image_new (); |
177 | - g_signal_connect (priv->secondary_image, "notify", |
178 | - G_CALLBACK (ido_scale_menu_item_secondary_image_notify), |
179 | - self); |
180 | - |
181 | - priv->primary_label = gtk_label_new (""); |
182 | - priv->secondary_label = gtk_label_new (""); |
183 | - |
184 | - priv->hbox = hbox; |
185 | - |
186 | - update_packing (self, priv->style, priv->style); |
187 | - |
188 | - g_signal_connect (self, "notify", |
189 | - G_CALLBACK (ido_scale_menu_item_notify), |
190 | - NULL); |
191 | - |
192 | - gtk_container_add (GTK_CONTAINER (self), hbox); |
193 | } |
194 | |
195 | static void |
196 | @@ -378,6 +399,10 @@ |
197 | ido_scale_menu_item_set_style (menu_item, g_value_get_enum (value)); |
198 | break; |
199 | |
200 | + case PROP_RANGE_STYLE: |
201 | + priv->range_style = g_value_get_enum (value); |
202 | + break; |
203 | + |
204 | default: |
205 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
206 | break; |
207 | @@ -392,11 +417,12 @@ |
208 | { |
209 | IdoScaleMenuItem *menu_item = IDO_SCALE_MENU_ITEM (object); |
210 | IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menu_item); |
211 | - GtkAdjustment *adjustment = gtk_range_get_adjustment (GTK_RANGE (priv->scale)); |
212 | + GtkAdjustment *adjustment; |
213 | |
214 | switch (prop_id) |
215 | { |
216 | case PROP_ADJUSTMENT: |
217 | + adjustment = gtk_range_get_adjustment (GTK_RANGE (priv->scale)); |
218 | g_value_set_object (value, adjustment); |
219 | break; |
220 | |
221 | @@ -404,6 +430,10 @@ |
222 | g_value_set_boolean (value, priv->reverse_scroll); |
223 | break; |
224 | |
225 | + case PROP_RANGE_STYLE: |
226 | + g_value_set_enum (value, priv->range_style); |
227 | + break; |
228 | + |
229 | default: |
230 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
231 | break; |
232 | @@ -607,6 +637,7 @@ |
233 | /** |
234 | * ido_scale_menu_item_new: |
235 | * @label: the text of the new menu item. |
236 | + * @size: The size style of the range. |
237 | * @adjustment: A #GtkAdjustment describing the slider value. |
238 | * @returns: a new #IdoScaleMenuItem. |
239 | * |
240 | @@ -614,16 +645,19 @@ |
241 | **/ |
242 | GtkWidget* |
243 | ido_scale_menu_item_new (const gchar *label, |
244 | + IdoRangeStyle range_style, |
245 | GtkAdjustment *adjustment) |
246 | { |
247 | return g_object_new (IDO_TYPE_SCALE_MENU_ITEM, |
248 | - "adjustment", adjustment, |
249 | + "adjustment", adjustment, |
250 | + "range-style", range_style, |
251 | NULL); |
252 | } |
253 | |
254 | /** |
255 | * ido_scale_menu_item_new_with_label: |
256 | * @label: the text of the menu item. |
257 | + * @size: The size style of the range. |
258 | * @min: The minimum value of the slider. |
259 | * @max: The maximum value of the slider. |
260 | * @step: The step increment of the slider. |
261 | @@ -632,17 +666,19 @@ |
262 | * Creates a new #IdoScaleMenuItem containing a label. |
263 | **/ |
264 | GtkWidget* |
265 | -ido_scale_menu_item_new_with_range (const gchar *label, |
266 | - gdouble value, |
267 | - gdouble min, |
268 | - gdouble max, |
269 | - gdouble step) |
270 | +ido_scale_menu_item_new_with_range (const gchar *label, |
271 | + IdoRangeStyle range_style, |
272 | + gdouble value, |
273 | + gdouble min, |
274 | + gdouble max, |
275 | + gdouble step) |
276 | { |
277 | GtkObject *adjustment = gtk_adjustment_new (value, min, max, step, 10 * step, 0); |
278 | |
279 | return g_object_new (IDO_TYPE_SCALE_MENU_ITEM, |
280 | - "label", label, |
281 | - "adjustment", adjustment, |
282 | + "label", label, |
283 | + "range-style", range_style, |
284 | + "adjustment", adjustment, |
285 | NULL); |
286 | } |
287 | |
288 | |
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 | #define __IDO_SCALE_MENU_ITEM_H__ |
294 | |
295 | #include <gtk/gtkmenuitem.h> |
296 | +#include "idorange.h" |
297 | |
298 | G_BEGIN_DECLS |
299 | |
300 | @@ -63,8 +64,10 @@ |
301 | |
302 | GType ido_scale_menu_item_get_type (void) G_GNUC_CONST; |
303 | GtkWidget *ido_scale_menu_item_new (const gchar *label, |
304 | + IdoRangeStyle size, |
305 | GtkAdjustment *adjustment); |
306 | GtkWidget *ido_scale_menu_item_new_with_range (const gchar *label, |
307 | + IdoRangeStyle size, |
308 | gdouble value, |
309 | gdouble min, |
310 | gdouble max, |