[gnome-control-center/gbsneto/region-redesign: 5/10] region: Switch formats row to AdwActionRow
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gbsneto/region-redesign: 5/10] region: Switch formats row to AdwActionRow
- Date: Sun, 6 Feb 2022 04:03:24 +0000 (UTC)
commit 7170459847bdd290aad8b1874be32ead7b001e00
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Feb 5 12:46:18 2022 -0300
region: Switch formats row to AdwActionRow
panels/region/cc-region-panel.c | 40 ++++++++++++++--------------------
panels/region/cc-region-panel.ui | 46 ++++++++--------------------------------
2 files changed, 25 insertions(+), 61 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 7023cf4b0..8cca6030d 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -48,8 +48,6 @@
struct _CcRegionPanel {
CcPanel parent_instance;
- GtkLabel *formats_label;
- GtkListBox *formats_list;
GtkListBoxRow *formats_row;
GtkInfoBar *infobar;
GtkSizeGroup *input_size_group;
@@ -453,22 +451,6 @@ choose_region_permission_cb (GObject *source, GAsyncResult *res, gpointer user_d
show_region_chooser (self);
}
-static void
-activate_language_row (CcRegionPanel *self,
- GtkListBoxRow *row)
-{
- if (row == self->formats_row) {
- if (!self->login || g_permission_get_allowed (self->permission)) {
- show_region_chooser (self);
- } else if (g_permission_get_can_acquire (self->permission)) {
- g_permission_acquire_async (self->permission,
- cc_panel_get_cancellable (CC_PANEL (self)),
- choose_region_permission_cb,
- self);
- }
- }
-}
-
static void
update_region_label (CcRegionPanel *self)
{
@@ -481,7 +463,7 @@ update_region_label (CcRegionPanel *self)
if (!name)
name = gnome_get_country_from_locale (DEFAULT_LOCALE, DEFAULT_LOCALE);
- gtk_label_set_label (self->formats_label, name);
+ adw_action_row_set_subtitle (ADW_ACTION_ROW (self->formats_row), name);
}
static void
@@ -539,9 +521,6 @@ setup_language_section (CcRegionPanel *self)
g_signal_connect_object (self->locale_settings, "changed::" KEY_REGION,
G_CALLBACK (update_region_from_setting), self, G_CONNECT_SWAPPED);
- g_signal_connect_object (self->formats_list, "row-activated",
- G_CALLBACK (activate_language_row), self, G_CONNECT_SWAPPED);
-
update_language_from_user (self);
update_region_from_setting (self);
}
@@ -736,6 +715,20 @@ session_proxy_ready (GObject *source,
self->session = proxy;
}
+static void
+on_user_formats_row_activated_cb (GtkListBoxRow *row,
+ CcRegionPanel *self)
+{
+ if (!self->login || g_permission_get_allowed (self->permission)) {
+ show_region_chooser (self);
+ } else if (g_permission_get_can_acquire (self->permission)) {
+ g_permission_acquire_async (self->permission,
+ cc_panel_get_cancellable (CC_PANEL (self)),
+ choose_region_permission_cb,
+ self);
+ }
+}
+
static void
on_user_language_row_activated_cb (GtkListBoxRow *row,
CcRegionPanel *self)
@@ -763,8 +756,6 @@ cc_region_panel_class_init (CcRegionPanelClass * klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/region/cc-region-panel.ui");
- gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, formats_label);
- gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, formats_list);
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, formats_row);
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, infobar);
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, login_label);
@@ -773,6 +764,7 @@ cc_region_panel_class_init (CcRegionPanelClass * klass)
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, restart_button);
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, session_or_login_box);
+ gtk_widget_class_bind_template_callback (widget_class, on_user_formats_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, on_user_language_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, restart_now);
}
diff --git a/panels/region/cc-region-panel.ui b/panels/region/cc-region-panel.ui
index 9f161e9bb..0abc64608 100644
--- a/panels/region/cc-region-panel.ui
+++ b/panels/region/cc-region-panel.ui
@@ -109,44 +109,16 @@
<property name="description" translatable="yes">The format used for numbers, dates, and
currencies.</property>
<child>
- <object class="GtkListBox" id="formats_list">
- <property name="selection-mode">none</property>
- <style>
- <class name="boxed-list" />
- </style>
+ <object class="AdwActionRow" id="formats_row">
+ <property name="use-underline">True</property>
+ <property name="title" translatable="yes">_Formats</property>
+ <property name="activatable">True</property>
+ <signal name="activated" handler="on_user_formats_row_activated_cb"
object="CcRegionPanel" swapped="no" />
+
<child>
- <object class="GtkListBoxRow" id="formats_row">
- <child>
- <object class="GtkBox">
- <property name="height_request">50</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="margin_bottom">8</property>
- <property name="margin_top">8</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Formats</property>
- <property name="use_underline">True</property>
- <property name="hexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="formats_label">
- <property name="xalign">1</property>
- <property name="margin_bottom">8</property>
- <property name="margin_top">8</property>
- </object>
- </child>
- <child>
- <object class="GtkImage">
- <property name="valign">center</property>
- <property name="icon-name">go-next-symbolic</property>
- </object>
- </child>
- </object>
- </child>
+ <object class="GtkImage">
+ <property name="valign">center</property>
+ <property name="icon-name">go-next-symbolic</property>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]