Merge lp:~charlesk/ido/switch into lp:ido/12.10
- switch
- Merge into trunk.12.10
Status: | Merged |
---|---|
Approved by: | Charles Kerr |
Approved revision: | 118 |
Merged at revision: | 110 |
Proposed branch: | lp:~charlesk/ido/switch |
Merge into: | lp:ido/12.10 |
Diff against target: |
294 lines (+199/-5) 6 files modified
NEWS (+2/-0) configure.ac (+9/-5) example/menus.c (+8/-0) src/Makefile.am (+3/-0) src/idoswitchmenuitem.c (+120/-0) src/idoswitchmenuitem.h (+57/-0) |
To merge this branch: | bzr merge lp:~charlesk/ido/switch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
jenkins (community) | continuous-integration | Needs Fixing | |
Lars Karlitski (community) | Approve | ||
Sebastien Bacher | Needs Fixing | ||
Review via email: mp+120621@code.launchpad.net |
Commit message
Description of the change
Adds the GtkSwitchMenuItem
jenkins (martin-mrazik+qa) wrote : | # |
Sebastien Bacher (seb128) wrote : | # |
seems mostly fine to me, small comment, you use g_object_clear(), you should add a glib >= 2.28 check in configure
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:111
http://
Executed test runs:
FAILURE: http://
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:112
http://
Executed test runs:
FAILURE: http://
Lars Karlitski (larsu) wrote : | # |
Nice hack!
Three problems:
(1) the mouse capture isn't removed after the menu is closed
(2) the menu title is still painted as if the menu was open
(3) the switch handle can also be dragged, this doesn't work in the menu item
I tried for a little bit, but I haven't found a satisfactory solution for (1) and (2) yet. (3) can be solved by forwarding mouse button events from the menu item to the widget (cf. IdoScaleMenuItem).
The get_content_area API is a bit weird. Do we need to put anything other than a label in there?
Also, there's no need to keep the GBinding object around, it will be destroyed automatically.
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:115
http://
Executed test runs:
FAILURE: http://
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:116
http://
Executed test runs:
FAILURE: http://
Lars Karlitski (larsu) wrote : | # |
Approved, but please file a bug with the unfinished event propagation patches so that we don't lose the work you've already done.
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:117
http://
Executed test runs:
FAILURE: http://
Charles Kerr (charlesk) wrote : | # |
event propagation's been filed in a new ticket at Bug #1039840
the CI build is failing because of the gtk2 build in the debian rules, seb128 is working on that.
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:118
http://
Executed test runs:
FAILURE: http://
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Lars Karlitski (larsu) wrote : | # |
Thanks.
Preview Diff
1 | === modified file 'NEWS' | |||
2 | --- NEWS 2010-01-19 22:02:50 +0000 | |||
3 | +++ NEWS 2012-08-22 01:08:21 +0000 | |||
4 | @@ -0,0 +1,2 @@ | |||
5 | 1 | 12.10.0: | ||
6 | 2 | * new widget IdoSwitchMenuItem | ||
7 | 0 | 3 | ||
8 | === modified file 'configure.ac' | |||
9 | --- configure.ac 2012-04-25 20:24:26 +0000 | |||
10 | +++ configure.ac 2012-08-22 01:08:21 +0000 | |||
11 | @@ -1,9 +1,9 @@ | |||
12 | 1 | # | 1 | # |
13 | 2 | # shamelessly stolen from clutter-gtk | 2 | # shamelessly stolen from clutter-gtk |
14 | 3 | # | 3 | # |
18 | 4 | m4_define([ido_major_version], [0]) | 4 | m4_define([ido_major_version], [12]) |
19 | 5 | m4_define([ido_minor_version], [3]) | 5 | m4_define([ido_minor_version], [10]) |
20 | 6 | m4_define([ido_micro_version], [4]) | 6 | m4_define([ido_micro_version], [0]) |
21 | 7 | 7 | ||
22 | 8 | m4_define([ido_api_version], | 8 | m4_define([ido_api_version], |
23 | 9 | [ido_major_version.ido_minor_version]) | 9 | [ido_major_version.ido_minor_version]) |
24 | @@ -78,6 +78,8 @@ | |||
25 | 78 | AC_FUNC_MMAP | 78 | AC_FUNC_MMAP |
26 | 79 | AC_CHECK_FUNCS([memset munmap strcasecmp strdup]) | 79 | AC_CHECK_FUNCS([memset munmap strcasecmp strdup]) |
27 | 80 | 80 | ||
28 | 81 | GLIB_REQUIRED_VERSION=2.32.0 | ||
29 | 82 | |||
30 | 81 | AC_ARG_WITH([gtk], | 83 | AC_ARG_WITH([gtk], |
31 | 82 | [AS_HELP_STRING([--with-gtk], | 84 | [AS_HELP_STRING([--with-gtk], |
32 | 83 | [Which version of gtk to use @<:@default=3@:>@])], | 85 | [Which version of gtk to use @<:@default=3@:>@])], |
33 | @@ -86,9 +88,11 @@ | |||
34 | 86 | AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3]) | 88 | AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3]) |
35 | 87 | 89 | ||
36 | 88 | if test "x$with_gtk" = "x2"; then | 90 | if test "x$with_gtk" = "x2"; then |
38 | 89 | PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.19.7) | 91 | PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.19.7 |
39 | 92 | glib-2.0 >= GLIB_REQUIRED_VERSION]) | ||
40 | 90 | else | 93 | else |
42 | 91 | PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0.0) | 94 | PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= 3.0.0 |
43 | 95 | glib-2.0 >= GLIB_REQUIRED_VERSION]) | ||
44 | 92 | AC_DEFINE_UNQUOTED(USE_GTK3, , [Use GTK3]) | 96 | AC_DEFINE_UNQUOTED(USE_GTK3, , [Use GTK3]) |
45 | 93 | fi | 97 | fi |
46 | 94 | AC_SUBST(GTK_CFLAGS) | 98 | AC_SUBST(GTK_CFLAGS) |
47 | 95 | 99 | ||
48 | === modified file 'example/menus.c' | |||
49 | --- example/menus.c 2011-12-14 17:19:26 +0000 | |||
50 | +++ example/menus.c 2012-08-22 01:08:21 +0000 | |||
51 | @@ -3,6 +3,7 @@ | |||
52 | 3 | #include "idoscalemenuitem.h" | 3 | #include "idoscalemenuitem.h" |
53 | 4 | #include "idocalendarmenuitem.h" | 4 | #include "idocalendarmenuitem.h" |
54 | 5 | #include "idoentrymenuitem.h" | 5 | #include "idoentrymenuitem.h" |
55 | 6 | #include "idoswitchmenuitem.h" | ||
56 | 6 | #include "config.h" | 7 | #include "config.h" |
57 | 7 | 8 | ||
58 | 8 | static void | 9 | static void |
59 | @@ -27,6 +28,7 @@ | |||
60 | 27 | GtkWidget *root; | 28 | GtkWidget *root; |
61 | 28 | GtkWidget *menubar; | 29 | GtkWidget *menubar; |
62 | 29 | GtkWidget *image; | 30 | GtkWidget *image; |
63 | 31 | GtkWidget *label; | ||
64 | 30 | 32 | ||
65 | 31 | g_unsetenv ("UBUNTU_MENUPROXY"); | 33 | g_unsetenv ("UBUNTU_MENUPROXY"); |
66 | 32 | 34 | ||
67 | @@ -76,6 +78,12 @@ | |||
68 | 76 | menuitem = ido_entry_menu_item_new (); | 78 | menuitem = ido_entry_menu_item_new (); |
69 | 77 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); | 79 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); |
70 | 78 | 80 | ||
71 | 81 | menuitem = ido_switch_menu_item_new (); | ||
72 | 82 | label = gtk_label_new ("This is a switch"); | ||
73 | 83 | gtk_widget_show(label); | ||
74 | 84 | gtk_container_add (ido_switch_menu_item_get_content_area(IDO_SWITCH_MENU_ITEM(menuitem)), label); | ||
75 | 85 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); | ||
76 | 86 | |||
77 | 79 | menuitem = ido_calendar_menu_item_new (); | 87 | menuitem = ido_calendar_menu_item_new (); |
78 | 80 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); | 88 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); |
79 | 81 | 89 | ||
80 | 82 | 90 | ||
81 | === modified file 'src/Makefile.am' | |||
82 | --- src/Makefile.am 2012-04-12 15:18:01 +0000 | |||
83 | +++ src/Makefile.am 2012-08-22 01:08:21 +0000 | |||
84 | @@ -19,6 +19,7 @@ | |||
85 | 19 | idomessagedialog.h \ | 19 | idomessagedialog.h \ |
86 | 20 | idorange.h \ | 20 | idorange.h \ |
87 | 21 | idoscalemenuitem.h \ | 21 | idoscalemenuitem.h \ |
88 | 22 | idoswitchmenuitem.h \ | ||
89 | 22 | idotimeline.h \ | 23 | idotimeline.h \ |
90 | 23 | libido.h | 24 | libido.h |
91 | 24 | 25 | ||
92 | @@ -67,6 +68,7 @@ | |||
93 | 67 | idomessagedialog.c \ | 68 | idomessagedialog.c \ |
94 | 68 | idorange.c \ | 69 | idorange.c \ |
95 | 69 | idoscalemenuitem.c \ | 70 | idoscalemenuitem.c \ |
96 | 71 | idoswitchmenuitem.c \ | ||
97 | 70 | idotimeline.c | 72 | idotimeline.c |
98 | 71 | 73 | ||
99 | 72 | libido3_0_1_la_SOURCES = $(libido_0_1_la_SOURCES) | 74 | libido3_0_1_la_SOURCES = $(libido_0_1_la_SOURCES) |
100 | @@ -79,6 +81,7 @@ | |||
101 | 79 | idomessagedialog.h \ | 81 | idomessagedialog.h \ |
102 | 80 | idorange.h \ | 82 | idorange.h \ |
103 | 81 | idoscalemenuitem.h \ | 83 | idoscalemenuitem.h \ |
104 | 84 | idoswitchmenuitem.h \ | ||
105 | 82 | idotimeline.h \ | 85 | idotimeline.h \ |
106 | 83 | libido.h | 86 | libido.h |
107 | 84 | 87 | ||
108 | 85 | 88 | ||
109 | === added file 'src/idoswitchmenuitem.c' | |||
110 | --- src/idoswitchmenuitem.c 1970-01-01 00:00:00 +0000 | |||
111 | +++ src/idoswitchmenuitem.c 2012-08-22 01:08:21 +0000 | |||
112 | @@ -0,0 +1,120 @@ | |||
113 | 1 | /* | ||
114 | 2 | * A GtkCheckMenuItem that uses a GtkSwitch to show its 'active' property | ||
115 | 3 | * | ||
116 | 4 | * Copyright © 2012 Canonical Ltd. | ||
117 | 5 | * | ||
118 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
119 | 7 | * under the terms of the GNU General Public License version 3, as | ||
120 | 8 | * published by the Free Software Foundation. | ||
121 | 9 | * | ||
122 | 10 | * This program is distributed in the hope that it will be useful, but | ||
123 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
124 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
125 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
126 | 14 | * | ||
127 | 15 | * You should have received a copy of the GNU General Public License along | ||
128 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
129 | 17 | * | ||
130 | 18 | * Author: Charles Kerr <charles.kerr@canonical.com> | ||
131 | 19 | */ | ||
132 | 20 | |||
133 | 21 | #include "config.h" | ||
134 | 22 | |||
135 | 23 | #include "idoswitchmenuitem.h" | ||
136 | 24 | |||
137 | 25 | static gboolean ido_switch_menu_button_release_event (GtkWidget * widget, | ||
138 | 26 | GdkEventButton * event); | ||
139 | 27 | |||
140 | 28 | |||
141 | 29 | struct _IdoSwitchMenuItemPrivate | ||
142 | 30 | { | ||
143 | 31 | GtkWidget * box; | ||
144 | 32 | GtkWidget * content_area; | ||
145 | 33 | GtkWidget * switch_w; | ||
146 | 34 | }; | ||
147 | 35 | |||
148 | 36 | /*** | ||
149 | 37 | **** Life Cycle | ||
150 | 38 | ***/ | ||
151 | 39 | |||
152 | 40 | G_DEFINE_TYPE (IdoSwitchMenuItem, ido_switch_menu_item, GTK_TYPE_CHECK_MENU_ITEM) | ||
153 | 41 | |||
154 | 42 | static void | ||
155 | 43 | ido_switch_menu_item_class_init (IdoSwitchMenuItemClass *klass) | ||
156 | 44 | { | ||
157 | 45 | GObjectClass * gobject_class; | ||
158 | 46 | GtkWidgetClass * widget_class; | ||
159 | 47 | GtkCheckMenuItemClass * check_class; | ||
160 | 48 | |||
161 | 49 | gobject_class = G_OBJECT_CLASS (klass); | ||
162 | 50 | g_type_class_add_private (gobject_class, sizeof (IdoSwitchMenuItemPrivate)); | ||
163 | 51 | |||
164 | 52 | widget_class = GTK_WIDGET_CLASS (klass); | ||
165 | 53 | widget_class->button_release_event = ido_switch_menu_button_release_event; | ||
166 | 54 | |||
167 | 55 | check_class = GTK_CHECK_MENU_ITEM_CLASS (klass); | ||
168 | 56 | check_class->draw_indicator = NULL; | ||
169 | 57 | } | ||
170 | 58 | |||
171 | 59 | static void | ||
172 | 60 | ido_switch_menu_item_init (IdoSwitchMenuItem *item) | ||
173 | 61 | { | ||
174 | 62 | IdoSwitchMenuItemPrivate *priv; | ||
175 | 63 | |||
176 | 64 | priv = item->priv = G_TYPE_INSTANCE_GET_PRIVATE (item, IDO_TYPE_SWITCH_MENU_ITEM, IdoSwitchMenuItemPrivate); | ||
177 | 65 | priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); | ||
178 | 66 | priv->content_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); | ||
179 | 67 | priv->switch_w = gtk_switch_new (); | ||
180 | 68 | |||
181 | 69 | gtk_box_pack_start (GTK_BOX (priv->box), priv->content_area, TRUE, TRUE, 0); | ||
182 | 70 | gtk_box_pack_end (GTK_BOX (priv->box), priv->switch_w, FALSE, FALSE, 0); | ||
183 | 71 | gtk_container_add (GTK_CONTAINER (item), priv->box); | ||
184 | 72 | gtk_widget_show_all (priv->box); | ||
185 | 73 | |||
186 | 74 | g_object_bind_property (item, "active", | ||
187 | 75 | priv->switch_w, "active", | ||
188 | 76 | G_BINDING_SYNC_CREATE); | ||
189 | 77 | } | ||
190 | 78 | |||
191 | 79 | /*** | ||
192 | 80 | **** Don't popdown the menu immediately after clicking on a switch... | ||
193 | 81 | **** wait a moment so the user can see the GtkSwitch be toggled. | ||
194 | 82 | ***/ | ||
195 | 83 | |||
196 | 84 | static gboolean | ||
197 | 85 | popdown_later_cb (gpointer widget) | ||
198 | 86 | { | ||
199 | 87 | GtkWidget * parent = gtk_widget_get_parent (widget); | ||
200 | 88 | if (GTK_IS_MENU (parent)) | ||
201 | 89 | { | ||
202 | 90 | gtk_menu_shell_deactivate (GTK_MENU_SHELL(parent)); | ||
203 | 91 | } | ||
204 | 92 | g_object_unref (widget); | ||
205 | 93 | return FALSE; /* only call this cb once */ | ||
206 | 94 | } | ||
207 | 95 | |||
208 | 96 | static gboolean | ||
209 | 97 | ido_switch_menu_button_release_event (GtkWidget * widget, GdkEventButton * event) | ||
210 | 98 | { | ||
211 | 99 | gtk_menu_item_activate (GTK_MENU_ITEM(widget)); | ||
212 | 100 | g_timeout_add (500, popdown_later_cb, g_object_ref(widget)); | ||
213 | 101 | return TRUE; /* stop the event so that it doesn't trigger popdown() */ | ||
214 | 102 | } | ||
215 | 103 | |||
216 | 104 | /*** | ||
217 | 105 | **** Public API | ||
218 | 106 | ***/ | ||
219 | 107 | |||
220 | 108 | GtkWidget * | ||
221 | 109 | ido_switch_menu_item_new (void) | ||
222 | 110 | { | ||
223 | 111 | return g_object_new (IDO_TYPE_SWITCH_MENU_ITEM, NULL); | ||
224 | 112 | } | ||
225 | 113 | |||
226 | 114 | GtkContainer * | ||
227 | 115 | ido_switch_menu_item_get_content_area (IdoSwitchMenuItem * item) | ||
228 | 116 | { | ||
229 | 117 | g_return_val_if_fail (IDO_IS_SWITCH_MENU_ITEM(item), NULL); | ||
230 | 118 | |||
231 | 119 | return GTK_CONTAINER (item->priv->content_area); | ||
232 | 120 | } | ||
233 | 0 | 121 | ||
234 | === added file 'src/idoswitchmenuitem.h' | |||
235 | --- src/idoswitchmenuitem.h 1970-01-01 00:00:00 +0000 | |||
236 | +++ src/idoswitchmenuitem.h 2012-08-22 01:08:21 +0000 | |||
237 | @@ -0,0 +1,57 @@ | |||
238 | 1 | /* | ||
239 | 2 | * A GtkCheckMenuItem that uses a GtkSwitch to show its 'active' property. | ||
240 | 3 | * | ||
241 | 4 | * Copyright © 2012 Canonical Ltd. | ||
242 | 5 | * | ||
243 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
244 | 7 | * under the terms of the GNU General Public License version 3, as | ||
245 | 8 | * published by the Free Software Foundation. | ||
246 | 9 | * | ||
247 | 10 | * This program is distributed in the hope that it will be useful, but | ||
248 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
249 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
250 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
251 | 14 | * | ||
252 | 15 | * You should have received a copy of the GNU General Public License along | ||
253 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
254 | 17 | * | ||
255 | 18 | * Author: Charles Kerr <charles.kerr@canonical.com> | ||
256 | 19 | */ | ||
257 | 20 | |||
258 | 21 | #ifndef __IDO_SWITCH_MENU_ITEM_H__ | ||
259 | 22 | #define __IDO_SWITCH_MENU_ITEM_H__ | ||
260 | 23 | |||
261 | 24 | #include <gtk/gtk.h> | ||
262 | 25 | |||
263 | 26 | G_BEGIN_DECLS | ||
264 | 27 | |||
265 | 28 | #define IDO_TYPE_SWITCH_MENU_ITEM (ido_switch_menu_item_get_type ()) | ||
266 | 29 | #define IDO_SWITCH_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_SWITCH_MENU_ITEM, IdoSwitchMenuItem)) | ||
267 | 30 | #define IDO_SWITCH_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), IDO_TYPE_SWITCH_MENU_ITEM, IdoSwitchMenuItemClass)) | ||
268 | 31 | #define IDO_IS_SWITCH_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), IDO_TYPE_SWITCH_MENU_ITEM)) | ||
269 | 32 | #define IDO_IS_SWITCH_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), IDO_TYPE_SWITCH_MENU_ITEM)) | ||
270 | 33 | #define IDO_SWITCH_MENU_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), IDO_TYPE_SWITCH_MENU_ITEM, IdoSwitchMenuItemClass)) | ||
271 | 34 | |||
272 | 35 | typedef struct _IdoSwitchMenuItem IdoSwitchMenuItem; | ||
273 | 36 | typedef struct _IdoSwitchMenuItemClass IdoSwitchMenuItemClass; | ||
274 | 37 | typedef struct _IdoSwitchMenuItemPrivate IdoSwitchMenuItemPrivate; | ||
275 | 38 | |||
276 | 39 | struct _IdoSwitchMenuItem | ||
277 | 40 | { | ||
278 | 41 | GtkCheckMenuItem parent_instance; | ||
279 | 42 | |||
280 | 43 | IdoSwitchMenuItemPrivate *priv; | ||
281 | 44 | }; | ||
282 | 45 | |||
283 | 46 | struct _IdoSwitchMenuItemClass | ||
284 | 47 | { | ||
285 | 48 | GtkCheckMenuItemClass parent_class; | ||
286 | 49 | }; | ||
287 | 50 | |||
288 | 51 | GType ido_switch_menu_item_get_type (void) G_GNUC_CONST; | ||
289 | 52 | GtkWidget *ido_switch_menu_item_new (void); | ||
290 | 53 | GtkContainer *ido_switch_menu_item_get_content_area (IdoSwitchMenuItem * item); | ||
291 | 54 | |||
292 | 55 | G_END_DECLS | ||
293 | 56 | |||
294 | 57 | #endif /* __IDO_SWITCH_MENU_ITEM_H__ */ |
FAILED: Continuous integration, rev:110 jenkins. qa.ubuntu. com/job/ ido-ci/ 5/ jenkins. qa.ubuntu. com/job/ ido-ci/ ./label= quantal/ 5/console
http://
Executed test runs:
FAILURE: http://