[gnome-software/1111-app-details-addons] gs-details-page: Tweak presentation of add-ons
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1111-app-details-addons] gs-details-page: Tweak presentation of add-ons
- Date: Wed, 27 Jan 2021 01:17:01 +0000 (UTC)
commit 5b7a25be8fb7ccdb773c555e22fa56591a48143d
Author: Phaedrus Leeds <mwleeds endlessos org>
Date: Tue Jan 26 17:08:36 2021 -0800
gs-details-page: Tweak presentation of add-ons
Tweak the display of add-ons to more closely match the design mock-ups
(see the ticket linked below). The mock-ups use a circular checkbox but
I'm not sure how to do that so it's still a square one.
Note, there is an assertion failure when the removal confirmation dialog
is created:
Gdk gdk_wayland_window_set_dbus_properties_libgtk_only: assertion 'GDK_IS_WAYLAND_WINDOW (window)' failed
...but this isn't unique to the removal of add-ons (it happens for apps
too), and it doesn't prevent the confirmation dialog or the removal from
happening.
Helps: #1111
src/gs-app-addon-row.c | 35 ++++++++++++---
src/gs-app-addon-row.h | 4 +-
src/gs-app-addon-row.ui | 42 +++++++++++++-----
src/gs-details-page.c | 2 +-
src/gs-details-page.ui | 112 ++++++++++++++++++++++++------------------------
src/gs-page.c | 2 +-
6 files changed, 122 insertions(+), 75 deletions(-)
---
diff --git a/src/gs-app-addon-row.c b/src/gs-app-addon-row.c
index 9763e22a..f58437ce 100644
--- a/src/gs-app-addon-row.c
+++ b/src/gs-app-addon-row.c
@@ -22,7 +22,11 @@ struct _GsAppAddonRow
GtkWidget *name_label;
GtkWidget *description_label;
GtkWidget *label;
+ GtkWidget *button_remove;
GtkWidget *checkbox;
+
+ /* parent app page */
+ GsDetailsPage *details_page;
};
G_DEFINE_TYPE (GsAppAddonRow, gs_app_addon_row, GTK_TYPE_LIST_BOX_ROW)
@@ -38,6 +42,12 @@ checkbox_toggled (GtkWidget *widget, GsAppAddonRow *row)
g_object_notify (G_OBJECT (row), "selected");
}
+static void
+app_addon_remove_button_cb (GtkWidget *widget, GsAppAddonRow *row)
+{
+ gs_page_remove_app (GS_PAGE (row->details_page), row->app, NULL);
+}
+
/**
* gs_app_addon_row_get_summary:
*
@@ -112,19 +122,22 @@ gs_app_addon_row_refresh (GsAppAddonRow *row)
case GS_APP_STATE_AVAILABLE_LOCAL:
gtk_widget_set_sensitive (row->checkbox, TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (row->checkbox), FALSE);
+ gtk_widget_set_visible (row->button_remove, FALSE);
break;
case GS_APP_STATE_UPDATABLE:
case GS_APP_STATE_INSTALLED:
- gtk_widget_set_sensitive (row->checkbox, TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (row->checkbox), TRUE);
+ gtk_widget_set_visible (row->checkbox, FALSE);
+ gtk_widget_set_visible (row->button_remove, TRUE);
+ gtk_widget_set_sensitive (row->button_remove, TRUE);
break;
case GS_APP_STATE_INSTALLING:
gtk_widget_set_sensitive (row->checkbox, FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (row->checkbox), TRUE);
break;
case GS_APP_STATE_REMOVING:
- gtk_widget_set_sensitive (row->checkbox, FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (row->checkbox), FALSE);
+ gtk_widget_set_visible (row->checkbox, FALSE);
+ gtk_widget_set_visible (row->button_remove, TRUE);
+ gtk_widget_set_sensitive (row->button_remove, FALSE);
break;
default:
gtk_widget_set_sensitive (row->checkbox, FALSE);
@@ -171,6 +184,12 @@ gs_app_addon_row_set_addon (GsAppAddonRow *row, GsApp *app)
gs_app_addon_row_refresh (row);
}
+static void
+gs_app_addon_row_set_details_page (GsAppAddonRow *row, GsDetailsPage *details_page)
+{
+ row->details_page = g_object_ref (details_page);
+}
+
static void
gs_app_addon_row_destroy (GtkWidget *object)
{
@@ -180,6 +199,7 @@ gs_app_addon_row_destroy (GtkWidget *object)
g_signal_handlers_disconnect_by_func (row->app, gs_app_addon_row_notify_props_changed_cb,
row);
g_clear_object (&row->app);
+ g_clear_object (&row->details_page);
GTK_WIDGET_CLASS (gs_app_addon_row_parent_class)->destroy (object);
}
@@ -236,6 +256,7 @@ gs_app_addon_row_class_init (GsAppAddonRowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsAppAddonRow, description_label);
gtk_widget_class_bind_template_child (widget_class, GsAppAddonRow, label);
gtk_widget_class_bind_template_child (widget_class, GsAppAddonRow, checkbox);
+ gtk_widget_class_bind_template_child (widget_class, GsAppAddonRow, button_remove);
}
static void
@@ -246,6 +267,8 @@ gs_app_addon_row_init (GsAppAddonRow *row)
g_signal_connect (row->checkbox, "toggled",
G_CALLBACK (checkbox_toggled), row);
+ g_signal_connect (row->button_remove, "clicked",
+ G_CALLBACK (app_addon_remove_button_cb), row);
}
void
@@ -261,13 +284,15 @@ gs_app_addon_row_get_selected (GsAppAddonRow *row)
}
GtkWidget *
-gs_app_addon_row_new (GsApp *app)
+gs_app_addon_row_new (GsApp *app, GsDetailsPage *details_page)
{
GtkWidget *row;
g_return_val_if_fail (GS_IS_APP (app), NULL);
+ g_return_val_if_fail (GS_IS_DETAILS_PAGE (details_page), NULL);
row = g_object_new (GS_TYPE_APP_ADDON_ROW, NULL);
gs_app_addon_row_set_addon (GS_APP_ADDON_ROW (row), app);
+ gs_app_addon_row_set_details_page (GS_APP_ADDON_ROW (row), details_page);
return row;
}
diff --git a/src/gs-app-addon-row.h b/src/gs-app-addon-row.h
index 257ef866..35d29f62 100644
--- a/src/gs-app-addon-row.h
+++ b/src/gs-app-addon-row.h
@@ -12,6 +12,7 @@
#include <gtk/gtk.h>
#include "gnome-software-private.h"
+#include "gs-details-page.h"
G_BEGIN_DECLS
@@ -19,7 +20,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GsAppAddonRow, gs_app_addon_row, GS, APP_ADDON_ROW, GtkListBoxRow)
-GtkWidget *gs_app_addon_row_new (GsApp *app);
+GtkWidget *gs_app_addon_row_new (GsApp *app,
+ GsDetailsPage *details_page);
void gs_app_addon_row_refresh (GsAppAddonRow *row);
void gs_app_addon_row_set_selected (GsAppAddonRow *row,
gboolean selected);
diff --git a/src/gs-app-addon-row.ui b/src/gs-app-addon-row.ui
index 471d373a..1e141a2e 100644
--- a/src/gs-app-addon-row.ui
+++ b/src/gs-app-addon-row.ui
@@ -11,12 +11,6 @@
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="orientation">horizontal</property>
- <child>
- <object class="GtkCheckButton" id="checkbox">
- <property name="visible">True</property>
- <property name="valign">center</property>
- </object>
- </child>
<child>
<object class="GtkBox" id="name_box">
<property name="visible">True</property>
@@ -31,6 +25,9 @@
<property name="max_width_chars">20</property>
<property name="xalign">0.0</property>
<property name="yalign">0.5</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
</object>
</child>
<child>
@@ -49,11 +46,34 @@
</object>
</child>
<child>
- <object class="GtkLabel" id="label">
- <property name="visible">False</property>
- <property name="margin_start">12</property>
- <property name="width_request">100</property>
- <property name="xalign">1</property>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="valign">center</property>
+ <property name="hexpand">False</property>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">False</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+ <property name="width_request">100</property>
+ <property name="xalign">1</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_remove">
+ <property name="visible">False</property>
+ <property name="use_underline">True</property>
+ <property name="label" translatable="yes">_Uninstall</property>
+ <property name="width_request">105</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbox">
+ <property name="visible">True</property>
+ </object>
+ </child>
</object>
<packing>
<property name="pack_type">end</property>
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 4123ed98..f19d4920 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1486,7 +1486,7 @@ gs_details_page_refresh_addons (GsDetailsPage *self)
gs_app_get_state (addon) == GS_APP_STATE_UNAVAILABLE)
continue;
- row = gs_app_addon_row_new (addon);
+ row = gs_app_addon_row_new (addon, self);
gtk_container_add (GTK_CONTAINER (self->list_box_addons), row);
gtk_widget_show (row);
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index 2afc50ea..456c3e54 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -388,6 +388,62 @@
<property name="margin_bottom">14</property>
</object>
</child>
+ <child>
+ <object class="GtkBox" id="box_addons">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="margin_bottom">26</property>
+
+ <child>
+ <object class="GtkBox" id="box_addons_title">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="margin_bottom">18</property>
+ <child>
+ <object class="GtkLabel" id="label_addons_title">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Add-ons</property>
+ <style>
+ <class name="application-details-title"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_addons_uninstalled_app">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ <property name="max-width-chars">40</property>
+ <property name="label" translatable="yes">Selected add-ons will be
installed with the application.</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkFrame" id="box_addons_frame">
+ <property name="visible">True</property>
+ <property name="shadow_type">in</property>
+ <property name="halign">fill</property>
+ <property name="valign">start</property>
+ <style>
+ <class name="view"/>
+ </style>
+ <child>
+ <object class="GtkListBox" id="list_box_addons">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="selection_mode">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkLabel" id="label_webapp_warning">
<property name="visible">False</property>
@@ -1080,62 +1136,6 @@
</child>
</object>
</child>
- <child>
- <object class="GtkBox" id="box_addons">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin_bottom">26</property>
-
- <child>
- <object class="GtkBox" id="box_addons_title">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin_bottom">18</property>
- <child>
- <object class="GtkLabel" id="label_addons_title">
- <property name="visible">True</property>
- <property name="halign">start</property>
- <property name="valign">start</property>
- <property name="hexpand">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Add-ons</property>
- <style>
- <class name="application-details-title"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="label_addons_uninstalled_app">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="wrap">True</property>
- <property name="max-width-chars">40</property>
- <property name="label" translatable="yes">Selected add-ons will be
installed with the application.</property>
- </object>
- </child>
- </object>
- </child>
-
- <child>
- <object class="GtkFrame" id="box_addons_frame">
- <property name="visible">True</property>
- <property name="shadow_type">in</property>
- <property name="halign">fill</property>
- <property name="valign">start</property>
- <style>
- <class name="view"/>
- </style>
- <child>
- <object class="GtkListBox" id="list_box_addons">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="selection_mode">none</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="GtkBox" id="box_reviews">
<property name="visible">False</property>
diff --git a/src/gs-page.c b/src/gs-page.c
index d76db20f..9815623a 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -442,7 +442,7 @@ gs_page_remove_app (GsPage *page, GsApp *app, GCancellable *cancellable)
helper->action = GS_PLUGIN_ACTION_REMOVE;
helper->app = g_object_ref (app);
helper->page = g_object_ref (page);
- helper->cancellable = g_object_ref (cancellable);
+ helper->cancellable = cancellable != NULL ? g_object_ref (cancellable) : NULL;
if (gs_app_get_state (app) == GS_APP_STATE_QUEUED_FOR_INSTALL) {
g_autoptr(GsPluginJob) plugin_job = NULL;
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REMOVE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]