Merge lp:~larsu/unity/support-indicator-ng into lp:unity

Proposed by Lars Karlitski
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3181
Proposed branch: lp:~larsu/unity/support-indicator-ng
Merge into: lp:unity
Diff against target: 95 lines (+43/-0)
3 files modified
CMakeLists.txt (+1/-0)
config.h.cmake (+3/-0)
services/panel-service.c (+39/-0)
To merge this branch: bzr merge lp:~larsu/unity/support-indicator-ng
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Charles Kerr Pending
Review via email: mp+149136@code.launchpad.net

Commit message

panel-service: add support for indicator-ng

Picks up indicators on the bus that have a service file in /usr/share/unity/indicators.

Description of the change

panel-service: add support for indicator-ng

Picks up indicators on the bus that have a service file in /usr/share/unity/indicators. Indicators picked up this way are added to the left of all other indicators until we find a good way to set priorities.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Why not using g_file_enumerate_children(_async) instead of g_dir_read_name?

Revision history for this message
Lars Karlitski (larsu) wrote :

Thought about that, but didn't see a benefit in using it. We only need the names anyway.

Also, this mirrors what load_indicators does.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

The reason I said this is not to use sync operations on startup, considering also that this is ran on startup

Revision history for this message
Lars Karlitski (larsu) wrote :

I don't think that making this asynchronous will give us any benefit. The panel service has to know about all indicators before showing anything anyways, to avoid having indicators appear one after another.

Not that this is not a regression: indicator plugins are also loaded synchronously (and they need much longer to be loaded, since they have to be dlopened).

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

No regression indeed, it was just a nice to have...

review: Approve
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-01-18 16:59:54 +0000
3+++ CMakeLists.txt 2013-02-18 19:43:26 +0000
4@@ -135,6 +135,7 @@
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
13=== modified file 'config.h.cmake'
14--- config.h.cmake 2012-12-05 14:52:45 +0000
15+++ config.h.cmake 2013-02-18 19:43:26 +0000
16@@ -17,5 +17,8 @@
17 #ifndef INDICATORICONDIR
18 #cmakedefine INDICATORICONDIR "@INDICATORICONDIR@"
19 #endif
20+#ifndef INDICATOR_SERVICE_DIR
21+#cmakedefine INDICATOR_SERVICE_DIR "@INDICATOR_SERVICE_DIR@"
22+#endif
23
24 #endif // CONFIG_H
25
26=== modified file 'services/panel-service.c'
27--- services/panel-service.c 2013-02-04 21:12:57 +0000
28+++ services/panel-service.c 2013-02-18 19:43:26 +0000
29@@ -27,6 +27,7 @@
30 #include <gtk/gtk.h>
31 #include <gdk/gdkx.h>
32 #include <glib/gi18n-lib.h>
33+#include <libindicator/indicator-ng.h>
34
35 #include <X11/extensions/XInput2.h>
36 #include <X11/XKBlib.h>
37@@ -123,6 +124,7 @@
38 IndicatorObject *object,
39 const gchar *_name);
40 static void load_indicators (PanelService *self);
41+static void load_indicators_from_indicator_files (PanelService *self);
42 static void sort_indicators (PanelService *self);
43
44 static void notify_object (IndicatorObject *object);
45@@ -557,6 +559,7 @@
46
47 suppress_signals = TRUE;
48 load_indicators (self);
49+ load_indicators_from_indicator_files (self);
50 sort_indicators (self);
51 suppress_signals = FALSE;
52
53@@ -1011,6 +1014,42 @@
54 g_dir_close (dir);
55 }
56
57+static void
58+load_indicators_from_indicator_files (PanelService *self)
59+{
60+ GDir *dir;
61+ const gchar *name;
62+ GError *error = NULL;
63+
64+ dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
65+ if (!dir)
66+ {
67+ g_warning ("unable to open indicator service file directory: %s", error->message);
68+ g_error_free (error);
69+ return;
70+ }
71+
72+ while ((name = g_dir_read_name (dir)))
73+ {
74+ gchar *filename;
75+ IndicatorNg *indicator;
76+
77+ filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL);
78+ indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
79+ if (indicator)
80+ {
81+ load_indicator (self, INDICATOR_OBJECT (indicator), NULL);
82+ }
83+ else
84+ {
85+ g_warning ("unable to load '%s': %s", name, error->message);
86+ g_clear_error (&error);
87+ }
88+
89+ g_free (filename);
90+ }
91+}
92+
93 static gint
94 name2order (const gchar * name, const gchar * hint)
95 {