Skip to content

Commit aa6334e

Browse files
committed
extension-row: Remove row expansion
1 parent ca2862b commit aa6334e

File tree

3 files changed

+60
-170
lines changed

3 files changed

+60
-170
lines changed

src/exm-extension-row.blp

Lines changed: 34 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
11
using Gtk 4.0;
22
using Adw 1;
33

4-
template $ExmExtensionRow : Adw.ExpanderRow {
4+
template $ExmExtensionRow : Adw.ActionRow {
55
title-lines: 1;
66
subtitle-lines: 1;
77

8-
[action]
9-
Gtk.Switch ext_toggle {
10-
valign: center;
11-
halign: center;
12-
13-
action-name: 'row.state-set';
14-
}
15-
16-
[action]
17-
Gtk.Button prefs_btn {
18-
styles ["flat"]
19-
20-
icon-name: "settings-symbolic";
21-
valign: center;
22-
halign: center;
23-
24-
action-name: 'row.open-prefs';
8+
activatable-widget: expander-arrow;
259

26-
tooltip-text: _("Open extension preferences");
27-
}
28-
29-
[action]
30-
Gtk.Image error_icon {
31-
styles ["error"]
10+
[suffix]
11+
Gtk.Image update_icon {
12+
styles ["update"]
3213

33-
icon-name: "dialog-error-symbolic";
14+
icon-name: "software-update-available-symbolic";
3415
valign: center;
3516
halign: center;
3617

@@ -39,10 +20,10 @@ template $ExmExtensionRow : Adw.ExpanderRow {
3920

4021
visible: false;
4122

42-
tooltip-text: _("An error occurred while loading this extension");
23+
tooltip-text: _("A newer version of this extension is available");
4324
}
4425

45-
[action]
26+
[suffix]
4627
Gtk.Image out_of_date_icon {
4728
styles ["error"]
4829

@@ -58,140 +39,47 @@ template $ExmExtensionRow : Adw.ExpanderRow {
5839
tooltip-text: _("This extension is incompatible with your current version of GNOME");
5940
}
6041

61-
[action]
62-
Gtk.Image update_icon {
63-
styles ["update"]
64-
65-
icon-name: "software-update-available-symbolic";
66-
valign: center;
67-
halign: center;
42+
Gtk.ListBoxRow {
43+
activatable: false;
44+
focusable: false;
45+
height-request: 46;
6846

6947
margin-start: 9;
7048
margin-end: 9;
7149

7250
visible: false;
7351

74-
tooltip-text: _("A newer version of this extension is available");
52+
tooltip-text: _("An error occurred while loading this extension");
7553
}
7654

77-
Gtk.ListBoxRow {
78-
activatable: false;
79-
80-
Gtk.Grid {
81-
styles ["row-content"]
82-
83-
row-spacing: 15;
84-
column-spacing: 15;
85-
86-
Gtk.Label {
87-
styles ["dim-label"]
88-
89-
label: _("Description");
90-
91-
xalign: 0;
92-
yalign: 0;
93-
94-
layout {
95-
row: 0;
96-
column: 0;
97-
}
98-
}
99-
100-
Gtk.Label description_label {
101-
styles ["multiline"]
102-
xalign: 0;
103-
wrap-mode: word;
104-
wrap: true;
105-
selectable: true;
106-
107-
layout {
108-
row: 0;
109-
column: 1;
110-
}
111-
}
112-
113-
Gtk.Label {
114-
styles ["dim-label"]
115-
116-
label: _("Version");
117-
118-
xalign: 0;
119-
yalign: 0;
120-
121-
layout {
122-
row: 1;
123-
column: 0;
124-
}
125-
}
126-
127-
Gtk.Label version_label {
128-
xalign: 0;
129-
wrap-mode: word;
130-
wrap: true;
131-
selectable: true;
132-
133-
layout {
134-
row: 1;
135-
column: 1;
136-
}
137-
}
138-
139-
Gtk.Label error_label_tag {
140-
styles ["dim-label"]
141-
142-
label: _("Error");
143-
144-
xalign: 0;
145-
yalign: 0;
146-
147-
layout {
148-
row: 2;
149-
column: 0;
150-
}
151-
}
152-
153-
Gtk.Label error_label {
154-
xalign: 0;
155-
wrap-mode: word;
156-
wrap: true;
157-
selectable: true;
158-
159-
layout {
160-
row: 2;
161-
column: 1;
162-
}
163-
}
164-
}
165-
}
55+
[suffix]
56+
Gtk.Button prefs_btn {
57+
styles ["flat"]
16658

167-
Gtk.ListBoxRow {
168-
activatable: false;
169-
focusable: false;
170-
height-request: 46;
59+
icon-name: "settings-symbolic";
60+
valign: center;
61+
halign: center;
17162

172-
Gtk.Box {
173-
halign: end;
174-
spacing: 6;
175-
margin-start: 4;
176-
margin-end: 4;
63+
action-name: 'row.open-prefs';
17764

178-
Gtk.Button details_btn {
179-
styles ["flat"]
65+
tooltip-text: _("Open extension preferences");
66+
}
18067

181-
label: _("See Details");
182-
valign: center;
68+
[suffix]
69+
Gtk.Switch ext_toggle {
70+
valign: center;
71+
halign: center;
18372

184-
action-name: 'win.show-detail';
185-
}
73+
action-name: 'row.state-set';
74+
}
18675

187-
Gtk.Button remove_btn {
188-
styles ["destructive-action"]
76+
[suffix]
77+
Gtk.Image expander-arrow {
78+
styles ["expander-row-arrow"]
18979

190-
label: _("Remove");
191-
valign: center;
80+
valign: center;
81+
halign: end;
19282

193-
action-name: 'row.remove';
194-
}
195-
}
83+
icon-name: "go-next-symbolic";
19684
}
19785
}

src/exm-extension-row.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55

66
struct _ExmExtensionRow
77
{
8-
AdwExpanderRow parent_instance;
8+
AdwActionRow parent_instance;
99

1010
GSimpleActionGroup *action_group;
1111

1212
ExmExtension *extension;
1313
gchar *uuid;
1414

15-
GtkButton *remove_btn;
15+
// GtkButton *remove_btn;
1616
GtkButton *prefs_btn;
17-
GtkButton *details_btn;
17+
// GtkButton *details_btn;
1818
GtkSwitch *ext_toggle;
1919

20-
GtkLabel *description_label;
21-
GtkLabel *version_label;
22-
GtkLabel *error_label;
23-
GtkLabel *error_label_tag;
20+
// GtkLabel *description_label;
21+
// GtkLabel *version_label;
22+
// GtkLabel *error_label;
23+
// GtkLabel *error_label_tag;
2424

2525
GtkImage *update_icon;
2626
GtkImage *error_icon;
@@ -29,7 +29,7 @@ struct _ExmExtensionRow
2929
guint signal_handler;
3030
};
3131

32-
G_DEFINE_FINAL_TYPE (ExmExtensionRow, exm_extension_row, ADW_TYPE_EXPANDER_ROW)
32+
G_DEFINE_FINAL_TYPE (ExmExtensionRow, exm_extension_row, ADW_TYPE_ACTION_ROW)
3333

3434
enum {
3535
PROP_0,
@@ -176,13 +176,13 @@ update_state (ExmExtension *extension,
176176
g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (is_enabled));
177177
}
178178

179-
static void
179+
/*static void
180180
set_error_label_visible (ExmExtensionRow *self,
181181
gboolean visible)
182182
{
183183
gtk_widget_set_visible (GTK_WIDGET (self->error_label), visible);
184184
gtk_widget_set_visible (GTK_WIDGET (self->error_label_tag), visible);
185-
}
185+
}*/
186186

187187
static void
188188
unbind_extension (ExmExtensionRow *self)
@@ -234,21 +234,23 @@ bind_extension (ExmExtensionRow *self,
234234

235235
g_object_set (self, "title", g_markup_escape_text(name, -1), "subtitle", uuid, NULL);
236236
g_object_set (self->prefs_btn, "visible", has_prefs, NULL);
237-
g_object_set (self->remove_btn, "visible", is_user, NULL);
237+
// g_object_set (self->remove_btn, "visible", is_user, NULL);
238238
g_object_set (self->update_icon, "visible", has_update, NULL);
239-
g_object_set (self->version_label, "label", version, NULL);
239+
// g_object_set (self->version_label, "label", version, NULL);
240+
// TODO: Re-add version
240241

241242
// Trim description label's leading and trailing whitespace
242-
char *description_trimmed = g_strchomp (g_strstrip (description));
243+
/*char *description_trimmed = g_strchomp (g_strstrip (description));
243244
g_object_set (self->description_label, "label", description_trimmed, NULL);
244-
g_free (description_trimmed);
245+
g_free (description_trimmed);*/
245246

246247
// Only show if error_msg exists and is not empty
247-
g_object_set (self->error_label, "label", error_msg, NULL);
248+
/*g_object_set (self->error_label, "label", error_msg, NULL);
248249
gboolean has_error = (error_msg != NULL) && (strlen(error_msg) != 0);
249-
set_error_label_visible (self, has_error);
250+
set_error_label_visible (self, has_error);*/
250251

251-
gtk_actionable_set_action_target (GTK_ACTIONABLE (self->details_btn), "s", uuid);
252+
gtk_actionable_set_action_name (GTK_ACTIONABLE (self), "win.show-detail");
253+
gtk_actionable_set_action_target (GTK_ACTIONABLE (self), "s", uuid);
252254

253255
// One way binding from extension ("source of truth") to switch
254256
self->signal_handler = g_signal_connect (self->extension,
@@ -293,14 +295,14 @@ exm_extension_row_class_init (ExmExtensionRowClass *klass)
293295

294296
gtk_widget_class_set_template_from_resource (widget_class, "/com/mattjakeman/ExtensionManager/exm-extension-row.ui");
295297

296-
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, description_label);
297-
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_label);
298-
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_label_tag);
299-
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, version_label);
298+
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, description_label);
299+
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_label);
300+
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_label_tag);
301+
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, version_label);
300302

301303
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, prefs_btn);
302-
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, remove_btn);
303-
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, details_btn);
304+
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, remove_btn);
305+
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, details_btn);
304306
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, ext_toggle);
305307
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, update_icon);
306308
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_icon);

src/exm-extension-row.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ G_BEGIN_DECLS
88

99
#define EXM_TYPE_EXTENSION_ROW (exm_extension_row_get_type())
1010

11-
G_DECLARE_FINAL_TYPE (ExmExtensionRow, exm_extension_row, EXM, EXTENSION_ROW, AdwExpanderRow)
11+
G_DECLARE_FINAL_TYPE (ExmExtensionRow, exm_extension_row, EXM, EXTENSION_ROW, AdwActionRow)
1212

1313
ExmExtensionRow *
1414
exm_extension_row_new (ExmExtension *extension);

0 commit comments

Comments
 (0)