Merge lp:~ted/hud/insensitive-items into lp:hud/13.10

Proposed by Ted Gould
Status: Merged
Approved by: Lars Karlitski
Approved revision: 346
Merged at revision: 340
Proposed branch: lp:~ted/hud/insensitive-items
Merge into: lp:hud/13.10
Diff against target: 154 lines (+65/-43)
3 files modified
src/menumodel-collector.c (+19/-8)
tests/test-menu-input-model-shortcuts.c (+1/-0)
tests/test-menu-input-model-simple.c (+45/-35)
To merge this branch: bzr merge lp:~ted/hud/insensitive-items
Reviewer Review Type Date Requested Status
Lars Karlitski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+191512@code.launchpad.net

Commit message

Don't show disabled items in search results

Description of the change

Wow. Turns out there was a bug in the test-suite with how it built all of the actions in application mode as well. Made fixing this much harder than expected :-)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

Approving, despite the inconsistent brace placement :P

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/menumodel-collector.c'
2--- src/menumodel-collector.c 2013-10-09 09:15:55 +0000
3+++ src/menumodel-collector.c 2013-10-16 21:45:04 +0000
4@@ -934,15 +934,20 @@
5 for (i = 0; i < items->len; i++)
6 {
7 HudResult *result;
8- HudItem *item;
9+ HudModelItem *item;
10
11 item = g_ptr_array_index (items, i);
12
13- if (search_string == NULL && hud_model_item_is_toolbar(HUD_MODEL_ITEM(item))) {
14- continue;
15- }
16-
17- result = hud_result_get_if_matched (item, search_string, collector->penalty);
18+ if (!g_action_group_get_action_enabled(G_ACTION_GROUP(item->group), item->action_name))
19+ {
20+ continue;
21+ }
22+
23+ if (search_string == NULL && hud_model_item_is_toolbar(item)) {
24+ continue;
25+ }
26+
27+ result = hud_result_get_if_matched (HUD_ITEM(item), search_string, collector->penalty);
28 if (result)
29 append_func(result, user_data);
30 }
31@@ -963,10 +968,16 @@
32 for (i = 0; i < items->len; i++)
33 {
34 HudResult *result;
35- HudItem *item;
36+ HudModelItem *item;
37
38 item = g_ptr_array_index (items, i);
39- result = hud_result_get_if_matched (item, search_string, collector->penalty);
40+
41+ if (!g_action_group_get_action_enabled(G_ACTION_GROUP(item->group), item->action_name))
42+ {
43+ continue;
44+ }
45+
46+ result = hud_result_get_if_matched (HUD_ITEM(item), search_string, collector->penalty);
47 if (result) {
48 append_func(collector->app_id, collector->icon, collector->type, user_data);
49 g_object_unref(result);
50
51=== modified file 'tests/test-menu-input-model-shortcuts.c'
52--- tests/test-menu-input-model-shortcuts.c 2013-08-22 02:07:03 +0000
53+++ tests/test-menu-input-model-shortcuts.c 2013-10-16 21:45:04 +0000
54@@ -54,6 +54,7 @@
55 g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("save", G_VARIANT_TYPE_BOOLEAN)));
56 g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("quiter", G_VARIANT_TYPE_BOOLEAN)));
57 g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("close", G_VARIANT_TYPE_BOOLEAN)));
58+ g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("nothing", G_VARIANT_TYPE_BOOLEAN)));
59
60 GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
61
62
63=== modified file 'tests/test-menu-input-model-simple.c'
64--- tests/test-menu-input-model-simple.c 2013-08-22 02:07:03 +0000
65+++ tests/test-menu-input-model-simple.c 2013-10-16 21:45:04 +0000
66@@ -23,43 +23,53 @@
67 int
68 main (int argv, char ** argc)
69 {
70- if (!(argv == 3 || argv == 4)) {
71- g_print("'%s <DBus name> <Object Path> [Is Application]' is how you should use this program.\n", argc[0]);
72- return 1;
73- }
74+ if (!(argv == 3 || argv == 4)) {
75+ g_print("'%s <DBus name> <Object Path> [Is Application]' is how you should use this program.\n", argc[0]);
76+ return 1;
77+ }
78
79 #ifndef GLIB_VERSION_2_36
80- g_type_init ();
81+ g_type_init ();
82 #endif
83
84- gboolean is_application = (argv == 4 && !g_strcmp0(argc[3], "TRUE"));
85-
86- GMenu * menu = g_menu_new();
87- GMenuItem * item = NULL;
88- if (is_application)
89- item = g_menu_item_new("Simple", "app.simple");
90- else
91- item = g_menu_item_new("Simple", "simple");
92-
93- g_menu_item_set_attribute_value(item, "description", g_variant_new_string("A simple description"));
94- g_menu_item_set_attribute_value(item, "keywords", g_variant_new_string("hard;difficult;;challenging;"));
95- g_menu_append_item(menu, item);
96-
97- GSimpleActionGroup * ag = g_simple_action_group_new();
98- if (is_application)
99- g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("app.simple", G_VARIANT_TYPE_BOOLEAN)));
100- else
101- g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("simple", G_VARIANT_TYPE_BOOLEAN)));
102-
103- GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
104-
105- g_dbus_connection_export_action_group(session, argc[2], G_ACTION_GROUP(ag), NULL);
106- g_dbus_connection_export_menu_model(session, argc[2], G_MENU_MODEL(menu), NULL);
107-
108- g_bus_own_name(G_BUS_TYPE_SESSION, argc[1], 0, NULL, NULL, NULL, NULL, NULL);
109-
110- GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);
111- g_main_loop_run(mainloop);
112-
113- return 0;
114+ gboolean is_application = (argv == 4 && !g_strcmp0(argc[3], "TRUE"));
115+
116+ GMenu * menu = g_menu_new();
117+ GMenuItem * item = NULL;
118+ GMenuItem * ditem = NULL;
119+ if (is_application) {
120+ item = g_menu_item_new("Simple", "app.simple");
121+ ditem = g_menu_item_new("Disable", "app.disable");
122+ } else {
123+ item = g_menu_item_new("Simple", "simple");
124+ ditem = g_menu_item_new("Disable", "disable");
125+ }
126+
127+ g_menu_item_set_attribute_value(item, "description", g_variant_new_string("A simple description"));
128+ g_menu_item_set_attribute_value(item, "keywords", g_variant_new_string("hard;difficult;;challenging;"));
129+ g_menu_append_item(menu, item);
130+ g_menu_append_item(menu, ditem);
131+
132+ GSimpleActionGroup * ag = g_simple_action_group_new();
133+ g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("simple", G_VARIANT_TYPE_BOOLEAN)));
134+
135+ GSimpleAction * disable = g_simple_action_new("disable", NULL);
136+ g_simple_action_set_enabled(disable, FALSE);
137+ g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(disable));
138+
139+ GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
140+
141+ g_debug("Exporting Simple Action Group");
142+ g_dbus_connection_export_action_group(session, argc[2], G_ACTION_GROUP(ag), NULL);
143+ g_debug("Exporting Simple Menu");
144+ g_dbus_connection_export_menu_model(session, argc[2], G_MENU_MODEL(menu), NULL);
145+
146+ g_debug("Investing in name ownership '%s'", argc[1]);
147+ g_bus_own_name(G_BUS_TYPE_SESSION, argc[1], 0, NULL, NULL, NULL, NULL, NULL);
148+
149+ g_debug("Looping");
150+ GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);
151+ g_main_loop_run(mainloop);
152+
153+ return 0;
154 }

Subscribers

People subscribed via source and target branches