Merge lp:~donadigo/wingpanel-indicator-session/switch-to-user into lp:~wingpanel-devs/wingpanel-indicator-session/trunk

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Cody Garver
Approved revision: 69
Merged at revision: 72
Proposed branch: lp:~donadigo/wingpanel-indicator-session/switch-to-user
Merge into: lp:~wingpanel-devs/wingpanel-indicator-session/trunk
Diff against target: 208 lines (+81/-14)
7 files modified
cmake/ValaPrecompile.cmake (+0/-1)
src/CMakeLists.txt (+1/-0)
src/Indicator.vala (+1/-1)
src/Services/DbusInterfaces.vala (+2/-2)
src/Services/UserManager.vala (+4/-5)
src/Widgets/UserBox.vala (+10/-5)
src/Widgets/UserListBox.vala (+63/-0)
To merge this branch: bzr merge lp:~donadigo/wingpanel-indicator-session/switch-to-user
Reviewer Review Type Date Requested Status
Felipe Escoto Needs Fixing
Review via email: mp+286558@code.launchpad.net

Commit message

* Fix bug #1508584: "Switch to another user".
* Remove warnings.

Description of the change

Fix bug #1508584: "Switch to another user".

Switch to user is now implemented and I removed a --save-temps warning from CMake.

NOTE: switch_to_guest currently does not work because of Greeter not handling it yet.

To post a comment you must log in.
67. By Adam Bieńkowski

Switch to guest is now working properly

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Updated.

68. By Adam Bieńkowski

Set the has_guest variable in construct

Revision history for this message
Felipe Escoto (philip.scott) wrote :

Alright, so buttons do work! But two things...

Buttons should maybe be non-focusable (Looks very ugly when they're either blue or gray depending on their focus)

there is also a lot of white space around each of the userboxes, if you could get them closer to how the battery or sound plug look it would be awesome!.

Im glad you were able to get switching to other users working :)

review: Needs Fixing
69. By Adam Bieńkowski

