[gnome-control-center/gbsneto/gtk4: 31/31] region: Port to GTK4




commit 9b25d73c145b1ad86ebcd6fd595097ac001f728e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Oct 31 22:12:05 2021 -0300

    region: Port to GTK4
    
    An uneventful port.

 panels/meson.build                 |   2 +-
 panels/region/cc-format-chooser.c  | 153 +++++++++++----------
 panels/region/cc-format-chooser.ui |  82 +++--------
 panels/region/cc-format-preview.c  |   2 +-
 panels/region/cc-format-preview.ui |  33 +----
 panels/region/cc-region-panel.c    |  25 ++--
 panels/region/cc-region-panel.ui   | 273 ++++++++++++++-----------------------
 shell/cc-panel-loader.c            |   4 +-
 8 files changed, 217 insertions(+), 357 deletions(-)
---
diff --git a/panels/meson.build b/panels/meson.build
index 96651cf2e..f57bdbffa 100644
--- a/panels/meson.build
+++ b/panels/meson.build
@@ -20,7 +20,7 @@ panels = [
 #  'online-accounts',
   'power',
   'printers',
-#  'region',
+  'region',
   'removable-media',
   'search',
   'sharing',
diff --git a/panels/region/cc-format-chooser.c b/panels/region/cc-format-chooser.c
index a635a39e4..7a4c731ee 100644
--- a/panels/region/cc-format-chooser.c
+++ b/panels/region/cc-format-chooser.c
@@ -27,9 +27,8 @@
 #include <langinfo.h>
 #include <string.h>
 #include <glib/gi18n.h>
-#include <handy.h>
+#include <adwaita.h>
 
-#include "list-box-helper.h"
 #include "cc-common-language.h"
 #include "cc-format-preview.h"
 #include "cc-util.h"
@@ -38,29 +37,31 @@
 #include <libgnome-desktop/gnome-languages.h>
 
 struct _CcFormatChooser {
-        GtkDialog parent_instance;
-
-        GtkWidget *title_bar;
-        GtkWidget *title_buttons;
-        GtkWidget *cancel_button;
-        GtkWidget *back_button;
-        GtkWidget *done_button;
-        GtkWidget *empty_results_view;
-        GtkWidget *main_leaflet;
-        GtkWidget *region_filter_entry;
-        GtkWidget *region_list;
-        GtkWidget *region_list_stack;
-        GtkWidget *common_region_title;
-        GtkWidget *common_region_listbox;
-        GtkWidget *region_title;
-        GtkWidget *region_listbox;
-        CcFormatPreview *format_preview;
-        gboolean adding;
-        gboolean showing_extra;
-        gboolean no_results;
-        gchar *region;
-        gchar *preview_region;
-        gchar **filter_words;
+  GtkDialog parent_instance;
+
+  GtkWidget *title_bar;
+  GtkWidget *title_buttons;
+  GtkWidget *cancel_button;
+  GtkWidget *back_button;
+  GtkWidget *done_button;
+  GtkWidget *empty_results_view;
+  GtkWidget *main_leaflet;
+  GtkWidget *region_filter_entry;
+  GtkWidget *region_list;
+  GtkWidget *region_list_stack;
+  GtkWidget *common_region_title;
+  GtkWidget *common_region_listbox;
+  GtkWidget *region_box;
+  GtkWidget *region_title;
+  GtkWidget *region_listbox;
+  GtkWidget *preview_box;
+  CcFormatPreview *format_preview;
+  gboolean adding;
+  gboolean showing_extra;
+  gboolean no_results;
+  gchar *region;
+  gchar *preview_region;
+  gchar **filter_words;
 };
 
 G_DEFINE_TYPE (CcFormatChooser, cc_format_chooser, GTK_TYPE_DIALOG)
@@ -69,17 +70,17 @@ static void
 update_check_button_for_list (GtkWidget   *list_box,
                               const gchar *locale_id)
 {
-  g_autoptr(GList) children = NULL;
-  GList *l;
+  GtkWidget *child;
 
-  g_assert (GTK_IS_CONTAINER (list_box));
-
-  children = gtk_container_get_children (GTK_CONTAINER (list_box));
-  for (l = children; l; l = l->next)
+  for (child = gtk_widget_get_first_child (list_box);
+       child;
+       child = gtk_widget_get_next_sibling (child))
     {
-      GtkWidget *row = l->data;
-      GtkWidget *check = g_object_get_data (G_OBJECT (row), "check");
-      const gchar *region = g_object_get_data (G_OBJECT (row), "locale-id");
+      if (!GTK_IS_LIST_BOX_ROW (child))
+        continue;
+
+      GtkWidget *check = g_object_get_data (G_OBJECT (child), "check");
+      const gchar *region = g_object_get_data (G_OBJECT (child), "locale-id");
       if (check == NULL || region == NULL)
         continue;
 
@@ -134,8 +135,7 @@ padded_label_new (const char *text)
 
         label = gtk_label_new (text);
         gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
-        gtk_widget_show (label);
-        gtk_container_add (GTK_CONTAINER (widget), label);
+        gtk_box_append (GTK_BOX (widget), label);
 
         return widget;
 }
@@ -145,22 +145,18 @@ format_chooser_back_button_clicked_cb (CcFormatChooser *self)
 {
   g_assert (CC_IS_FORMAT_CHOOSER (self));
 
-  gtk_header_bar_set_title (GTK_HEADER_BAR (self->title_bar), _("Formats"));
-  hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->main_leaflet), "region-list");
+  gtk_window_set_title (GTK_WINDOW (self), _("Formats"));
+  adw_leaflet_set_visible_child (ADW_LEAFLET (self->main_leaflet), self->region_list);
   gtk_stack_set_visible_child (GTK_STACK (self->title_buttons), self->cancel_button);
   gtk_widget_show (self->done_button);
 }
 
 static void
