Merge lp:~ubuntu-mate-dev/indicator-session/mate-integration into lp:indicator-session

Proposed by Martin Wimpress 
Status: Merged
Approved by: Iain Lane
Approved revision: 507
Merged at revision: 494
Proposed branch: lp:~ubuntu-mate-dev/indicator-session/mate-integration
Merge into: lp:indicator-session
Diff against target: 175 lines (+65/-11)
3 files modified
debian/changelog (+6/-0)
debian/control (+1/-1)
src/backend-dbus/actions.c (+58/-10)
To merge this branch: bzr merge lp:~ubuntu-mate-dev/indicator-session/mate-integration
Reviewer Review Type Date Requested Status
Iain Lane Approve
Ubuntu Sponsors Pending
Review via email: mp+325600@code.launchpad.net

Description of the change

This merge proposal adds the remaining support for MATE Desktop. When MATE is the desktop session:

  * "About This Computer" launches `mate-system-monitor --show-system-tab`
  * "Ubuntu Help..." launches the MATE User Guide.
  * "System Settings..." launches `mate-control-center`
  * "Lock/Switch Account..." invokes `mate-screensaver-command --lock`

`mate-system-monitor` is added to debian/control Suggests: to provide the hint it is required for MATE. It is installed by default in Ubuntu MATE.

`mate-user-guide` is added to debian/control Suggests: to provide the hint it is required for MATE. It is installed by default in Ubuntu MATE.

`have_mate_program()` checks that the active session is MATE and the required program exists, making this a safe mechanism to launch `"yelp help:mate-user-guide` specifically for MATE and fall through the just `yelp` on the other desktop environments.

To post a comment you must log in.
497. By Martin Wimpress 

Fold some code. Turn discrete functions into a single generic function.

498. By Martin Wimpress 

debian/control: Add Suggests (indicator-session) mate-system-monitor.

499. By Martin Wimpress 

Add support for mate-user-guide.

500. By Martin Wimpress 

Split XDG_CURRENT_DESKTOP by : and compare each desktop.

Revision history for this message
Iain Lane (laney) wrote :

Some small refactoring then looks good.

review: Needs Fixing
501. By Martin Wimpress 

Refactor have_mate_program() as per the review comments.

502. By Martin Wimpress 

Add support for mate-session-save to handle prompts for shutdown, reboot, log-out, etc.

Revision history for this message
Martin Wimpress  (flexiondotorg) wrote :

> Some small refactoring then looks good.

I've refactored have_mate_program() as per you comments. I've also add support for mate-session-save to handle the prompts for shutdown, reboot, etc.

Revision history for this message
Jeremy Bícha (jbicha) wrote :

Could you drop the added suggests? That feels like something that MATE should be depending on or recommending rather than indicator-session.

503. By Martin Wimpress 

debian/control: Drop Suggests (indicator-session) mate-system-monitor and mate-user-guide as per the review comments.

504. By Martin Wimpress 

Remove unnecessary declaration. Whitespace cleanup.

505. By Martin Wimpress 

Drop changelog changes.

506. By Martin Wimpress 

Declare desktop_names as (const gchar * const *)

507. By Martin Wimpress 

Declare desktop_name as GStrv and cast desktop_name to (const gchar * const *)

Revision history for this message
Iain Lane (laney) wrote :

ty, looks good to me

review: Approve
508. By Martin Wimpress 

