Commit 54525251 authored by Christian Persch's avatar Christian Persch

Make GtkFontChooser an interface

Make the GtkFontChooser API similar to the Gtk{File,Recent,App}Chooser
APIs by introducing GtkFontChooser as an interface, that has a default
implementation in GtkFontChooserWidget.

https://bugzilla.gnome.org/show_bug.cgi?id=657627
parent 291b0440
......@@ -1480,7 +1480,6 @@ gtk_font_selection_dialog_get_type
<FILE>gtkfontchooser</FILE>
<TITLE>GtkFontChooser</TITLE>
GtkFontChooser
gtk_font_chooser_new
gtk_font_chooser_get_family
gtk_font_chooser_get_face
gtk_font_chooser_get_size
......@@ -1494,17 +1493,32 @@ GtkFontFilterFunc
gtk_font_chooser_set_filter_func
<SUBSECTION Standard>
GtkFontChooserClass
GtkFontChooserIface
GTK_TYPE_FONT_CHOOSER
GTK_FONT_CHOOSER
GTK_FONT_CHOOSER_CLASS
GTK_FONT_CHOOSER_IFACE
GTK_IS_FONT_CHOOSER
GTK_IS_FONT_CHOOSER_CLASS
GTK_FONT_CHOOSER_GET_CLASS
GTK_IS_FONT_CHOOSER_IFACE
GTK_FONT_CHOOSER_GET_IFACE
</SECTION>
<SECTION>
<FILE>gtkfontchooserwidget</FILE>
<TITLE>GtkFontChooserWidget</TITLE>
GtkFontChooserWidget
<SUBSECTION Standard>
GtkFontChooserWidgetClass
GTK_TYPE_FONT_CHOOSER_WIDGET
GTK_FONT_CHOOSER_WIDGET
GTK_FONT_CHOOSER_WIDGET_CLASS
GTK_IS_FONT_CHOOSER_WIDGET
GTK_IS_FONT_CHOOSER_WIDGET_CLASS
GTK_FONT_CHOOSER_WIDGET_GET_CLASS
<SUBSECTION Private>
GtkFontChooserPrivate
gtk_font_chooser_get_type
GtkFontChooserWidgetPrivate
gtk_font_chooser_widget_get_type
</SECTION>
<SECTION>
......@@ -1512,11 +1526,6 @@ gtk_font_chooser_get_type
<TITLE>GtkFontChooserDialog</TITLE>
GtkFontChooserDialog
gtk_font_chooser_dialog_new
gtk_font_chooser_dialog_get_font_chooser
gtk_font_chooser_dialog_get_font_name
gtk_font_chooser_dialog_set_font_name
gtk_font_chooser_dialog_get_preview_text
gtk_font_chooser_dialog_set_preview_text
<SUBSECTION Standard>
GtkFontChooserDialogClass
......
......@@ -66,6 +66,9 @@ gtk_file_chooser_widget_get_type
gtk_file_filter_get_type
gtk_fixed_get_type
gtk_font_button_get_type
gtk_font_chooser_get_type
gtk_font_chooser_dialog_get_type
gtk_font_chooser_widget_get_type
gtk_font_selection_dialog_get_type
gtk_font_selection_get_type
gtk_frame_get_type
......
......@@ -221,6 +221,7 @@ gtk_public_h_sources = \
gtkfontsel.h \
gtkfontchooser.h \
gtkfontchooserdialog.h \
gtkfontchooserwidget.h \
gtkframe.h \
gtkgradient.h \
gtkgrid.h \
......@@ -408,6 +409,8 @@ gtk_private_h_sources = \
gtkfilechooserutils.h \
gtkfilesystem.h \
gtkfilesystemmodel.h \
gtkfontchooserprivate.h \
gtkfontchooserutils.h \
gtkiconcache.h \
gtkimageprivate.h \
gtkimcontextsimpleseqs.h \
......@@ -555,6 +558,8 @@ gtk_base_c_sources = \
gtkfontsel.c \
gtkfontchooser.c \
gtkfontchooserdialog.c \
gtkfontchooserutils.c \
gtkfontchooserwidget.c \
gtkframe.c \
gtkgradient.c \
gtkgrid.c \
......
......@@ -104,6 +104,7 @@
#include <gtk/gtkfontsel.h>
#include <gtk/gtkfontchooser.h>
#include <gtk/gtkfontchooserdialog.h>
#include <gtk/gtkfontchooserwidget.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkgradient.h>
#include <gtk/gtkgrid.h>
......
......@@ -1047,9 +1047,6 @@ gtk_font_button_set_show_style
gtk_font_button_set_title
gtk_font_button_set_use_font
gtk_font_button_set_use_size
gtk_font_chooser_dialog_get_font_chooser
gtk_font_chooser_dialog_get_font_name
gtk_font_chooser_dialog_get_preview_text
gtk_font_chooser_dialog_get_type
gtk_font_chooser_dialog_new
gtk_font_chooser_dialog_set_font_name
......@@ -1061,11 +1058,12 @@ gtk_font_chooser_get_preview_text
gtk_font_chooser_get_show_preview_entry
gtk_font_chooser_get_size
gtk_font_chooser_get_type
gtk_font_chooser_new
gtk_font_chooser_set_filter_func
gtk_font_chooser_set_font_name
gtk_font_chooser_set_preview_text
gtk_font_chooser_set_show_preview_entry
gtk_font_chooser_widget_get_type
gtk_font_chooser_widget_new
gtk_font_selection_dialog_get_cancel_button
gtk_font_selection_dialog_get_font_name
gtk_font_selection_dialog_get_font_selection
......
......@@ -33,6 +33,7 @@
#include "gtkmain.h"
#include "gtkbox.h"
#include "gtklabel.h"
#include "gtkfontchooser.h"
#include "gtkfontchooserdialog.h"
#include "gtkimage.h"
#include "gtkmarshalers.h"
......@@ -689,8 +690,8 @@ gtk_font_button_set_font_name (GtkFontButton *font_button,
gtk_font_button_update_font_info (font_button);
if (font_button->priv->font_dialog)
result = gtk_font_chooser_dialog_set_font_name (GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog),
font_button->priv->fontname);
result = gtk_font_chooser_set_font_name (GTK_FONT_CHOOSER (font_button->priv->font_dialog),
font_button->priv->fontname);
else
result = FALSE;
......@@ -702,8 +703,8 @@ gtk_font_button_set_font_name (GtkFontButton *font_button,
static void
gtk_font_button_clicked (GtkButton *button)
{
GtkFontChooserDialog *font_dialog;
GtkFontButton *font_button = GTK_FONT_BUTTON (button);
GtkFontChooser *font_dialog;
GtkFontButton *font_button = GTK_FONT_BUTTON (button);
if (!font_button->priv->font_dialog)
{
......@@ -714,7 +715,7 @@ gtk_font_button_clicked (GtkButton *button)
font_button->priv->font_dialog = gtk_font_chooser_dialog_new (font_button->priv->title,
NULL);
font_dialog = GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog);
font_dialog = GTK_FONT_CHOOSER (font_button->priv->font_dialog);
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
......@@ -734,8 +735,8 @@ gtk_font_button_clicked (GtkButton *button)
if (!gtk_widget_get_visible (font_button->priv->font_dialog))
{
font_dialog = GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog);
gtk_font_chooser_dialog_set_font_name (font_dialog, font_button->priv->fontname);
font_dialog = GTK_FONT_CHOOSER (font_button->priv->font_dialog);
gtk_font_chooser_set_font_name (font_dialog, font_button->priv->fontname);
}
gtk_window_present (GTK_WINDOW (font_button->priv->font_dialog));
......@@ -754,7 +755,7 @@ response_cb (GtkDialog *dialog,
return;
g_free (font_button->priv->fontname);
font_button->priv->fontname = gtk_font_chooser_dialog_get_font_name (GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog));
font_button->priv->fontname = gtk_font_chooser_get_font_name (GTK_FONT_CHOOSER (font_button->priv->font_dialog));
/* Set label font */
gtk_font_button_update_font_info (font_button);
......
This diff is collapsed.
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
* gtkfontchooser.h - Abstract interface for font file selectors GUIs
*
* Copyright (C) 2006, Emmanuele Bassi
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -8,7 +11,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
......@@ -24,71 +27,15 @@
#ifndef __GTK_FONT_CHOOSER_H__
#define __GTK_FONT_CHOOSER_H__
#include <gtk/gtkbox.h>
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GTK_TYPE_FONT_CHOOSER (gtk_font_chooser_get_type ())
#define GTK_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER, GtkFontChooser))
#define GTK_FONT_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FONT_CHOOSER, GtkFontChooserClass))
#define GTK_IS_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER))
#define GTK_IS_FONT_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FONT_CHOOSER))
#define GTK_FONT_CHOOSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FONT_CHOOSER, GtkFontChooserClass))
typedef struct _GtkFontChooser GtkFontChooser;
typedef struct _GtkFontChooserPrivate GtkFontChooserPrivate;
typedef struct _GtkFontChooserClass GtkFontChooserClass;
struct _GtkFontChooser
{
GtkBox parent_instance;
/*< private >*/
GtkFontChooserPrivate *priv;
};
struct _GtkFontChooserClass
{
GtkBoxClass parent_class;
void (* font_activated) (GtkFontChooser *chooser,
const gchar *fontname);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
/*****************************************************************************
* GtkFontChooser functions.
* see the comments in the GtkFontChooserDialog functions.
*****************************************************************************/
GType gtk_font_chooser_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_font_chooser_new (void);
PangoFontFamily*
gtk_font_chooser_get_family (GtkFontChooser *fontchooser);
PangoFontFace*
gtk_font_chooser_get_face (GtkFontChooser *fontchooser);
gint gtk_font_chooser_get_size (GtkFontChooser *fontchooser);
gchar* gtk_font_chooser_get_font_name (GtkFontChooser *fontchooser);
gboolean gtk_font_chooser_set_font_name (GtkFontChooser *fontchooser,
const gchar *fontname);
const gchar* gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser);
void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
const gchar *text);
gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser);
void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
gboolean show_preview_entry);
/**
* GtkFontFilterFunc:
* @family: a #PangoFontFamily
* @face: a #PangoFontFace belonging to @family
* @data (closure): user data passed to gtk_font_chooser_set_filter_func()
* @data: (closure): user data passed to gtk_font_chooser_set_filter_func()
*
* The type of function that is used for deciding what fonts get
* shown in a #GtkFontChooser. See gtk_font_chooser_set_filter_func().
......@@ -99,10 +46,57 @@ typedef gboolean (*GtkFontFilterFunc) (const PangoFontFamily *family,
const PangoFontFace *face,
gpointer data);
void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
GtkFontFilterFunc filter,
gpointer data,
GDestroyNotify destroy);
#define GTK_TYPE_FONT_CHOOSER (gtk_font_chooser_get_type ())
#define GTK_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER, GtkFontChooser))
#define GTK_IS_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER))
#define GTK_FONT_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FONT_CHOOSER, GtkFontChooserIface))
typedef struct _GtkFontChooser GtkFontChooser; /* dummy */
typedef struct _GtkFontChooserIface GtkFontChooserIface;
struct _GtkFontChooserIface
{
GTypeInterface base_iface;
/* Methods */
gchar * (* get_font_name) (GtkFontChooser *chooser);
gboolean (* set_font_name) (GtkFontChooser *chooser,
const gchar *fontname);
PangoFontFamily * (* get_font_family) (GtkFontChooser *chooser);
PangoFontFace * (* get_font_face) (GtkFontChooser *chooser);
gint (* get_font_size) (GtkFontChooser *chooser);
void (* set_filter_func) (GtkFontChooser *chooser,
GtkFontFilterFunc filter,
gpointer data,
GDestroyNotify destroy);
/* Signals */
void (* font_activated) (GtkFontChooser *chooser,
const gchar *fontname);
/* Paddig */
gpointer padding[12];
};
GType gtk_font_chooser_get_type (void) G_GNUC_CONST;
PangoFontFamily *gtk_font_chooser_get_family (GtkFontChooser *fontchooser);
PangoFontFace *gtk_font_chooser_get_face (GtkFontChooser *fontchooser);
gint gtk_font_chooser_get_size (GtkFontChooser *fontchooser);
gchar* gtk_font_chooser_get_font_name (GtkFontChooser *fontchooser);
gboolean gtk_font_chooser_set_font_name (GtkFontChooser *fontchooser,
const gchar *font_name);
gchar* gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser);
void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
const gchar *text);
gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser);
void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
gboolean show_preview_entry);
void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
GtkFontFilterFunc filter,
gpointer user_data,
GDestroyNotify destroy);
G_END_DECLS
......
......@@ -27,6 +27,9 @@
#include "gtkfontchooserdialog.h"
#include "gtkfontchooser.h"
#include "gtkfontchooserwidget.h"
#include "gtkfontchooserutils.h"
#include "gtkbox.h"
#include "gtkstock.h"
#include "gtkintl.h"
#include "gtkaccessible.h"
......@@ -50,19 +53,11 @@ struct _GtkFontChooserDialogPrivate
*
* The #GtkFontChooserDialog widget is a dialog box for selecting a font.
*
* To set the font which is initially selected, use
* gtk_font_chooser_dialog_set_font_name().
*
* To get the selected font use gtk_font_chooser_dialog_get_font_name().
*
* To change the text which is shown in the preview area, use
* gtk_font_chooser_dialog_set_preview_text().
*
*
* <refsect2 id="GtkFontChooserDialog-BUILDER-UI">
* <title>GtkFontChooserDialog as GtkBuildable</title>
* The GtkFontChooserDialog implementation of the GtkBuildable interface
* exposes the embedded #GtkFontChooser as internal child with the
* name "font_chooser". It also exposes the buttons with the names
* exposes the buttons with the names
* "select_button" and "cancel_button.
* </refsect2>
*
......@@ -75,14 +70,57 @@ static GObject *gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildab
const gchar *childname);
G_DEFINE_TYPE_WITH_CODE (GtkFontChooserDialog, gtk_font_chooser_dialog, GTK_TYPE_DIALOG,
G_IMPLEMENT_INTERFACE (GTK_TYPE_FONT_CHOOSER,
_gtk_font_chooser_delegate_iface_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_font_chooser_dialog_buildable_interface_init))
gtk_font_chooser_dialog_buildable_interface_init))
static GtkBuildableIface *parent_buildable_iface;
static void
gtk_font_chooser_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkFontChooserDialog *dialog = GTK_FONT_CHOOSER_DIALOG (object);
GtkFontChooserDialogPrivate *priv = dialog->priv;
switch (prop_id)
{
default:
g_object_set_property (G_OBJECT (priv->fontchooser), pspec->name, value);
break;
}
}
static void
gtk_font_chooser_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkFontChooserDialog *dialog = GTK_FONT_CHOOSER_DIALOG (object);
GtkFontChooserDialogPrivate *priv = dialog->priv;
switch (prop_id)
{
default:
g_object_get_property (G_OBJECT (priv->fontchooser), pspec->name, value);
break;
}
}
static void
gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gtk_font_chooser_dialog_get_property;
gobject_class->set_property = gtk_font_chooser_dialog_set_property;
_gtk_font_chooser_install_properties (gobject_class);
g_type_class_add_private (klass, sizeof (GtkFontChooserDialogPrivate));
}
......@@ -121,7 +159,7 @@ gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
gtk_window_set_resizable (GTK_WINDOW (fontchooserdiag), TRUE);
/* Create the content area */
priv->fontchooser = gtk_font_chooser_new ();
priv->fontchooser = gtk_font_chooser_widget_new ();
gtk_container_set_border_width (GTK_CONTAINER (priv->fontchooser), 5);
gtk_widget_show (priv->fontchooser);
gtk_box_pack_start (GTK_BOX (content_area),
......@@ -147,6 +185,9 @@ gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
gtk_window_set_title (GTK_WINDOW (fontchooserdiag), _("Font Selection"));
gtk_widget_pop_composite_child ();
_gtk_font_chooser_set_delegate (GTK_FONT_CHOOSER (fontchooserdiag),
GTK_FONT_CHOOSER (priv->fontchooser));
}
/** gtk_font_chooser_dialog_new:
......@@ -173,24 +214,6 @@ gtk_font_chooser_dialog_new (const gchar *title,
return GTK_WIDGET (dialog);
}
/**
* gtk_font_chooser_dialog_get_font_chooser:
* @fcd: a #GtkFontChooserDialog
*
* Retrieves the #GtkFontChooser widget embedded in the dialog.
*
* Returns: (transfer none): the embedded #GtkFontChooser
*
* Since: 3.2
*/
GtkWidget*
gtk_font_chooser_dialog_get_font_chooser (GtkFontChooserDialog *fcd)
{
g_return_val_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd), NULL);
return fcd->priv->fontchooser;
}
static void
gtk_font_chooser_dialog_buildable_interface_init (GtkBuildableIface *iface)
{
......@@ -211,113 +234,6 @@ gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildable *buildable,
return G_OBJECT (priv->select_button);
else if (g_strcmp0 (childname, "cancel_button") == 0)
return G_OBJECT (priv->cancel_button);
else if (g_strcmp0 (childname, "font_chooser") == 0)
return G_OBJECT (priv->fontchooser);
return parent_buildable_iface->get_internal_child (buildable, builder, childname);
}
/**
* gtk_font_chooser_dialog_get_font_name:
* @fcd: a #GtkFontChooserDialog
*
* Gets the currently-selected font name.
*
* Note that this can be a different string than what you set with
* gtk_font_chooser_dialog_set_font_name(), as the font chooser widget
* may normalize font names and thus return a string with a different
* structure. For example, "Helvetica Italic Bold 12" could be normalized
* to "Helvetica Bold Italic 12".
*
* Use pango_font_description_equal() if you want to compare two
* font descriptions.
*
* Return value: A string with the name of the current font, or %NULL
* if no font is selected. You must free this string with g_free().
*
* Since: 3.2
*/
gchar*
gtk_font_chooser_dialog_get_font_name (GtkFontChooserDialog *fcd)
{
GtkFontChooserDialogPrivate *priv;
g_return_val_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd), NULL);
priv = fcd->priv;
return gtk_font_chooser_get_font_name (GTK_FONT_CHOOSER (priv->fontchooser));
}
/**
* gtk_font_chooser_dialog_set_font_name:
* @fcd: a #GtkFontChooserDialog
* @fontname: a font name like "Helvetica 12" or "Times Bold 18"
*
* Sets the currently selected font.
*
* Return value: %TRUE if the font selected in @fcd is now the
* @fontname specified, %FALSE otherwise.
*
* Since: 3.2
*/
gboolean
gtk_font_chooser_dialog_set_font_name (GtkFontChooserDialog *fcd,
const gchar *fontname)
{
GtkFontChooserDialogPrivate *priv;
g_return_val_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd), FALSE);
g_return_val_if_fail (fontname, FALSE);
priv = fcd->priv;
return gtk_font_chooser_set_font_name (GTK_FONT_CHOOSER (priv->fontchooser), fontname);
}
/**
* gtk_font_chooser_dialog_get_preview_text:
* @fcd: a #GtkFontChooserDialog
*
* Gets the text displayed in the preview area.
*
* Return value: the text displayed in the preview area.
* This string is owned by the widget and should not be
* modified or freed
*
* Since: 3.2
*/
const gchar*
gtk_font_chooser_dialog_get_preview_text (GtkFontChooserDialog *fcd)
{
GtkFontChooserDialogPrivate *priv;
g_return_val_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd), NULL);
priv = fcd->priv;
return gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (priv->fontchooser));
}
/**
* gtk_font_chooser_dialog_set_preview_text:
* @fcd: a #GtkFontChooserDialog
* @text: the text to display in the preview area
*
* Sets the text displayed in the preview area.
*
* Since: 3.2
*/
void
gtk_font_chooser_dialog_set_preview_text (GtkFontChooserDialog *fcd,
const gchar *text)
{
GtkFontChooserDialogPrivate *priv;
g_return_if_fail (GTK_IS_FONT_CHOOSER_DIALOG (fcd));
g_return_if_fail (text != NULL);
priv = fcd->priv;
gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (priv->fontchooser), text);
}
......@@ -62,15 +62,6 @@ GType gtk_font_chooser_dialog_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_font_chooser_dialog_new (const gchar *title,
GtkWindow *window);
GtkWidget* gtk_font_chooser_dialog_get_font_chooser (GtkFontChooserDialog *fcd);
gchar* gtk_font_chooser_dialog_get_font_name (GtkFontChooserDialog *fcd);
gboolean gtk_font_chooser_dialog_set_font_name (GtkFontChooserDialog *fcd,
const gchar *fontname);
const gchar*
gtk_font_chooser_dialog_get_preview_text (GtkFontChooserDialog *fcd);
void gtk_font_chooser_dialog_set_preview_text (GtkFontChooserDialog *fcd,
const gchar *text);
G_END_DECLS
#endif /* __GTK_FONT_CHOOSER_DIALOG_H__ */
/* gtkfontprivatechooser.h - Interface definitions for font selectors UI
*
* Copyright (C) 2006 Emmanuele Bassi
*
* All rights reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_FONT_CHOOSER_PRIVATE_H__
#define __GTK_FONT_CHOOSER_PRIVATE_H__
#include "gtkfontchooser.h"
G_BEGIN_DECLS
void _gtk_font_chooser_font_activated (GtkFontChooser *chooser,
const gchar *fontname);
G_END_DECLS
#endif /* ! __GTK_FONT_CHOOSER_PRIVATE_H__ */
/* gtkfontchooserutils.h - Private utility functions for implementing a
* GtkFontChooser interface
*
* Copyright (C) 2006 Emmanuele Bassi
*
* All rights reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Based on gtkfilechooserutils.c:
* Copyright (C) 2003 Red Hat, Inc.
*/
#include "config.h"
#include "gtkfontchooserutils.h"
static GtkFontChooser *
get_delegate (GtkFontChooser *receiver)
{
return g_object_get_qdata (G_OBJECT (receiver),
GTK_FONT_CHOOSER_DELEGATE_QUARK);
}
static gchar *
delegate_get_font_name (GtkFontChooser *chooser)
{
return gtk_font_chooser_get_font_name (get_delegate (chooser));
}
static gboolean
delegate_set_font_name (GtkFontChooser *chooser,
const gchar *fontname)
{
return gtk_font_chooser_set_font_name (get_delegate (chooser), fontname);
}
static PangoFontFamily *
delegate_get_font_family (GtkFontChooser *chooser)
{
return gtk_font_chooser_get_family (get_delegate (chooser));
}
static PangoFontFace *
delegate_get_font_face (GtkFontChooser *chooser)
{
return gtk_font_chooser_get_face (get_delegate (chooser));
}
static int
delegate_get_font_size (GtkFontChooser *chooser)
{
return gtk_font_chooser_get_size (get_delegate (chooser));
}
static void
delegate_set_filter_func (GtkFontChooser *chooser,
GtkFontFilterFunc filter_func,
gpointer filter_data,
GDestroyNotify data_destroy)
{
gtk_font_chooser_set_filter_func (get_delegate (chooser),
filter_func,
filter_data,
data_destroy);
}
static void
delegate_notify (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
gpointer iface;
iface = g_type_interface_peek (g_type_class_peek (G_OBJECT_TYPE (object)),
GTK_TYPE_FONT_CHOOSER);
if (g_object_interface_find_property (iface, pspec->name))
g_object_notify_by_pspec (user_data, pspec);
}
static void
delegate_font_activated (GtkFontChooser *receiver,
const gchar *fontname,
GtkFontChooser *delegate)
{
_gtk_font_chooser_font_activated (delegate, fontname);
}
GQuark
_gtk_font_chooser_delegate_get_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("gtk-font-chooser-delegate");
return quark;
}
/**
* _gtk_font_chooser_install_properties:
* @klass: the class structure for a type deriving from #GObject
*