-cc_format_chooser_preview_button_set_visible (GtkListBoxRow *row,
-                                              gpointer       user_data)
+set_preview_button_visible (GtkWidget *row,
+                            gboolean   visible)
 {
   GtkWidget *button;
-  gboolean visible;
-
-  g_assert (GTK_IS_LIST_BOX_ROW (row));
 
-  visible = GPOINTER_TO_INT (user_data);
   button = g_object_get_data (G_OBJECT (row), "preview-button");
   g_assert (button);
 
@@ -171,23 +167,34 @@ cc_format_chooser_preview_button_set_visible (GtkListBoxRow *row,
 static void
 format_chooser_leaflet_fold_changed_cb (CcFormatChooser *self)
 {
+  GtkWidget *child;
   gboolean folded;
 
   g_assert (CC_IS_FORMAT_CHOOSER (self));
 
-  folded = hdy_leaflet_get_folded (HDY_LEAFLET (self->main_leaflet));
-  gtk_container_foreach (GTK_CONTAINER (self->common_region_listbox),
-                         (GtkCallback)cc_format_chooser_preview_button_set_visible,
-                         GINT_TO_POINTER (folded));
-  gtk_container_foreach (GTK_CONTAINER (self->region_listbox),
-                         (GtkCallback)cc_format_chooser_preview_button_set_visible,
-                         GINT_TO_POINTER (folded));
+  folded = adw_leaflet_get_folded (ADW_LEAFLET (self->main_leaflet));
+
+  for (child = gtk_widget_get_first_child (self->common_region_listbox);
+       child;
+       child = gtk_widget_get_next_sibling (child))
+    {
+      if (GTK_IS_LIST_BOX_ROW (child))
+        set_preview_button_visible (child, folded);
+    }
+
+  for (child = gtk_widget_get_first_child (self->region_listbox);
+       child;
+       child = gtk_widget_get_next_sibling (child))
+    {
+      if (GTK_IS_LIST_BOX_ROW (child))
+        set_preview_button_visible (child, folded);
+    }
 
   if (!folded)
     {
       cc_format_preview_set_region (self->format_preview, self->region);
-      gtk_header_bar_set_title (GTK_HEADER_BAR (self->title_bar), _("Formats"));
-      hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->main_leaflet), "region-list");
+      gtk_window_set_title (GTK_WINDOW (self), _("Formats"));
+      adw_leaflet_set_visible_child (ADW_LEAFLET (self->main_leaflet), self->region_box);
       gtk_stack_set_visible_child (GTK_STACK (self->title_buttons), self->cancel_button);
       gtk_widget_show (self->done_button);
     }
@@ -210,12 +217,12 @@ preview_button_clicked_cb (CcFormatChooser *self,
   locale_name = g_object_get_data (G_OBJECT (row), "locale-name");
   cc_format_preview_set_region (self->format_preview, region);
 
-  hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->main_leaflet), "preview");
+  adw_leaflet_set_visible_child (ADW_LEAFLET (self->main_leaflet), self->preview_box);
   gtk_stack_set_visible_child (GTK_STACK (self->title_buttons), self->back_button);
   gtk_widget_hide (self->done_button);
 
   if (locale_name)
-    gtk_header_bar_set_title (GTK_HEADER_BAR (self->title_bar), locale_name);
+    gtk_window_set_title (GTK_WINDOW (self), locale_name);
 }
 
 static GtkWidget *
