[epiphany] prefs-dialog: Expose restore-session-policy



commit 70bc6b8dc35dcaec955f489fa67e40427f861dd5
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon Jan 18 11:44:26 2016 -0600

    prefs-dialog: Expose restore-session-policy
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724583

 src/prefs-dialog.c            |   32 ++++++++++++++++++++++++++++++++
 src/resources/prefs-dialog.ui |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 0 deletions(-)
---
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 1bfb62c..aad4a00 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -59,6 +59,7 @@ struct PrefsDialogPrivate
        GtkWidget *download_button_label;
        GtkWidget *automatic_downloads_checkbutton;
        GtkWidget *search_engine_combo;
+       GtkWidget *restore_session_checkbutton;
        GtkWidget *popups_allow_checkbutton;
        GtkWidget *adblock_allow_checkbutton;
        GtkWidget *enable_plugins_checkbutton;
@@ -166,6 +167,7 @@ prefs_dialog_class_init (PrefsDialogClass *klass)
        /* general */
        gtk_widget_class_bind_template_child_private (widget_class, PrefsDialog, 
automatic_downloads_checkbutton);
        gtk_widget_class_bind_template_child_private (widget_class, PrefsDialog, search_engine_combo);
+       gtk_widget_class_bind_template_child_private (widget_class, PrefsDialog, restore_session_checkbutton);
        gtk_widget_class_bind_template_child_private (widget_class, PrefsDialog, popups_allow_checkbutton);
        gtk_widget_class_bind_template_child_private (widget_class, PrefsDialog, adblock_allow_checkbutton);
        gtk_widget_class_bind_template_child_private (widget_class, PrefsDialog, enable_plugins_checkbutton);
@@ -1080,6 +1082,28 @@ create_search_engine_combo (GtkComboBox *combo)
                                      NULL);
 }
 
+static gboolean
+restore_session_get_mapping  (GValue   *value,
+                             GVariant *variant,
+                             gpointer  user_data)
+{
+       const char *policy = g_variant_get_string (variant, NULL);
+       /* FIXME: Is it possible to somehow use EPHY_PREFS_RESTORE_SESSION_POLICY_ALWAYS here? */
+       g_value_set_boolean (value, !strcmp (policy, "always"));
+       return TRUE;
+}
+
+static GVariant *
+restore_session_set_mapping (const GValue *value,
+                            const GVariantType *expected_type,
+                            gpointer user_data)
+{
+       /* FIXME: Is it possible to somehow use EphyPrefsRestoreSessionPolicy here? */
+       if (g_value_get_boolean (value))
+               return g_variant_new_string ("always");
+       return g_variant_new_string ("crashed");
+}
+
 static void
 setup_general_page (PrefsDialog *dialog)
 {
@@ -1095,6 +1119,14 @@ setup_general_page (PrefsDialog *dialog)
                         priv->automatic_downloads_checkbutton,
                         "active",
                         G_SETTINGS_BIND_DEFAULT);
+       g_settings_bind_with_mapping (settings,
+                                     EPHY_PREFS_RESTORE_SESSION_POLICY,
+                                     priv->restore_session_checkbutton,
+                                     "active",
+                                     G_SETTINGS_BIND_DEFAULT,
+                                     restore_session_get_mapping,
+                                     restore_session_set_mapping,
+                                     NULL, NULL);
        g_settings_bind (web_settings,
                         EPHY_PREFS_WEB_ENABLE_POPUPS,
                         priv->popups_allow_checkbutton,
diff --git a/src/resources/prefs-dialog.ui b/src/resources/prefs-dialog.ui
index 6fb3a56..710b983 100644
--- a/src/resources/prefs-dialog.ui
+++ b/src/resources/prefs-dialog.ui
@@ -153,6 +153,38 @@
                       <object class="GtkLabel">
                         <property name="visible">True</property>
                         <property name="halign">start</property>
+                        <property name="label" translatable="yes">Session</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">True</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <property name="margin-start">12</property>
+                        <child>
+                          <object class="GtkCheckButton" id="restore_session_checkbutton">
+                            <property name="label" translatable="yes">_Remember previous tabs on 
startup</property>
+                            <property name="visible">True</property>
+                            <property name="use-underline">True</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkBox">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkLabel">
+                        <property name="visible">True</property>
+                        <property name="halign">start</property>
                         <property name="label" translatable="yes">Web Content</property>
                         <attributes>
                           <attribute name="weight" value="bold"/>


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