Skip to content

Commit 5841d83

Browse files
authored
Merge pull request #780 from mjakeman/local-session-modes
extension-row: Add Session Modes row
2 parents 2faf60c + c1b6e14 commit 5841d83

6 files changed

+274
-147
lines changed

src/exm-extension-row.blp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ template $ExmExtensionRow: Adw.ExpanderRow {
1717
[suffix]
1818
Gtk.Button prefs_btn {
1919
styles [
20-
"flat"
20+
"flat",
2121
]
2222

2323
icon-name: "settings-symbolic";
@@ -32,7 +32,7 @@ template $ExmExtensionRow: Adw.ExpanderRow {
3232
[suffix]
3333
Gtk.Image error_icon {
3434
styles [
35-
"error"
35+
"error",
3636
]
3737

3838
icon-name: "dialog-error-symbolic";
@@ -49,7 +49,7 @@ template $ExmExtensionRow: Adw.ExpanderRow {
4949
[suffix]
5050
Gtk.Image out_of_date_icon {
5151
styles [
52-
"error"
52+
"error",
5353
]
5454

5555
icon-name: "clock-alt-symbolic";
@@ -66,7 +66,7 @@ template $ExmExtensionRow: Adw.ExpanderRow {
6666
[suffix]
6767
Gtk.Image update_icon {
6868
styles [
69-
"update"
69+
"update",
7070
]
7171

7272
icon-name: "software-update-available-symbolic";
@@ -80,27 +80,10 @@ template $ExmExtensionRow: Adw.ExpanderRow {
8080
tooltip-text: _("A newer version of this extension is available");
8181
}
8282

83-
[suffix]
84-
Gtk.Image info_icon {
85-
styles [
86-
"warning"
87-
]
88-
89-
icon-name: "dialog-information-symbolic";
90-
valign: center;
91-
halign: center;
92-
focusable: true;
93-
margin-start: 9;
94-
margin-end: 9;
95-
visible: false;
96-
// Translators: Icon's tooltip when an extension works in login and/or lock screen session modes
97-
tooltip-text: _("This extension could be activated in session modes such as the login screen or the lock screen");
98-
}
99-
10083
Adw.ActionRow description_row {
10184
styles [
10285
"multiline",
103-
"property"
86+
"property",
10487
]
10588

10689
title: _("Description");
@@ -109,21 +92,37 @@ template $ExmExtensionRow: Adw.ExpanderRow {
10992

11093
Adw.ActionRow version_row {
11194
styles [
112-
"property"
95+
"property",
11396
]
11497

11598
title: _("Version");
99+
subtitle: bind template.extension as <$ExmExtension>.version;
100+
}
101+
102+
Adw.ActionRow session_modes_row {
103+
styles [
104+
"property",
105+
]
106+
107+
title: _("Session Modes");
108+
visible: false;
109+
110+
[suffix]
111+
Gtk.Image info_icon {
112+
focusable: true;
113+
icon-name: "dialog-information-symbolic";
114+
}
116115
}
117116

118117
Adw.ActionRow error_row {
119118
styles [
120119
"monospace",
121120
"multiline",
122-
"property"
121+
"property",
123122
]
124123

125124
title: _("Error");
126-
subtitle: bind template.extension as <$ExmExtension>.error_msg;
125+
subtitle: bind template.extension as <$ExmExtension>.error;
127126
subtitle-selectable: true;
128127
}
129128

@@ -140,7 +139,7 @@ template $ExmExtensionRow: Adw.ExpanderRow {
140139

141140
Gtk.Button details_btn {
142141
styles [
143-
"flat"
142+
"flat",
144143
]
145144

146145
label: _("See Details");
@@ -151,7 +150,7 @@ template $ExmExtensionRow: Adw.ExpanderRow {
151150

152151
Gtk.Button remove_btn {
153152
styles [
154-
"destructive-action"
153+
"destructive-action",
155154
]
156155

157156
label: _("Remove…");

src/exm-extension-row.c

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121

2222
#include "exm-extension-row.h"
2323

24+
#include "exm-config.h"
2425
#include "exm-enums.h"
2526
#include "exm-types.h"
2627

27-
#include "exm-config.h"
28+
#include <glib/gi18n.h>
2829

2930
struct _ExmExtensionRow
3031
{
@@ -44,12 +45,13 @@ struct _ExmExtensionRow
4445

4546
AdwActionRow *description_row;
4647
AdwActionRow *version_row;
48+
AdwActionRow *session_modes_row;
49+
GtkImage *info_icon;
4750
AdwActionRow *error_row;
4851

4952
GtkImage *update_icon;
5053
GtkImage *error_icon;
5154
GtkImage *out_of_date_icon;
52-
GtkImage *info_icon;
5355
};
5456

5557
G_DEFINE_FINAL_TYPE (ExmExtensionRow, exm_extension_row, ADW_TYPE_EXPANDER_ROW)
@@ -153,6 +155,62 @@ unbind_extension (ExmExtensionRow *self)
153155
}
154156
}
155157

158+
static void
159+
add_session_modes (GPtrArray *session_modes,
160+
ExmExtensionRow *self)
161+
{
162+
if (!session_modes || session_modes->len == 0)
163+
return;
164+
165+
GPtrArray *subtitles = g_ptr_array_new_with_free_func (g_free);
166+
gboolean has_unlock_dialog = FALSE;
167+
gboolean has_gdm = FALSE;
168+
169+
for (guint i = 0; i < session_modes->len; i++)
170+
{
171+
gchar *mode = g_ptr_array_index (session_modes, i);
172+
173+
if (g_strcmp0 (mode, "unlock-dialog") == 0)
174+
{
175+
g_ptr_array_add (subtitles, g_strdup (_("Unlock Dialog")));
176+
has_unlock_dialog = TRUE;
177+
}
178+
else if (g_strcmp0 (mode, "gdm") == 0)
179+
{
180+
// Translators: GNOME Display Manager
181+
g_ptr_array_add (subtitles, g_strdup (_("GDM")));
182+
has_gdm = TRUE;
183+
}
184+
}
185+
186+
if (has_unlock_dialog && has_gdm)
187+
{
188+
// Translators: Icon's tooltip when an extension runs on both, login and lock screens
189+
gtk_widget_set_tooltip_text (GTK_WIDGET (self->info_icon), _("This extension will run while the screen is locked and no user is logged in"));
190+
}
191+
else if (has_unlock_dialog)
192+
{
193+
// Translators: Icon's tooltip when an extension runs on the lock screen
194+
gtk_widget_set_tooltip_text (GTK_WIDGET (self->info_icon), _("This extension will run while the screen is locked"));
195+
}
196+
else if (has_gdm)
197+
{
198+
// Translators: Icon's tooltip when an extension runs on the login screen
199+
gtk_widget_set_tooltip_text (GTK_WIDGET (self->info_icon), _("This extension will run while no user is logged in"));
200+
}
201+
202+
if (subtitles->len > 0)
203+
{
204+
g_ptr_array_add (subtitles, NULL);
205+
gchar *subtitle = g_strjoinv (" / ", (gchar **)subtitles->pdata);
206+
adw_action_row_set_subtitle (self->session_modes_row, subtitle);
207+
gtk_widget_set_visible (GTK_WIDGET (self->session_modes_row), TRUE);
208+
g_free (subtitle);
209+
}
210+
211+
g_ptr_array_free (subtitles, TRUE);
212+
}
213+
156214
static void
157215
bind_extension (ExmExtensionRow *self,
158216
ExmExtension *extension)
@@ -173,49 +231,45 @@ bind_extension (ExmExtensionRow *self,
173231
if (self->extension == NULL)
174232
return;
175233

176-
gchar *name, *uuid, *description, *version, *version_name, *error_msg;
234+
gchar *name, *uuid, *description, *version, *error;
177235
gboolean enabled, has_prefs, is_user;
178236
ExmExtensionState state;
237+
GPtrArray *session_modes;
179238
g_object_get (self->extension,
180-
"display-name", &name,
239+
"name", &name,
181240
"uuid", &uuid,
182241
"description", &description,
183242
"state", &state,
184243
"enabled", &enabled,
244+
"version", &version,
245+
"error", &error,
185246
"has-prefs", &has_prefs,
186247
"is-user", &is_user,
187-
"version", &version,
188-
"version-name", &version_name,
189-
"error-msg", &error_msg,
248+
"session-modes", &session_modes,
190249
NULL);
191250

192251
self->uuid = g_strdup (uuid);
193252

194-
g_object_set (self, "title", g_markup_escape_text(name, -1), NULL);
195-
adw_action_row_set_subtitle (self->version_row, version_name ? g_strdup_printf ("%s (%s)", version_name, version)
196-
: version);
253+
g_object_set (self, "title", g_markup_escape_text (name, -1), NULL);
197254

198255
// Trim description label's leading and trailing whitespace
199256
char *description_trimmed = g_strchomp (g_strstrip (description));
200257
adw_action_row_set_subtitle (self->description_row, description_trimmed);
201258
g_free (description_trimmed);
202259

203-
// Only show if error_msg exists and is not empty
204-
gboolean has_error = (error_msg != NULL) && (strlen(error_msg) != 0);
260+
// Only show if error exists and is not empty
261+
gboolean has_error = (error != NULL) && (strlen (error) != 0);
205262
gtk_widget_set_visible (GTK_WIDGET (self->error_row), has_error);
206263

207264
gtk_widget_set_visible (GTK_WIDGET (self->error_icon), state == EXM_EXTENSION_STATE_ERROR);
208265
gtk_widget_set_visible (GTK_WIDGET (self->out_of_date_icon), state == EXM_EXTENSION_STATE_OUT_OF_DATE);
209266

210-
gtk_widget_set_visible (GTK_WIDGET (self->info_icon),
211-
(state == EXM_EXTENSION_STATE_INITIALIZED
212-
|| state == EXM_EXTENSION_STATE_INACTIVE)
213-
&& enabled);
214-
215267
gtk_widget_set_visible (GTK_WIDGET (self->version_row), version != NULL);
216268

217269
gtk_actionable_set_action_target (GTK_ACTIONABLE (self->details_btn), "s", uuid);
218270

271+
add_session_modes (session_modes, self);
272+
219273
GAction *action;
220274

221275
action = g_action_map_lookup_action (G_ACTION_MAP (self->action_group), "open-prefs");
@@ -300,6 +354,8 @@ exm_extension_row_class_init (ExmExtensionRowClass *klass)
300354

301355
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, description_row);
302356
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, version_row);
357+
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, session_modes_row);
358+
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, info_icon);
303359
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_row);
304360

305361
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, prefs_btn);
@@ -309,7 +365,6 @@ exm_extension_row_class_init (ExmExtensionRowClass *klass)
309365
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, update_icon);
310366
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_icon);
311367
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, out_of_date_icon);
312-
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, info_icon);
313368

314369
gtk_widget_class_bind_template_callback (widget_class, on_state_changed);
315370
}

src/exm-installed-page.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ bind_list_box (GListModel *model,
214214
g_return_if_fail (G_IS_LIST_MODEL (model));
215215

216216
// Sort alphabetically
217-
expression = gtk_property_expression_new (EXM_TYPE_EXTENSION, NULL, "display-name");
217+
expression = gtk_property_expression_new (EXM_TYPE_EXTENSION, NULL, "name");
218218
alphabetical_sorter = gtk_string_sorter_new (expression);
219219

220220
if (self->sort_enabled_first)

src/exm-upgrade-result.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ exm_upgrade_result_get_name (ExmUpgradeResult *self)
116116

117117
if (self->local_data)
118118
{
119-
g_object_get (self->local_data, "display-name", &name, NULL);
119+
g_object_get (self->local_data, "name", &name, NULL);
120120
return name;
121121
}
122122

0 commit comments

Comments
 (0)