[gnome-software: 7/13] app-row: Don't show an insensitive button when narrow
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 7/13] app-row: Don't show an insensitive button when narrow
- Date: Mon, 12 Jul 2021 09:59:17 +0000 (UTC)
commit e76b028916c4bd539e29aece135f673fcc9af103
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Jun 30 16:15:34 2021 +0200
app-row: Don't show an insensitive button when narrow
This saves up horizontal space, especially as there usually is no icon
for this case.
src/gs-app-row.c | 15 +++++++++++++++
src/gs-app-row.ui | 14 ++++++++++----
2 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 4fe68b727..5d675aa97 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -32,6 +32,7 @@ typedef struct
GtkWidget *description_box;
GtkWidget *description_label;
GtkWidget *button_box;
+ GtkWidget *button_revealer;
GtkWidget *button;
GtkWidget *spinner;
GtkWidget *label;
@@ -109,6 +110,15 @@ gs_app_row_get_description (GsAppRow *app_row)
return g_string_new (tmp);
}
+static void
+gs_app_row_update_button_reveal (GsAppRow *app_row)
+{
+ GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
+ gboolean sensitive = gtk_widget_get_sensitive (priv->button);
+
+ gtk_widget_set_visible (priv->button_revealer, sensitive || !priv->is_narrow);
+}
+
static void
gs_app_row_refresh_button (GsAppRow *app_row, gboolean missing_search_result)
{
@@ -117,6 +127,7 @@ gs_app_row_refresh_button (GsAppRow *app_row, gboolean missing_search_result)
/* disabled */
if (!priv->show_buttons) {
+ gs_app_row_update_button_reveal (app_row);
gtk_widget_set_visible (priv->button, FALSE);
return;
}
@@ -248,6 +259,8 @@ gs_app_row_refresh_button (GsAppRow *app_row, gboolean missing_search_result)
gtk_widget_set_sensitive (priv->button, TRUE);
break;
}
+
+ gs_app_row_update_button_reveal (app_row);
}
static void
@@ -807,6 +820,7 @@ gs_app_row_class_init (GsAppRowClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, description_box);
gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, description_label);
gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, button_box);
+ gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, button_revealer);
gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, button);
gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, spinner);
gtk_widget_class_bind_template_child_private (widget_class, GsAppRow, label);
@@ -986,6 +1000,7 @@ gs_app_row_set_is_narrow (GsAppRow *app_row, gboolean is_narrow)
return;
priv->is_narrow = is_narrow;
+ gs_app_row_update_button_reveal (app_row);
g_object_notify_by_pspec (G_OBJECT (app_row), obj_props[PROP_IS_NARROW]);
}
diff --git a/src/gs-app-row.ui b/src/gs-app-row.ui
index 4b1a99a0c..e825092a3 100644
--- a/src/gs-app-row.ui
+++ b/src/gs-app-row.ui
@@ -202,10 +202,16 @@
<property name="halign">end</property>
<property name="valign">center</property>
<child>
- <object class="GsProgressButton" id="button">
- <property name="visible">False</property>
- <property name="halign">end</property>
- <property name="show-icon" bind-source="GsAppRow" bind-property="is-narrow"
bind-flags="sync-create"/>
+ <object class="GtkRevealer" id="button_revealer">
+ <property name="visible">True</property>
+ <property name="reveal-child">True</property>
+ <child>
+ <object class="GsProgressButton" id="button">
+ <property name="visible">False</property>
+ <property name="halign">end</property>
+ <property name="show-icon" bind-source="GsAppRow" bind-property="is-narrow"
bind-flags="sync-create"/>
+ </object>
+ </child>
</object>
<packing>
<property name="pack_type">end</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]