[gnome-control-center/gbsneto/region-redesign: 8/14] region: Switch language 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: 8/14] region: Switch language row to AdwActionRow
- Date: Mon, 7 Feb 2022 10:03:53 +0000 (UTC)
commit ae93012543fd933870c05a8d38ceae9a9e6ba8b9
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Feb 5 12:40:38 2022 -0300
region: Switch language row to AdwActionRow
panels/region/cc-region-panel.c | 37 ++++++++++++++--------------
panels/region/cc-region-panel.ui | 53 +++++++---------------------------------
2 files changed, 27 insertions(+), 63 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 684d6964a..7023cf4b0 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -54,8 +54,6 @@ struct _CcRegionPanel {
GtkInfoBar *infobar;
GtkSizeGroup *input_size_group;
GtkLabel *login_label;
- GtkLabel *language_label;
- GtkListBox *language_list;
GtkListBoxRow *language_row;
GtkToggleButton *login_language_button;
GtkButton *restart_button;
@@ -459,16 +457,7 @@ static void
activate_language_row (CcRegionPanel *self,
GtkListBoxRow *row)
{
- if (row == self->language_row) {
- if (!self->login || g_permission_get_allowed (self->permission)) {
- show_language_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_language_permission_cb,
- self);
- }
- } else if (row == self->formats_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)) {
@@ -515,7 +504,7 @@ update_language_label (CcRegionPanel *self)
if (!name)
name = gnome_get_language_from_locale (DEFAULT_LOCALE, DEFAULT_LOCALE);
- gtk_label_set_label (self->language_label, name);
+ adw_action_row_set_subtitle (ADW_ACTION_ROW (self->language_row), name);
/* Formats will change too if not explicitly set. */
update_region_label (self);
@@ -550,9 +539,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->language_list, "row-activated",
- G_CALLBACK (activate_language_row), self, G_CONNECT_SWAPPED);
-
g_signal_connect_object (self->formats_list, "row-activated",
G_CALLBACK (activate_language_row), self, G_CONNECT_SWAPPED);
@@ -671,7 +657,7 @@ login_changed (CcRegionPanel *self)
(g_permission_get_allowed (self->permission) ||
g_permission_get_can_acquire (self->permission));
/* FIXME: insensitive doesn't look quite right for this */
- gtk_widget_set_sensitive (GTK_WIDGET (self->language_list), !self->login || can_acquire);
+ gtk_widget_set_sensitive (GTK_WIDGET (self->language_row), !self->login || can_acquire);
update_language_label (self);
}
@@ -750,6 +736,20 @@ session_proxy_ready (GObject *source,
self->session = proxy;
}
+static void
+on_user_language_row_activated_cb (GtkListBoxRow *row,
+ CcRegionPanel *self)
+{
+ if (!self->login || g_permission_get_allowed (self->permission)) {
+ show_language_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_language_permission_cb,
+ self);
+ }
+}
+
static void
cc_region_panel_class_init (CcRegionPanelClass * klass)
{
@@ -768,13 +768,12 @@ cc_region_panel_class_init (CcRegionPanelClass * klass)
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);
- gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, language_label);
- gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, language_list);
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, language_row);
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, login_language_button);
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_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 87126d87e..d8b802a72 100644
--- a/panels/region/cc-region-panel.ui
+++ b/panels/region/cc-region-panel.ui
@@ -80,51 +80,16 @@
<property name="description" translatable="yes">The language used for text in windows and
web pages.</property>
<child>
- <object class="GtkListBox" id="language_list">
- <property name="margin_bottom">18</property>
- <property name="selection-mode">none</property>
- <style>
- <class name="boxed-list" />
- </style>
+ <object class="AdwActionRow" id="language_row">
+ <property name="use-underline">True</property>
+ <property name="title" translatable="yes">_Language</property>
+ <property name="activatable">True</property>
+ <signal name="activated" handler="on_user_language_row_activated_cb"
object="CcRegionPanel" swapped="no" />
+
<child>
- <object class="GtkListBoxRow" id="language_row">
- <child>
- <object class="GtkBox" id="language_box">
- <property name="orientation">vertical</property>
- <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="ellipsize">end</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Language</property>
- <property name="use_underline">True</property>
- <property name="hexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="language_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>
- </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]