@@ -236,23 +243,19 @@ region_widget_new (CcFormatChooser *self,
         locale_untranslated_name = gnome_get_country_from_locale (locale_id, "C");
 
         row = gtk_list_box_row_new ();
-        gtk_widget_show (row);
         box = padded_label_new (locale_name);
-        gtk_widget_show (box);
-        gtk_container_add (GTK_CONTAINER (row), box);
+        gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
 
-        button = gtk_button_new_from_icon_name ("view-layout-symbolic", GTK_ICON_SIZE_BUTTON);
+        check = gtk_image_new_from_icon_name ("object-select-symbolic");
+        gtk_widget_set_hexpand (check, TRUE);
+        gtk_widget_set_opacity (check, 0.0);
+        gtk_box_append (GTK_BOX (box), check);
+
+        button = gtk_button_new_from_icon_name ("view-layout-symbolic");
         g_signal_connect_object (button, "clicked", G_CALLBACK (preview_button_clicked_cb),
                                  self, G_CONNECT_SWAPPED);
         gtk_widget_show (button);
-        gtk_box_pack_end (GTK_BOX (box), button, FALSE, TRUE, 0);
-
-        check = gtk_image_new ();
-        gtk_widget_show (check);
-        gtk_image_set_from_icon_name (GTK_IMAGE (check), "object-select-symbolic", GTK_ICON_SIZE_MENU);
-        gtk_widget_set_opacity (check, 0.0);
-        g_object_set (check, "icon-size", GTK_ICON_SIZE_MENU, NULL);
-        gtk_container_add (GTK_CONTAINER (box), check);
+        gtk_box_append (GTK_BOX (box), button);
 
         g_object_set_data (G_OBJECT (row), "check", check);
         g_object_set_data (G_OBJECT (row), "preview-button", button);
@@ -285,8 +288,7 @@ add_regions (CcFormatChooser *chooser,
                 if (!widget)
                         continue;
 
-                gtk_widget_show (widget);
-                gtk_container_add (GTK_CONTAINER (chooser->common_region_listbox), widget);
+                gtk_list_box_append (GTK_LIST_BOX (chooser->common_region_listbox), widget);
           }
 
         /* Populate All locales */
@@ -303,8 +305,7 @@ add_regions (CcFormatChooser *chooser,
                 if (!widget)
                   continue;
 
-                gtk_widget_show (widget);
-                gtk_container_add (GTK_CONTAINER (chooser->region_listbox), widget);
+                gtk_list_box_append (GTK_LIST_BOX (chooser->region_listbox), widget);
         }
 
         chooser->adding = FALSE;
@@ -377,7 +378,7 @@ filter_changed (CcFormatChooser *chooser)
         g_clear_pointer (&chooser->filter_words, g_strfreev);
 
         filter_contents =
-                cc_util_normalize_casefold_and_unaccent (gtk_entry_get_text (GTK_ENTRY 
(chooser->region_filter_entry)));
+                cc_util_normalize_casefold_and_unaccent (gtk_editable_get_text (GTK_EDITABLE 
(chooser->region_filter_entry)));
 
         /* The popular listbox is shown only if search is empty */
         visible = filter_contents == NULL || *filter_contents == '\0';
@@ -473,10 +474,12 @@ cc_format_chooser_class_init (CcFormatChooserClass *klass)
         gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_filter_entry);
         gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, common_region_title);
         gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, common_region_listbox);
+        gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_box);
         gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_title);
         gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_listbox);
         gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_list);
         gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_list_stack);
+        gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, preview_box);
         gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, empty_results_view);
         gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, format_preview);
 
@@ -497,10 +500,6 @@ cc_format_chooser_init (CcFormatChooser *chooser)
                                     (GtkListBoxSortFunc)sort_regions, chooser, NULL);
         gtk_list_box_set_filter_func (GTK_LIST_BOX (chooser->region_listbox),
                                       region_visible, chooser, NULL);
-        gtk_list_box_set_header_func (GTK_LIST_BOX (chooser->region_listbox),
-                                      cc_list_box_update_header_func, NULL, NULL);
-        gtk_list_box_set_header_func (GTK_LIST_BOX (chooser->common_region_listbox),
-                                      cc_list_box_update_header_func, NULL, NULL);
 
         add_all_regions (chooser);
         gtk_list_box_invalidate_filter (GTK_LIST_BOX (chooser->region_listbox));
@@ -522,7 +521,7 @@ void
 cc_format_chooser_clear_filter (CcFormatChooser *chooser)
 {
         g_return_if_fail (CC_IS_FORMAT_CHOOSER (chooser));
-        gtk_entry_set_text (GTK_ENTRY (chooser->region_filter_entry), "");
+        gtk_editable_set_text (GTK_EDITABLE (chooser->region_filter_entry), "");
 }
 
 const gchar *
diff --git a/panels/region/cc-format-chooser.ui b/panels/region/cc-format-chooser.ui
index e91a54796..56fe9b0c5 100644
--- a/panels/region/cc-format-chooser.ui
+++ b/panels/region/cc-format-chooser.ui
@@ -2,9 +2,7 @@
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
   <template class="CcFormatChooser" parent="GtkDialog">
-    <property name="can_focus">False</property>
     <property name="title" translatable="yes">Formats</property>
-    <property name="type_hint">dialog</property>
     <property name="modal">True</property>
     <property name="default-width">700</property>
     <property name="default-height">500</property>
@@ -12,17 +10,15 @@
     <!-- Titlebar -->
     <child type="titlebar">
       <object class="GtkHeaderBar" id="title_bar">
-        <property name="visible">1</property>
 
         <child>
           <object class="GtkStack" id="title_buttons">
