Merge lp:~mterry/unity-greeter/dbus-interface into lp:unity-greeter

Proposed by Michael Terry
Status: Superseded
Proposed branch: lp:~mterry/unity-greeter/dbus-interface
Merge into: lp:unity-greeter
Diff against target: 212 lines (+111/-23)
4 files modified
data/com.canonical.unity-greeter.gschema.xml (+4/-0)
src/greeter-list.vala (+49/-1)
src/menubar.vala (+51/-22)
src/settings.vala (+7/-0)
To merge this branch: bzr merge lp:~mterry/unity-greeter/dbus-interface
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Unity Greeter Development Team Pending
Review via email: mp+151587@code.launchpad.net

This proposal has been superseded by a proposal from 2013-03-04.

Commit message

Expose a dbus session interface for setting active users.

Description of the change

Expose a dbus session interface for setting active users. This could be useful for custom indicators (which can only happen after https://code.launchpad.net/~mterry/unity-greeter/indicator-gsettings/+merge/151573 )

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

Wait, I'm just now realizing you said elsewhere: "there could potentially be more than one greeter running at the same time so the bus address would need to be unique"

When does LightDM spawn more than one? I can rework patch to fit.

777. By Michael Terry

Merge indicator-gsettings branch

778. By Michael Terry

Use unique dbus name, rather than claiming a global one

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/com.canonical.unity-greeter.gschema.xml'
2--- data/com.canonical.unity-greeter.gschema.xml 2012-09-11 17:52:41 +0000
3+++ data/com.canonical.unity-greeter.gschema.xml 2013-03-04 19:12:20 +0000
4@@ -82,5 +82,9 @@
5 <default>true</default>
6 <summary>Whether to play sound when greeter is ready</summary>
7 </key>
8+ <key name="indicators" type="as">
9+ <default>['ug-keyboard', 'ug-accessibility', 'session', 'datetime', 'power', 'soundmenu', 'application']</default>
10+ <summary>Which indicators to load</summary>
11+ </key>
12 </schema>
13 </schemalist>
14
15=== modified file 'src/greeter-list.vala'
16--- src/greeter-list.vala 2013-01-03 15:15:54 +0000
17+++ src/greeter-list.vala 2013-03-04 19:12:20 +0000
18@@ -24,6 +24,22 @@
19 return (int) (size % grid_size) / 2;
20 }
21
22+[DBus (name="com.canonical.UnityGreeter.List")]
23+public class ListDBusInterface : Object
24+{
25+ private GreeterList list;
26+
27+ public ListDBusInterface (GreeterList list)
28+ {
29+ this.list = list;
30+ }
31+
32+ public void set_active_entry (string entry_name)
33+ {
34+ list.set_active_entry (entry_name);
35+ }
36+}
37+
38 public abstract class GreeterList : FadableBox
39 {
40 public Background background { get; construct; }
41@@ -49,6 +65,7 @@
42
43 protected List<PromptBox> entries = null;
44
45+ private ListDBusInterface dbus_object;
46
47 private double scroll_target_location;
48 private double scroll_start_location;
49@@ -152,6 +169,29 @@
50
51 scroll_timer = new AnimateTimer (AnimateTimer.ease_out_quint, AnimateTimer.FAST);
52 scroll_timer.animate.connect (animate_scrolling);
53+
54+ try
55+ {
56+ Bus.get.begin (BusType.SESSION, null, on_bus_acquired);
57+ }
58+ catch (IOError e)
59+ {
60+ debug ("Error getting session bus: %s", e.message);
61+ }
62+ }
63+
64+ private void on_bus_acquired (Object? obj, AsyncResult res)
65+ {
66+ try
67+ {
68+ var conn = Bus.get.end (res);
69+ this.dbus_object = new ListDBusInterface (this);
70+ conn.register_object ("/list", this.dbus_object);
71+ }
72+ catch (IOError e)
73+ {
74+ debug ("Error registering user list dbus object: %s", e.message);
75+ }
76 }
77
78 public enum ScrollTarget
79@@ -354,7 +394,15 @@
80 {
81 var e = find_entry (name);
82 if (e != null)
83- select_entry (e, 1.0);
84+ {
85+ var direction = 1.0;
86+ if (selected_entry != null &&
87+ entries.index (selected_entry) > entries.index (e))
88+ {
89+ direction = -1.0;
90+ }
91+ select_entry (e, direction);
92+ }
93 }
94
95 public void set_active_first_entry_with_prefix (string prefix)
96
97=== modified file 'src/menubar.vala'
98--- src/menubar.vala 2013-02-20 16:17:42 +0000
99+++ src/menubar.vala 2013-03-04 19:12:20 +0000
100@@ -322,6 +322,42 @@
101 return keyboard_item;
102 }
103
104+ private void load_indicator (string indicator_name)
105+ {
106+ if (indicator_name == "ug-keyboard")
107+ {
108+ var keyboard_item = make_keyboard_indicator ();
109+ insert (keyboard_item, (int) get_children ().length () - 1);
110+ }
111+ else if (indicator_name == "ug-accessibility")
112+ {
113+ var a11y_item = make_a11y_indicator ();
114+ insert (a11y_item, (int) get_children ().length () - 1);
115+ }
116+ else
117+ {
118+ // Find file, if it exists
119+ string[] names_to_try = {"lib" + indicator_name + ".so",
120+ indicator_name + ".so",
121+ indicator_name};
122+ foreach (var filename in names_to_try)
123+ {
124+ var full_path = Path.build_filename (Config.INDICATORDIR, filename);
125+ var io = new Indicator.Object.from_file (full_path);
126+ if (io == null)
127+ continue;
128+
129+ indicator_objects.append (io);
130+ io.entry_added.connect (indicator_added_cb);
131+ io.entry_removed.connect (indicator_removed_cb);
132+ foreach (var entry in io.get_entries ())
133+ indicator_added_cb (io, entry);
134+
135+ break;
136+ }
137+ }
138+ }
139+
140 private void setup_indicators ()
141 {
142 /* Set indicators to run with reduced functionality */
143@@ -334,30 +370,23 @@
144 /* Hint to have gnome-settings-daemon run in greeter mode */
145 greeter_set_env ("RUNNING_UNDER_GDM", "1");
146
147- var keyboard_item = make_keyboard_indicator ();
148- insert (keyboard_item, (int) get_children ().length () - 1);
149-
150- var a11y_item = make_a11y_indicator ();
151- insert (a11y_item, (int) get_children ().length () - 1);
152+ /* Let indicators know about our unique dbus name */
153+ try
154+ {
155+ var conn = Bus.get_sync (BusType.SESSION);
156+ greeter_set_env ("UNITY_GREETER_DBUS_NAME", conn.get_unique_name ());
157+ }
158+ catch (IOError e)
159+ {
160+ debug ("Could not set DBUS_NAME: %s", e.message);
161+ }
162
163 debug ("LANG=%s LANGUAGE=%s", Environment.get_variable ("LANG"), Environment.get_variable ("LANGUAGE"));
164- string[] filenames = { Path.build_filename (Config.INDICATORDIR, "libsession.so"),
165- Path.build_filename (Config.INDICATORDIR, "libdatetime.so"),
166- Path.build_filename (Config.INDICATORDIR, "libpower.so"),
167- Path.build_filename (Config.INDICATORDIR, "libsoundmenu.so"),
168- Path.build_filename (Config.INDICATORDIR, "libapplication.so") };
169- foreach (var filename in filenames)
170- {
171- var io = new Indicator.Object.from_file (filename);
172- if (io == null)
173- continue;
174-
175- indicator_objects.append (io);
176- io.entry_added.connect (indicator_added_cb);
177- io.entry_removed.connect (indicator_removed_cb);
178- foreach (var entry in io.get_entries ())
179- indicator_added_cb (io, entry);
180- }
181+
182+ var indicator_list = UGSettings.get_strv(UGSettings.KEY_INDICATORS);
183+ foreach (var indicator in indicator_list)
184+ load_indicator(indicator);
185+
186 debug ("LANG=%s LANGUAGE=%s", Environment.get_variable ("LANG"), Environment.get_variable ("LANGUAGE"));
187 }
188
189
190=== modified file 'src/settings.vala'
191--- src/settings.vala 2012-09-11 17:52:41 +0000
192+++ src/settings.vala 2013-03-04 19:12:20 +0000
193@@ -37,6 +37,7 @@
194 public static const string KEY_HIGH_CONTRAST = "high-contrast";
195 public static const string KEY_SCREEN_READER = "screen-reader";
196 public static const string KEY_PLAY_READY_SOUND = "play-ready-sound";
197+ public static const string KEY_INDICATORS = "indicators";
198
199 public static bool get_boolean (string key)
200 {
201@@ -75,5 +76,11 @@
202 return gsettings.set_boolean (key, value);
203 }
204
205+ public static string[] get_strv (string key)
206+ {
207+ var gsettings = new Settings (SCHEMA);
208+ return gsettings.get_strv (key);
209+ }
210+
211 private static const string SCHEMA = "com.canonical.unity-greeter";
212 }

Subscribers

People subscribed via source and target branches