[console/zbrown/quick-ci-check: 3/4] pages: drop settings properties




commit 1ac7dea4dbcd462b3d49dab01713f654f2bb5677
Author: Zander Brown <zbrown gnome org>
Date:   Mon Aug 15 00:24:16 2022 +0100

    pages: drop settings properties
    
    pages itself never used them, were simply propogated into tabs. tabs now own
    their own settings reference, so no need to proxy the various properties down
    to tabs anymore

 src/kgx-pages.c   | 195 +++++++++++-------------------------------------------
 src/kgx-pages.ui  |  26 +++++++-
 src/kgx-tab.c     |  75 ---------------------
 src/kgx-window.c  |  85 +++++++++---------------
 src/kgx-window.h  |   1 +
 src/kgx-window.ui |   3 +
 6 files changed, 100 insertions(+), 285 deletions(-)
---
diff --git a/src/kgx-pages.c b/src/kgx-pages.c
index 3f43f17..db059fc 100644
--- a/src/kgx-pages.c
+++ b/src/kgx-pages.c
@@ -38,6 +38,12 @@
 typedef struct _KgxPagesPrivate KgxPagesPrivate;
 struct _KgxPagesPrivate {
   GtkWidget            *view;
+  char                 *title;
+  GFile                *path;
+  KgxTab               *active_page;
+  gboolean              is_active;
+  KgxStatus             page_status;
+  gboolean              search_mode_enabled;
 
   GtkWidget            *status;
   GtkWidget            *status_revealer;
@@ -46,29 +52,10 @@ struct _KgxPagesPrivate {
   int                   last_rows;
   guint                 timeout;
 
-  gulong                size_watcher;
-
-  KgxTab               *active_page;
-
-  char                 *title;
-  GBinding             *title_bind;
-  GFile                *path;
-  GBinding             *path_bind;
+  GSignalGroup         *active_page_signals;
 
-  KgxStatus             page_status;
-  GBinding             *page_status_bind;
-
-  gboolean              is_active;
   GBinding             *is_active_bind;
 
-  gboolean              search_mode_enabled;
-  GBinding             *search_bind;
-
-  PangoFontDescription *font;
-  double                zoom;
-  KgxTheme              theme;
-  gint64                scrollback_lines;
-
   AdwTabPage           *action_page;
 };
 
@@ -82,13 +69,10 @@ enum {
   PROP_TAB_COUNT,
   PROP_TITLE,
   PROP_PATH,
-  PROP_THEME,
-  PROP_FONT,
-  PROP_ZOOM,
+  PROP_ACTIVE_PAGE,
   PROP_IS_ACTIVE,
   PROP_STATUS,
   PROP_SEARCH_MODE_ENABLED,
-  PROP_SCROLLBACK_LINES,
   LAST_PROP
 };
 static GParamSpec *pspecs[LAST_PROP] = { NULL, };
@@ -110,14 +94,11 @@ kgx_pages_dispose (GObject *object)
 
   g_clear_handle_id (&priv->timeout, g_source_remove);
 
-  if (priv->active_page) {
-    g_clear_signal_handler (&priv->size_watcher, priv->active_page);
-  }
-
   g_clear_pointer (&priv->title, g_free);
   g_clear_object (&priv->path);
 
-  g_clear_pointer (&priv->font, pango_font_description_free);
+  g_clear_object (&priv->active_page_signals);
+  g_clear_weak_pointer (&priv->active_page);
 
   G_OBJECT_CLASS (kgx_pages_parent_class)->dispose (object);
 }
