forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
7687393583
commit
34b4de09fc
@ -208,6 +208,21 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
|
||||
gtk_widget_class_bind_template_callback (widget_class, font_activated_cb);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user