-            <property name="visible">1</property>
-            <property name="homogeneous">0</property>
+            <property name="hhomogeneous">False</property>
+            <property name="vhomogeneous">False</property>
 
             <!-- Cancel button -->
             <child>
               <object class="GtkButton" id="cancel_button">
-                <property name="visible">1</property>
                 <property name="valign">center</property>
                 <property name="use-underline">1</property>
                 <property name="label" translatable="yes">_Cancel</property>
@@ -32,33 +28,22 @@
             <!-- Back button -->
             <child>
               <object class="GtkButton" id="back_button">
-                <property name="visible">1</property>
+                <property name="icon_name">go-previous-symbolic</property>
                 <signal name="clicked" handler="format_chooser_back_button_clicked_cb" 
object="CcFormatChooser" swapped="yes" />
                 <style>
                   <class name="image-button" />
                 </style>
-                <child>
-                  <object class="GtkImage">
-                    <property name="visible">1</property>
-                    <property name="icon_name">go-previous-symbolic</property>
-                  </object>
-                </child>
-                <child internal-child="accessible">
-                  <object class="AtkObject">
-                    <property name="accessible-name" translatable="yes">Back</property>
-                  </object>
-                </child>
+                <accessibility>
+                  <property name="label" translatable="yes">Back</property>
+                </accessibility>
               </object>
             </child>
 
           </object>
         </child>
 
-        <child>
+        <child type="end">
           <object class="GtkButton" id="done_button">
-            <property name="visible">1</property>
-            <property name="can-default">1</property>
-            <property name="receives-default">1</property>
             <property name="valign">center</property>
             <property name="use-underline">1</property>
             <property name="label" translatable="yes">_Done</property>
@@ -66,36 +51,26 @@
              <class name="suggested-action" />
             </style>
           </object>
-          <packing>
-            <property name="pack-type">end</property>
-          </packing>
         </child>
 
       </object>
     </child>
-    <child internal-child="vbox">
+    <child>
       <object class="GtkBox" id="dialog-vbox1">
-        <property name="can_focus">False</property>
-        <property name="border-width">0</property>
         <property name="orientation">vertical</property>
         <child>
-          <object class="HdyLeaflet" id="main_leaflet">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
+          <object class="AdwLeaflet" id="main_leaflet">
             <property name="hexpand">True</property>
             <property name="vexpand">True</property>
             <signal name="notify::fold" handler="format_chooser_leaflet_fold_changed_cb" 
object="CcFormatChooser" swapped="yes"/>
             <child>
-              <object class="GtkBox">
-                <property name="visible">True</property>
+              <object class="GtkBox" id="region_box">
                 <property name="margin-top">18</property>
-                <property name="can_focus">False</property>
                 <property name="vexpand">True</property>
                 <property name="orientation">vertical</property>
 
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">True</property>
                     <property name="margin-start">18</property>
                     <property name="margin-end">18</property>
                     <property name="label" translatable="yes">Choose the format for numbers, dates and 
currencies. Changes take effect on next login.</property>
@@ -111,9 +86,7 @@
                 <!-- Language search -->
                 <child>
                   <object class="GtkSearchEntry" id="region_filter_entry">
-                    <property name="visible">True</property>
                     <property name="hexpand">True</property>
-                    <property name="can_focus">True</property>
                     <property name="placeholder-text" translatable="yes">Search locales…</property>
                     <property name="margin-top">12</property>
                     <property name="margin-bottom">18</property>
@@ -125,7 +98,6 @@
 
                 <child>
                   <object class="GtkSeparator">
-                    <property name="visible">1</property>
                     <style>
                       <class name="sidebar" />
                     </style>
@@ -135,26 +107,23 @@
                 <!-- Language format list -->
                 <child>
                   <object class="GtkStack" id="region_list_stack">
-                    <property name="visible">True</property>
                     <child>
                       <object class="GtkScrolledWindow" id="region_list">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
                         <property name="vexpand">True</property>
                         <property name="hscrollbar_policy">never</property>
                         <property name="vscrollbar_policy">automatic</property>
                         <property name="propagate-natural-height">True</property>
                         <child>
                           <object class="GtkBox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="margin">18</property>
+                            <property name="margin-top">18</property>
+                            <property name="margin-bottom">18</property>
+                            <property name="margin-start">18</property>
+                            <property name="margin-end">18</property>
                             <property name="orientation">vertical</property>
 
                             <!-- Common formats title -->
                             <child>
                               <object class="GtkLabel" id="common_region_title">
-                                <property name="visible">True</property>
                                 <property name="label" translatable="yes">Common Formats</property>
                                 <property name="halign">start</property>
                                 <property name="margin-bottom">6</property>
@@ -170,14 +139,12 @@
                             <!-- Common formats list -->
                             <child>
                               <object class="GtkListBox" id="common_region_listbox">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
                                 <property name="vexpand">True</property>
                                 <property name="margin-bottom">24</property>
                                 <property name="selection-mode">none</property>
                                 <signal name="row-activated" handler="row_activated" 