Remove button class

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Updated.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmake/ValaPrecompile.cmake'
2--- cmake/ValaPrecompile.cmake 2015-04-26 18:48:58 +0000
3+++ cmake/ValaPrecompile.cmake 2016-04-09 15:57:33 +0000
4@@ -229,7 +229,6 @@
5 ${vala_pkg_opts}
6 ${ARGS_OPTIONS}
7 "-g"
8- "--save-temps"
9 ${in_files}
10 ${custom_vapi_arguments}
11 COMMAND
12
13=== modified file 'src/CMakeLists.txt'
14--- src/CMakeLists.txt 2016-01-15 17:52:30 +0000
15+++ src/CMakeLists.txt 2016-04-09 15:57:33 +0000
16@@ -15,6 +15,7 @@
17 vala_precompile (VALA_C ${CMAKE_PROJECT_NAME}
18 Indicator.vala
19 Widgets/UserBox.vala
20+ Widgets/UserListBox.vala
21 Widgets/EndSessionDialog.vala
22 Services/User.vala
23 Services/UserManager.vala
24
25=== modified file 'src/Indicator.vala'
26--- src/Indicator.vala 2016-01-19 03:11:06 +0000
27+++ src/Indicator.vala 2016-04-09 15:57:33 +0000
28@@ -67,7 +67,7 @@
29 main_grid.add (manager.user_grid);
30
31 if (manager.has_guest) {
32- main_grid.add (manager.guest (false));
33+ manager.user_grid.add_guest (manager.guest (false));
34 }
35
36 main_grid.add (new Wingpanel.Widgets.Separator ());
37
38=== modified file 'src/Services/DbusInterfaces.vala'
39--- src/Services/DbusInterfaces.vala 2016-01-15 17:52:30 +0000
40+++ src/Services/DbusInterfaces.vala 2016-04-09 15:57:33 +0000
41@@ -48,8 +48,8 @@
42 [DBus (name = "org.freedesktop.DisplayManager.Seat")]
43 interface SeatInterface : Object {
44 //public abstract void SwitchToGreeter () throws IOError;
45- //public abstract void SwitchToGuest (string session_name) throws IOError;
46- //public abstract void SwitchToUser (string username, string session_name) throws IOError;
47+ public abstract void switch_to_guest (string session_name) throws IOError;
48+ public abstract void switch_to_user (string username, string session_name) throws IOError;
49 }
50
51 /* for User.vala, to get the user properties */
52
53=== modified file 'src/Services/UserManager.vala'
54--- src/Services/UserManager.vala 2016-01-15 17:52:30 +0000
55+++ src/Services/UserManager.vala 2016-04-09 15:57:33 +0000
56@@ -22,7 +22,7 @@
57 private AccountsInterface accounts_interface;
58 private PropertiesInterface state_properties;
59
60- public Gtk.Grid user_grid;
61+ public Session.Widgets.UserListBox user_grid;
62 public Session.Widgets.Userbox current_user;
63
64 public bool has_guest {public get; private set; default = false;}
65@@ -32,12 +32,11 @@
66 }
67
68 private void init () {
69- user_grid = new Gtk.Grid ();
70- user_grid.set_orientation (Gtk.Orientation.VERTICAL);
71+ user_grid = new Session.Widgets.UserListBox ();
72
73 try {
74 accounts_interface = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.Accounts", "/org/freedesktop/Accounts", DBusProxyFlags.NONE);
75- state_properties = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.DisplayManager", "/org/freedesktop/DisplayManager/Seat0", DBusProxyFlags.NONE);
76+ state_properties = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.DisplayManager", Environment.get_variable ("XDG_SEAT_PATH"), DBusProxyFlags.NONE);
77 has_guest = state_properties.get ("org.freedesktop.DisplayManager.Seat", "HasGuestAccount").get_boolean ();
78
79 connect_signals ();
80@@ -94,7 +93,7 @@
81 }
82
83 public Session.Widgets.Userbox guest (bool logged_in) {
84- var userbox = new Session.Widgets.Userbox.from_data (_("Guest"), logged_in);
85+ var userbox = new Session.Widgets.Userbox.from_data (_("Guest"), logged_in, true);
86 userbox.visible = true;
87
88 return userbox;
89
90=== modified file 'src/Widgets/UserBox.vala'
91--- src/Widgets/UserBox.vala 2016-02-25 02:11:40 +0000
92+++ src/Widgets/UserBox.vala 2016-04-09 15:57:33 +0000
93@@ -17,12 +17,13 @@
94 * Boston, MA 02111-1307, USA.
95 */
96
97-public class Session.Widgets.Userbox : Gtk.Grid {
98+public class Session.Widgets.Userbox : Gtk.ListBoxRow {
99 private const string LOGGED_IN = _("Logged in");
100 private const string LOGGED_OFF = _("Logged out");
101 private const int ICON_SIZE = 48;
102
103 public Session.Services.User user { public get; private set; }
104+ public bool is_guest = false;
105
106 private Granite.Widgets.Avatar avatar;
107 private Gtk.Label fullname_label;
108@@ -35,13 +36,16 @@
109 user.update_properties ();
110 }
111
112- public Userbox.from_data (string fullname, bool logged_in) {
113+ public Userbox.from_data (string fullname, bool logged_in, bool is_guest = false) {
114+ this.is_guest = is_guest;
115 build_ui (false);
116 fullname_label.label = "<b>" + fullname + "</b>";
117 update_state (logged_in);
118 }
119
120 private void build_ui (bool load_icon = true) {
121+ var grid = new Gtk.Grid ();
122+
123 fullname_label = new Gtk.Label ("");
124 fullname_label.use_markup = true;
125 fullname_label.valign = Gtk.Align.END;
126@@ -61,9 +65,10 @@
127 avatar.margin_bottom = 3;
128 avatar.margin_start = 6;
129
130- this.attach (avatar, 0, 0, 3, 3);
131- this.attach (fullname_label, 3, 0, 2, 1);
132- this.attach (status_label, 3, 1, 2, 1);
133+ grid.attach (avatar, 0, 0, 3, 3);
134+ grid.attach (fullname_label, 3, 0, 2, 1);
135+ grid.attach (status_label, 3, 1, 2, 1);
136+ this.add (grid);
137 }
138
139 public void update (string? fullname, string icon) {
140
141=== added file 'src/Widgets/UserListBox.vala'
142--- src/Widgets/UserListBox.vala 1970-01-01 00:00:00 +0000
143+++ src/Widgets/UserListBox.vala 2016-04-09 15:57:33 +0000
144@@ -0,0 +1,63 @@
145+/*
146+ * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
147+ *
148+ * This program is free software; you can redistribute it and/or
149+ * modify it under the terms of the GNU General Public
150+ * License as published by the Free Software Foundation; either
151+ * version 2 of the License, or (at your option) any later version.
152+ *
153+ * This program is distributed in the hope that it will be useful,
154+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
155+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
156+ * General Public License for more details.
157+ *
158+ * You should have received a copy of the GNU General Public
159+ * License along with this program; if not, write to the
160+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
161+ * Boston, MA 02111-1307, USA.
162+ */
163+
164+ public class Session.Widgets.UserListBox : Gtk.ListBox {
165+ private SeatInterface? seat = null;
166+ private string session_path;
167+ private bool has_guest;
168+
169+ public UserListBox () {
170+ has_guest = false;
171+ session_path = Environment.get_variable ("XDG_SESSION_PATH");
172+
173+ try {
174+ seat = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.DisplayManager", Environment.get_variable ("XDG_SEAT_PATH"), DBusProxyFlags.NONE);
175+ } catch (IOError e) {
176+ stderr.printf ("DisplayManager.Seat error: %s\n", e.message);
177+ }
178+
179+ this.set_activate_on_single_click (true);
180+ }
181+
182+ public void add_guest (Userbox user) {
183+ if (!has_guest) {
184+ this.add (user);
185+ has_guest = true;
186+ }
187+ }
188+
189+ public override void row_activated (Gtk.ListBoxRow row) {
190+ var userbox = (Userbox)row;
191+ if (userbox == null
192+ || seat == null
193+ || session_path == "") {
194+ return;
195+ }
196+
197+ try {
198+ if (userbox.is_guest) {
199+ seat.switch_to_guest ("");
200+ } else {
201+ seat.switch_to_user (userbox.user.user_name, session_path);
202+ }
203+ } catch (IOError e) {
204+ stderr.printf ("DisplayManager.Seat error: %s\n", e.message);
205+ }
206+ }
207+ }
208\ No newline at end of file

Subscribers

People subscribed via source and target branches