applications: Make CcInfoRow subclass AdwActionRow

Same case as previous commit
This commit is contained in:
Georges Basile Stavracas Neto 2022-01-20 13:09:39 -03:00
parent 0bab8a6217
commit 9e38b89752
4 changed files with 16 additions and 65 deletions

View file

@ -435,7 +435,6 @@
<child> <child>
<object class="CcInfoRow" id="total"> <object class="CcInfoRow" id="total">
<property name="title" translatable="yes">&lt;b&gt;Total&lt;/b&gt;</property> <property name="title" translatable="yes">&lt;b&gt;Total&lt;/b&gt;</property>
<property name="use-markup">1</property>
<property name="info">Unknown</property> <property name="info">Unknown</property>
</object> </object>
</child> </child>

View file

@ -28,7 +28,6 @@ struct _CcInfoRow
{ {
GtkListBoxRow parent; GtkListBoxRow parent;
GtkWidget *title;
GtkWidget *info; GtkWidget *info;
GtkWidget *expander; GtkWidget *expander;
@ -36,13 +35,11 @@ struct _CcInfoRow
gboolean link; gboolean link;
}; };
G_DEFINE_TYPE (CcInfoRow, cc_info_row, GTK_TYPE_LIST_BOX_ROW) G_DEFINE_TYPE (CcInfoRow, cc_info_row, ADW_TYPE_ACTION_ROW)
enum enum
{ {
PROP_0, PROP_0,
PROP_TITLE,
PROP_USE_MARKUP,
PROP_INFO, PROP_INFO,
PROP_HAS_EXPANDER, PROP_HAS_EXPANDER,
PROP_IS_LINK, PROP_IS_LINK,
@ -59,18 +56,12 @@ cc_info_row_get_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_TITLE:
g_value_set_string (value, gtk_label_get_label (GTK_LABEL (row->title)));
break;
case PROP_INFO: case PROP_INFO:
g_value_set_string (value, gtk_label_get_label (GTK_LABEL (row->info))); g_value_set_string (value, gtk_label_get_label (GTK_LABEL (row->info)));
break; break;
case PROP_HAS_EXPANDER: case PROP_HAS_EXPANDER:
g_value_set_boolean (value, gtk_widget_get_visible (row->expander)); g_value_set_boolean (value, gtk_widget_get_visible (row->expander));
break; break;
case PROP_USE_MARKUP:
g_value_set_boolean (value, gtk_label_get_use_markup (GTK_LABEL (row->title)));
break;
case PROP_IS_LINK: case PROP_IS_LINK:
g_value_set_boolean (value, row->link); g_value_set_boolean (value, row->link);
break; break;
@ -104,10 +95,6 @@ cc_info_row_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_TITLE:
gtk_label_set_label (GTK_LABEL (row->title), g_value_get_string (value));
break;
case PROP_INFO: case PROP_INFO:
gtk_label_set_label (GTK_LABEL (row->info), g_value_get_string (value)); gtk_label_set_label (GTK_LABEL (row->info), g_value_get_string (value));
break; break;
@ -117,10 +104,6 @@ cc_info_row_set_property (GObject *object,
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), g_value_get_boolean (value)); gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), g_value_get_boolean (value));
break; break;
case PROP_USE_MARKUP:
gtk_label_set_use_markup (GTK_LABEL (row->title), g_value_get_boolean (value));
break;
case PROP_IS_LINK: case PROP_IS_LINK:
row->link = g_value_get_boolean (value); row->link = g_value_get_boolean (value);
update_expander (row); update_expander (row);
@ -147,21 +130,11 @@ cc_info_row_class_init (CcInfoRowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/applications/cc-info-row.ui"); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/applications/cc-info-row.ui");
g_object_class_install_property (object_class,
PROP_TITLE,
g_param_spec_string ("title", "title", "title",
NULL, G_PARAM_READWRITE));
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_INFO, PROP_INFO,
g_param_spec_string ("info", "info", "info", g_param_spec_string ("info", "info", "info",
NULL, G_PARAM_READWRITE)); NULL, G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_USE_MARKUP,
g_param_spec_boolean ("use-markup", "use-markup", "use-markup",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_HAS_EXPANDER, PROP_HAS_EXPANDER,
g_param_spec_boolean ("has-expander", "has-expander", "has-expander", g_param_spec_boolean ("has-expander", "has-expander", "has-expander",
@ -177,7 +150,6 @@ cc_info_row_class_init (CcInfoRowClass *klass)
g_param_spec_boolean ("is-link", "is-link", "is-link", g_param_spec_boolean ("is-link", "is-link", "is-link",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
gtk_widget_class_bind_template_child (widget_class, CcInfoRow, title);
gtk_widget_class_bind_template_child (widget_class, CcInfoRow, info); gtk_widget_class_bind_template_child (widget_class, CcInfoRow, info);
gtk_widget_class_bind_template_child (widget_class, CcInfoRow, expander); gtk_widget_class_bind_template_child (widget_class, CcInfoRow, expander);
} }

View file

@ -20,12 +20,12 @@
#pragma once #pragma once
#include <gtk/gtk.h> #include <adwaita.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define CC_TYPE_INFO_ROW (cc_info_row_get_type()) #define CC_TYPE_INFO_ROW (cc_info_row_get_type())
G_DECLARE_FINAL_TYPE (CcInfoRow, cc_info_row, CC, INFO_ROW, GtkListBoxRow) G_DECLARE_FINAL_TYPE (CcInfoRow, cc_info_row, CC, INFO_ROW, AdwActionRow)
CcInfoRow* cc_info_row_new (void); CcInfoRow* cc_info_row_new (void);

View file

@ -1,39 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="CcInfoRow" parent="GtkListBoxRow"> <template class="CcInfoRow" parent="AdwActionRow">
<property name="activatable">False</property>
<child> <child>
<object class="GtkBox"> <object class="GtkLabel" id="info">
<property name="margin-top">12</property> <property name="valign">center</property>
<property name="margin-bottom">12</property> <style>
<property name="margin-start">12</property> <class name="dim-label"/>
<property name="margin-end">12</property> </style>
<property name="spacing">12</property> </object>
<child> </child>
<object class="GtkLabel" id="title"> <child>
<property name="xalign">0</property> <object class="GtkImage" id="expander">
<property name="hexpand">1</property> <property name="visible">False</property>
<property name="ellipsize">end</property> <property name="valign">center</property>
</object> <property name="icon-name">pan-end-symbolic</property>
</child>
<child>
<object class="GtkLabel" id="info">
<property name="valign">center</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkImage" id="expander">
<property name="visible">False</property>
<property name="valign">center</property>
<property name="icon-name">pan-end-symbolic</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object> </object>
</child> </child>
</template> </template>