object="CcFormatChooser" swapped="yes" />
                                 <style>
-                                 <class name="frame" />
+                                 <class name="content" />
                                 </style>
                               </object>
                             </child>
@@ -185,7 +152,6 @@
                             <!-- Complete formats title -->
                             <child>
                               <object class="GtkLabel" id="region_title">
-                                <property name="visible">True</property>
                                 <property name="label" translatable="yes">All Formats</property>
                                 <property name="halign">start</property>
                                 <property name="margin-bottom">6</property>
@@ -201,15 +167,13 @@
                             <!-- Complete formats list -->
                             <child>
                               <object class="GtkListBox" id="region_listbox">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
                                 <property name="vexpand">True</property>
                                 <property name="halign">fill</property>
                                 <property name="valign">start</property>
                                 <property name="selection-mode">none</property>
                                 <signal name="row-activated" handler="row_activated" 
object="CcFormatChooser" swapped="yes" />
                                 <style>
-                                 <class name="frame" />
+                                 <class name="content" />
                                 </style>
                               </object>
                             </child>
@@ -222,7 +186,6 @@
                     <!-- Empty search results view -->
                     <child>
                       <object class="GtkBox" id="empty_results_view">
-                        <property name="visible">True</property>
                         <property name="valign">center</property>
                         <property name="halign">center</property>
                         <property name="hexpand">False</property>
@@ -231,14 +194,12 @@
                         <property name="spacing">6</property>
                         <child>
                           <object class="GtkImage">
-                            <property name="visible">True</property>
                             <property name="icon-name">system-search-symbolic</property>
                             <property name="pixel-size">64</property>
                           </object>
                         </child>
                         <child>
                           <object class="GtkLabel">
-                            <property name="visible">True</property>
                             <property name="label" translatable="yes">No Search Results</property>
                             <attributes>
                               <attribute name="weight" value="bold"/>
@@ -248,7 +209,6 @@
                         </child>
                         <child>
                           <object class="GtkLabel">
-                            <property name="visible">True</property>
                             <property name="wrap">True</property>
                             <property name="max-width-chars">24</property>
                             <property name="justify">center</property>
@@ -265,14 +225,10 @@
                 </child>
 
               </object>
-              <packing>
-                <property name="name">region-list</property>
-              </packing>
             </child>
 
             <child>
               <object class="GtkSeparator" id="panel_separator">
-                <property name="visible">1</property>
                 <property name="orientation">vertical</property>
                 <style>
                  <class name="sidebar" />
@@ -282,16 +238,13 @@
 
             <!-- Format preview -->
             <child>
-              <object class="GtkBox">
-                <property name="visible">1</property>
+              <object class="GtkBox" id="preview_box">
                 <property name="orientation">vertical</property>
                 <style>
                   <class name="view" />
                 </style>
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
                     <property name="margin_top">24</property>
                     <property name="margin_bottom">6</property>
                     <property name="halign">center</property>
@@ -306,7 +259,6 @@
                 </child>
                 <child>
                   <object class="CcFormatPreview" id="format_preview">
-                    <property name="visible">1</property>
                     <property name="width-request">300</property>
                   </object>
                 </child>