@@ -145,14 +126,8 @@ kgx_pages_get_property (GObject    *object,
     case PROP_PATH:
       g_value_set_object (value, priv->path);
       break;
-    case PROP_THEME:
-      g_value_set_enum (value, priv->theme);
-      break;
-    case PROP_FONT:
-      g_value_set_boxed (value, priv->font);
-      break;
-    case PROP_ZOOM:
-      g_value_set_double (value, priv->zoom);
+    case PROP_ACTIVE_PAGE:
+      g_value_set_object (value, priv->active_page);
       break;
     case PROP_IS_ACTIVE:
       g_value_set_boolean (value, priv->is_active);
@@ -163,9 +138,6 @@ kgx_pages_get_property (GObject    *object,
     case PROP_SEARCH_MODE_ENABLED:
       g_value_set_boolean (value, priv->search_mode_enabled);
       break;
-    case PROP_SCROLLBACK_LINES:
-      g_value_set_int64 (value, priv->scrollback_lines);
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -188,20 +160,20 @@ kgx_pages_set_property (GObject      *object,
       priv->title = g_value_dup_string (value);
       break;
     case PROP_PATH:
-      g_clear_object (&priv->path);
-      priv->path = g_value_dup_object (value);
-      break;
-    case PROP_THEME:
-      priv->theme = g_value_get_enum (value);
+      g_set_object (&priv->path, g_value_get_object (value));
       break;
-    case PROP_FONT:
-      if (priv->font) {
-        g_boxed_free (PANGO_TYPE_FONT_DESCRIPTION, priv->font);
+    case PROP_ACTIVE_PAGE:
+      if (priv->active_page) {
+        g_object_set (priv->active_page, "is-active", FALSE, NULL);
+      }
+      g_clear_object (&priv->is_active_bind);
+      g_set_weak_pointer (&priv->active_page, g_value_get_object (value));
+      if (priv->active_page) {
+        priv->is_active_bind =
+          g_object_bind_property (self, "is-active",
+                                  priv->active_page, "is-active",
+                                  G_BINDING_SYNC_CREATE);
       }
-      priv->font = g_value_dup_boxed (value);
-      break;
-    case PROP_ZOOM:
-      priv->zoom = g_value_get_double (value);
       break;
     case PROP_IS_ACTIVE:
       priv->is_active = g_value_get_boolean (value);
@@ -212,9 +184,6 @@ kgx_pages_set_property (GObject      *object,
     case PROP_SEARCH_MODE_ENABLED:
       priv->search_mode_enabled = g_value_get_boolean (value);
       break;
-    case PROP_SCROLLBACK_LINES:
-      priv->scrollback_lines = g_value_get_int64 (value);
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -271,60 +240,6 @@ size_changed (KgxTab   *tab,
 }
 
 
-static void
-page_changed (GObject *object, GParamSpec *pspec, KgxPages *self)
-{
-  KgxPagesPrivate *priv;
-  AdwTabPage *page = NULL;
-  KgxTab *tab;
-
-  priv = kgx_pages_get_instance_private (self);
-  page = adw_tab_view_get_selected_page (ADW_TAB_VIEW (priv->view));
-
-  if (!page) {
-    return;
-  }
-
-  tab = KGX_TAB (adw_tab_page_get_child (page));
-
-  g_clear_signal_handler (&priv->size_watcher, priv->active_page);
-  priv->size_watcher = g_signal_connect (tab,
-                                         "size-changed", G_CALLBACK (size_changed),
-                                         self);
-
-  g_clear_object (&priv->title_bind);
-  priv->title_bind = g_object_bind_property (tab, "tab-title",
-                                             self, "title",
-                                             G_BINDING_SYNC_CREATE);
-
-  g_clear_object (&priv->path_bind);
-  priv->path_bind = g_object_bind_property (tab, "tab-path",
-                                            self, "path",
-                                            G_BINDING_SYNC_CREATE);
-
-  if (priv->active_page) {
-    g_object_set (priv->active_page, "is-active", FALSE, NULL);
-  }
-
-  g_clear_object (&priv->is_active_bind);
-  priv->is_active_bind = g_object_bind_property (self, "is-active",
-                                                 tab, "is-active",
-                                                 G_BINDING_SYNC_CREATE);
-
-  g_clear_object (&priv->page_status_bind);
-  priv->page_status_bind = g_object_bind_property (tab, "tab-status",
-                                                   self, "status",
-                                                   G_BINDING_SYNC_CREATE);
-
-  g_clear_object (&priv->search_bind);
-  priv->search_bind = g_object_bind_property (tab, "search-mode-enabled",
-                                              self, "search-mode-enabled",
-                                              G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
-  priv->active_page = KGX_TAB (tab);
-}
-
-
 static void
 died (KgxTab         *page,
       GtkMessageType  type,
@@ -390,18 +305,13 @@ page_detached (AdwTabView *view,
                int         position,
                KgxPages   *self)
 {
-  KgxTab *tab;
   KgxPagesPrivate *priv;
   GtkRoot *root;
 
   g_return_if_fail (ADW_IS_TAB_PAGE (page));
 
-  tab = KGX_TAB (adw_tab_page_get_child (page));
-
   priv = kgx_pages_get_instance_private (self);
 
-  g_signal_handlers_disconnect_by_data (tab, self);
-
   if (adw_tab_view_get_n_pages (ADW_TAB_VIEW (priv->view)) == 0) {
     root = gtk_widget_get_root (GTK_WIDGET (self));
 
@@ -409,9 +319,6 @@ page_detached (AdwTabView *view,
       /* Not a massive fan, would prefer it if window observed pages is empty */
       gtk_window_close (GTK_WINDOW (root));
     }
-
-    priv->active_page = NULL;
-    priv->size_watcher = 0;
   }
 }
 
@@ -594,29 +501,17 @@ kgx_pages_class_init (KgxPagesClass *klass)
                          G_PARAM_READWRITE);
 
   /**
-   * KgxPages:theme:
+   * KgxPages:active-page:
    *
-   * The #KgxTheme to apply to the #KgxTerminal s in the #KgxTab s
+   * The #KgxTab in #KgxPages:tab-view's current #AdwTabPage
    *
-   * Stability: Private
+   * Note the writability of this property in an implementation detail, DO NOT
+   * set this property
    */
-  pspecs[PROP_THEME] =
-    g_param_spec_enum ("theme", "Theme", "The path of the active page",
-                       KGX_TYPE_THEME,
-                       KGX_THEME_NIGHT,
-                       G_PARAM_READWRITE);
-
-  pspecs[PROP_FONT] =
-    g_param_spec_boxed ("font", "Font", "Monospace font",
-                         PANGO_TYPE_FONT_DESCRIPTION,
-                         G_PARAM_READWRITE);
-
-  pspecs[PROP_ZOOM] =
-    g_param_spec_double ("zoom", "Zoom", "Font scaling",
-                         KGX_FONT_SCALE_MIN,
-                         KGX_FONT_SCALE_MAX,
-                         KGX_FONT_SCALE_DEFAULT,
-                         G_PARAM_READWRITE);
+  pspecs[PROP_ACTIVE_PAGE] =
+    g_param_spec_object ("active-page", NULL, NULL,
+                         KGX_TYPE_TAB,
+                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   pspecs[PROP_IS_ACTIVE] =
     g_param_spec_boolean ("is-active", "Is Active", "Is active pages",
@@ -635,20 +530,6 @@ kgx_pages_class_init (KgxPagesClass *klass)
                           FALSE,
                           G_PARAM_READWRITE);
 
-  /**
-   * KgxTab:scrollback-lines:
-   *
-   * How many lines of scrollback #KgxTerminal should keep
-   *
-   * Bound to ‘scrollback-lines’ GSetting so changes persist
-   *
-   * Stability: Private
-   */
-  pspecs[PROP_SCROLLBACK_LINES] =
-    g_param_spec_int64 ("scrollback-lines", "Scrollback Lines", "Size of the scrollback",
-                        G_MININT64, G_MAXINT64, 512,
-                        G_PARAM_READWRITE);
-
   g_object_class_install_properties (object_class, LAST_PROP, pspecs);
 
   signals[ZOOM] = g_signal_new ("zoom",
@@ -676,7 +557,6 @@ kgx_pages_class_init (KgxPagesClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, KgxPages, status);
   gtk_widget_class_bind_template_child_private (widget_class, KgxPages, status_revealer);
 
-  gtk_widget_class_bind_template_callback (widget_class, page_changed);
   gtk_widget_class_bind_template_callback (widget_class, page_attached);
   gtk_widget_class_bind_template_callback (widget_class, page_detached);
   gtk_widget_class_bind_template_callback (widget_class, create_window);
@@ -693,12 +573,17 @@ kgx_pages_init (KgxPages *self)
 {
   KgxPagesPrivate *priv = kgx_pages_get_instance_private (self);
 
-  priv->font = NULL;
-  priv->zoom = KGX_FONT_SCALE_DEFAULT;
-  priv->theme = KGX_THEME_NIGHT;
+  priv->active_page_signals = g_signal_group_new (KGX_TYPE_TAB);
+  g_signal_group_connect (priv->active_page_signals,
+                          "size-changed", G_CALLBACK (size_changed),
+                          self);
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  g_object_bind_property (self, "active-page",
+                          priv->active_page_signals, "target",
+                          G_BINDING_SYNC_CREATE);
+
   adw_tab_view_remove_shortcuts (ADW_TAB_VIEW (priv->view),
                                  ADW_TAB_VIEW_SHORTCUT_CONTROL_HOME |
                                  ADW_TAB_VIEW_SHORTCUT_CONTROL_END |
diff --git a/src/kgx-pages.ui b/src/kgx-pages.ui
index 591dcf2..bfa6704 100644
--- a/src/kgx-pages.ui
+++ b/src/kgx-pages.ui
@@ -2,13 +2,37 @@
 <interface>
   <requires lib="gtk" version="4.0"/>
   <template class="KgxPages" parent="AdwBin">
+    <binding name="active-page">
+      <lookup name="child">
+        <lookup name="selected-page">view</lookup>
+      </lookup>
+    </binding>
+    <binding name="title">
+      <lookup name="tab-title">
+        <lookup name="active-page">KgxPages</lookup>
+      </lookup>
+    </binding>
+    <binding name="path">
+      <lookup name="tab-path">
+        <lookup name="active-page">KgxPages</lookup>
+      </lookup>
+    </binding>
+    <binding name="status">
+      <lookup name="tab-status">
+        <lookup name="active-page">KgxPages</lookup>
+      </lookup>
+    </binding>
+    <binding name="search-mode-enabled">
+      <lookup name="search-mode-enabled">
+        <lookup name="active-page">KgxPages</lookup>
+      </lookup>
+    </binding>
     <property name="child">
       <object class="GtkOverlay">
         <child>
           <object class="AdwTabView" id="view">
             <property name="menu-model">tab-menu</property>
             <property name="default-icon">view_default_icon</property>
-            <signal name="notify::selected-page" handler="page_changed" swapped="no"/>
             <signal name="page-attached" handler="page_attached" swapped="no"/>
             <signal name="page-detached" handler="page_detached" swapped="no"/>
             <signal name="create-window" handler="create_window" swapped="no"/>
diff --git a/src/kgx-tab.c b/src/kgx-tab.c
index cfa6b18..84caceb 100644
--- a/src/kgx-tab.c
+++ b/src/kgx-tab.c
@@ -47,11 +47,7 @@ struct _KgxTabPrivate {
   char                 *title;
   char                 *tooltip;
   GFile                *path;
-  PangoFontDescription *font;
-  double                zoom;
   KgxStatus             status;
-  KgxTheme              theme;
-  gint64                scrollback_lines;
 
   gboolean              is_active;
   gboolean              close_on_quit;
@@ -100,14 +96,10 @@ enum {
   PROP_TAB_PATH,
   PROP_TAB_STATUS,
   PROP_TAB_TOOLTIP,
-  PROP_FONT,
-  PROP_ZOOM,
-  PROP_THEME,
   PROP_IS_ACTIVE,
   PROP_CLOSE_ON_QUIT,
   PROP_NEEDS_ATTENTION,
   PROP_SEARCH_MODE_ENABLED,
-  PROP_SCROLLBACK_LINES,
   LAST_PROP
 };
 static GParamSpec *pspecs[LAST_PROP] = { NULL, };
@@ -143,7 +135,6 @@ kgx_tab_dispose (GObject *object)
   g_clear_pointer (&priv->title, g_free);
   g_clear_pointer (&priv->tooltip, g_free);
   g_clear_object (&priv->path);
-  g_clear_pointer (&priv->font, pango_font_description_free);
 
   g_clear_pointer (&priv->root, g_hash_table_unref);
   g_clear_pointer (&priv->remote, g_hash_table_unref);
@@ -310,18 +301,9 @@ kgx_tab_get_property (GObject    *object,
     case PROP_TAB_TOOLTIP:
       g_value_set_string (value, priv->tooltip);
       break;
-    case PROP_FONT:
-      g_value_set_boxed (value, priv->font);
-      break;
-    case PROP_ZOOM:
-      g_value_set_double (value, priv->zoom);
-      break;
     case PROP_IS_ACTIVE:
       g_value_set_boolean (value, priv->is_active);
       break;
-    case PROP_THEME:
-      g_value_set_enum (value, priv->theme);
-      break;
     case PROP_CLOSE_ON_QUIT:
       g_value_set_boolean (value, priv->close_on_quit);
       break;
@@ -331,9 +313,6 @@ kgx_tab_get_property (GObject    *object,
     case PROP_SEARCH_MODE_ENABLED:
       g_value_set_boolean (value, priv->search_mode_enabled);
       break;
-    case PROP_SCROLLBACK_LINES:
-      g_value_set_int64 (value, priv->scrollback_lines);
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -417,21 +396,9 @@ kgx_tab_set_property (GObject      *object,
       g_clear_pointer (&priv->tooltip, g_free);
       priv->tooltip = g_value_dup_string (value);
       break;
-    case PROP_FONT:
-      if (priv->font) {
-        g_boxed_free (PANGO_TYPE_FONT_DESCRIPTION, priv->font);
-      }
-      priv->font = g_value_dup_boxed (value);
-      break;
-    case PROP_ZOOM:
-      priv->zoom = g_value_get_double (value);
-      break;
     case PROP_IS_ACTIVE:
       kgx_tab_set_is_active (self, g_value_get_boolean (value));
       break;
-    case PROP_THEME:
-      priv->theme = g_value_get_enum (value);
-      break;
     case PROP_CLOSE_ON_QUIT:
       priv->close_on_quit = g_value_get_boolean (value);
       break;
@@ -441,9 +408,6 @@ kgx_tab_set_property (GObject      *object,
     case PROP_SEARCH_MODE_ENABLED:
       priv->search_mode_enabled = g_value_get_boolean (value);
       break;
-    case PROP_SCROLLBACK_LINES:
-      priv->scrollback_lines = g_value_get_int64 (value);
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -601,18 +565,6 @@ kgx_tab_class_init (KgxTabClass *klass)
                          NULL,
                          G_PARAM_READWRITE);
 
-  pspecs[PROP_FONT] =
-    g_param_spec_boxed ("font", "Font", "Monospace font",
-                         PANGO_TYPE_FONT_DESCRIPTION,
-                         G_PARAM_READWRITE);
-
-  pspecs[PROP_ZOOM] =
-    g_param_spec_double ("zoom", "Zoom", "Font scaling",
-                         KGX_FONT_SCALE_MIN,
-                         KGX_FONT_SCALE_MAX,
-                         KGX_FONT_SCALE_DEFAULT,
-                         G_PARAM_READWRITE);
-
   /**
    * KgxTab:is-active:
    *
@@ -625,19 +577,6 @@ kgx_tab_class_init (KgxTabClass *klass)
                           FALSE,
                           G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
 
-  /**
-   * KgxTab:theme:
-   *
-   * The #KgxTheme to apply to the #KgxTerminal s in the #KgxTab
-   *
-   * Stability: Private
-   */
-  pspecs[PROP_THEME] =
-    g_param_spec_enum ("theme", "Theme", "The path of the active tab",
-                       KGX_TYPE_THEME,
-                       KGX_THEME_NIGHT,
-                       G_PARAM_READWRITE);
-
   pspecs[PROP_CLOSE_ON_QUIT] =
     g_param_spec_boolean ("close-on-quit", "Close on quit",
                           "Should the tab close when dead",
@@ -656,20 +595,6 @@ kgx_tab_class_init (KgxTabClass *klass)
                           FALSE,
                           G_PARAM_READWRITE);
 
-  /**
-   * KgxTab:scrollback-lines:
-   *
-   * How many lines of scrollback #KgxTerminal should keep
-   *
-   * Bound to ‘scrollback-lines’ GSetting so changes persist
-   *
-   * Stability: Private
-   */
-  pspecs[PROP_SCROLLBACK_LINES] =
-    g_param_spec_int64 ("scrollback-lines", "Scrollback Lines", "Size of the scrollback",
-                        G_MININT64, G_MAXINT64, 512,
-                        G_PARAM_READWRITE);
-
   g_object_class_install_properties (object_class, LAST_PROP, pspecs);
 
   signals[SIZE_CHANGED] = g_signal_new ("size-changed",
diff --git a/src/kgx-window.c b/src/kgx-window.c
index c22983e..e97f903 100644
--- a/src/kgx-window.c
+++ b/src/kgx-window.c
@@ -53,59 +53,6 @@ enum {
 static GParamSpec *pspecs[LAST_PROP] = { NULL, };
 
 
-static gboolean
-scale_to_label (GBinding     *binding,
-                const GValue *from_value,
-                GValue       *to_value,
-                gpointer      user_data)
-{
-  int zoom = round (g_value_get_double (from_value) * 100);
-
-  g_value_take_string (to_value, g_strdup_printf ("%i%%", zoom));
-
-  return TRUE;
-}
-
-
-static void
-kgx_window_constructed (GObject *object)
-{
-  KgxWindow *self = KGX_WINDOW (object);
-  AdwStyleManager *style_manager;
-
-  G_OBJECT_CLASS (kgx_window_parent_class)->constructed (object);
-
-  style_manager = adw_style_manager_get_default ();
-
-  g_object_bind_property (self->settings, "theme",
-                          self->pages, "theme",
-                          G_BINDING_SYNC_CREATE);
-  g_object_bind_property (self->settings, "theme",
-                          self->theme_switcher, "theme",
-                          G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-  g_object_bind_property (style_manager, "system-supports-color-schemes",
-                          self->theme_switcher, "show-system",
-                          G_BINDING_SYNC_CREATE);
-
-  g_object_bind_property (self->settings, "font",
-                          self->pages, "font",
-                          G_BINDING_SYNC_CREATE);
-
-  g_object_bind_property (self->settings, "font-scale",
-                          self->pages, "zoom",
-                          G_BINDING_SYNC_CREATE);
-
-  g_object_bind_property (self->settings, "scrollback-lines",
-                          self->pages, "scrollback-lines",
-                          G_BINDING_SYNC_CREATE);
-
-  g_object_bind_property_full (self->settings, "font-scale",
-                               self->zoom_level, "label",
-                               G_BINDING_SYNC_CREATE,
-                               scale_to_label, NULL, NULL, NULL);
-}
-
-
 static void
 kgx_window_dispose (GObject *object)
 {
@@ -307,7 +254,6 @@ kgx_window_class_init (KgxWindowClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GtkWindowClass *window_class = GTK_WINDOW_CLASS (klass);
 
-  object_class->constructed = kgx_window_constructed;
   object_class->dispose = kgx_window_dispose;
   object_class->set_property = kgx_window_set_property;
   object_class->get_property = kgx_window_get_property;
@@ -334,6 +280,7 @@ kgx_window_class_init (KgxWindowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, KgxWindow, tab_switcher);
   gtk_widget_class_bind_template_child (widget_class, KgxWindow, pages);
   gtk_widget_class_bind_template_child (widget_class, KgxWindow, primary_menu);
+  gtk_widget_class_bind_template_child (widget_class, KgxWindow, settings_binds);
 
   gtk_widget_class_bind_template_callback (widget_class, active_changed);
   gtk_widget_class_bind_template_callback (widget_class, size_changed);
@@ -346,6 +293,20 @@ kgx_window_class_init (KgxWindowClass *klass)
 }
 
 
+static gboolean
+scale_to_label (GBinding     *binding,
+                const GValue *from_value,
+                GValue       *to_value,
+                gpointer      user_data)
+{
+  int zoom = round (g_value_get_double (from_value) * 100);
+
+  g_value_take_string (to_value, g_strdup_printf ("%i%%", zoom));
+
+  return TRUE;
+}
+
+
 static void
 new_activated (GSimpleAction *action,
                GVariant      *parameter,
@@ -528,6 +489,7 @@ kgx_window_init (KgxWindow *self)
 {
   g_autoptr (GtkWindowGroup) group = NULL;
   g_autoptr (GPropertyAction) pact = NULL;
+  AdwStyleManager *style_manager;
 
   g_type_ensure (KGX_TYPE_TAB_BUTTON);
   g_type_ensure (KGX_TYPE_TAB_SWITCHER);
@@ -535,6 +497,21 @@ kgx_window_init (KgxWindow *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  style_manager = adw_style_manager_get_default ();
+
+  g_object_bind_property (style_manager, "system-supports-color-schemes",
+                          self->theme_switcher, "show-system",
+                          G_BINDING_SYNC_CREATE);
+
+  g_binding_group_bind (self->settings_binds, "theme",
+                        self->theme_switcher, "theme",
+                        G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+  g_binding_group_bind_full (self->settings_binds, "font-scale",
+                             self->zoom_level, "label",
+                             G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL,
+                             scale_to_label, NULL, NULL, NULL);
+
   g_action_map_add_action_entries (G_ACTION_MAP (self),
                                    win_entries,
                                    G_N_ELEMENTS (win_entries),
diff --git a/src/kgx-window.h b/src/kgx-window.h
index 2fe538c..45830f5 100644
--- a/src/kgx-window.h
+++ b/src/kgx-window.h
@@ -53,6 +53,7 @@ struct _KgxWindow
 
   /*< public >*/
   KgxSettings          *settings;
+  GBindingGroup        *settings_binds;
 
   /* Size indicator */
   int                   last_cols;
diff --git a/src/kgx-window.ui b/src/kgx-window.ui
index dcfc0c9..e5615dc 100644
--- a/src/kgx-window.ui
+++ b/src/kgx-window.ui
@@ -183,4 +183,7 @@
       <class name="terminal-window"/>
     </style>
   </template>
+  <object class="GBindingGroup" id="settings_binds">
+    <property name="source" bind-source="KgxWindow" bind-property="settings" bind-flags="sync-create"/>
+  </object>
 </interface>


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