[gnome-terminal/gnome-3-18] profile: editor: Make colour buttons show their dialogue in editor mode



commit 66ded608af82e06a0d1945c2b3f7afc6d450aedc
Author: Christian Persch <chpe gnome org>
Date:   Wed Oct 7 15:37:51 2015 +0200

    profile: editor: Make colour buttons show their dialogue in editor mode
    
    We use the colour buttons to edit the colour palette, so it's not good
    usability to pop up the dialogue in palette mode. Since there is no way
    to make the GtkColorButton's dialogue show up in editor mode, and since
    GtkColorChooserDialog even unset editor mode on ::map, we need this gross
    hack to work around it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756192
    (cherry picked from commit 097864897c293a64dda65cc14b34b81f3d4d0813)

 src/profile-editor.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/src/profile-editor.c b/src/profile-editor.c
index c5019fd..a96145f 100644
--- a/src/profile-editor.c
+++ b/src/profile-editor.c
@@ -755,6 +755,44 @@ bool_to_scrollbar_policy (const GValue *value,
   return g_variant_new_string (g_value_get_boolean (value) ? "always" : "never");
 }
 
+/* ATTENTION: HACK HACK HACK!
+ * GtkColorButton usability is broken. It always pops up the
+ * GtkColorChooserDialog with show-editor=FALSE, which brings
+ * up the dialogue in palette mode, when all we want is pick
+ * a colour. Since there is no way to get to the colour
+ * dialogue of the button, and the dialogue always sets
+ * show-editor=FALSE in its map anyway, we need to override
+ * the map implementation, set show-editor=TRUE and chain to
+ * the parent's map. This is reasonably safe to do since that's
+ * all the map functiondoes, and we can change this for _all_
+ * colour chooser buttons, since they are used only in our
+ * profile preferences dialogue.
+ */
+
+static void
+fixup_color_chooser_dialog_map (GtkWidget *widget)
+{
+  g_object_set (GTK_COLOR_CHOOSER_DIALOG (widget), "show-editor", TRUE, NULL);
+
+  GTK_WIDGET_CLASS (g_type_class_peek_parent (GTK_COLOR_CHOOSER_DIALOG_GET_CLASS (widget)))->map (widget);
+}
+
+static void
+fixup_color_chooser_button (void)
+{
+  static gboolean done = FALSE;
+
+  if (!done) {
+    GtkColorChooserDialogClass *klass;
+    klass = g_type_class_ref (GTK_TYPE_COLOR_CHOOSER_DIALOG);
+    g_assert (klass != NULL);
+    GTK_WIDGET_CLASS (klass)->map = fixup_color_chooser_dialog_map;
+    g_type_class_unref (klass);
+    done = TRUE;
+  }
+}
+/* END HACK */
+
 /**
  * terminal_profile_edit:
  * @profile: a #GSettings
@@ -788,6 +826,8 @@ terminal_profile_edit (GSettings  *profile,
       return;
     }
 
+  fixup_color_chooser_button ();
+
   profiles_list = terminal_app_get_profiles_list (terminal_app_get ());
 
   builder = gtk_builder_new ();


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