Merge lp:~3v1n0/unity/positionless-indicator-keynav into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3531
Proposed branch: lp:~3v1n0/unity/positionless-indicator-keynav
Merge into: lp:unity
Diff against target: 164 lines (+54/-12)
2 files modified
CMakeLists.txt (+2/-1)
services/panel-service.c (+52/-11)
To merge this branch: bzr merge lp:~3v1n0/unity/positionless-indicator-keynav
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+187125@code.launchpad.net

Commit message

PanelService: set proper priority for floating position-less NG indicators

Description of the change

Add a new fake kind of indicators to the indicator_order list: "floating-indicators"
this will match all the NG indicators with no position set (such as the keyboard
indicator) and will set the proper priority to the floating indicators we find.

Also use libindicator prefix by default as indicators path.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Freaking TestIconLoader tests...re-approving.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Come on Jenkins, get it together Man!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-08-30 19:03:49 +0000
3+++ CMakeLists.txt 2013-09-24 00:27:43 +0000
4@@ -155,12 +155,13 @@
5 set (VERSION "${UNITY_VERSION}")
6 set (BUILDDIR "${CMAKE_BINARY_DIR}")
7 set (TESTDATADIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/data")
8-set (INDICATOR_SERVICE_DIR "${CMAKE_INSTALL_PREFIX}/share/unity/indicators")
9
10 find_package (PkgConfig)
11 execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} unity --variable lensesdir OUTPUT_VARIABLE LENSES_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
12 execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator3-0.4 --variable indicatordir OUTPUT_VARIABLE INDICATORDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
13 execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator3-0.4 --variable iconsdir OUTPUT_VARIABLE INDICATORICONDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
14+execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator3-0.4 --variable prefix OUTPUT_VARIABLE INDICATORPREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
15+set (INDICATOR_SERVICE_DIR "${INDICATORPREFIX}/share/unity/indicators")
16
17 configure_file (${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
18
19
20=== modified file 'services/panel-service.c'
21--- services/panel-service.c 2013-09-13 09:04:15 +0000
22+++ services/panel-service.c 2013-09-24 00:27:43 +0000
23@@ -108,6 +108,7 @@
24 static const gchar * indicator_order[][2] = {
25 {"libappmenu.so", NULL}, /* indicator-appmenu" */
26 {"libapplication.so", NULL}, /* indicator-application" */
27+ {"floating-indicators", NULL}, /* position-less NG indicators */
28 {"libprintersmenu.so", NULL}, /* indicator-printers */
29 {"libsyncindicator.so", NULL}, /* indicator-sync */
30 {"libapplication.so", "gsd-keyboard-xkb"}, /* keyboard layout selector */
31@@ -154,10 +155,11 @@
32 g_idle_remove_by_data (self);
33 gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, self);
34
35- if (priv->upstart != NULL)
36+ if (priv->upstart != NULL)
37 {
38 int event_sent = 0;
39- event_sent = upstart_emit_event_sync (NULL, priv->upstart, "indicator-services-end", NULL, 0);
40+ event_sent = upstart_emit_event_sync (NULL, priv->upstart,
41+ "indicator-services-end", NULL, 0);
42 if (event_sent != 0)
43 g_warning("Unable to signal for indicator services to start");
44
45@@ -532,7 +534,7 @@
46 {
47 modifiers |= GDK_SHIFT_MASK;
48 }
49- if (g_strrstr (binding, "<Control>"))
50+ if (g_strrstr (binding, "<Control>") || g_strrstr (binding, "<Primary>"))
51 {
52 modifiers |= GDK_CONTROL_MASK;
53 }
54@@ -1181,7 +1183,7 @@
55 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
56 if (indicator)
57 {
58- load_indicator (self, INDICATOR_OBJECT (indicator), NULL);
59+ load_indicator (self, INDICATOR_OBJECT (indicator), name);
60 }
61 else
62 {
63@@ -1211,11 +1213,23 @@
64 return -1;
65 }
66
67+static gint
68+name2priority (const gchar * name, const gchar * hint)
69+{
70+ gint order = name2order (name, hint);
71+ if (order > -1)
72+ return order * MAX_INDICATOR_ENTRIES;
73+
74+ return order;
75+}
76+
77 static void
78 sort_indicators (PanelService *self)
79 {
80 GSList *i;
81 int k = 0;
82+ int floating_indicators = 0;
83+ int max_priority = G_N_ELEMENTS(indicator_order) * MAX_INDICATOR_ENTRIES;
84
85 for (i = self->priv->indicators; i; i = i->next)
86 {
87@@ -1229,10 +1243,20 @@
88 * higher position though, so that they appear to the right of the
89 * indicators that return a proper position */
90 if (pos < 0)
91- pos = 1000 - name2order (g_object_get_data (G_OBJECT (io), "id"), NULL);
92+ {
93+ gint prio = name2priority (g_object_get_data (G_OBJECT (io), "id"), NULL);
94+
95+ if (prio < 0)
96+ {
97+ prio = name2priority ("floating-indicators", NULL) + floating_indicators;
98+ floating_indicators++;
99+ }
100+
101+ pos = max_priority - prio;
102+ }
103
104 /* unity's concept of priorities is inverse to ours right now */
105- g_object_set_data (G_OBJECT (i->data), "priority", GINT_TO_POINTER (1000 - pos));
106+ g_object_set_data (G_OBJECT (i->data), "priority", GINT_TO_POINTER (max_priority - pos));
107
108 g_object_set_data (G_OBJECT (i->data), "position", GINT_TO_POINTER (k));
109 self->priv->timeouts[k] = SYNC_NEUTRAL;
110@@ -1356,8 +1380,16 @@
111 IndicatorObjectEntry *entry = e->data;
112 gchar *id = get_indicator_entry_id_by_entry (entry);
113
114- prio = parent_prio + index;
115- index++;
116+ if (entry->name_hint)
117+ {
118+ prio = name2priority (indicator_id, entry->name_hint);
119+ }
120+
121+ if (prio < 0)
122+ {
123+ prio = parent_prio + index;
124+ index++;
125+ }
126
127 indicator_entry_to_variant (entry, id, indicator_id, b, prio);
128 g_free (id);
129@@ -1667,6 +1699,7 @@
130 {
131 gint parent_priority = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (l->data), "priority"));
132 entries = indicator_object_get_entries (l->data);
133+ const gchar *indicator_id = g_object_get_data (G_OBJECT (l->data), "id");
134 if (entries)
135 {
136 int index = 0;
137@@ -1679,8 +1712,16 @@
138 if (!panel_service_entry_is_visible (self, new_entry))
139 continue;
140
141- prio = parent_priority * MAX_INDICATOR_ENTRIES + index;
142- index++;
143+ if (new_entry->name_hint)
144+ {
145+ prio = name2priority (indicator_id, new_entry->name_hint);
146+ }
147+
148+ if (prio < 0)
149+ {
150+ prio = parent_priority + index;
151+ index++;
152+ }
153
154 gpointer *values = g_new (gpointer, 2);
155 values[0] = new_entry;
156@@ -1705,7 +1746,7 @@
157 }
158 else
159 {
160- values = ll->prev ? ll->prev->data : g_list_last(ordered_entries)->data;
161+ values = ll->prev ? ll->prev->data : g_list_last (ordered_entries)->data;
162 }
163
164 new_entry = values[0];