Skip to content

Commit

Permalink
extension-row: Remove row expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
mjakeman committed Feb 22, 2024
1 parent 1844278 commit 58d08ee
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 170 deletions.
180 changes: 34 additions & 146 deletions src/exm-extension-row.blp
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
using Gtk 4.0;
using Adw 1;

template $ExmExtensionRow : Adw.ExpanderRow {
template $ExmExtensionRow : Adw.ActionRow {
title-lines: 1;
subtitle-lines: 1;

[action]
Gtk.Switch ext_toggle {
valign: center;
halign: center;

action-name: 'row.state-set';
}

[action]
Gtk.Button prefs_btn {
styles ["flat"]

icon-name: "settings-symbolic";
valign: center;
halign: center;

action-name: 'row.open-prefs';
activatable-widget: expander-arrow;

tooltip-text: _("Open extension preferences");
}

[action]
Gtk.Image error_icon {
styles ["error"]
[suffix]
Gtk.Image update_icon {
styles ["update"]

icon-name: "dialog-error-symbolic";
icon-name: "software-update-available-symbolic";
valign: center;
halign: center;

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

visible: false;

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

[action]
[suffix]
Gtk.Image out_of_date_icon {
styles ["error"]

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

[action]
Gtk.Image update_icon {
styles ["update"]

icon-name: "software-update-available-symbolic";
valign: center;
halign: center;
Gtk.ListBoxRow {
activatable: false;
focusable: false;
height-request: 46;

margin-start: 9;
margin-end: 9;

visible: false;

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

Gtk.ListBoxRow {
activatable: false;

Gtk.Grid {
styles ["row-content"]

row-spacing: 15;
column-spacing: 15;

Gtk.Label {
styles ["dim-label"]

label: _("Description");

xalign: 0;
yalign: 0;

layout {
row: 0;
column: 0;
}
}

Gtk.Label description_label {
styles ["multiline"]
xalign: 0;
wrap-mode: word;
wrap: true;
selectable: true;

layout {
row: 0;
column: 1;
}
}

Gtk.Label {
styles ["dim-label"]

label: _("Version");

xalign: 0;
yalign: 0;

layout {
row: 1;
column: 0;
}
}

Gtk.Label version_label {
xalign: 0;
wrap-mode: word;
wrap: true;
selectable: true;

layout {
row: 1;
column: 1;
}
}

Gtk.Label error_label_tag {
styles ["dim-label"]

label: _("Error");

xalign: 0;
yalign: 0;

layout {
row: 2;
column: 0;
}
}

Gtk.Label error_label {
xalign: 0;
wrap-mode: word_char;
wrap: true;
selectable: true;

layout {
row: 2;
column: 1;
}
}
}
}
[suffix]
Gtk.Button prefs_btn {
styles ["flat"]

Gtk.ListBoxRow {
activatable: false;
focusable: false;
height-request: 46;
icon-name: "settings-symbolic";
valign: center;
halign: center;

Gtk.Box {
halign: end;
spacing: 6;
margin-start: 4;
margin-end: 4;
action-name: 'row.open-prefs';

Gtk.Button details_btn {
styles ["flat"]
tooltip-text: _("Open extension preferences");
}

label: _("See Details");
valign: center;
[suffix]
Gtk.Switch ext_toggle {
valign: center;
halign: center;

action-name: 'win.show-detail';
}
action-name: 'row.state-set';
}

Gtk.Button remove_btn {
styles ["destructive-action"]
[suffix]
Gtk.Image expander-arrow {
styles ["expander-row-arrow"]

label: _("Remove");
valign: center;
valign: center;
halign: end;

action-name: 'row.remove';
}
}
icon-name: "go-next-symbolic";
}
}
48 changes: 25 additions & 23 deletions src/exm-extension-row.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@

struct _ExmExtensionRow
{
AdwExpanderRow parent_instance;
AdwActionRow parent_instance;

GSimpleActionGroup *action_group;

ExmExtension *extension;
gchar *uuid;

GtkButton *remove_btn;
// GtkButton *remove_btn;
GtkButton *prefs_btn;
GtkButton *details_btn;
// GtkButton *details_btn;
GtkSwitch *ext_toggle;

GtkLabel *description_label;
GtkLabel *version_label;
GtkLabel *error_label;
GtkLabel *error_label_tag;
// GtkLabel *description_label;
// GtkLabel *version_label;
// GtkLabel *error_label;
// GtkLabel *error_label_tag;

GtkImage *update_icon;
GtkImage *error_icon;
Expand All @@ -29,7 +29,7 @@ struct _ExmExtensionRow
guint signal_handler;
};

G_DEFINE_FINAL_TYPE (ExmExtensionRow, exm_extension_row, ADW_TYPE_EXPANDER_ROW)
G_DEFINE_FINAL_TYPE (ExmExtensionRow, exm_extension_row, ADW_TYPE_ACTION_ROW)

enum {
PROP_0,
Expand Down Expand Up @@ -176,13 +176,13 @@ update_state (ExmExtension *extension,
g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (is_enabled));
}

static void
/*static void
set_error_label_visible (ExmExtensionRow *self,
gboolean visible)
{
gtk_widget_set_visible (GTK_WIDGET (self->error_label), visible);
gtk_widget_set_visible (GTK_WIDGET (self->error_label_tag), visible);
}
}*/

static void
unbind_extension (ExmExtensionRow *self)
Expand Down Expand Up @@ -234,21 +234,23 @@ bind_extension (ExmExtensionRow *self,

g_object_set (self, "title", g_markup_escape_text(name, -1), "subtitle", uuid, NULL);
g_object_set (self->prefs_btn, "visible", has_prefs, NULL);
g_object_set (self->remove_btn, "visible", is_user, NULL);
// g_object_set (self->remove_btn, "visible", is_user, NULL);
g_object_set (self->update_icon, "visible", has_update, NULL);
g_object_set (self->version_label, "label", version, NULL);
// g_object_set (self->version_label, "label", version, NULL);
// TODO: Re-add version

// Trim description label's leading and trailing whitespace
char *description_trimmed = g_strchomp (g_strstrip (description));
/*char *description_trimmed = g_strchomp (g_strstrip (description));
g_object_set (self->description_label, "label", description_trimmed, NULL);
g_free (description_trimmed);
g_free (description_trimmed);*/

// Only show if error_msg exists and is not empty
g_object_set (self->error_label, "label", error_msg, NULL);
/*g_object_set (self->error_label, "label", error_msg, NULL);
gboolean has_error = (error_msg != NULL) && (strlen(error_msg) != 0);
set_error_label_visible (self, has_error);
set_error_label_visible (self, has_error);*/

gtk_actionable_set_action_target (GTK_ACTIONABLE (self->details_btn), "s", uuid);
gtk_actionable_set_action_name (GTK_ACTIONABLE (self), "win.show-detail");
gtk_actionable_set_action_target (GTK_ACTIONABLE (self), "s", uuid);

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

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

gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, description_label);
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_label);
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_label_tag);
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, version_label);
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, description_label);
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_label);
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_label_tag);
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, version_label);

gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, prefs_btn);
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, remove_btn);
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, details_btn);
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, remove_btn);
// gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, details_btn);
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, ext_toggle);
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, update_icon);
gtk_widget_class_bind_template_child (widget_class, ExmExtensionRow, error_icon);
Expand Down
2 changes: 1 addition & 1 deletion src/exm-extension-row.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ G_BEGIN_DECLS

#define EXM_TYPE_EXTENSION_ROW (exm_extension_row_get_type())

G_DECLARE_FINAL_TYPE (ExmExtensionRow, exm_extension_row, EXM, EXTENSION_ROW, AdwExpanderRow)
G_DECLARE_FINAL_TYPE (ExmExtensionRow, exm_extension_row, EXM, EXTENSION_ROW, AdwActionRow)

ExmExtensionRow *
exm_extension_row_new (ExmExtension *extension);
Expand Down

0 comments on commit 58d08ee

Please sign in to comment.