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
=== modified file 'cmake/ValaPrecompile.cmake'
--- cmake/ValaPrecompile.cmake 2015-04-26 18:48:58 +0000
+++ cmake/ValaPrecompile.cmake 2016-04-09 15:57:33 +0000
@@ -229,7 +229,6 @@
229 ${vala_pkg_opts} 229 ${vala_pkg_opts}
230 ${ARGS_OPTIONS} 230 ${ARGS_OPTIONS}
231 "-g"231 "-g"
232 "--save-temps"
233 ${in_files} 232 ${in_files}
234 ${custom_vapi_arguments}233 ${custom_vapi_arguments}
235 COMMAND234 COMMAND
236235
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2016-01-15 17:52:30 +0000
+++ src/CMakeLists.txt 2016-04-09 15:57:33 +0000
@@ -15,6 +15,7 @@
15vala_precompile (VALA_C ${CMAKE_PROJECT_NAME}15vala_precompile (VALA_C ${CMAKE_PROJECT_NAME}
16 Indicator.vala16 Indicator.vala
17 Widgets/UserBox.vala17 Widgets/UserBox.vala
18 Widgets/UserListBox.vala
18 Widgets/EndSessionDialog.vala19 Widgets/EndSessionDialog.vala
19 Services/User.vala20 Services/User.vala
20 Services/UserManager.vala21 Services/UserManager.vala
2122
=== modified file 'src/Indicator.vala'
--- src/Indicator.vala 2016-01-19 03:11:06 +0000
+++ src/Indicator.vala 2016-04-09 15:57:33 +0000
@@ -67,7 +67,7 @@
67 main_grid.add (manager.user_grid);67 main_grid.add (manager.user_grid);
6868
69 if (manager.has_guest) {69 if (manager.has_guest) {
70 main_grid.add (manager.guest (false));70 manager.user_grid.add_guest (manager.guest (false));
71 }71 }
7272
73 main_grid.add (new Wingpanel.Widgets.Separator ());73 main_grid.add (new Wingpanel.Widgets.Separator ());
7474
=== modified file 'src/Services/DbusInterfaces.vala'
--- src/Services/DbusInterfaces.vala 2016-01-15 17:52:30 +0000
+++ src/Services/DbusInterfaces.vala 2016-04-09 15:57:33 +0000
@@ -48,8 +48,8 @@
48[DBus (name = "org.freedesktop.DisplayManager.Seat")]48[DBus (name = "org.freedesktop.DisplayManager.Seat")]
49interface SeatInterface : Object {49interface SeatInterface : Object {
50 //public abstract void SwitchToGreeter () throws IOError;50 //public abstract void SwitchToGreeter () throws IOError;
51 //public abstract void SwitchToGuest (string session_name) throws IOError;51 public abstract void switch_to_guest (string session_name) throws IOError;
52 //public abstract void SwitchToUser (string username, string session_name) throws IOError;52 public abstract void switch_to_user (string username, string session_name) throws IOError;
53}53}
5454
55/* for User.vala, to get the user properties */55/* for User.vala, to get the user properties */
5656
=== modified file 'src/Services/UserManager.vala'
--- src/Services/UserManager.vala 2016-01-15 17:52:30 +0000
+++ src/Services/UserManager.vala 2016-04-09 15:57:33 +0000
@@ -22,7 +22,7 @@
22 private AccountsInterface accounts_interface;22 private AccountsInterface accounts_interface;
23 private PropertiesInterface state_properties;23 private PropertiesInterface state_properties;
2424
25 public Gtk.Grid user_grid;25 public Session.Widgets.UserListBox user_grid;
26 public Session.Widgets.Userbox current_user;26 public Session.Widgets.Userbox current_user;
27 27
28 public bool has_guest {public get; private set; default = false;}28 public bool has_guest {public get; private set; default = false;}
@@ -32,12 +32,11 @@
32 }32 }
3333
34 private void init () {34 private void init () {
35 user_grid = new Gtk.Grid ();35 user_grid = new Session.Widgets.UserListBox ();
36 user_grid.set_orientation (Gtk.Orientation.VERTICAL);
3736
38 try {37 try {
39 accounts_interface = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.Accounts", "/org/freedesktop/Accounts", DBusProxyFlags.NONE);38 accounts_interface = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.Accounts", "/org/freedesktop/Accounts", DBusProxyFlags.NONE);
40 state_properties = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.DisplayManager", "/org/freedesktop/DisplayManager/Seat0", DBusProxyFlags.NONE);39 state_properties = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.DisplayManager", Environment.get_variable ("XDG_SEAT_PATH"), DBusProxyFlags.NONE);
41 has_guest = state_properties.get ("org.freedesktop.DisplayManager.Seat", "HasGuestAccount").get_boolean ();40 has_guest = state_properties.get ("org.freedesktop.DisplayManager.Seat", "HasGuestAccount").get_boolean ();
4241
43 connect_signals ();42 connect_signals ();
@@ -94,7 +93,7 @@
94 }93 }
9594
96 public Session.Widgets.Userbox guest (bool logged_in) {95 public Session.Widgets.Userbox guest (bool logged_in) {
97 var userbox = new Session.Widgets.Userbox.from_data (_("Guest"), logged_in);96 var userbox = new Session.Widgets.Userbox.from_data (_("Guest"), logged_in, true);
98 userbox.visible = true;97 userbox.visible = true;
9998
100 return userbox;99 return userbox;
101100
=== modified file 'src/Widgets/UserBox.vala'
--- src/Widgets/UserBox.vala 2016-02-25 02:11:40 +0000
+++ src/Widgets/UserBox.vala 2016-04-09 15:57:33 +0000
@@ -17,12 +17,13 @@
17 * Boston, MA 02111-1307, USA.17 * Boston, MA 02111-1307, USA.
18 */18 */
1919
20public class Session.Widgets.Userbox : Gtk.Grid {20public class Session.Widgets.Userbox : Gtk.ListBoxRow {
21 private const string LOGGED_IN = _("Logged in");21 private const string LOGGED_IN = _("Logged in");
22 private const string LOGGED_OFF = _("Logged out");22 private const string LOGGED_OFF = _("Logged out");
23 private const int ICON_SIZE = 48;23 private const int ICON_SIZE = 48;
2424
25 public Session.Services.User user { public get; private set; }25 public Session.Services.User user { public get; private set; }
26 public bool is_guest = false;
2627
27 private Granite.Widgets.Avatar avatar;28 private Granite.Widgets.Avatar avatar;
28 private Gtk.Label fullname_label;29 private Gtk.Label fullname_label;
@@ -35,13 +36,16 @@
35 user.update_properties ();36 user.update_properties ();
36 }37 }
3738
38 public Userbox.from_data (string fullname, bool logged_in) {39 public Userbox.from_data (string fullname, bool logged_in, bool is_guest = false) {
40 this.is_guest = is_guest;
39 build_ui (false);41 build_ui (false);
40 fullname_label.label = "<b>" + fullname + "</b>";42 fullname_label.label = "<b>" + fullname + "</b>";
41 update_state (logged_in);43 update_state (logged_in);
42 }44 }
4345
44 private void build_ui (bool load_icon = true) {46 private void build_ui (bool load_icon = true) {
47 var grid = new Gtk.Grid ();
48
45 fullname_label = new Gtk.Label ("");49 fullname_label = new Gtk.Label ("");
46 fullname_label.use_markup = true;50 fullname_label.use_markup = true;
47 fullname_label.valign = Gtk.Align.END;51 fullname_label.valign = Gtk.Align.END;
@@ -61,9 +65,10 @@
61 avatar.margin_bottom = 3;65 avatar.margin_bottom = 3;
62 avatar.margin_start = 6;66 avatar.margin_start = 6;
6367
64 this.attach (avatar, 0, 0, 3, 3);68 grid.attach (avatar, 0, 0, 3, 3);
65 this.attach (fullname_label, 3, 0, 2, 1);69 grid.attach (fullname_label, 3, 0, 2, 1);
66 this.attach (status_label, 3, 1, 2, 1);70 grid.attach (status_label, 3, 1, 2, 1);
71 this.add (grid);
67 }72 }
6873
69 public void update (string? fullname, string icon) {74 public void update (string? fullname, string icon) {
7075
=== added file 'src/Widgets/UserListBox.vala'
--- src/Widgets/UserListBox.vala 1970-01-01 00:00:00 +0000
+++ src/Widgets/UserListBox.vala 2016-04-09 15:57:33 +0000
@@ -0,0 +1,63 @@
1/*
2 * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20 public class Session.Widgets.UserListBox : Gtk.ListBox {
21 private SeatInterface? seat = null;
22 private string session_path;
23 private bool has_guest;
24
25 public UserListBox () {
26 has_guest = false;
27 session_path = Environment.get_variable ("XDG_SESSION_PATH");
28
29 try {
30 seat = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.DisplayManager", Environment.get_variable ("XDG_SEAT_PATH"), DBusProxyFlags.NONE);
31 } catch (IOError e) {
32 stderr.printf ("DisplayManager.Seat error: %s\n", e.message);
33 }
34
35 this.set_activate_on_single_click (true);
36 }
37
38 public void add_guest (Userbox user) {
39 if (!has_guest) {
40 this.add (user);
41 has_guest = true;
42 }
43 }
44
45 public override void row_activated (Gtk.ListBoxRow row) {
46 var userbox = (Userbox)row;
47 if (userbox == null
48 || seat == null
49 || session_path == "") {
50 return;
51 }
52
53 try {
54 if (userbox.is_guest) {
55 seat.switch_to_guest ("");
56 } else {
57 seat.switch_to_user (userbox.user.user_name, session_path);
58 }
59 } catch (IOError e) {
60 stderr.printf ("DisplayManager.Seat error: %s\n", e.message);
61 }
62 }
63 }
0\ No newline at end of file64\ No newline at end of file

Subscribers

People subscribed via source and target branches