[devhelp] Window: move more code from new() to init()



commit da9cb4ac8fa32abdb24621bb34cba5742dd960cd
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Feb 9 15:12:15 2018 +0100

    Window: move more code from new() to init()
    
    And better bind the paned GSetting.

 src/dh-window.c |   28 ++++++++++------------------
 1 files changed, 10 insertions(+), 18 deletions(-)
---
diff --git a/src/dh-window.c b/src/dh-window.c
index 89c1f56..31b3801 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -756,6 +756,7 @@ dh_window_init (DhWindow *window)
         DhWindowPrivate *priv = dh_window_get_instance_private (window);
         GtkApplication *app;
         DhSettings *settings;
+        GSettings *paned_settings;
 
         gtk_widget_init_template (GTK_WIDGET (window));
 
@@ -774,6 +775,12 @@ dh_window_init (DhWindow *window)
                                  window,
                                  0);
 
+        paned_settings = dh_settings_peek_paned_settings (settings);
+        g_settings_bind (paned_settings, "position",
+                         priv->hpaned, "position",
+                         G_SETTINGS_BIND_DEFAULT |
+                         G_SETTINGS_BIND_NO_SENSITIVITY);
+
         /* Sidebar */
         priv->sidebar = DH_SIDEBAR (dh_sidebar_new (NULL));
         gtk_widget_show (GTK_WIDGET (priv->sidebar));
@@ -823,18 +830,12 @@ dh_window_init (DhWindow *window)
                                 "switch-page",
                                 G_CALLBACK (notebook_switch_page_after_cb),
                                 window);
-}
-
-static void
-window_populate (DhWindow *window)
-{
-        DhWindowPrivate *priv = dh_window_get_instance_private (window);
-
-        /* Focus search in sidebar by default */
-        dh_sidebar_set_search_focus (priv->sidebar);
 
         window_update_zoom_actions_state (window);
         window_open_new_tab (window, NULL, TRUE);
+
+        /* Focus search in sidebar by default. */
+        dh_sidebar_set_search_focus (priv->sidebar);
 }
 
 static gchar *
@@ -1316,7 +1317,6 @@ GtkWidget *
 dh_window_new (GtkApplication *application)
 {
         DhWindow *window;
-        DhWindowPrivate *priv;
         DhSettings *settings;
 
         g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL);
@@ -1325,19 +1325,11 @@ dh_window_new (GtkApplication *application)
                                "application", application,
                                NULL);
 
-        priv = dh_window_get_instance_private (window);
-
-        window_populate (window);
-
         settings = dh_settings_get_singleton ();
         gtk_widget_realize (GTK_WIDGET (window));
         dh_util_window_settings_restore (GTK_WINDOW (window),
                                          dh_settings_peek_window_settings (settings));
 
-        g_settings_bind (dh_settings_peek_paned_settings (settings), "position",
-                         priv->hpaned, "position",
-                         G_SETTINGS_BIND_DEFAULT);
-
         return GTK_WIDGET (window);
 }
 


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