diff --git a/panels/region/cc-format-preview.c b/panels/region/cc-format-preview.c
index e9f64affe..1c111ed24 100644
--- a/panels/region/cc-format-preview.c
+++ b/panels/region/cc-format-preview.c
@@ -32,7 +32,7 @@
 #include <glib/gi18n.h>
 
 struct _CcFormatPreview {
-  GtkDialog  parent_instance;
+  GtkBox     parent_instance;
 
   GtkWidget *date_format_label;
   GtkWidget *date_time_format_label;
diff --git a/panels/region/cc-format-preview.ui b/panels/region/cc-format-preview.ui
index 3aec600dc..2773aa98b 100644
--- a/panels/region/cc-format-preview.ui
+++ b/panels/region/cc-format-preview.ui
@@ -2,9 +2,10 @@
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
   <template class="CcFormatPreview" parent="GtkBox">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="margin">24</property>
+    <property name="margin-top">24</property>
+    <property name="margin-bottom">24</property>
+    <property name="margin-start">24</property>
+    <property name="margin-end">24</property>
     <property name="hexpand">True</property>
     <property name="spacing">4</property>
     <property name="orientation">vertical</property>
@@ -12,8 +13,6 @@
     <!-- Dates -->
     <child>
       <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="label" translatable="yes">Dates</property>
         <style>
@@ -23,8 +22,6 @@
     </child>
     <child>
       <object class="GtkLabel" id="date_format_label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="label">23 January 2013</property>
       </object>
@@ -33,8 +30,6 @@
     <!-- Times -->
     <child>
       <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="margin-top">18</property>
         <property name="label" translatable="yes">Times</property>
@@ -45,8 +40,6 @@
     </child>
     <child>
       <object class="GtkLabel" id="time_format_label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="label">11:31 AM</property>
       </object>
@@ -55,8 +48,6 @@
     <!-- Date & Times -->
     <child>
       <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="margin-top">18</property>
         <property name="label" translatable="yes">Dates &amp; Times</property>
@@ -67,8 +58,6 @@
     </child>
     <child>
       <object class="GtkLabel" id="date_time_format_label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="label">Sun Wed  2 11:31:00 KST 2013</property>
       </object>
@@ -77,8 +66,6 @@
     <!-- Numbers -->
     <child>
       <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="margin-top">18</property>
         <property name="label" translatable="yes">Numbers</property>
@@ -89,8 +76,6 @@
     </child>
     <child>
       <object class="GtkLabel" id="number_format_label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="label">123,456,789.00</property>
       </object>
@@ -99,8 +84,6 @@
     <!-- Measurement -->
     <child>
       <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="margin-top">18</property>
         <property name="label" translatable="yes">Measurement</property>
@@ -111,8 +94,6 @@
     </child>
     <child>
       <object class="GtkLabel" id="measurement_format_label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="label">Metric</property>
       </object>
@@ -121,8 +102,6 @@
     <!-- Paper -->
     <child>
       <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="margin-top">18</property>
         <property name="label" translatable="yes">Paper</property>
@@ -133,11 +112,9 @@
     </child>
     <child>
       <object class="GtkLabel" id="paper_format_label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="xalign">0</property>
         <property name="label">A4</property>
       </object>
     </child>
   </template>
-</interface>
\ No newline at end of file
+</interface>
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 375c34036..1cbf22c46 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -27,7 +27,6 @@
 #include <gtk/gtk.h>
 #include <polkit/polkit.h>
 
-#include "list-box-helper.h"
 #include "cc-region-panel.h"
 #include "cc-region-resources.h"
 #include "cc-language-chooser.h"
@@ -57,7 +56,6 @@ struct _CcRegionPanel {
         GtkLabel        *language_label;
         GtkListBox      *language_list;
         GtkListBoxRow   *language_row;
-        GtkFrame        *language_section_frame;
         GtkToggleButton *login_language_button;
         GtkButton       *restart_button;
         GtkRevealer     *restart_revealer;
@@ -110,7 +108,7 @@ cc_region_panel_finalize (GObject *object)
 
         chooser = g_object_get_data (G_OBJECT (self), "input-chooser");
         if (chooser)
-                gtk_widget_destroy (chooser);
+                gtk_window_destroy (GTK_WINDOW (chooser));
 
         G_OBJECT_CLASS (cc_region_panel_parent_class)->finalize (object);
 }
@@ -319,7 +317,7 @@ language_response (CcRegionPanel     *self,
                 update_region (self, NULL);
         }
 
-        gtk_widget_destroy (GTK_WIDGET (chooser));
+        gtk_window_destroy (GTK_WINDOW (chooser));
 }
 
 static void
@@ -366,7 +364,7 @@ format_response (CcRegionPanel   *self,
                 update_region (self, region);
         }
 
-        gtk_widget_destroy (GTK_WIDGET (chooser));
+        gtk_window_destroy (GTK_WINDOW (chooser));
 }
 
 static const gchar *
@@ -382,9 +380,11 @@ static void
 show_language_chooser (CcRegionPanel *self)
 {
         CcLanguageChooser *chooser;
+        CcShell *shell;
 
+        shell = cc_panel_get_shell (CC_PANEL (self));
         chooser = cc_language_chooser_new ();
-        gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET 
(self))));
+        gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (cc_shell_get_toplevel (shell)));
         cc_language_chooser_set_language (chooser, get_effective_language (self));
         g_signal_connect_object (chooser, "response",
                                  G_CALLBACK (language_response), self, G_CONNECT_SWAPPED);
@@ -414,9 +414,11 @@ static void
 show_region_chooser (CcRegionPanel *self)
 {
         CcFormatChooser *chooser;
+        CcShell *shell;
 
+        shell = cc_panel_get_shell (CC_PANEL (self));
         chooser = cc_format_chooser_new ();
-        gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET 
(self))));
+        gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (cc_shell_get_toplevel (shell)));
         cc_format_chooser_set_region (chooser, get_effective_region (self));
         g_signal_connect_object (chooser, "response",
                                  G_CALLBACK (format_response), self, G_CONNECT_SWAPPED);
@@ -548,15 +550,9 @@ 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);
 
-        gtk_list_box_set_header_func (self->language_list,
-                                      cc_list_box_update_header_func,
-                                      NULL, NULL);
         g_signal_connect_object (self->language_list, "row-activated",
                                  G_CALLBACK (activate_language_row), self, G_CONNECT_SWAPPED);
 
-        gtk_list_box_set_header_func (self->formats_list,
-                                      cc_list_box_update_header_func,
-                                      NULL, NULL);
         g_signal_connect_object (self->formats_list, "row-activated",
                                  G_CALLBACK (activate_language_row), self, G_CONNECT_SWAPPED);
 
