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
This commit is contained in:
@ -1480,7 +1480,6 @@ gtk_font_selection_dialog_get_type
|
|||||||
<FILE>gtkfontchooser</FILE>
|
<FILE>gtkfontchooser</FILE>
|
||||||
<TITLE>GtkFontChooser</TITLE>
|
<TITLE>GtkFontChooser</TITLE>
|
||||||
GtkFontChooser
|
GtkFontChooser
|
||||||
gtk_font_chooser_new
|
|
||||||
gtk_font_chooser_get_family
|
gtk_font_chooser_get_family
|
||||||
gtk_font_chooser_get_face
|
gtk_font_chooser_get_face
|
||||||
gtk_font_chooser_get_size
|
gtk_font_chooser_get_size
|
||||||
@ -1494,17 +1493,32 @@ GtkFontFilterFunc
|
|||||||
gtk_font_chooser_set_filter_func
|
gtk_font_chooser_set_filter_func
|
||||||
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GtkFontChooserClass
|
GtkFontChooserIface
|
||||||
GTK_TYPE_FONT_CHOOSER
|
GTK_TYPE_FONT_CHOOSER
|
||||||
GTK_FONT_CHOOSER
|
GTK_FONT_CHOOSER
|
||||||
GTK_FONT_CHOOSER_CLASS
|
GTK_FONT_CHOOSER_IFACE
|
||||||
GTK_IS_FONT_CHOOSER
|
GTK_IS_FONT_CHOOSER
|
||||||
GTK_IS_FONT_CHOOSER_CLASS
|
GTK_IS_FONT_CHOOSER_IFACE
|
||||||
GTK_FONT_CHOOSER_GET_CLASS
|
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>
|
<SUBSECTION Private>
|
||||||
GtkFontChooserPrivate
|
GtkFontChooserWidgetPrivate
|
||||||
gtk_font_chooser_get_type
|
gtk_font_chooser_widget_get_type
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
@ -1512,11 +1526,6 @@ gtk_font_chooser_get_type
|
|||||||
<TITLE>GtkFontChooserDialog</TITLE>
|
<TITLE>GtkFontChooserDialog</TITLE>
|
||||||
GtkFontChooserDialog
|
GtkFontChooserDialog
|
||||||
gtk_font_chooser_dialog_new
|
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>
|
<SUBSECTION Standard>
|
||||||
GtkFontChooserDialogClass
|
GtkFontChooserDialogClass
|
||||||
|
|||||||
@ -66,6 +66,9 @@ gtk_file_chooser_widget_get_type
|
|||||||
gtk_file_filter_get_type
|
gtk_file_filter_get_type
|
||||||
gtk_fixed_get_type
|
gtk_fixed_get_type
|
||||||
gtk_font_button_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_dialog_get_type
|
||||||
gtk_font_selection_get_type
|
gtk_font_selection_get_type
|
||||||
gtk_frame_get_type
|
gtk_frame_get_type
|
||||||
|
|||||||
@ -221,6 +221,7 @@ gtk_public_h_sources = \
|
|||||||
gtkfontsel.h \
|
gtkfontsel.h \
|
||||||
gtkfontchooser.h \
|
gtkfontchooser.h \
|
||||||
gtkfontchooserdialog.h \
|
gtkfontchooserdialog.h \
|
||||||
|
gtkfontchooserwidget.h \
|
||||||
gtkframe.h \
|
gtkframe.h \
|
||||||
gtkgradient.h \
|
gtkgradient.h \
|
||||||
gtkgrid.h \
|
gtkgrid.h \
|
||||||
@ -408,6 +409,8 @@ gtk_private_h_sources = \
|
|||||||
gtkfilechooserutils.h \
|
gtkfilechooserutils.h \
|
||||||
gtkfilesystem.h \
|
gtkfilesystem.h \
|
||||||
gtkfilesystemmodel.h \
|
gtkfilesystemmodel.h \
|
||||||
|
gtkfontchooserprivate.h \
|
||||||
|
gtkfontchooserutils.h \
|
||||||
gtkiconcache.h \
|
gtkiconcache.h \
|
||||||
gtkimageprivate.h \
|
gtkimageprivate.h \
|
||||||
gtkimcontextsimpleseqs.h \
|
gtkimcontextsimpleseqs.h \
|
||||||
@ -555,6 +558,8 @@ gtk_base_c_sources = \
|
|||||||
gtkfontsel.c \
|
gtkfontsel.c \
|
||||||
gtkfontchooser.c \
|
gtkfontchooser.c \
|
||||||
gtkfontchooserdialog.c \
|
gtkfontchooserdialog.c \
|
||||||
|
gtkfontchooserutils.c \
|
||||||
|
gtkfontchooserwidget.c \
|
||||||
gtkframe.c \
|
gtkframe.c \
|
||||||
gtkgradient.c \
|
gtkgradient.c \
|
||||||
gtkgrid.c \
|
gtkgrid.c \
|
||||||
|
|||||||
@ -104,6 +104,7 @@
|
|||||||
#include <gtk/gtkfontsel.h>
|
#include <gtk/gtkfontsel.h>
|
||||||
#include <gtk/gtkfontchooser.h>
|
#include <gtk/gtkfontchooser.h>
|
||||||
#include <gtk/gtkfontchooserdialog.h>
|
#include <gtk/gtkfontchooserdialog.h>
|
||||||
|
#include <gtk/gtkfontchooserwidget.h>
|
||||||
#include <gtk/gtkframe.h>
|
#include <gtk/gtkframe.h>
|
||||||
#include <gtk/gtkgradient.h>
|
#include <gtk/gtkgradient.h>
|
||||||
#include <gtk/gtkgrid.h>
|
#include <gtk/gtkgrid.h>
|
||||||
|
|||||||
@ -1047,9 +1047,6 @@ gtk_font_button_set_show_style
|
|||||||
gtk_font_button_set_title
|
gtk_font_button_set_title
|
||||||
gtk_font_button_set_use_font
|
gtk_font_button_set_use_font
|
||||||
gtk_font_button_set_use_size
|
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_get_type
|
||||||
gtk_font_chooser_dialog_new
|
gtk_font_chooser_dialog_new
|
||||||
gtk_font_chooser_dialog_set_font_name
|
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_show_preview_entry
|
||||||
gtk_font_chooser_get_size
|
gtk_font_chooser_get_size
|
||||||
gtk_font_chooser_get_type
|
gtk_font_chooser_get_type
|
||||||
gtk_font_chooser_new
|
|
||||||
gtk_font_chooser_set_filter_func
|
gtk_font_chooser_set_filter_func
|
||||||
gtk_font_chooser_set_font_name
|
gtk_font_chooser_set_font_name
|
||||||
gtk_font_chooser_set_preview_text
|
gtk_font_chooser_set_preview_text
|
||||||
gtk_font_chooser_set_show_preview_entry
|
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_cancel_button
|
||||||
gtk_font_selection_dialog_get_font_name
|
gtk_font_selection_dialog_get_font_name
|
||||||
gtk_font_selection_dialog_get_font_selection
|
gtk_font_selection_dialog_get_font_selection
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
#include "gtkmain.h"
|
#include "gtkmain.h"
|
||||||
#include "gtkbox.h"
|
#include "gtkbox.h"
|
||||||
#include "gtklabel.h"
|
#include "gtklabel.h"
|
||||||
|
#include "gtkfontchooser.h"
|
||||||
#include "gtkfontchooserdialog.h"
|
#include "gtkfontchooserdialog.h"
|
||||||
#include "gtkimage.h"
|
#include "gtkimage.h"
|
||||||
#include "gtkmarshalers.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);
|
gtk_font_button_update_font_info (font_button);
|
||||||
|
|
||||||
if (font_button->priv->font_dialog)
|
if (font_button->priv->font_dialog)
|
||||||
result = gtk_font_chooser_dialog_set_font_name (GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog),
|
result = gtk_font_chooser_set_font_name (GTK_FONT_CHOOSER (font_button->priv->font_dialog),
|
||||||
font_button->priv->fontname);
|
font_button->priv->fontname);
|
||||||
else
|
else
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
|
|
||||||
@ -702,8 +703,8 @@ gtk_font_button_set_font_name (GtkFontButton *font_button,
|
|||||||
static void
|
static void
|
||||||
gtk_font_button_clicked (GtkButton *button)
|
gtk_font_button_clicked (GtkButton *button)
|
||||||
{
|
{
|
||||||
GtkFontChooserDialog *font_dialog;
|
GtkFontChooser *font_dialog;
|
||||||
GtkFontButton *font_button = GTK_FONT_BUTTON (button);
|
GtkFontButton *font_button = GTK_FONT_BUTTON (button);
|
||||||
|
|
||||||
if (!font_button->priv->font_dialog)
|
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,
|
font_button->priv->font_dialog = gtk_font_chooser_dialog_new (font_button->priv->title,
|
||||||
NULL);
|
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))
|
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))
|
if (!gtk_widget_get_visible (font_button->priv->font_dialog))
|
||||||
{
|
{
|
||||||
font_dialog = GTK_FONT_CHOOSER_DIALOG (font_button->priv->font_dialog);
|
font_dialog = GTK_FONT_CHOOSER (font_button->priv->font_dialog);
|
||||||
gtk_font_chooser_dialog_set_font_name (font_dialog, font_button->priv->fontname);
|
gtk_font_chooser_set_font_name (font_dialog, font_button->priv->fontname);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (font_button->priv->font_dialog));
|
gtk_window_present (GTK_WINDOW (font_button->priv->font_dialog));
|
||||||
@ -754,7 +755,7 @@ response_cb (GtkDialog *dialog,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
g_free (font_button->priv->fontname);
|
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 */
|
/* Set label font */
|
||||||
gtk_font_button_update_font_info (font_button);
|
gtk_font_button_update_font_info (font_button);
|
||||||
|
|||||||
1195
gtk/gtkfontchooser.c
1195
gtk/gtkfontchooser.c
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,8 @@
|
|||||||
/* GTK - The GIMP Toolkit
|
/* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* 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,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* 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.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
@ -24,71 +27,15 @@
|
|||||||
#ifndef __GTK_FONT_CHOOSER_H__
|
#ifndef __GTK_FONT_CHOOSER_H__
|
||||||
#define __GTK_FONT_CHOOSER_H__
|
#define __GTK_FONT_CHOOSER_H__
|
||||||
|
|
||||||
#include <gtk/gtkbox.h>
|
#include <gtk/gtkwidget.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
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:
|
* GtkFontFilterFunc:
|
||||||
* @family: a #PangoFontFamily
|
* @family: a #PangoFontFamily
|
||||||
* @face: a #PangoFontFace belonging to @family
|
* @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
|
* The type of function that is used for deciding what fonts get
|
||||||
* shown in a #GtkFontChooser. See gtk_font_chooser_set_filter_func().
|
* shown in a #GtkFontChooser. See gtk_font_chooser_set_filter_func().
|
||||||
@ -99,10 +46,57 @@ typedef gboolean (*GtkFontFilterFunc) (const PangoFontFamily *family,
|
|||||||
const PangoFontFace *face,
|
const PangoFontFace *face,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
|
#define GTK_TYPE_FONT_CHOOSER (gtk_font_chooser_get_type ())
|
||||||
GtkFontFilterFunc filter,
|
#define GTK_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER, GtkFontChooser))
|
||||||
gpointer data,
|
#define GTK_IS_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER))
|
||||||
GDestroyNotify destroy);
|
#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
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,9 @@
|
|||||||
|
|
||||||
#include "gtkfontchooserdialog.h"
|
#include "gtkfontchooserdialog.h"
|
||||||
#include "gtkfontchooser.h"
|
#include "gtkfontchooser.h"
|
||||||
|
#include "gtkfontchooserwidget.h"
|
||||||
|
#include "gtkfontchooserutils.h"
|
||||||
|
#include "gtkbox.h"
|
||||||
#include "gtkstock.h"
|
#include "gtkstock.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
#include "gtkaccessible.h"
|
#include "gtkaccessible.h"
|
||||||
@ -50,19 +53,11 @@ struct _GtkFontChooserDialogPrivate
|
|||||||
*
|
*
|
||||||
* The #GtkFontChooserDialog widget is a dialog box for selecting a font.
|
* 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">
|
* <refsect2 id="GtkFontChooserDialog-BUILDER-UI">
|
||||||
* <title>GtkFontChooserDialog as GtkBuildable</title>
|
* <title>GtkFontChooserDialog as GtkBuildable</title>
|
||||||
* The GtkFontChooserDialog implementation of the GtkBuildable interface
|
* The GtkFontChooserDialog implementation of the GtkBuildable interface
|
||||||
* exposes the embedded #GtkFontChooser as internal child with the
|
* exposes the buttons with the names
|
||||||
* name "font_chooser". It also exposes the buttons with the names
|
|
||||||
* "select_button" and "cancel_button.
|
* "select_button" and "cancel_button.
|
||||||
* </refsect2>
|
* </refsect2>
|
||||||
*
|
*
|
||||||
@ -75,14 +70,57 @@ static GObject *gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildab
|
|||||||
const gchar *childname);
|
const gchar *childname);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GtkFontChooserDialog, gtk_font_chooser_dialog, GTK_TYPE_DIALOG,
|
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,
|
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 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
|
static void
|
||||||
gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
|
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));
|
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);
|
gtk_window_set_resizable (GTK_WINDOW (fontchooserdiag), TRUE);
|
||||||
|
|
||||||
/* Create the content area */
|
/* 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_container_set_border_width (GTK_CONTAINER (priv->fontchooser), 5);
|
||||||
gtk_widget_show (priv->fontchooser);
|
gtk_widget_show (priv->fontchooser);
|
||||||
gtk_box_pack_start (GTK_BOX (content_area),
|
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_window_set_title (GTK_WINDOW (fontchooserdiag), _("Font Selection"));
|
||||||
|
|
||||||
gtk_widget_pop_composite_child ();
|
gtk_widget_pop_composite_child ();
|
||||||
|
|
||||||
|
_gtk_font_chooser_set_delegate (GTK_FONT_CHOOSER (fontchooserdiag),
|
||||||
|
GTK_FONT_CHOOSER (priv->fontchooser));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** gtk_font_chooser_dialog_new:
|
/** gtk_font_chooser_dialog_new:
|
||||||
@ -173,24 +214,6 @@ gtk_font_chooser_dialog_new (const gchar *title,
|
|||||||
return GTK_WIDGET (dialog);
|
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
|
static void
|
||||||
gtk_font_chooser_dialog_buildable_interface_init (GtkBuildableIface *iface)
|
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);
|
return G_OBJECT (priv->select_button);
|
||||||
else if (g_strcmp0 (childname, "cancel_button") == 0)
|
else if (g_strcmp0 (childname, "cancel_button") == 0)
|
||||||
return G_OBJECT (priv->cancel_button);
|
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);
|
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,
|
GtkWidget* gtk_font_chooser_dialog_new (const gchar *title,
|
||||||
GtkWindow *window);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_FONT_CHOOSER_DIALOG_H__ */
|
#endif /* __GTK_FONT_CHOOSER_DIALOG_H__ */
|
||||||
|
|||||||
35
gtk/gtkfontchooserprivate.h
Normal file
35
gtk/gtkfontchooserprivate.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* 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__ */
|
||||||
186
gtk/gtkfontchooserutils.c
Normal file
186
gtk/gtkfontchooserutils.c
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
/* 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
|
||||||
|
*
|
||||||
|
* Installs the necessary properties for a class implementing
|
||||||
|
* #GtkFontChooser. A #GtkParamSpecOverride property is installed
|
||||||
|
* for each property, using the values from the #GtkFontChooserProp
|
||||||
|
* enumeration. The caller must make sure itself that the enumeration
|
||||||
|
* values don't collide with some other property values they
|
||||||
|
* are using.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_gtk_font_chooser_install_properties (GObjectClass *klass)
|
||||||
|
{
|
||||||
|
g_object_class_override_property (klass,
|
||||||
|
GTK_FONT_CHOOSER_PROP_FONT_NAME,
|
||||||
|
"font-name");
|
||||||
|
g_object_class_override_property (klass,
|
||||||
|
GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT,
|
||||||
|
"preview-text");
|
||||||
|
g_object_class_override_property (klass,
|
||||||
|
GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY,
|
||||||
|
"show-preview-entry");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _gtk_font_chooser_delegate_iface_init:
|
||||||
|
* @iface: a #GtkFontChooserIface
|
||||||
|
*
|
||||||
|
* An interface-initialization function for use in cases where
|
||||||
|
* an object is simply delegating the methods, signals of
|
||||||
|
* the #GtkFontChooser interface to another object.
|
||||||
|
* _gtk_font_chooser_set_delegate() must be called on each
|
||||||
|
* instance of the object so that the delegate object can
|
||||||
|
* be found.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_gtk_font_chooser_delegate_iface_init (GtkFontChooserIface *iface)
|
||||||
|
{
|
||||||
|
iface->get_font_name = delegate_get_font_name;
|
||||||
|
iface->set_font_name = delegate_set_font_name;
|
||||||
|
iface->get_font_family = delegate_get_font_family;
|
||||||
|
iface->get_font_face = delegate_get_font_face;
|
||||||
|
iface->get_font_size = delegate_get_font_size;
|
||||||
|
iface->set_filter_func = delegate_set_filter_func;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _gtk_font_chooser_set_delegate:
|
||||||
|
* @receiver: a #GObject implementing #GtkFontChooser
|
||||||
|
* @delegate: another #GObject implementing #GtkFontChooser
|
||||||
|
*
|
||||||
|
* Establishes that calls on @receiver for #GtkFontChooser
|
||||||
|
* methods should be delegated to @delegate, and that
|
||||||
|
* #GtkFontChooser signals emitted on @delegate should be
|
||||||
|
* forwarded to @receiver. Must be used in conjunction with
|
||||||
|
* _gtk_font_chooser_delegate_iface_init().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_gtk_font_chooser_set_delegate (GtkFontChooser *receiver,
|
||||||
|
GtkFontChooser *delegate)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (receiver));
|
||||||
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (delegate));
|
||||||
|
|
||||||
|
g_object_set_qdata (G_OBJECT (receiver),
|
||||||
|
GTK_FONT_CHOOSER_DELEGATE_QUARK,
|
||||||
|
delegate);
|
||||||
|
|
||||||
|
g_signal_connect (delegate, "notify",
|
||||||
|
G_CALLBACK (delegate_notify), receiver);
|
||||||
|
g_signal_connect (delegate, "font-activated",
|
||||||
|
G_CALLBACK (delegate_font_activated), receiver);
|
||||||
|
}
|
||||||
53
gtk/gtkfontchooserutils.h
Normal file
53
gtk/gtkfontchooserutils.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/* 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.h:
|
||||||
|
* Copyright (C) 2003 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GTK_FONT_CHOOSER_UTILS_H__
|
||||||
|
#define __GTK_FONT_CHOOSER_UTILS_H__
|
||||||
|
|
||||||
|
#include "gtkfontchooserprivate.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GTK_FONT_CHOOSER_DELEGATE_QUARK (_gtk_font_chooser_delegate_get_quark ())
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GTK_FONT_CHOOSER_PROP_FIRST = 0x4000,
|
||||||
|
GTK_FONT_CHOOSER_PROP_FONT_NAME,
|
||||||
|
GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT,
|
||||||
|
GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY,
|
||||||
|
GTK_FONT_CHOOSER_PROP_LAST
|
||||||
|
} GtkFontChooserProp;
|
||||||
|
|
||||||
|
void _gtk_font_chooser_install_properties (GObjectClass *klass);
|
||||||
|
void _gtk_font_chooser_delegate_iface_init (GtkFontChooserIface *iface);
|
||||||
|
void _gtk_font_chooser_set_delegate (GtkFontChooser *receiver,
|
||||||
|
GtkFontChooser *delegate);
|
||||||
|
|
||||||
|
GQuark _gtk_font_chooser_delegate_get_quark (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GTK_FONT_CHOOSER_UTILS_H__ */
|
||||||
1198
gtk/gtkfontchooserwidget.c
Normal file
1198
gtk/gtkfontchooserwidget.c
Normal file
File diff suppressed because it is too large
Load Diff
71
gtk/gtkfontchooserwidget.h
Normal file
71
gtk/gtkfontchooserwidget.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/* GTK - The GIMP Toolkit
|
||||||
|
* 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
|
||||||
|
* 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||||
|
#error "Only <gtk/gtk.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GTK_FONT_CHOOSER_WIDGET_H__
|
||||||
|
#define __GTK_FONT_CHOOSER_WIDGET_H__
|
||||||
|
|
||||||
|
#include <gtk/gtkbox.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GTK_TYPE_FONT_CHOOSER_WIDGET (gtk_font_chooser_widget_get_type ())
|
||||||
|
#define GTK_FONT_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER_WIDGET, GtkFontChooserWidget))
|
||||||
|
#define GTK_FONT_CHOOSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FONT_CHOOSER_WIDGET, GtkFontChooserWidgetClass))
|
||||||
|
#define GTK_IS_FONT_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER_WIDGET))
|
||||||
|
#define GTK_IS_FONT_CHOOSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FONT_CHOOSER_WIDGET))
|
||||||
|
#define GTK_FONT_CHOOSER_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FONT_CHOOSER_WIDGET, GtkFontChooserWidgetClass))
|
||||||
|
|
||||||
|
typedef struct _GtkFontChooserWidget GtkFontChooserWidget;
|
||||||
|
typedef struct _GtkFontChooserWidgetPrivate GtkFontChooserWidgetPrivate;
|
||||||
|
typedef struct _GtkFontChooserWidgetClass GtkFontChooserWidgetClass;
|
||||||
|
|
||||||
|
struct _GtkFontChooserWidget
|
||||||
|
{
|
||||||
|
GtkBox parent_instance;
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
GtkFontChooserWidgetPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GtkFontChooserWidgetClass
|
||||||
|
{
|
||||||
|
GtkBoxClass parent_class;
|
||||||
|
|
||||||
|
/* Padding for future expansion */
|
||||||
|
void (*_gtk_reserved1) (void);
|
||||||
|
void (*_gtk_reserved2) (void);
|
||||||
|
void (*_gtk_reserved3) (void);
|
||||||
|
void (*_gtk_reserved4) (void);
|
||||||
|
void (*_gtk_reserved5) (void);
|
||||||
|
void (*_gtk_reserved6) (void);
|
||||||
|
void (*_gtk_reserved7) (void);
|
||||||
|
void (*_gtk_reserved8) (void);
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gtk_font_chooser_widget_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GtkWidget* gtk_font_chooser_widget_new (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GTK_FONT_CHOOSER_WIDGET_H__ */
|
||||||
@ -40,7 +40,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
gtk_init (NULL, NULL);
|
gtk_init (NULL, NULL);
|
||||||
|
|
||||||
fontchooser = gtk_font_chooser_new ();
|
fontchooser = gtk_font_chooser_widget_new ();
|
||||||
|
|
||||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_widget_set_size_request (window, 600, 600);
|
gtk_widget_set_size_request (window, 600, 600);
|
||||||
|
|||||||
Reference in New Issue
Block a user