[gnome-software/1111-app-details-addons: 1/3] 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: 1/3] gs-details-page: Tweak presentation of add-ons
- Date: Fri, 29 Jan 2021 00:45:15 +0000 (UTC)
commit 9df33c88444e0322d9946f35dd0d17022a2e0073
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 | 38 +++++++++++++---
src/gs-app-addon-row.ui | 42 +++++++++++++-----
src/gs-details-page.c | 14 ++++++
src/gs-details-page.ui | 112 ++++++++++++++++++++++++------------------------
src/gs-page.c | 2 +-
5 files changed, 135 insertions(+), 73 deletions(-)
---
diff --git a/src/gs-app-addon-row.c b/src/gs-app-addon-row.c
index 9763e22a..9f269849 100644
--- a/src/gs-app-addon-row.c
+++ b/src/gs-app-addon-row.c
@@ -22,6 +22,7 @@ struct _GsAppAddonRow
GtkWidget *name_label;
GtkWidget *description_label;
GtkWidget *label;
+ GtkWidget *button_remove;
GtkWidget *checkbox;
};
@@ -32,12 +33,25 @@ enum {
PROP_SELECTED
};
+enum {
+ SIGNAL_REMOVE_BUTTON_CLICKED,
+ SIGNAL_LAST
+};
+
+static guint signals [SIGNAL_LAST] = { 0 };
+
static void
checkbox_toggled (GtkWidget *widget, GsAppAddonRow *row)
{
g_object_notify (G_OBJECT (row), "selected");
}
+static void
+app_addon_remove_button_cb (GtkWidget *widget, GsAppAddonRow *row)
+{
+ g_signal_emit (row, signals[SIGNAL_REMOVE_BUTTON_CLICKED], 0);
+}
+
/**
* gs_app_addon_row_get_summary:
*
@@ -101,8 +115,9 @@ gs_app_addon_row_refresh (GsAppAddonRow *row)
break;
}
- /* update the checkbox */
+ /* update the checkbox and remove button */
g_signal_handlers_block_by_func (row->checkbox, checkbox_toggled, row);
+ g_signal_handlers_block_by_func (row->checkbox, app_addon_remove_button_cb, row);
switch (gs_app_get_state (row->app)) {
case GS_APP_STATE_QUEUED_FOR_INSTALL:
gtk_widget_set_sensitive (row->checkbox, TRUE);
@@ -112,19 +127,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);
@@ -132,6 +150,7 @@ gs_app_addon_row_refresh (GsAppAddonRow *row)
break;
}
g_signal_handlers_unblock_by_func (row->checkbox, checkbox_toggled, row);
+ g_signal_handlers_unblock_by_func (row->checkbox, app_addon_remove_button_cb, row);
}
GsApp *
@@ -230,12 +249,19 @@ gs_app_addon_row_class_init (GsAppAddonRowClass *klass)
FALSE, G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_SELECTED, pspec);
+ signals [SIGNAL_REMOVE_BUTTON_CLICKED] =
+ g_signal_new ("remove-button-clicked",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-app-addon-row.ui");
gtk_widget_class_bind_template_child (widget_class, GsAppAddonRow, name_label);
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 +272,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
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..f363d011 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1467,6 +1467,7 @@ list_sort_func (GtkListBoxRow *a,
}
static void gs_details_page_addon_selected_cb (GsAppAddonRow *row, GParamSpec *pspec, GsDetailsPage *self);
+static void gs_details_page_addon_remove_cb (GsAppAddonRow *row, gpointer user_data);
static void
gs_details_page_refresh_addons (GsDetailsPage *self)
@@ -1494,6 +1495,9 @@ gs_details_page_refresh_addons (GsDetailsPage *self)
g_signal_connect (row, "notify::selected",
G_CALLBACK (gs_details_page_addon_selected_cb),
self);
+ g_signal_connect (row, "remove-button-clicked",
+ G_CALLBACK (gs_details_page_addon_remove_cb),
+ self);
}
}
@@ -2242,6 +2246,16 @@ gs_details_page_addon_selected_cb (GsAppAddonRow *row,
}
}
+static void
+gs_details_page_addon_remove_cb (GsAppAddonRow *row, gpointer user_data)
+{
+ GsApp *addon;
+ GsDetailsPage *self = GS_DETAILS_PAGE (user_data);
+
+ addon = gs_app_addon_row_get_addon (row);
+ gs_page_remove_app (GS_PAGE (self), addon, NULL);
+}
+
static void
gs_details_page_app_launch_button_cb (GtkWidget *widget, GsDetailsPage *self)
{
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]