@@ -675,7 +671,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_section_frame), !self->login || can_acquire);
+        gtk_widget_set_sensitive (GTK_WIDGET (self->language_list), !self->login || can_acquire);
 
         update_language_label (self);
 }
@@ -774,7 +770,6 @@ cc_region_panel_class_init (CcRegionPanelClass * klass)
         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, language_section_frame);
         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, restart_revealer);
diff --git a/panels/region/cc-region-panel.ui b/panels/region/cc-region-panel.ui
index fc698f0af..a7e096954 100644
--- a/panels/region/cc-region-panel.ui
+++ b/panels/region/cc-region-panel.ui
@@ -2,17 +2,12 @@
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
   <template class="CcRegionPanel" parent="CcPanel">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
 
     <child>
       <object class="GtkScrolledWindow">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
         <property name="hscrollbar-policy">never</property>
         <child>
-          <object class="HdyClamp">
-            <property name="visible">True</property>
+          <object class="AdwClamp">
             <property name="margin_top">32</property>
             <property name="margin_bottom">32</property>
             <property name="margin_start">12</property>
@@ -21,59 +16,38 @@
             <!-- Content -->
             <child>
               <object class="GtkBox">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">12</property>
                 <property name="hexpand">True</property>
-               <child>
-                 <object class="GtkBox" id="session_or_login_box">
-                   <property name="visible">True</property>
-                   <property name="can_focus">False</property>
-                   <property name="orientation">horizontal</property>
-                   <property name="homogeneous">True</property>
-                   <property name="halign">center</property>
-                   <property name="hexpand">True</property>
-                   <style>
-                     <class name="linked"/>
-                   </style>
-                   <child>
-                     <object class="GtkRadioButton" id="session_language_button">
-                       <property name="label" translatable="yes">My Account</property>
-                       <property name="visible">True</property>
-                       <property name="can_focus">True</property>
-                       <property name="receives_default">False</property>
-                       <property name="xalign">0</property>
-                       <property name="active">True</property>
-                       <property name="draw_indicator">False</property>
-                     </object>
-                   </child>
-                   <child>
-                     <object class="GtkRadioButton" id="login_language_button">
-                       <property name="label" translatable="yes">Login Screen</property>
-                       <property name="visible">True</property>
-                       <property name="can_focus">True</property>
-                       <property name="receives_default">False</property>
-                       <property name="xalign">0</property>
-                       <property name="active">False</property>
-                       <property name="draw_indicator">False</property>
-                       <property name="group">session_language_button</property>
-                       <style>
-                         <class name="raised"/>
-                       </style>
-                     </object>
-                   </child>
-                 </object>
-                 <packing>
-                   <property name="expand">False</property>
-                   <property name="fill">True</property>
-                   <property name="position">0</property>
-                 </packing>
-               </child>
+                <child>
+                  <object class="GtkBox" id="session_or_login_box">
+                    <property name="orientation">horizontal</property>
+                    <property name="homogeneous">True</property>
+                    <property name="halign">center</property>
+                    <property name="hexpand">True</property>
+                    <style>
+                      <class name="linked"/>
+                    </style>
+                    <child>
+                      <object class="GtkToggleButton" id="session_language_button">
+                        <property name="label" translatable="yes">My Account</property>
+                        <property name="active">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkToggleButton" id="login_language_button">
+                        <property name="label" translatable="yes">Login Screen</property>
+                        <property name="active">False</property>
+                        <property name="group">session_language_button</property>
+                        <style>
+                          <class name="raised"/>
+                        </style>
+                      </object>
+                    </child>
+                  </object>
+                </child>
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">Language</property>
                     <attributes>
@@ -83,8 +57,6 @@
                 </child>
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">The language used for text in windows and web 
pages.</property>
                     <style>
@@ -93,96 +65,78 @@
                   </object>
                 </child>
                 <child>
-                  <object class="GtkFrame" id="language_section_frame">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                  <object class="GtkListBox" id="language_list">
                     <property name="margin_bottom">18</property>
-                    <property name="shadow_type">in</property>
+                    <property name="selection-mode">none</property>
+                    <style>
+                      <class name="content" />
+                    </style>
                     <child>
-                      <object class="GtkListBox" id="language_list">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="selection-mode">none</property>
+                      <object class="GtkListBoxRow" id="language_row">
                         <child>
-                          <object class="GtkListBoxRow" id="language_row">
-                            <property name="visible">True</property>
+                          <object class="GtkBox" id="language_box">
+                            <property name="orientation">vertical</property>
                             <child>
-                              <object class="GtkBox" id="language_box">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="orientation">vertical</property>
+                              <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>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkRevealer" id="restart_revealer">
+                                <property name="transition_type">slide-up</property>
                                 <child>
                                   <object class="GtkBox">
-                                    <property name="visible">True</property>
-                                    <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="visible">True</property>
-                                        <property name="can_focus">False</property>
                                         <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>
