applications: Make CcToggleRow subclass AdwActionRow

Makes paddings, margins, behavior consistent with other panels.
This commit is contained in:
Georges Basile Stavracas Neto 2022-01-20 12:36:27 -03:00
parent 1b42b854c2
commit 0bab8a6217
3 changed files with 9 additions and 39 deletions

View file

@ -26,18 +26,16 @@
struct _CcToggleRow
{
GtkListBoxRow parent;
AdwActionRow parent;
GtkWidget *title;
GtkWidget *toggle;
};
G_DEFINE_TYPE (CcToggleRow, cc_toggle_row, GTK_TYPE_LIST_BOX_ROW)
G_DEFINE_TYPE (CcToggleRow, cc_toggle_row, ADW_TYPE_ACTION_ROW)
enum
{
PROP_0,
PROP_TITLE,
PROP_ALLOWED
};
@ -57,9 +55,6 @@ cc_toggle_row_get_property (GObject *object,
switch (prop_id)
{
case PROP_TITLE:
g_value_set_string (value, gtk_label_get_label (GTK_LABEL (row->title)));
break;
case PROP_ALLOWED:
g_value_set_boolean (value, cc_toggle_row_get_allowed (row));
break;
@ -79,9 +74,6 @@ cc_toggle_row_set_property (GObject *object,
switch (prop_id)
{
case PROP_TITLE:
gtk_label_set_label (GTK_LABEL (row->title), g_value_get_string (value));
break;
case PROP_ALLOWED:
cc_toggle_row_set_allowed (row, g_value_get_boolean (value));
break;
@ -102,17 +94,11 @@ cc_toggle_row_class_init (CcToggleRowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/applications/cc-toggle-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,
PROP_ALLOWED,
g_param_spec_boolean ("allowed", "allowed", "allowed",
FALSE, G_PARAM_READWRITE));
gtk_widget_class_bind_template_child (widget_class, CcToggleRow, title);
gtk_widget_class_bind_template_child (widget_class, CcToggleRow, toggle);
gtk_widget_class_bind_template_callback (widget_class, changed_cb);

View file

@ -20,12 +20,12 @@
#pragma once
#include <gtk/gtk.h>
#include <adwaita.h>
G_BEGIN_DECLS
#define CC_TYPE_TOGGLE_ROW (cc_toggle_row_get_type())
G_DECLARE_FINAL_TYPE (CcToggleRow, cc_toggle_row, CC, TOGGLE_ROW, GtkListBoxRow)
G_DECLARE_FINAL_TYPE (CcToggleRow, cc_toggle_row, CC, TOGGLE_ROW, AdwActionRow)
CcToggleRow* cc_toggle_row_new (void);

View file

@ -1,27 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="CcToggleRow" parent="GtkListBoxRow">
<property name="activatable">False</property>
<template class="CcToggleRow" parent="AdwActionRow">
<property name="activatable-widget">toggle</property>
<child>
<object class="GtkBox">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="title">
<property name="xalign">0</property>
<property name="hexpand">1</property>
<property name="ellipsize">end</property>
</object>
</child>
<child>
<object class="GtkSwitch" id="toggle">
<property name="valign">center</property>
<signal name="notify::active" handler="changed_cb" swapped="yes"/>
</object>
</child>
<object class="GtkSwitch" id="toggle">
<property name="valign">center</property>
<signal name="notify::active" handler="changed_cb" swapped="yes"/>
</object>
</child>
</template>