forked from AuroraMiddleware/gtk
Redo font map support in GtkFontChooser
We can't add properties to the interface, since it breaks 3rd party implementations of the GtkFontChooser interface. These exist, for example in gnumeric. So, instead of a new property, add getter/setter vfuncs.
This commit is contained in:
parent
8c6130e68a
commit
6f955a7df6
@ -386,9 +386,11 @@ gtk_font_button_get_font_desc (GtkFontButton *font_button)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_button_set_font_map (GtkFontButton *font_button,
|
||||
PangoFontMap *font_map)
|
||||
gtk_font_button_font_chooser_set_font_map (GtkFontChooser *chooser,
|
||||
PangoFontMap *font_map)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
|
||||
|
||||
if (g_set_object (&font_button->priv->font_map, font_map))
|
||||
{
|
||||
PangoContext *context;
|
||||
@ -398,11 +400,17 @@ gtk_font_button_set_font_map (GtkFontButton *font_button,
|
||||
|
||||
context = gtk_widget_get_pango_context (font_button->priv->font_label);
|
||||
pango_context_set_font_map (context, font_map);
|
||||
|
||||
g_object_notify (G_OBJECT (font_button), "font-map");
|
||||
}
|
||||
}
|
||||
|
||||
static PangoFontMap *
|
||||
gtk_font_button_font_chooser_get_font_map (GtkFontChooser *chooser)
|
||||
{
|
||||
GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
|
||||
|
||||
return font_button->priv->font_map;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_button_font_chooser_notify (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@ -421,6 +429,8 @@ gtk_font_button_font_chooser_iface_init (GtkFontChooserIface *iface)
|
||||
iface->get_font_face = gtk_font_button_font_chooser_get_font_face;
|
||||
iface->get_font_size = gtk_font_button_font_chooser_get_font_size;
|
||||
iface->set_filter_func = gtk_font_button_font_chooser_set_filter_func;
|
||||
iface->set_font_map = gtk_font_button_font_chooser_set_font_map;
|
||||
iface->get_font_map = gtk_font_button_font_chooser_get_font_map;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkFontButton, gtk_font_button, GTK_TYPE_BUTTON,
|
||||
@ -655,9 +665,6 @@ gtk_font_button_set_property (GObject *object,
|
||||
case PROP_SHOW_SIZE:
|
||||
gtk_font_button_set_show_size (font_button, g_value_get_boolean (value));
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_FONT_MAP:
|
||||
gtk_font_button_set_font_map (font_button, g_value_get_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
@ -702,9 +709,6 @@ gtk_font_button_get_property (GObject *object,
|
||||
case PROP_SHOW_SIZE:
|
||||
g_value_set_boolean (value, gtk_font_button_get_show_size (font_button));
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_FONT_MAP:
|
||||
g_value_set_object (value, font_button->priv->font_map);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
|
@ -105,18 +105,6 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
||||
TRUE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
/**
|
||||
* GtkFontChooser:font-map:
|
||||
*
|
||||
* A custom font map to use for this widget, instead of the
|
||||
* default one.
|
||||
*
|
||||
* Since: 3.18
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_object ("font-map", P_("Font map"), P_("A custom PangoFontMap"),
|
||||
PANGO_TYPE_FONT_MAP,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
/**
|
||||
* GtkFontChooser::font-activated:
|
||||
* @self: the object which received the signal
|
||||
@ -466,7 +454,8 @@ gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
|
||||
g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
|
||||
g_return_if_fail (fontmap == NULL || PANGO_IS_FONT_MAP (fontmap));
|
||||
|
||||
g_object_set (fontchooser, "font-map", fontmap, NULL);
|
||||
if (GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font_map)
|
||||
GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font_map (fontchooser, fontmap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -483,11 +472,12 @@ gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
|
||||
PangoFontMap *
|
||||
gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser)
|
||||
{
|
||||
PangoFontMap *fontmap;
|
||||
PangoFontMap *fontmap = NULL;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
|
||||
|
||||
g_object_get (fontchooser, "font-map", &fontmap, NULL);
|
||||
if (GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_map)
|
||||
fontmap = GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_map (fontchooser);
|
||||
|
||||
return fontmap;
|
||||
}
|
||||
|
@ -70,8 +70,13 @@ struct _GtkFontChooserIface
|
||||
void (* font_activated) (GtkFontChooser *chooser,
|
||||
const gchar *fontname);
|
||||
|
||||
/* More methods */
|
||||
void (* set_font_map) (GtkFontChooser *fontchooser,
|
||||
PangoFontMap *map);
|
||||
PangoFontMap * (* get_font_map) (GtkFontChooser *fontchooser);
|
||||
|
||||
/* Padding */
|
||||
gpointer padding[12];
|
||||
gpointer padding[10];
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_3_2
|
||||
|
@ -63,6 +63,19 @@ delegate_set_filter_func (GtkFontChooser *chooser,
|
||||
data_destroy);
|
||||
}
|
||||
|
||||
static void
|
||||
delegate_set_font_map (GtkFontChooser *chooser,
|
||||
PangoFontMap *map)
|
||||
{
|
||||
gtk_font_chooser_set_font_map (get_delegate (chooser), map);
|
||||
}
|
||||
|
||||
static PangoFontMap *
|
||||
delegate_get_font_map (GtkFontChooser *chooser)
|
||||
{
|
||||
return gtk_font_chooser_get_font_map (get_delegate (chooser));
|
||||
}
|
||||
|
||||
static void
|
||||
delegate_notify (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@ -121,9 +134,6 @@ _gtk_font_chooser_install_properties (GObjectClass *klass)
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY,
|
||||
"show-preview-entry");
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FONT_CHOOSER_PROP_FONT_MAP,
|
||||
"font-map");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,6 +154,8 @@ _gtk_font_chooser_delegate_iface_init (GtkFontChooserIface *iface)
|
||||
iface->get_font_face = delegate_get_font_face;
|
||||
iface->get_font_size = delegate_get_font_size;
|
||||
iface->set_filter_func = delegate_set_filter_func;
|
||||
iface->set_font_map = delegate_set_font_map;
|
||||
iface->get_font_map = delegate_get_font_map;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,6 @@ typedef enum {
|
||||
GTK_FONT_CHOOSER_PROP_FONT_DESC,
|
||||
GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT,
|
||||
GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY,
|
||||
GTK_FONT_CHOOSER_PROP_FONT_MAP,
|
||||
GTK_FONT_CHOOSER_PROP_LAST
|
||||
} GtkFontChooserProp;
|
||||
|
||||
|
@ -171,8 +171,6 @@ static void gtk_font_chooser_widget_cell_data_func (GtkTreeViewColum
|
||||
GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
static void gtk_font_chooser_widget_set_font_map (GtkFontChooserWidget *fontchooser,
|
||||
PangoFontMap *fontmap);
|
||||
|
||||
static void gtk_font_chooser_widget_iface_init (GtkFontChooserIface *iface);
|
||||
|
||||
@ -203,9 +201,6 @@ gtk_font_chooser_widget_set_property (GObject *object,
|
||||
case GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY:
|
||||
gtk_font_chooser_widget_set_show_preview_entry (fontchooser, g_value_get_boolean (value));
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_FONT_MAP:
|
||||
gtk_font_chooser_widget_set_font_map (fontchooser, g_value_get_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -234,9 +229,6 @@ gtk_font_chooser_widget_get_property (GObject *object,
|
||||
case GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY:
|
||||
g_value_set_boolean (value, gtk_font_chooser_widget_get_show_preview_entry (fontchooser));
|
||||
break;
|
||||
case GTK_FONT_CHOOSER_PROP_FONT_MAP:
|
||||
g_value_set_object (value, fontchooser->priv->font_map);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -1231,9 +1223,10 @@ gtk_font_chooser_widget_set_show_preview_entry (GtkFontChooserWidget *fontchoose
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_chooser_widget_set_font_map (GtkFontChooserWidget *fontchooser,
|
||||
PangoFontMap *fontmap)
|
||||
gtk_font_chooser_widget_set_font_map (GtkFontChooser *chooser,
|
||||
PangoFontMap *fontmap)
|
||||
{
|
||||
GtkFontChooserWidget *fontchooser = GTK_FONT_CHOOSER_WIDGET (chooser);
|
||||
GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
|
||||
|
||||
if (g_set_object (&priv->font_map, fontmap))
|
||||
@ -1255,6 +1248,15 @@ gtk_font_chooser_widget_set_font_map (GtkFontChooserWidget *fontchooser,
|
||||
}
|
||||
}
|
||||
|
||||
static PangoFontMap *
|
||||
gtk_font_chooser_widget_get_font_map (GtkFontChooser *chooser)
|
||||
{
|
||||
GtkFontChooserWidget *fontchooser = GTK_FONT_CHOOSER_WIDGET (chooser);
|
||||
GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
|
||||
|
||||
return priv->font_map;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_font_chooser_widget_set_filter_func (GtkFontChooser *chooser,
|
||||
GtkFontFilterFunc filter,
|
||||
@ -1281,4 +1283,6 @@ gtk_font_chooser_widget_iface_init (GtkFontChooserIface *iface)
|
||||
iface->get_font_face = gtk_font_chooser_widget_get_face;
|
||||
iface->get_font_size = gtk_font_chooser_widget_get_size;
|
||||
iface->set_filter_func = gtk_font_chooser_widget_set_filter_func;
|
||||
iface->set_font_map = gtk_font_chooser_widget_set_font_map;
|
||||
iface->get_font_map = gtk_font_chooser_widget_get_font_map;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user