[gnome-software/1392-unify-lozenge-styling: 80/85] gs-context-dialog-row: Use GsLozenge
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1392-unify-lozenge-styling: 80/85] gs-context-dialog-row: Use GsLozenge
- Date: Mon, 16 May 2022 13:08:42 +0000 (UTC)
commit 5e976b87976e36bf54e28d27e54e519fa8b8ab75
Author: Milan Crha <mcrha redhat com>
Date: Tue May 3 20:49:09 2022 +0200
gs-context-dialog-row: Use GsLozenge
This fails to build at this moment, but will be fixed in the next commit.
src/gs-context-dialog-row.c | 37 +++++++++++++++----------------------
src/gs-context-dialog-row.h | 4 ++--
src/gs-context-dialog-row.ui | 29 +++--------------------------
3 files changed, 20 insertions(+), 50 deletions(-)
---
diff --git a/src/gs-context-dialog-row.c b/src/gs-context-dialog-row.c
index 11c9f3822..73f8fcbfc 100644
--- a/src/gs-context-dialog-row.c
+++ b/src/gs-context-dialog-row.c
@@ -30,6 +30,7 @@
#include <gtk/gtk.h>
#include "gs-context-dialog-row.h"
+#include "gs-lozenge.h"
#include "gs-enums.h"
struct _GsContextDialogRow
@@ -38,9 +39,7 @@ struct _GsContextDialogRow
GsContextDialogRowImportance importance;
- GtkWidget *lozenge; /* (unowned) */
- GtkImage *lozenge_content_image; /* (unowned) */
- GtkLabel *lozenge_content_text; /* (unowned) */
+ GsLozenge *lozenge; /* (unowned) */
};
G_DEFINE_TYPE (GsContextDialogRow, gs_context_dialog_row, ADW_TYPE_ACTION_ROW)
@@ -111,14 +110,10 @@ gs_context_dialog_row_set_property (GObject *object,
switch ((GsContextDialogRowProperty) prop_id) {
case PROP_ICON_NAME:
- gtk_image_set_from_icon_name (self->lozenge_content_image, g_value_get_string (value));
- gtk_widget_set_visible (GTK_WIDGET (self->lozenge_content_image), TRUE);
- gtk_widget_set_visible (GTK_WIDGET (self->lozenge_content_text), FALSE);
+ gs_lozenge_set_icon_name (self->lozenge, g_value_get_string (value));
break;
case PROP_CONTENT:
- gtk_label_set_text (self->lozenge_content_text, g_value_get_string (value));
- gtk_widget_set_visible (GTK_WIDGET (self->lozenge_content_image), FALSE);
- gtk_widget_set_visible (GTK_WIDGET (self->lozenge_content_text), TRUE);
+ gs_lozenge_set_text (self->lozenge, g_value_get_string (value));
break;
case PROP_IMPORTANCE: {
GtkStyleContext *context;
@@ -127,7 +122,7 @@ gs_context_dialog_row_set_property (GObject *object,
self->importance = g_value_get_enum (value);
css_class = css_class_for_importance (self->importance);
- context = gtk_widget_get_style_context (self->lozenge);
+ context = gtk_widget_get_style_context (GTK_WIDGET (self->lozenge));
gtk_style_context_remove_class (context, "green");
gtk_style_context_remove_class (context, "yellow");
@@ -204,8 +199,6 @@ gs_context_dialog_row_class_init (GsContextDialogRowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-context-dialog-row.ui");
gtk_widget_class_bind_template_child (widget_class, GsContextDialogRow, lozenge);
- gtk_widget_class_bind_template_child (widget_class, GsContextDialogRow, lozenge_content_image);
- gtk_widget_class_bind_template_child (widget_class, GsContextDialogRow, lozenge_content_text);
}
/**
@@ -282,7 +275,7 @@ gs_context_dialog_row_get_icon_name (GsContextDialogRow *self)
{
g_return_val_if_fail (GS_IS_CONTEXT_DIALOG_ROW (self), NULL);
- return gtk_image_get_icon_name (self->lozenge_content_image);
+ return gs_lozenge_get_icon_name (self->lozenge);
}
/**
@@ -299,7 +292,7 @@ gs_context_dialog_row_get_content (GsContextDialogRow *self)
{
g_return_val_if_fail (GS_IS_CONTEXT_DIALOG_ROW (self), NULL);
- return gtk_label_get_text (self->lozenge_content_text);
+ return gs_lozenge_get_text (self->lozenge);
}
/**
@@ -316,25 +309,25 @@ gs_context_dialog_row_get_content_is_markup (GsContextDialogRow *self)
{
g_return_val_if_fail (GS_IS_CONTEXT_DIALOG_ROW (self), FALSE);
- return gtk_label_get_use_markup (self->lozenge_content_text);
+ return gs_lozenge_get_use_markup (self->lozenge);
}
/**
- * gs_context_dialog_row_set_content_is_markup:
+ * gs_context_dialog_row_set_content_markup:
* @self: a #GsContextDialogRow
- * @is_markup: value to set
+ * @markup: markup to set
*
- * Set to %TRUE, when the #GsContextDialogRow:content is markup.
+ * Set the @markup content as markup.
*
* Since: 43
*/
void
-gs_context_dialog_row_set_content_is_markup (GsContextDialogRow *self,
- gboolean is_markup)
+gs_context_dialog_row_set_content_markup (GsContextDialogRow *self,
+ const gchar *markup)
{
g_return_if_fail (GS_IS_CONTEXT_DIALOG_ROW (self));
- gtk_label_set_use_markup (self->lozenge_content_text, is_markup);
+ gs_lozenge_set_markup (self->lozenge, markup);
}
/**
@@ -378,5 +371,5 @@ gs_context_dialog_row_set_size_groups (GsContextDialogRow *self,
g_return_if_fail (description == NULL || GTK_IS_SIZE_GROUP (description));
if (lozenge != NULL)
- gtk_size_group_add_widget (lozenge, self->lozenge);
+ gtk_size_group_add_widget (lozenge, GTK_WIDGET (self->lozenge));
}
diff --git a/src/gs-context-dialog-row.h b/src/gs-context-dialog-row.h
index 74c805918..d5d68fd25 100644
--- a/src/gs-context-dialog-row.h
+++ b/src/gs-context-dialog-row.h
@@ -57,9 +57,9 @@ const gchar *gs_context_dialog_row_get_content (GsContextDialogRow
*self);
GsContextDialogRowImportance gs_context_dialog_row_get_importance (GsContextDialogRow *self);
gboolean gs_context_dialog_row_get_content_is_markup
(GsContextDialogRow *self);
-void gs_context_dialog_row_set_content_is_markup
+void gs_context_dialog_row_set_content_markup
(GsContextDialogRow *self,
- gboolean is_markup);
+ const gchar *markup);
void gs_context_dialog_row_set_size_groups (GsContextDialogRow *self,
GtkSizeGroup *lozenge,
diff --git a/src/gs-context-dialog-row.ui b/src/gs-context-dialog-row.ui
index f759f9bf1..7c8d29eeb 100644
--- a/src/gs-context-dialog-row.ui
+++ b/src/gs-context-dialog-row.ui
@@ -6,35 +6,12 @@
<property name="focusable">False</property>
<child type="prefix">
- <object class="GtkBox" id="lozenge">
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="hexpand">False</property>
- <property name="margin-top">8</property>
- <property name="margin-bottom">8</property>
+ <object class="GsLozenge" id="lozenge">
+ <property name="circular">True</property>
+ <property name="pixel-size">16</property>
<style>
- <class name="context-tile-lozenge"/>
<class name="grey"/>
</style>
- <child>
- <object class="GtkImage" id="lozenge_content_image">
- <property name="halign">center</property>
- <property name="hexpand">True</property>
- <!-- this is a placeholder: the icon is actually set in code -->
- <property name="icon-name">safety-symbolic</property>
- <property name="pixel-size">16</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="lozenge_content_text">
- <property name="halign">center</property>
- <property name="hexpand">True</property>
- <!-- this is a placeholder: the text is actually set in code -->
- <property name="label">20 MB</property>
- <property name="visible">False</property>
- <property name="xalign">0.5</property>
- </object>
- </child>
</object>
</child>
</template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]