+                                        <property name="wrap">True</property>
+                                        <property name="max-width-chars">35</property>
+                                        <property name="label" translatable="yes">Restart the session for 
changes to take effect</property>
+                                        <style>
+                                          <class name="dim-label"/>
+                                        </style>
+                                        <attributes>
+                                          <attribute name="scale" value="0.9"/>
+                                        </attributes>
                                       </object>
                                     </child>
                                     <child>
-                                      <object class="GtkLabel" id="language_label">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="xalign">1</property>
+                                      <object class="GtkButton" id="restart_button">
                                         <property name="margin_bottom">8</property>
                                         <property name="margin_top">8</property>
-                                      </object>
-                                    </child>
-                                  </object>
-                                </child>
-                                <child>
-                                  <object class="GtkRevealer" id="restart_revealer">
-                                    <property name="visible">True</property>
-                                    <property name="transition_type">slide-up</property>
-                                    <child>
-                                      <object class="GtkBox">
-                                        <property name="visible">True</property>
-                                        <property name="margin_start">12</property>
-                                        <property name="margin_end">12</property>
-                                        <property name="spacing">12</property>
-                                        <child>
-                                          <object class="GtkLabel">
-                                            <property name="visible">True</property>
-                                            <property name="margin_bottom">8</property>
-                                            <property name="margin_top">8</property>
-                                            <property name="xalign">0</property>
-                                            <property name="hexpand">True</property>
-                                            <property name="wrap">True</property>
-                                            <property name="max-width-chars">35</property>
-                                            <property name="label" translatable="yes">Restart the session 
for changes to take effect</property>
-                                            <style>
-                                              <class name="dim-label"/>
-                                            </style>
-                                            <attributes>
-                                              <attribute name="scale" value="0.9"/>
-                                            </attributes>
-                                          </object>
-                                        </child>
-                                        <child>
-                                          <object class="GtkButton" id="restart_button">
-                                            <property name="visible">True</property>
-                                            <property name="margin_bottom">8</property>
-                                            <property name="margin_top">8</property>
-                                            <property name="valign">end</property>
-                                            <property name="label" translatable="yes">Restart…</property>
-                                            <style>
-                                              <class name="suggested-action"/>
-                                            </style>
-                                            <signal name="clicked" handler="restart_now" 
object="CcRegionPanel" swapped="yes"/>
-                                          </object>
-                                        </child>
+                                        <property name="valign">end</property>
+                                        <property name="label" translatable="yes">Restart…</property>
+                                        <style>
+                                          <class name="suggested-action"/>
+                                        </style>
+                                        <signal name="clicked" handler="restart_now" object="CcRegionPanel" 
swapped="yes"/>
                                       </object>
                                     </child>
                                   </object>
@@ -197,8 +151,6 @@
                 </child>
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">Formats</property>
                     <attributes>
@@ -208,8 +160,6 @@
                 </child>
                 <child>
                   <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">The format used for numbers, dates, and 
currencies.</property>
                     <style>
@@ -218,47 +168,34 @@
                   </object>
                 </child>
                 <child>
-                  <object class="GtkFrame">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="shadow_type">in</property>
+                  <object class="GtkListBox" id="formats_list">
+                    <property name="selection-mode">none</property>
+                    <style>
+                      <class name="content" />
+                    </style>
                     <child>
-                      <object class="GtkListBox" id="formats_list">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="selection-mode">none</property>
+                      <object class="GtkListBoxRow" id="formats_row">
                         <child>
-                          <object class="GtkListBoxRow" id="formats_row">
-                            <property name="visible">True</property>
+                          <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="GtkBox">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <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="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <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="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="xalign">1</property>
-                                    <property name="margin_bottom">8</property>
-                                    <property name="margin_top">8</property>
-                                  </object>
-                                </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>
                           </object>
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index d1473e459..643068752 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -52,7 +52,7 @@ extern GType cc_notifications_panel_get_type (void);
 //extern GType cc_goa_panel_get_type (void);
 extern GType cc_power_panel_get_type (void);
 extern GType cc_printers_panel_get_type (void);
-//extern GType cc_region_panel_get_type (void);
+extern GType cc_region_panel_get_type (void);
 extern GType cc_removable_media_panel_get_type (void);
 extern GType cc_search_panel_get_type (void);
 extern GType cc_sharing_panel_get_type (void);
@@ -123,7 +123,7 @@ static CcPanelLoaderVtable default_panels[] =
   //PANEL_TYPE("online-accounts",  cc_goa_panel_get_type,                  NULL),
   PANEL_TYPE("power",            cc_power_panel_get_type,                NULL),
   PANEL_TYPE("printers",         cc_printers_panel_get_type,             NULL),
-  //PANEL_TYPE("region",           cc_region_panel_get_type,               NULL),
+  PANEL_TYPE("region",           cc_region_panel_get_type,               NULL),
   PANEL_TYPE("removable-media",  cc_removable_media_panel_get_type,      NULL),
   PANEL_TYPE("search",           cc_search_panel_get_type,               NULL),
   PANEL_TYPE("sharing",          cc_sharing_panel_get_type,              NULL),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]