diff --git a/src/exm-search-row.blp b/src/exm-search-row.blp index 4bc328de..a8fca145 100644 --- a/src/exm-search-row.blp +++ b/src/exm-search-row.blp @@ -1,73 +1,91 @@ using Gtk 4.0; using Adw 1; -template $ExmSearchRow : Gtk.ListBoxRow { - styles ["search-row"] - - activatable: true; - - Gtk.Box header { - styles ["header"] - hexpand: true; - spacing: 10; - - Gtk.Grid { - hexpand: true; - column-spacing: 10; - - Gtk.Box { - hexpand: true; - orientation: vertical; - valign: center; - - Gtk.Label title { - styles ["title"] - ellipsize: end; - xalign: 0; - } - - Gtk.Label subtitle { - styles ["subtitle"] - ellipsize: end; - xalign: 0; - } - - layout { - row: 0; - column: 1; - } - } - - Gtk.Label description_label { - styles ["dim-label"] - - margin-top: 5; - single-line-mode: true; - xalign: 0; - wrap: true; - wrap-mode: word_char; - ellipsize: end; - lines: 2; - - layout { - row: 1; - column: 1; - } - } - } - - $ExmInstallButton install_btn { - valign: center; - halign: end; - } - - Gtk.Image { - styles ["expander-row-arrow"] - - valign: center; - halign: end; - - icon-name: "go-next-symbolic"; - } - } +template $ExmSearchRow: Gtk.ListBoxRow { + styles [ + "search-row" + ] + + activatable: true; + action-name: "win.show-detail"; + + Gtk.Box header { + styles [ + "header" + ] + + hexpand: true; + spacing: 10; + + Gtk.Grid { + hexpand: true; + column-spacing: 10; + + Gtk.Box { + hexpand: true; + orientation: vertical; + valign: center; + + Gtk.Label title { + styles [ + "title" + ] + + ellipsize: end; + xalign: 0; + label: bind template.search-result as <$ExmSearchResult>.name; + } + + Gtk.Label subtitle { + styles [ + "subtitle" + ] + + ellipsize: end; + xalign: 0; + label: bind template.search-result as <$ExmSearchResult>.creator; + } + + layout { + row: 0; + column: 1; + } + } + + Gtk.Label description_label { + styles [ + "dim-label" + ] + + margin-top: 5; + single-line-mode: true; + xalign: 0; + wrap: true; + wrap-mode: word_char; + ellipsize: end; + lines: 2; + label: bind template.search-result as <$ExmSearchResult>.description; + + layout { + row: 1; + column: 1; + } + } + } + + $ExmInstallButton install_btn { + valign: center; + halign: end; + } + + Gtk.Image { + styles [ + "expander-row-arrow" + ] + + valign: center; + halign: end; + icon-name: "go-next-symbolic"; + } + } } diff --git a/src/exm-search-row.c b/src/exm-search-row.c index 38d5e904..84895507 100644 --- a/src/exm-search-row.c +++ b/src/exm-search-row.c @@ -16,10 +16,7 @@ struct _ExmSearchRow gboolean is_supported; gchar *uuid; - GtkLabel *description_label; ExmInstallButton *install_btn; - GtkLabel *title; - GtkLabel *subtitle; }; G_DEFINE_FINAL_TYPE (ExmSearchRow, exm_search_row, GTK_TYPE_LIST_BOX_ROW) @@ -127,42 +124,17 @@ install_remote (GtkButton *button, static void exm_search_row_constructed (GObject *object) { - // TODO: This big block of property assignments is currently copy/pasted - // from ExmExtension. We can replace this with GtkExpression lookups - // once blueprint-compiler supports expressions. - // (See https://gitlab.gnome.org/jwestman/blueprint-compiler/-/issues/5) - ExmSearchRow *self = EXM_SEARCH_ROW (object); ExmInstallButtonState install_state; - gchar *uri; - int pk; - - gchar *uuid, *name, *creator, *icon_uri, *screenshot_uri, *link, *description; + gchar *uuid; g_object_get (self->search_result, "uuid", &uuid, - "name", &name, - "creator", &creator, - "icon", &icon_uri, - "screenshot", &screenshot_uri, - "link", &link, - "description", &description, - "pk", &pk, NULL); - uri = g_uri_resolve_relative ("https://extensions.gnome.org/", - link, - G_URI_FLAGS_NONE, - NULL); - - gtk_actionable_set_action_name (GTK_ACTIONABLE (self), "win.show-detail"); gtk_actionable_set_action_target (GTK_ACTIONABLE (self), "s", uuid); - gtk_label_set_label (self->title, name); - gtk_label_set_label (self->subtitle, creator); - gtk_label_set_label (self->description_label, description); - install_state = self->is_installed ? EXM_INSTALL_BUTTON_STATE_INSTALLED : (self->is_supported @@ -212,10 +184,7 @@ exm_search_row_class_init (ExmSearchRowClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/com/mattjakeman/ExtensionManager/exm-search-row.ui"); - gtk_widget_class_bind_template_child (widget_class, ExmSearchRow, description_label); gtk_widget_class_bind_template_child (widget_class, ExmSearchRow, install_btn); - gtk_widget_class_bind_template_child (widget_class, ExmSearchRow, title); - gtk_widget_class_bind_template_child (widget_class, ExmSearchRow, subtitle); } static void