1 /* gtkfontchooserutils.h - Private utility functions for implementing a
2 * GtkFontChooser interface
4 * Copyright (C) 2006 Emmanuele Bassi
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
23 * Based on gtkfilechooserutils.c:
24 * Copyright (C) 2003 Red Hat, Inc.
29 #include "gtkfontchooserutils.h"
31 static GtkFontChooser *
32 get_delegate (GtkFontChooser *receiver)
34 return g_object_get_qdata (G_OBJECT (receiver),
35 GTK_FONT_CHOOSER_DELEGATE_QUARK);
38 static PangoFontFamily *
39 delegate_get_font_family (GtkFontChooser *chooser)
41 return gtk_font_chooser_get_font_family (get_delegate (chooser));
44 static PangoFontFace *
45 delegate_get_font_face (GtkFontChooser *chooser)
47 return gtk_font_chooser_get_font_face (get_delegate (chooser));
51 delegate_get_font_size (GtkFontChooser *chooser)
53 return gtk_font_chooser_get_font_size (get_delegate (chooser));
57 delegate_set_filter_func (GtkFontChooser *chooser,
58 GtkFontFilterFunc filter_func,
60 GDestroyNotify data_destroy)
62 gtk_font_chooser_set_filter_func (get_delegate (chooser),
69 delegate_notify (GObject *object,
75 iface = g_type_interface_peek (g_type_class_peek (G_OBJECT_TYPE (object)),
76 GTK_TYPE_FONT_CHOOSER);
77 if (g_object_interface_find_property (iface, pspec->name))
78 g_object_notify_by_pspec (user_data, pspec);
82 delegate_font_activated (GtkFontChooser *receiver,
83 const gchar *fontname,
84 GtkFontChooser *delegate)
86 _gtk_font_chooser_font_activated (delegate, fontname);
90 _gtk_font_chooser_delegate_get_quark (void)
92 static GQuark quark = 0;
94 if (G_UNLIKELY (quark == 0))
95 quark = g_quark_from_static_string ("gtk-font-chooser-delegate");
101 * _gtk_font_chooser_install_properties:
102 * @klass: the class structure for a type deriving from #GObject
104 * Installs the necessary properties for a class implementing
105 * #GtkFontChooser. A #GtkParamSpecOverride property is installed
106 * for each property, using the values from the #GtkFontChooserProp
107 * enumeration. The caller must make sure itself that the enumeration
108 * values don't collide with some other property values they
112 _gtk_font_chooser_install_properties (GObjectClass *klass)
114 g_object_class_override_property (klass,
115 GTK_FONT_CHOOSER_PROP_FONT,
117 g_object_class_override_property (klass,
118 GTK_FONT_CHOOSER_PROP_FONT_DESC,
120 g_object_class_override_property (klass,
121 GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT,
123 g_object_class_override_property (klass,
124 GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY,
125 "show-preview-entry");
129 * _gtk_font_chooser_delegate_iface_init:
130 * @iface: a #GtkFontChooserIface
132 * An interface-initialization function for use in cases where
133 * an object is simply delegating the methods, signals of
134 * the #GtkFontChooser interface to another object.
135 * _gtk_font_chooser_set_delegate() must be called on each
136 * instance of the object so that the delegate object can
140 _gtk_font_chooser_delegate_iface_init (GtkFontChooserIface *iface)
142 iface->get_font_family = delegate_get_font_family;
143 iface->get_font_face = delegate_get_font_face;
144 iface->get_font_size = delegate_get_font_size;
145 iface->set_filter_func = delegate_set_filter_func;
149 * _gtk_font_chooser_set_delegate:
150 * @receiver: a #GObject implementing #GtkFontChooser
151 * @delegate: another #GObject implementing #GtkFontChooser
153 * Establishes that calls on @receiver for #GtkFontChooser
154 * methods should be delegated to @delegate, and that
155 * #GtkFontChooser signals emitted on @delegate should be
156 * forwarded to @receiver. Must be used in conjunction with
157 * _gtk_font_chooser_delegate_iface_init().
160 _gtk_font_chooser_set_delegate (GtkFontChooser *receiver,
161 GtkFontChooser *delegate)
163 g_return_if_fail (GTK_IS_FONT_CHOOSER (receiver));
164 g_return_if_fail (GTK_IS_FONT_CHOOSER (delegate));
166 g_object_set_qdata (G_OBJECT (receiver),
167 GTK_FONT_CHOOSER_DELEGATE_QUARK,
170 g_signal_connect (delegate, "notify",
171 G_CALLBACK (delegate_notify), receiver);
172 g_signal_connect (delegate, "font-activated",
173 G_CALLBACK (delegate_font_activated), receiver);