[gtk+] font chooser dialog: Improve sensitivity handling



commit 34b4de09fcad15659b5380e251e50031779e8d82
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jan 3 14:04:50 2018 -0500

    font chooser dialog: Improve sensitivity handling
    
    We should not tie the sensitivity of the select button
    to the tweak action, since there may be fonts which are
    selectable, but not tweakable.
    
    Instead, enable the select button when a font is selected,
    as it should be.

 gtk/gtkfontchooserdialog.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkfontchooserdialog.c b/gtk/gtkfontchooserdialog.c
index 45dc87d..dca4811 100644
--- a/gtk/gtkfontchooserdialog.c
+++ b/gtk/gtkfontchooserdialog.c
@@ -209,6 +209,21 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
 }
 
 static void
+update_button (GtkFontChooserDialog *dialog)
+{
+  GtkFontChooserDialogPrivate *priv = dialog->priv;
+  PangoFontDescription *desc;
+
+  desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (priv->fontchooser));
+
+  gtk_widget_set_sensitive (priv->select_button, desc != NULL);
+
+  if (desc)
+    pango_font_description_free (desc);
+}
+
+
+static void
 gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
 {
   GtkFontChooserDialogPrivate *priv;
@@ -222,11 +237,9 @@ gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
   _gtk_font_chooser_set_delegate (GTK_FONT_CHOOSER (fontchooserdiag),
                                   GTK_FONT_CHOOSER (priv->fontchooser));
 
-  g_object_bind_property (gtk_font_chooser_widget_get_tweak_action (priv->fontchooser),
-                          "enabled",
-                          priv->select_button,
-                          "sensitive",
-                          G_BINDING_SYNC_CREATE);
+  g_signal_connect_swapped (priv->fontchooser, "notify::font-desc",
+                            G_CALLBACK (update_button), fontchooserdiag);
+  update_button (fontchooserdiag);
 }
 
 /**


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