[evolution/gnome-3-26] Store To Do bar width as proportion, not as absolute value



commit 8d56fd10913cb784f1684cf5a8ba8fae6d6de025
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 30 09:16:48 2017 +0100

    Store To Do bar width as proportion, not as absolute value
    
    Related to bug 785178.

 src/modules/mail/e-mail-shell-content.c |   54 +++++++++++++++++++++++++++----
 1 files changed, 47 insertions(+), 7 deletions(-)
---
diff --git a/src/modules/mail/e-mail-shell-content.c b/src/modules/mail/e-mail-shell-content.c
index 60ac7a3..fa1e73b 100644
--- a/src/modules/mail/e-mail-shell-content.c
+++ b/src/modules/mail/e-mail-shell-content.c
@@ -104,6 +104,39 @@ reconnect_folder_loaded_event (EMailReader *child,
        g_signal_emit_by_name (parent, "folder-loaded");
 }
 
+/* To recognize old values from new values */
+#define PROPORTION_LOWER_LIMIT 1000000
+
+static gboolean
+mail_shell_content_map_setting_to_proportion_cb (GValue *value,
+                                                GVariant *variant,
+                                                gpointer user_data)
+{
+       gint stored;
+       gdouble proportion = 0.15;
+
+       stored = g_variant_get_int32 (variant);
+
+       if (stored >= PROPORTION_LOWER_LIMIT)
+               proportion = (stored - PROPORTION_LOWER_LIMIT) / ((gdouble) PROPORTION_LOWER_LIMIT);
+
+       g_value_set_double (value, proportion);
+
+       return TRUE;
+}
+
+static GVariant *
+mail_shell_content_map_proportion_to_setting_cb (const GValue *value,
+                                                const GVariantType *expected_type,
+                                                gpointer user_data)
+{
+       gdouble proportion;
+
+       proportion = g_value_get_double (value);
+
+       return g_variant_new_int32 (PROPORTION_LOWER_LIMIT + (gint32) (proportion * PROPORTION_LOWER_LIMIT));
+}
+
 static void
 mail_shell_content_set_property (GObject *object,
                                  guint property_id,
@@ -226,7 +259,8 @@ mail_shell_content_constructed (GObject *object)
 
        /* Build content widgets. */
 
-       widget = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+       widget = e_paned_new (GTK_ORIENTATION_HORIZONTAL);
+       e_paned_set_fixed_resize (E_PANED (widget), FALSE);
        gtk_container_add (GTK_CONTAINER (shell_content), widget);
        gtk_widget_show (widget);
 
@@ -271,15 +305,21 @@ mail_shell_content_constructed (GObject *object)
        settings = e_util_ref_settings ("org.gnome.evolution.mail");
 
        if (e_shell_window_is_main_instance (e_shell_view_get_shell_window (shell_view))) {
-               g_settings_bind (
+               g_settings_bind_with_mapping (
                        settings, "to-do-bar-width",
-                       paned, "position",
-                       G_SETTINGS_BIND_DEFAULT);
+                       paned, "proportion",
+                       G_SETTINGS_BIND_DEFAULT,
+                       mail_shell_content_map_setting_to_proportion_cb,
+                       mail_shell_content_map_proportion_to_setting_cb,
+                       NULL, NULL);
        } else {
-               g_settings_bind (
+               g_settings_bind_with_mapping (
                        settings, "to-do-bar-width-sub",
-                       paned, "position",
-                       G_SETTINGS_BIND_DEFAULT);
+                       paned, "proportion",
+                       G_SETTINGS_BIND_DEFAULT,
+                       mail_shell_content_map_setting_to_proportion_cb,
+                       mail_shell_content_map_proportion_to_setting_cb,
+                       NULL, NULL);
        }
 
        g_settings_bind (


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