debian/changelog: Add MATE Desktop support. (LP: #1697792)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2017-06-05 14:22:45 +0000
3+++ debian/changelog 2017-07-17 19:15:26 +0000
4@@ -1,3 +1,9 @@
5+indicator-session (17.3.20+17.10.20170717-0ubuntu1) artful; urgency=medium
6+
7+ * Add MATE Desktop support. (LP: #1697792)
8+
9+ -- Martin Wimpress <martin.wimpress@ubuntu.com> Mon, 17 Jul 2017 20:13:27 +0100
10+
11 indicator-session (17.3.20+17.10.20170605-0ubuntu1) artful; urgency=medium
12
13 * Don't recommend obsolete Ubuntu Online Accounts settings panel
14
15=== modified file 'debian/control'
16--- debian/control 2017-06-05 13:55:18 +0000
17+++ debian/control 2017-07-17 19:15:26 +0000
18@@ -38,7 +38,7 @@
19 unity-control-center | gnome-control-center | mate-control-center,
20 Suggests: lightdm,
21 apport,
22- zenity
23+ zenity,
24 Description: indicator showing session management, status and user switching
25 This indicator is designed to be placed on the right side of a panel and
26 give the user easy control for changing their instant message status.
27
28=== modified file 'src/backend-dbus/actions.c'
29--- src/backend-dbus/actions.c 2017-06-05 13:54:46 +0000
30+++ src/backend-dbus/actions.c 2017-07-17 19:15:26 +0000
31@@ -90,10 +90,29 @@
32 {
33 PROMPT_NONE,
34 PROMPT_WITH_ZENITY,
35- PROMPT_WITH_UNITY
36+ PROMPT_WITH_UNITY,
37+ PROMPT_WITH_MATE
38 }
39 prompt_status_t;
40
41+static gboolean
42+have_mate_program (const gchar *program)
43+{
44+ const gchar *xdg_current_desktop;
45+ g_auto(GStrv) desktop_names = NULL;
46+
47+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
48+ if (xdg_current_desktop != NULL) {
49+ desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
50+ if (g_strv_contains ((const gchar * const *) desktop_names, "MATE")) {
51+ g_autofree gchar *path = g_find_program_in_path (program);
52+ return path != NULL;
53+ }
54+ }
55+
56+ return FALSE;
57+}
58+
59 static prompt_status_t
60 get_prompt_status (IndicatorSessionActionsDbus * self)
61 {
62@@ -102,6 +121,10 @@
63
64 if (!g_settings_get_boolean (p->indicator_settings, "suppress-logout-restart-shutdown"))
65 {
66+ /* can we use the MATE prompt? */
67+ if ((prompt == PROMPT_NONE) && have_mate_program ("mate-session-save"))
68+ prompt = PROMPT_WITH_MATE;
69+
70 /* can we use the Unity prompt? */
71 if ((prompt == PROMPT_NONE) && p && p->end_session_dialog)
72 {
73@@ -723,6 +746,15 @@
74 }
75
76 static void
77+run_outside_app (const char * cmd)
78+{
79+ GError * err = NULL;
80+ g_debug ("%s calling \"%s\"", G_STRFUNC, cmd);
81+ g_spawn_command_line_async (cmd, &err);
82+ log_and_clear_error (&err, G_STRLOC, G_STRFUNC);
83+}
84+
85+static void
86 my_logout (IndicatorSessionActions * actions)
87 {
88 IndicatorSessionActionsDbus * self = INDICATOR_SESSION_ACTIONS_DBUS (actions);
89@@ -733,6 +765,11 @@
90 show_unity_end_session_dialog (self, END_SESSION_TYPE_LOGOUT);
91 break;
92
93+ case PROMPT_WITH_MATE:
94+ /* --logout-dialog presents Logout and (if available) Switch User options */
95+ run_outside_app ("mate-session-save --logout-dialog");
96+ break;
97+
98 case PROMPT_NONE:
99 logout_now (self);
100 break;
101@@ -770,6 +807,11 @@
102 show_unity_end_session_dialog (self, END_SESSION_TYPE_REBOOT);
103 break;
104
105+ case PROMPT_WITH_MATE:
106+ /* --shutdown-dialog presents Restart, Shutdown and (if available) Suspend options */
107+ run_outside_app ("mate-session-save --shutdown-dialog");
108+ break;
109+
110 case PROMPT_NONE:
111 reboot_now (self);
112 break;
113@@ -799,6 +841,11 @@
114 show_unity_end_session_dialog (self, END_SESSION_TYPE_REBOOT);
115 break;
116
117+ case PROMPT_WITH_MATE:
118+ /* --shutdown-dialog presents Restart, Shutdown and (if available) Suspend options */
119+ run_outside_app ("mate-session-save --shutdown-dialog");
120+ break;
121+
122 case PROMPT_WITH_ZENITY:
123 if (zenity_question (self,
124 "system-shutdown",
125@@ -820,19 +867,12 @@
126 ***/
127
128 static void
129-run_outside_app (const char * cmd)
130-{
131- GError * err = NULL;
132- g_debug ("%s calling \"%s\"", G_STRFUNC, cmd);
133- g_spawn_command_line_async (cmd, &err);
134- log_and_clear_error (&err, G_STRLOC, G_STRFUNC);
135-}
136-
137-static void
138 my_help (IndicatorSessionActions * self G_GNUC_UNUSED)
139 {
140 if (g_getenv ("MIR_SOCKET") != NULL)
141 url_dispatch_send("http://www.askubuntu.com", NULL, NULL);
142+ else if (have_mate_program ("yelp"))
143+ run_outside_app ("yelp help:mate-user-guide");
144 else
145 run_outside_app ("yelp");
146 }
147@@ -876,6 +916,8 @@
148 url_dispatch_send("settings:///system", NULL, NULL);
149 else if (have_unity_control_center ())
150 run_outside_app ("unity-control-center");
151+ else if (have_mate_program ("mate-control-center"))
152+ run_outside_app ("mate-control-center");
153 else
154 run_outside_app ("gnome-control-center");
155 }
156@@ -898,6 +940,8 @@
157 url_dispatch_send("settings:///system/about", NULL, NULL);
158 else if (have_unity_control_center ())
159 run_outside_app ("unity-control-center info");
160+ else if (have_mate_program ("mate-system-monitor"))
161+ run_outside_app ("mate-system-monitor --show-system-tab");
162 else
163 run_outside_app ("gnome-control-center info");
164 }
165@@ -922,6 +966,10 @@
166 unity_session_call_lock (p->unity_session, p->cancellable, NULL, NULL);
167 }
168 }
169+ else if (have_mate_program ("mate-screensaver-command"))
170+ {
171+ run_outside_app ("mate-screensaver-command --lock");
172+ }
173 else
174 {
175 g_return_if_fail (p->screen_saver != NULL);

Subscribers

People subscribed via source and target branches