return w;
}
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *
create_font_button (void)
{
return gtk_font_button_new ();
}
+G_GNUC_END_IGNORE_DEPRECATIONS
static GtkWidget *
create_level_bar (void)
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998 David Abilleira Freijeiro <odaf@nexo.es>
+ * All rights reserved.
+ *
+ * Based on gnome-color-picker by Federico Mena <federico@nuclecu.unam.mx>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include "config.h"
+
+#include "gtkfontbutton.h"
+
+#include "gtkbinlayout.h"
+#include "gtkbox.h"
+#include "gtkfontchooser.h"
+#include "gtkfontchooserdialog.h"
+#include "gtkfontchooserutils.h"
+#include <glib/gi18n-lib.h>
+#include "gtklabel.h"
+#include "gtkmarshalers.h"
+#include "gtkprivate.h"
+#include "gtkseparator.h"
+#include "gtkwidgetprivate.h"
+
+#include <string.h>
+#include <stdio.h>
+
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+/**
+ * GtkFontButton:
+ *
+ * The `GtkFontButton` allows to open a font chooser dialog to change
+ * the font.
+ *
+ * 
+ *
+ * It is suitable widget for selecting a font in a preference dialog.
+ *
+ * # CSS nodes
+ *
+ * ```
+ * fontbutton
+ * ╰── button.font
+ * ╰── [content]
+ * ```
+ *
+ * `GtkFontButton` has a single CSS node with name fontbutton which
+ * contains a button node with the .font style class.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+
+typedef struct _GtkFontButtonClass GtkFontButtonClass;
+
+struct _GtkFontButton
+{
+ GtkWidget parent_instance;
+
+ char *title;
+ char *fontname;
+
+ guint use_font : 1;
+ guint use_size : 1;
+ guint show_preview_entry : 1;
+ guint modal : 1;
+
+ GtkFontChooserLevel level;
+
+ GtkWidget *button;
+ GtkWidget *font_dialog;
+ GtkWidget *font_label;
+ GtkWidget *size_label;
+ GtkWidget *font_size_box;
+
+ int font_size;
+ PangoFontDescription *font_desc;
+ PangoFontFamily *font_family;
+ PangoFontFace *font_face;
+ PangoFontMap *font_map;
+ char *font_features;
+ PangoLanguage *language;
+ char *preview_text;
+ GtkFontFilterFunc font_filter;
+ gpointer font_filter_data;
+ GDestroyNotify font_filter_data_destroy;
+};
+
+struct _GtkFontButtonClass
+{
+ GtkWidgetClass parent_class;
+
+ void (* font_set) (GtkFontButton *gfp);
+ void (* activate) (GtkFontButton *self);
+};
+
+/* Signals */
+enum
+{
+ FONT_SET,
+ ACTIVATE,
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_TITLE,
+ PROP_MODAL,
+ PROP_USE_FONT,
+ PROP_USE_SIZE
+};
+
+/* Prototypes */
+static void gtk_font_button_finalize (GObject *object);
+static void gtk_font_button_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gtk_font_button_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static void gtk_font_button_clicked (GtkButton *button,
+ gpointer user_data);
+
+/* Dialog response functions */
+static void response_cb (GtkDialog *dialog,
+ int response_id,
+ gpointer data);
+static void dialog_destroy (GtkWidget *widget,
+ gpointer data);
+
+/* Auxiliary functions */
+static void gtk_font_button_label_use_font (GtkFontButton *gfs);
+static void gtk_font_button_update_font_info (GtkFontButton *gfs);
+
+static void gtk_font_button_set_font_name (GtkFontButton *button,
+ const char *fontname);
+static const char *gtk_font_button_get_font_name (GtkFontButton *button);
+static void gtk_font_button_set_level (GtkFontButton *font_button,
+ GtkFontChooserLevel level);
+static void gtk_font_button_set_language (GtkFontButton *button,
+ const char *language);
+
+static guint font_button_signals[LAST_SIGNAL] = { 0 };
+
+static PangoFontFamily * gtk_font_button_font_chooser_get_font_family (GtkFontChooser *chooser);
+static PangoFontFace * gtk_font_button_font_chooser_get_font_face (GtkFontChooser *chooser);
+static int gtk_font_button_font_chooser_get_font_size (GtkFontChooser *chooser);
+static void gtk_font_button_font_chooser_set_filter_func (GtkFontChooser *chooser,
+ GtkFontFilterFunc filter_func,
+ gpointer filter_data,
+ GDestroyNotify data_destroy);
+static void gtk_font_button_font_chooser_set_font_map (GtkFontChooser *chooser,
+ PangoFontMap *font_map);
+static PangoFontMap * gtk_font_button_font_chooser_get_font_map (GtkFontChooser *chooser);
+
+
+static void
+gtk_font_button_font_chooser_iface_init (GtkFontChooserIface *iface)
+{
+ iface->get_font_family = gtk_font_button_font_chooser_get_font_family;
+ 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_WIDGET,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_FONT_CHOOSER,
+ gtk_font_button_font_chooser_iface_init))
+
+static void
+clear_font_data (GtkFontButton *font_button)
+{
+ g_clear_object (&font_button->font_family);
+ g_clear_object (&font_button->font_face);
+ g_clear_pointer (&font_button->font_desc, pango_font_description_free);
+ g_clear_pointer (&font_button->fontname, g_free);
+ g_clear_pointer (&font_button->font_features, g_free);
+}
+
+static void
+clear_font_filter_data (GtkFontButton *font_button)
+{
+ if (font_button->font_filter_data_destroy)
+ font_button->font_filter_data_destroy (font_button->font_filter_data);
+ font_button->font_filter = NULL;
+ font_button->font_filter_data = NULL;
+ font_button->font_filter_data_destroy = NULL;
+}
+
+static gboolean
+font_description_style_equal (const PangoFontDescription *a,
+ const PangoFontDescription *b)
+{
+ return (pango_font_description_get_weight (a) == pango_font_description_get_weight (b) &&
+ pango_font_description_get_style (a) == pango_font_description_get_style (b) &&
+ pango_font_description_get_stretch (a) == pango_font_description_get_stretch (b) &&
+ pango_font_description_get_variant (a) == pango_font_description_get_variant (b));
+}
+
+static void
+gtk_font_button_update_font_data (GtkFontButton *font_button)
+{
+ PangoFontFamily **families;
+ PangoFontFace **faces;
+ int n_families, n_faces, i;
+ const char *family;
+
+ g_assert (font_button->font_desc != NULL);
+
+ font_button->fontname = pango_font_description_to_string (font_button->font_desc);
+
+ family = pango_font_description_get_family (font_button->font_desc);
+ if (family == NULL)
+ return;
+
+ n_families = 0;
+ families = NULL;
+ pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (font_button)),
+ &families, &n_families);
+ n_faces = 0;
+ faces = NULL;
+ for (i = 0; i < n_families; i++)
+ {
+ const char *name = pango_font_family_get_name (families[i]);
+
+ if (!g_ascii_strcasecmp (name, family))
+ {
+ font_button->font_family = g_object_ref (families[i]);
+
+ pango_font_family_list_faces (families[i], &faces, &n_faces);
+ break;
+ }
+ }
+ g_free (families);
+
+ for (i = 0; i < n_faces; i++)
+ {
+ PangoFontDescription *tmp_desc = pango_font_face_describe (faces[i]);
+
+ if (font_description_style_equal (tmp_desc, font_button->font_desc))
+ {
+ font_button->font_face = g_object_ref (faces[i]);
+
+ pango_font_description_free (tmp_desc);
+ break;
+ }
+ else
+ pango_font_description_free (tmp_desc);
+ }
+
+ g_free (faces);
+}
+
+static char *
+gtk_font_button_get_preview_text (GtkFontButton *font_button)
+{
+ if (font_button->font_dialog)
+ return gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (font_button->font_dialog));
+
+ return g_strdup (font_button->preview_text);
+}
+
+static void
+gtk_font_button_set_preview_text (GtkFontButton *font_button,
+ const char *preview_text)
+{
+ if (font_button->font_dialog)
+ {
+ gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (font_button->font_dialog),
+ preview_text);
+ return;
+ }
+
+ g_free (font_button->preview_text);
+ font_button->preview_text = g_strdup (preview_text);
+}
+
+
+static gboolean
+gtk_font_button_get_show_preview_entry (GtkFontButton *font_button)
+{
+ if (font_button->font_dialog)
+ return gtk_font_chooser_get_show_preview_entry (GTK_FONT_CHOOSER (font_button->font_dialog));
+
+ return font_button->show_preview_entry;
+}
+
+static void
+gtk_font_button_set_show_preview_entry (GtkFontButton *font_button,
+ gboolean show)
+{
+ show = show != FALSE;
+
+ if (font_button->show_preview_entry != show)
+ {
+ font_button->show_preview_entry = show;
+ if (font_button->font_dialog)
+ gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (font_button->font_dialog), show);
+ g_object_notify (G_OBJECT (font_button), "show-preview-entry");
+ }
+}
+
+static PangoFontFamily *
+gtk_font_button_font_chooser_get_font_family (GtkFontChooser *chooser)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
+
+ return font_button->font_family;
+}
+
+static PangoFontFace *
+gtk_font_button_font_chooser_get_font_face (GtkFontChooser *chooser)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
+
+ return font_button->font_face;
+}
+
+static int
+gtk_font_button_font_chooser_get_font_size (GtkFontChooser *chooser)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
+
+ return font_button->font_size;
+}
+
+static void
+gtk_font_button_font_chooser_set_filter_func (GtkFontChooser *chooser,
+ GtkFontFilterFunc filter_func,
+ gpointer filter_data,
+ GDestroyNotify data_destroy)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
+
+ if (font_button->font_dialog)
+ {
+ gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (font_button->font_dialog),
+ filter_func,
+ filter_data,
+ data_destroy);
+ return;
+ }
+
+ clear_font_filter_data (font_button);
+ font_button->font_filter = filter_func;
+ font_button->font_filter_data = filter_data;
+ font_button->font_filter_data_destroy = data_destroy;
+}
+
+static void
+gtk_font_button_take_font_desc (GtkFontButton *font_button,
+ PangoFontDescription *font_desc)
+{
+ GObject *object = G_OBJECT (font_button);
+
+ if (font_button->font_desc && font_desc &&
+ pango_font_description_equal (font_button->font_desc, font_desc))
+ {
+ pango_font_description_free (font_desc);
+ return;
+ }
+
+ g_object_freeze_notify (object);
+
+ clear_font_data (font_button);
+
+ if (font_desc)
+ font_button->font_desc = font_desc; /* adopted */
+ else
+ font_button->font_desc = pango_font_description_from_string (_("Sans 12"));
+
+ if (pango_font_description_get_size_is_absolute (font_button->font_desc))
+ font_button->font_size = pango_font_description_get_size (font_button->font_desc);
+ else
+ font_button->font_size = pango_font_description_get_size (font_button->font_desc) / PANGO_SCALE;
+
+ gtk_font_button_update_font_data (font_button);
+ gtk_font_button_update_font_info (font_button);
+
+ if (font_button->font_dialog)
+ gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (font_button->font_dialog),
+ font_button->font_desc);
+
+ g_object_notify (G_OBJECT (font_button), "font");
+ g_object_notify (G_OBJECT (font_button), "font-desc");
+
+ g_object_thaw_notify (object);
+}
+
+static const PangoFontDescription *
+gtk_font_button_get_font_desc (GtkFontButton *font_button)
+{
+ return font_button->font_desc;
+}
+
+static void
+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->font_map, font_map))
+ {
+ PangoContext *context;
+
+ if (!font_map)
+ font_map = pango_cairo_font_map_get_default ();
+
+ context = gtk_widget_get_pango_context (font_button->font_label);
+ pango_context_set_font_map (context, font_map);
+ if (font_button->font_dialog)
+ gtk_font_chooser_set_font_map (GTK_FONT_CHOOSER (font_button->font_dialog), font_map);
+ }
+}
+
+static PangoFontMap *
+gtk_font_button_font_chooser_get_font_map (GtkFontChooser *chooser)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
+
+ return font_button->font_map;
+}
+
+static void
+gtk_font_button_font_chooser_notify (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ /* We do not forward the notification of the "font" property to the dialog! */
+ if (pspec->name == I_("preview-text") ||
+ pspec->name == I_("show-preview-entry"))
+ g_object_notify_by_pspec (user_data, pspec);
+}
+
+static void
+gtk_font_button_activate (GtkFontButton *self)
+{
+ gtk_widget_activate (self->button);
+}
+
+static void
+gtk_font_button_unrealize (GtkWidget *widget)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (widget);
+
+ g_clear_pointer ((GtkWindow **) &font_button->font_dialog, gtk_window_destroy);
+
+ GTK_WIDGET_CLASS (gtk_font_button_parent_class)->unrealize (widget);
+}
+
+static void
+gtk_font_button_class_init (GtkFontButtonClass *klass)
+{
+ GObjectClass *gobject_class;
+ GtkWidgetClass *widget_class;
+
+ gobject_class = (GObjectClass *) klass;
+ widget_class = (GtkWidgetClass *) klass;
+
+ gobject_class->finalize = gtk_font_button_finalize;
+ gobject_class->set_property = gtk_font_button_set_property;
+ gobject_class->get_property = gtk_font_button_get_property;
+
+ widget_class->grab_focus = gtk_widget_grab_focus_child;
+ widget_class->focus = gtk_widget_focus_child;
+ widget_class->unrealize = gtk_font_button_unrealize;
+
+ klass->font_set = NULL;
+ klass->activate = gtk_font_button_activate;
+
+ _gtk_font_chooser_install_properties (gobject_class);
+
+ /**
+ * GtkFontButton:title: (attributes org.gtk.Property.get=gtk_font_button_get_title org.gtk.Property.set=gtk_font_button_set_title)
+ *
+ * The title of the font chooser dialog.
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_TITLE,
+ g_param_spec_string ("title", NULL, NULL,
+ _("Pick a Font"),
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkFontButton:use-font: (attributes org.gtk.Property.get=gtk_font_button_get_use_font org.gtk.Property.set=gtk_font_button_set_use_font)
+ *
+ * Whether the buttons label will be drawn in the selected font.
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_USE_FONT,
+ g_param_spec_boolean ("use-font", NULL, NULL,
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+ /**
+ * GtkFontButton:use-size: (attributes org.gtk.Property.get=gtk_font_button_get_use_size org.gtk.Property.set=gtk_font_button_set_use_size)
+ *
+ * Whether the buttons label will use the selected font size.
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_USE_SIZE,
+ g_param_spec_boolean ("use-size", NULL, NULL,
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+ /**
+ * GtkFontButton:modal: (attributes org.gtk.Property.get=gtk_font_button_get_modal org.gtk.Property.set=gtk_font_button_set_modal)
+ *
+ * Whether the font chooser dialog should be modal.
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_MODAL,
+ g_param_spec_boolean ("modal", NULL, NULL,
+ TRUE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+ /**
+ * GtkFontButton::font-set:
+ * @widget: the object which received the signal
+ *
+ * Emitted when the user selects a font.
+ *
+ * When handling this signal, use [method@Gtk.FontChooser.get_font]
+ * to find out which font was just selected.
+ *
+ * Note that this signal is only emitted when the user changes the font.
+ * If you need to react to programmatic font changes as well, use
+ * the notify::font signal.
+ */
+ font_button_signals[FONT_SET] = g_signal_new (I_("font-set"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GtkFontButtonClass, font_set),
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE, 0);
+
+ /**
+ * GtkFontButton::activate:
+ * @widget: the object which received the signal.
+ *
+ * Emitted to when the font button is activated.
+ *
+ * The `::activate` signal on `GtkFontButton` is an action signal and
+ * emitting it causes the button to present its dialog.
+ *
+ * Since: 4.4
+ */
+ font_button_signals[ACTIVATE] =
+ g_signal_new (I_ ("activate"),
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkFontButtonClass, activate),
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE, 0);
+
+ gtk_widget_class_set_activate_signal (widget_class, font_button_signals[ACTIVATE]);
+
+ gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
+ gtk_widget_class_set_css_name (widget_class, I_("fontbutton"));
+}
+
+static void
+gtk_font_button_init (GtkFontButton *font_button)
+{
+ GtkWidget *box;
+
+ font_button->button = gtk_button_new ();
+ g_signal_connect (font_button->button, "clicked", G_CALLBACK (gtk_font_button_clicked), font_button);
+ font_button->font_label = gtk_label_new (_("Font"));
+ gtk_widget_set_hexpand (font_button->font_label, TRUE);
+ font_button->size_label = gtk_label_new ("14");
+ font_button->font_size_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_append (GTK_BOX (box), font_button->font_label);
+
+ gtk_box_append (GTK_BOX (font_button->font_size_box), gtk_separator_new (GTK_ORIENTATION_VERTICAL));
+ gtk_box_append (GTK_BOX (font_button->font_size_box), font_button->size_label);
+ gtk_box_append (GTK_BOX (box), font_button->font_size_box);
+
+ gtk_button_set_child (GTK_BUTTON (font_button->button), box);
+ gtk_widget_set_parent (font_button->button, GTK_WIDGET (font_button));
+
+ /* Initialize fields */
+ font_button->modal = TRUE;
+ font_button->use_font = FALSE;
+ font_button->use_size = FALSE;
+ font_button->show_preview_entry = TRUE;
+ font_button->font_dialog = NULL;
+ font_button->font_family = NULL;
+ font_button->font_face = NULL;
+ font_button->font_size = -1;
+ font_button->title = g_strdup (_("Pick a Font"));
+ font_button->level = GTK_FONT_CHOOSER_LEVEL_FAMILY |
+ GTK_FONT_CHOOSER_LEVEL_STYLE |
+ GTK_FONT_CHOOSER_LEVEL_SIZE;
+ font_button->language = pango_language_get_default ();
+
+ gtk_font_button_take_font_desc (font_button, NULL);
+
+ gtk_widget_add_css_class (font_button->button, "font");
+}
+
+static void
+gtk_font_button_finalize (GObject *object)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (object);
+
+ g_free (font_button->title);
+
+ clear_font_data (font_button);
+ clear_font_filter_data (font_button);
+
+ g_free (font_button->preview_text);
+
+ gtk_widget_unparent (font_button->button);
+
+ G_OBJECT_CLASS (gtk_font_button_parent_class)->finalize (object);
+}
+
+static void
+gtk_font_button_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (object);
+
+ switch (param_id)
+ {
+ case GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT:
+ gtk_font_button_set_preview_text (font_button, g_value_get_string (value));
+ break;
+ case GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY:
+ gtk_font_button_set_show_preview_entry (font_button, g_value_get_boolean (value));
+ break;
+ case PROP_TITLE:
+ gtk_font_button_set_title (font_button, g_value_get_string (value));
+ break;
+ case PROP_MODAL:
+ gtk_font_button_set_modal (font_button, g_value_get_boolean (value));
+ break;
+ case GTK_FONT_CHOOSER_PROP_FONT_DESC:
+ gtk_font_button_take_font_desc (font_button, g_value_dup_boxed (value));
+ break;
+ case GTK_FONT_CHOOSER_PROP_LANGUAGE:
+ gtk_font_button_set_language (font_button, g_value_get_string (value));
+ break;
+ case GTK_FONT_CHOOSER_PROP_LEVEL:
+ gtk_font_button_set_level (font_button, g_value_get_flags (value));
+ break;
+ case GTK_FONT_CHOOSER_PROP_FONT:
+ gtk_font_button_set_font_name (font_button, g_value_get_string (value));
+ break;
+ case PROP_USE_FONT:
+ gtk_font_button_set_use_font (font_button, g_value_get_boolean (value));
+ break;
+ case PROP_USE_SIZE:
+ gtk_font_button_set_use_size (font_button, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_font_button_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (object);
+
+ switch (param_id)
+ {
+ case GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT:
+ g_value_set_string (value, gtk_font_button_get_preview_text (font_button));
+ break;
+ case GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY:
+ g_value_set_boolean (value, gtk_font_button_get_show_preview_entry (font_button));
+ break;
+ case PROP_TITLE:
+ g_value_set_string (value, gtk_font_button_get_title (font_button));
+ break;
+ case PROP_MODAL:
+ g_value_set_boolean (value, gtk_font_button_get_modal (font_button));
+ break;
+ case GTK_FONT_CHOOSER_PROP_FONT_DESC:
+ g_value_set_boxed (value, gtk_font_button_get_font_desc (font_button));
+ break;
+ case GTK_FONT_CHOOSER_PROP_FONT_FEATURES:
+ g_value_set_string (value, font_button->font_features);
+ break;
+ case GTK_FONT_CHOOSER_PROP_LANGUAGE:
+ g_value_set_string (value, pango_language_to_string (font_button->language));
+ break;
+ case GTK_FONT_CHOOSER_PROP_LEVEL:
+ g_value_set_flags (value, font_button->level);
+ break;
+ case GTK_FONT_CHOOSER_PROP_FONT:
+ g_value_set_string (value, gtk_font_button_get_font_name (font_button));
+ break;
+ case PROP_USE_FONT:
+ g_value_set_boolean (value, gtk_font_button_get_use_font (font_button));
+ break;
+ case PROP_USE_SIZE:
+ g_value_set_boolean (value, gtk_font_button_get_use_size (font_button));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+
+/**
+ * gtk_font_button_new:
+ *
+ * Creates a new font picker widget.
+ *
+ * Returns: a new font picker widget.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+GtkWidget *
+gtk_font_button_new (void)
+{
+ return g_object_new (GTK_TYPE_FONT_BUTTON, NULL);
+}
+
+/**
+ * gtk_font_button_new_with_font:
+ * @fontname: Name of font to display in font chooser dialog
+ *
+ * Creates a new font picker widget showing the given font.
+ *
+ * Returns: a new font picker widget.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+GtkWidget *
+gtk_font_button_new_with_font (const char *fontname)
+{
+ return g_object_new (GTK_TYPE_FONT_BUTTON, "font", fontname, NULL);
+}
+
+/**
+ * gtk_font_button_set_title: (attributes org.gtk.Method.set_property=title)
+ * @font_button: a `GtkFontButton`
+ * @title: a string containing the font chooser dialog title
+ *
+ * Sets the title for the font chooser dialog.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+void
+gtk_font_button_set_title (GtkFontButton *font_button,
+ const char *title)
+{
+ char *old_title;
+ g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
+
+ old_title = font_button->title;
+ font_button->title = g_strdup (title);
+ g_free (old_title);
+
+ if (font_button->font_dialog)
+ gtk_window_set_title (GTK_WINDOW (font_button->font_dialog), font_button->title);
+
+ g_object_notify (G_OBJECT (font_button), "title");
+}
+
+/**
+ * gtk_font_button_get_title: (attributes org.gtk.Method.get_property=title)
+ * @font_button: a `GtkFontButton`
+ *
+ * Retrieves the title of the font chooser dialog.
+ *
+ * Returns: an internal copy of the title string
+ * which must not be freed.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+const char *
+gtk_font_button_get_title (GtkFontButton *font_button)
+{
+ g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), NULL);
+
+ return font_button->title;
+}
+
+/**
+ * gtk_font_button_set_modal: (attributes org.gtk.Method.set_property=modal)
+ * @font_button: a `GtkFontButton`
+ * @modal: %TRUE to make the dialog modal
+ *
+ * Sets whether the dialog should be modal.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+void
+gtk_font_button_set_modal (GtkFontButton *font_button,
+ gboolean modal)
+{
+ g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
+
+ if (font_button->modal == modal)
+ return;
+
+ font_button->modal = modal;
+
+ if (font_button->font_dialog)
+ gtk_window_set_modal (GTK_WINDOW (font_button->font_dialog), font_button->modal);
+
+ g_object_notify (G_OBJECT (font_button), "modal");
+}
+
+/**
+ * gtk_font_button_get_modal: (attributes org.gtk.Method.get_property=modal)
+ * @font_button: a `GtkFontButton`
+ *
+ * Gets whether the dialog is modal.
+ *
+ * Returns: %TRUE if the dialog is modal
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+gboolean
+gtk_font_button_get_modal (GtkFontButton *font_button)
+{
+ g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
+
+ return font_button->modal;
+}
+
+/**
+ * gtk_font_button_get_use_font: (attributes org.gtk.Method.get_property=use-font)
+ * @font_button: a `GtkFontButton`
+ *
+ * Returns whether the selected font is used in the label.
+ *
+ * Returns: whether the selected font is used in the label.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+gboolean
+gtk_font_button_get_use_font (GtkFontButton *font_button)
+{
+ g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
+
+ return font_button->use_font;
+}
+
+/**
+ * gtk_font_button_set_use_font: (attributes org.gtk.Method.set_property=use-font)
+ * @font_button: a `GtkFontButton`
+ * @use_font: If %TRUE, font name will be written using font chosen.
+ *
+ * If @use_font is %TRUE, the font name will be written
+ * using the selected font.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+void
+gtk_font_button_set_use_font (GtkFontButton *font_button,
+ gboolean use_font)
+{
+ g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
+
+ use_font = (use_font != FALSE);
+
+ if (font_button->use_font != use_font)
+ {
+ font_button->use_font = use_font;
+
+ gtk_font_button_label_use_font (font_button);
+
+ g_object_notify (G_OBJECT (font_button), "use-font");
+ }
+}
+
+
+/**
+ * gtk_font_button_get_use_size: (attributes org.gtk.Method.get_property=use-size)
+ * @font_button: a `GtkFontButton`
+ *
+ * Returns whether the selected size is used in the label.
+ *
+ * Returns: whether the selected size is used in the label.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+gboolean
+gtk_font_button_get_use_size (GtkFontButton *font_button)
+{
+ g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
+
+ return font_button->use_size;
+}
+
+/**
+ * gtk_font_button_set_use_size: (attributes org.gtk.Method.set_property=use-size)
+ * @font_button: a `GtkFontButton`
+ * @use_size: If %TRUE, font name will be written using the
+ * selected size.
+ *
+ * If @use_size is %TRUE, the font name will be written using
+ * the selected size.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialogButton] instead
+ */
+void
+gtk_font_button_set_use_size (GtkFontButton *font_button,
+ gboolean use_size)
+{
+ g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
+
+ use_size = (use_size != FALSE);
+ if (font_button->use_size != use_size)
+ {
+ font_button->use_size = use_size;
+
+ gtk_font_button_label_use_font (font_button);
+
+ g_object_notify (G_OBJECT (font_button), "use-size");
+ }
+}
+
+static const char *
+gtk_font_button_get_font_name (GtkFontButton *font_button)
+{
+ g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), NULL);
+
+ return font_button->fontname;
+}
+
+static void
+gtk_font_button_set_font_name (GtkFontButton *font_button,
+ const char *fontname)
+{
+ PangoFontDescription *font_desc;
+
+ font_desc = pango_font_description_from_string (fontname);
+ gtk_font_button_take_font_desc (font_button, font_desc);
+}
+
+static void
+gtk_font_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkFontChooser *font_dialog;
+ GtkFontButton *font_button = user_data;
+
+ if (!font_button->font_dialog)
+ {
+ GtkWidget *parent;
+
+ parent = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (font_button)));
+
+ font_button->font_dialog = gtk_font_chooser_dialog_new (font_button->title, NULL);
+ gtk_window_set_hide_on_close (GTK_WINDOW (font_button->font_dialog), TRUE);
+ gtk_window_set_modal (GTK_WINDOW (font_button->font_dialog), font_button->modal);
+ gtk_window_set_display (GTK_WINDOW (font_button->font_dialog), gtk_widget_get_display (GTK_WIDGET (button)));
+
+ font_dialog = GTK_FONT_CHOOSER (font_button->font_dialog);
+
+ if (font_button->font_map)
+ gtk_font_chooser_set_font_map (font_dialog, font_button->font_map);
+
+ gtk_font_chooser_set_show_preview_entry (font_dialog, font_button->show_preview_entry);
+ gtk_font_chooser_set_level (GTK_FONT_CHOOSER (font_dialog), font_button->level);
+ gtk_font_chooser_set_language (GTK_FONT_CHOOSER (font_dialog), pango_language_to_string (font_button->language));
+
+ if (font_button->preview_text)
+ {
+ gtk_font_chooser_set_preview_text (font_dialog, font_button->preview_text);
+ g_free (font_button->preview_text);
+ font_button->preview_text = NULL;
+ }
+
+ if (font_button->font_filter)
+ {
+ gtk_font_chooser_set_filter_func (font_dialog,
+ font_button->font_filter,
+ font_button->font_filter_data,
+ font_button->font_filter_data_destroy);
+ font_button->font_filter = NULL;
+ font_button->font_filter_data = NULL;
+ font_button->font_filter_data_destroy = NULL;
+ }
+
+ if (GTK_IS_WINDOW (parent))
+ {
+ if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (font_dialog)))
+ gtk_window_set_transient_for (GTK_WINDOW (font_dialog), GTK_WINDOW (parent));
+
+ if (gtk_window_get_modal (GTK_WINDOW (parent)))
+ gtk_window_set_modal (GTK_WINDOW (font_dialog), TRUE);
+ }
+
+ g_signal_connect (font_dialog, "notify",
+ G_CALLBACK (gtk_font_button_font_chooser_notify), button);
+
+ g_signal_connect (font_dialog, "response",
+ G_CALLBACK (response_cb), font_button);
+
+ g_signal_connect (font_dialog, "destroy",
+ G_CALLBACK (dialog_destroy), font_button);
+ }
+
+ if (!gtk_widget_get_visible (font_button->font_dialog))
+ {
+ font_dialog = GTK_FONT_CHOOSER (font_button->font_dialog);
+ gtk_font_chooser_set_font_desc (font_dialog, font_button->font_desc);
+ }
+
+ gtk_window_present (GTK_WINDOW (font_button->font_dialog));
+}
+
+
+static void
+response_cb (GtkDialog *dialog,
+ int response_id,
+ gpointer data)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (data);
+ GtkFontChooser *font_chooser;
+ GObject *object;
+
+ gtk_widget_hide (font_button->font_dialog);
+
+ if (response_id != GTK_RESPONSE_OK)
+ return;
+
+ font_chooser = GTK_FONT_CHOOSER (font_button->font_dialog);
+ object = G_OBJECT (font_chooser);
+
+ g_object_freeze_notify (object);
+
+ clear_font_data (font_button);
+
+ font_button->font_desc = gtk_font_chooser_get_font_desc (font_chooser);
+ if (font_button->font_desc)
+ font_button->fontname = pango_font_description_to_string (font_button->font_desc);
+ font_button->font_family = gtk_font_chooser_get_font_family (font_chooser);
+ if (font_button->font_family)
+ g_object_ref (font_button->font_family);
+ font_button->font_face = gtk_font_chooser_get_font_face (font_chooser);
+ if (font_button->font_face)
+ g_object_ref (font_button->font_face);
+ font_button->font_size = gtk_font_chooser_get_font_size (font_chooser);
+ g_free (font_button->font_features);
+ font_button->font_features = gtk_font_chooser_get_font_features (font_chooser);
+ font_button->language = pango_language_from_string (gtk_font_chooser_get_language (font_chooser));
+
+ /* Set label font */
+ gtk_font_button_update_font_info (font_button);
+
+ g_object_notify (G_OBJECT (font_button), "font");
+ g_object_notify (G_OBJECT (font_button), "font-desc");
+ g_object_notify (G_OBJECT (font_button), "font-features");
+
+ g_object_thaw_notify (object);
+
+ /* Emit font_set signal */
+ g_signal_emit (font_button, font_button_signals[FONT_SET], 0);
+}
+
+static void
+dialog_destroy (GtkWidget *widget,
+ gpointer data)
+{
+ GtkFontButton *font_button = GTK_FONT_BUTTON (data);
+
+ /* Dialog will get destroyed so reference is not valid now */
+ font_button->font_dialog = NULL;
+}
+
+static void
+gtk_font_button_label_use_font (GtkFontButton *font_button)
+{
+ if (!font_button->use_font)
+ gtk_label_set_attributes (GTK_LABEL (font_button->font_label), NULL);
+ else
+ {
+ PangoFontDescription *desc;
+ PangoAttrList *attrs;
+
+ desc = pango_font_description_copy (font_button->font_desc);
+
+ if (!font_button->use_size)
+ pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
+
+ attrs = pango_attr_list_new ();
+
+ /* Prevent font fallback */
+ pango_attr_list_insert (attrs, pango_attr_fallback_new (FALSE));
+
+ /* Force current font and features */
+ pango_attr_list_insert (attrs, pango_attr_font_desc_new (desc));
+ if (font_button->font_features)
+ pango_attr_list_insert (attrs, pango_attr_font_features_new (font_button->font_features));
+ if (font_button->language)
+ pango_attr_list_insert (attrs, pango_attr_language_new (font_button->language));
+
+ gtk_label_set_attributes (GTK_LABEL (font_button->font_label), attrs);
+
+ pango_attr_list_unref (attrs);
+ pango_font_description_free (desc);
+ }
+}
+
+static void
+gtk_font_button_update_font_info (GtkFontButton *font_button)
+{
+ const char *fam_name;
+ const char *face_name;
+ char *family_style;
+
+ if (font_button->font_family)
+ fam_name = pango_font_family_get_name (font_button->font_family);
+ else
+ fam_name = C_("font", "None");
+ if (font_button->font_face)
+ face_name = pango_font_face_get_face_name (font_button->font_face);
+ else
+ face_name = "";
+
+ if ((font_button->level & GTK_FONT_CHOOSER_LEVEL_STYLE) != 0)
+ family_style = g_strconcat (fam_name, " ", face_name, NULL);
+ else
+ family_style = g_strdup (fam_name);
+
+ gtk_label_set_text (GTK_LABEL (font_button->font_label), family_style);
+ g_free (family_style);
+
+ if ((font_button->level & GTK_FONT_CHOOSER_LEVEL_SIZE) != 0)
+ {
+ /* mirror Pango, which doesn't translate this either */
+ char *size = g_strdup_printf ("%2.4g%s",
+ pango_font_description_get_size (font_button->font_desc) / (double)PANGO_SCALE,
+ pango_font_description_get_size_is_absolute (font_button->font_desc) ? "px" : "");
+
+ gtk_label_set_text (GTK_LABEL (font_button->size_label), size);
+
+ g_free (size);
+
+ gtk_widget_show (font_button->font_size_box);
+ }
+ else
+ gtk_widget_hide (font_button->font_size_box);
+
+
+ gtk_font_button_label_use_font (font_button);
+}
+
+static void
+gtk_font_button_set_level (GtkFontButton *font_button,
+ GtkFontChooserLevel level)
+{
+ if (font_button->level == level)
+ return;
+
+ font_button->level = level;
+
+ if (font_button->font_dialog)
+ gtk_font_chooser_set_level (GTK_FONT_CHOOSER (font_button->font_dialog), level);
+
+ gtk_font_button_update_font_info (font_button);
+
+ g_object_notify (G_OBJECT (font_button), "level");
+}
+
+static void
+gtk_font_button_set_language (GtkFontButton *font_button,
+ const char *language)
+{
+ font_button->language = pango_language_from_string (language);
+
+ if (font_button->font_dialog)
+ gtk_font_chooser_set_language (GTK_FONT_CHOOSER (font_button->font_dialog), language);
+
+ g_object_notify (G_OBJECT (font_button), "language");
+}
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 1998 David Abilleira Freijeiro <odaf@nexo.es>
+ * All rights reserved
+ * Based on gnome-color-picker by Federico Mena <federico@nuclecu.unam.mx>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_FONT_BUTTON_H__
+#define __GTK_FONT_BUTTON_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkbutton.h>
+
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_FONT_BUTTON (gtk_font_button_get_type ())
+#define GTK_FONT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_BUTTON, GtkFontButton))
+#define GTK_IS_FONT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_BUTTON))
+
+typedef struct _GtkFontButton GtkFontButton;
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_font_button_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_4_10
+GtkWidget *gtk_font_button_new (void);
+GDK_DEPRECATED_IN_4_10
+GtkWidget *gtk_font_button_new_with_font (const char *fontname);
+
+GDK_DEPRECATED_IN_4_10
+const char * gtk_font_button_get_title (GtkFontButton *font_button);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_button_set_title (GtkFontButton *font_button,
+ const char *title);
+GDK_DEPRECATED_IN_4_10
+gboolean gtk_font_button_get_modal (GtkFontButton *font_button);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_button_set_modal (GtkFontButton *font_button,
+ gboolean modal);
+GDK_DEPRECATED_IN_4_10
+gboolean gtk_font_button_get_use_font (GtkFontButton *font_button);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_button_set_use_font (GtkFontButton *font_button,
+ gboolean use_font);
+GDK_DEPRECATED_IN_4_10
+gboolean gtk_font_button_get_use_size (GtkFontButton *font_button);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_button_set_use_size (GtkFontButton *font_button,
+ gboolean use_size);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontButton, g_object_unref)
+
+G_END_DECLS
+
+
+#endif /* __GTK_FONT_BUTTON_H__ */
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * gtkfontchooser.c - 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
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtkfontchooser.h"
+#include "gtkfontchooserprivate.h"
+#include "gtktypebuiltins.h"
+#include "gtkprivate.h"
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+/**
+ * GtkFontChooser:
+ *
+ * `GtkFontChooser` is an interface that can be implemented by widgets
+ * for choosing fonts.
+ *
+ * In GTK, the main objects that implement this interface are
+ * [class@Gtk.FontChooserWidget], [class@Gtk.FontChooserDialog] and
+ * [class@Gtk.FontButton].
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+
+enum
+{
+ SIGNAL_FONT_ACTIVATED,
+ LAST_SIGNAL
+};
+
+static guint chooser_signals[LAST_SIGNAL];
+
+typedef GtkFontChooserIface GtkFontChooserInterface;
+G_DEFINE_INTERFACE (GtkFontChooser, gtk_font_chooser, G_TYPE_OBJECT);
+
+static void
+gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
+{
+ /**
+ * GtkFontChooser:font: (attributes org.gtk.Property.get=gtk_font_chooser_get_font org.gtk.Property.set=gtk_font_chooser_set_font)
+ *
+ * The font description as a string, e.g. "Sans Italic 12".
+ */
+ g_object_interface_install_property
+ (iface,
+ g_param_spec_string ("font", NULL, NULL,
+ GTK_FONT_CHOOSER_DEFAULT_FONT_NAME,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkFontChooser:font-desc: (attributes org.gtk.Property.get=gtk_font_chooser_get_font_desc org.gtk.Property.set=gtk_font_chooser_set_font_desc)
+ *
+ * The font description as a `PangoFontDescription`.
+ */
+ g_object_interface_install_property
+ (iface,
+ g_param_spec_boxed ("font-desc", NULL, NULL,
+ PANGO_TYPE_FONT_DESCRIPTION,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkFontChooser:preview-text: (attributes org.gtk.Property.get=gtk_font_chooser_get_preview_text org.gtk.Property.set=gtk_font_chooser_set_preview_text)
+ *
+ * The string with which to preview the font.
+ */
+ g_object_interface_install_property
+ (iface,
+ g_param_spec_string ("preview-text", NULL, NULL,
+ pango_language_get_sample_string (NULL),
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkFontChooser:show-preview-entry: (attributes org.gtk.Property.get=gtk_font_chooser_get_show_preview_entry org.gtk.Property.set=gtk_font_chooser_set_show_preview_entry)
+ *
+ * Whether to show an entry to change the preview text.
+ */
+ g_object_interface_install_property
+ (iface,
+ g_param_spec_boolean ("show-preview-entry", NULL, NULL,
+ TRUE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+ /**
+ * GtkFontChooser:level: (attributes org.gtk.Property.get=gtk_font_chooser_get_level org.gtk.Property.set=gtk_font_chooser_set_level)
+ *
+ * The level of granularity to offer for selecting fonts.
+ */
+ g_object_interface_install_property
+ (iface,
+ g_param_spec_flags ("level", NULL, NULL,
+ GTK_TYPE_FONT_CHOOSER_LEVEL,
+ GTK_FONT_CHOOSER_LEVEL_FAMILY |
+ GTK_FONT_CHOOSER_LEVEL_STYLE |
+ GTK_FONT_CHOOSER_LEVEL_SIZE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+ /**
+ * GtkFontChooser:font-features: (attributes org.gtk.Property.get=gtk_font_chooser_get_font_features)
+ *
+ * The selected font features.
+ *
+ * The format of the string is compatible with
+ * CSS and with Pango attributes.
+ */
+ g_object_interface_install_property
+ (iface,
+ g_param_spec_string ("font-features", NULL, NULL,
+ "",
+ GTK_PARAM_READABLE));
+
+ /**
+ * GtkFontChooser:language: (attributes org.gtk.Property.get=gtk_font_chooser_get_language org.gtk.Property.set=gtk_font_chooser_set_language)
+ *
+ * The language for which the font features were selected.
+ */
+ g_object_interface_install_property
+ (iface,
+ g_param_spec_string ("language", NULL, NULL,
+ "",
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+ /**
+ * GtkFontChooser::font-activated:
+ * @self: the object which received the signal
+ * @fontname: the font name
+ *
+ * Emitted when a font is activated.
+ *
+ * This usually happens when the user double clicks an item,
+ * or an item is selected and the user presses one of the keys
+ * Space, Shift+Space, Return or Enter.
+ */
+ chooser_signals[SIGNAL_FONT_ACTIVATED] =
+ g_signal_new (I_("font-activated"),
+ GTK_TYPE_FONT_CHOOSER,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GtkFontChooserIface, font_activated),
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+}
+
+/**
+ * gtk_font_chooser_get_font_family:
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Gets the `PangoFontFamily` representing the selected font family.
+ *
+ * Font families are a collection of font faces.
+ *
+ * If the selected font is not installed, returns %NULL.
+ *
+ * Returns: (nullable) (transfer none): A `PangoFontFamily` representing the
+ * selected font family
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+PangoFontFamily *
+gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser)
+{
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
+
+ return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_family (fontchooser);
+}
+
+/**
+ * gtk_font_chooser_get_font_face:
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Gets the `PangoFontFace` representing the selected font group
+ * details (i.e. family, slant, weight, width, etc).
+ *
+ * If the selected font is not installed, returns %NULL.
+ *
+ * Returns: (nullable) (transfer none): A `PangoFontFace` representing the
+ * selected font group details
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+PangoFontFace *
+gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser)
+{
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
+
+ return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_face (fontchooser);
+}
+
+/**
+ * gtk_font_chooser_get_font_size:
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * The selected font size.
+ *
+ * Returns: A n integer representing the selected font size,
+ * or -1 if no font size is selected.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+int
+gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser)
+{
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), -1);
+
+ return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_size (fontchooser);
+}
+
+/**
+ * gtk_font_chooser_get_font: (attributes org.gtk.Method.get_property=font)
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Gets the currently-selected font name.
+ *
+ * Note that this can be a different string than what you set with
+ * [method@Gtk.FontChooser.set_font], 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 [method@Pango.FontDescription.equal] if you want to compare two
+ * font descriptions.
+ *
+ * Returns: (nullable) (transfer full): A string with the name
+ * of the current font
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+char *
+gtk_font_chooser_get_font (GtkFontChooser *fontchooser)
+{
+ char *fontname;
+
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
+
+ g_object_get (fontchooser, "font", &fontname, NULL);
+
+
+ return fontname;
+}
+
+/**
+ * gtk_font_chooser_set_font: (attributes org.gtk.Method.set_property=font)
+ * @fontchooser: a `GtkFontChooser`
+ * @fontname: a font name like “Helvetica 12” or “Times Bold 18”
+ *
+ * Sets the currently-selected font.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+void
+gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
+ const char *fontname)
+{
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
+ g_return_if_fail (fontname != NULL);
+
+ g_object_set (fontchooser, "font", fontname, NULL);
+}
+
+/**
+ * gtk_font_chooser_get_font_desc: (attributes org.gtk.Method.get_property=font-desc)
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Gets the currently-selected font.
+ *
+ * Note that this can be a different string than what you set with
+ * [method@Gtk.FontChooser.set_font], 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 [method@Pango.FontDescription.equal] if you want to compare two
+ * font descriptions.
+ *
+ * Returns: (nullable) (transfer full): A `PangoFontDescription` for the
+ * current font
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+PangoFontDescription *
+gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser)
+{
+ PangoFontDescription *font_desc;
+
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
+
+ g_object_get (fontchooser, "font-desc", &font_desc, NULL);
+
+ return font_desc;
+}
+
+/**
+ * gtk_font_chooser_set_font_desc: (attributes org.gtk.Method.set_property=font-desc)
+ * @fontchooser: a `GtkFontChooser`
+ * @font_desc: a `PangoFontDescription`
+ *
+ * Sets the currently-selected font from @font_desc.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+void
+gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
+ const PangoFontDescription *font_desc)
+{
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
+ g_return_if_fail (font_desc != NULL);
+
+ g_object_set (fontchooser, "font-desc", font_desc, NULL);
+}
+
+/**
+ * gtk_font_chooser_get_preview_text: (attributes org.gtk.Method.get_property=preview-text)
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Gets the text displayed in the preview area.
+ *
+ * Returns: (transfer full): the text displayed in the preview area
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+char *
+gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser)
+{
+ char *text;
+
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
+
+ g_object_get (fontchooser, "preview-text", &text, NULL);
+
+ return text;
+}
+
+/**
+ * gtk_font_chooser_set_preview_text: (attributes org.gtk.Method.set_property=preview-text)
+ * @fontchooser: a `GtkFontChooser`
+ * @text: (transfer none): the text to display in the preview area
+ *
+ * Sets the text displayed in the preview area.
+ *
+ * The @text is used to show how the selected font looks.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+void
+gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
+ const char *text)
+{
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
+ g_return_if_fail (text != NULL);
+
+ g_object_set (fontchooser, "preview-text", text, NULL);
+}
+
+/**
+ * gtk_font_chooser_get_show_preview_entry: (attributes org.gtk.Method.get_property=show-preview-entry)
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Returns whether the preview entry is shown or not.
+ *
+ * Returns: %TRUE if the preview entry is shown or %FALSE if it is hidden.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+gboolean
+gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser)
+{
+ gboolean show;
+
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), FALSE);
+
+ g_object_get (fontchooser, "show-preview-entry", &show, NULL);
+
+ return show;
+}
+
+/**
+ * gtk_font_chooser_set_show_preview_entry: (attributes org.gtk.Method.set_property=show-preview-entry)
+ * @fontchooser: a `GtkFontChooser`
+ * @show_preview_entry: whether to show the editable preview entry or not
+ *
+ * Shows or hides the editable preview entry.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+void
+gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
+ gboolean show_preview_entry)
+{
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
+
+ show_preview_entry = show_preview_entry != FALSE;
+ g_object_set (fontchooser, "show-preview-entry", show_preview_entry, NULL);
+}
+
+/**
+ * gtk_font_chooser_set_filter_func:
+ * @fontchooser: a `GtkFontChooser`
+ * @filter: (nullable): a `GtkFontFilterFunc`
+ * @user_data: (closure): data to pass to @filter
+ * @destroy: function to call to free @data when it is no longer needed
+ *
+ * Adds a filter function that decides which fonts to display
+ * in the font chooser.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+void
+gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
+ GtkFontFilterFunc filter,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
+
+ GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_filter_func (fontchooser,
+ filter,
+ user_data,
+ destroy);
+}
+
+void
+_gtk_font_chooser_font_activated (GtkFontChooser *chooser,
+ const char *fontname)
+{
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (chooser));
+
+ g_signal_emit (chooser, chooser_signals[SIGNAL_FONT_ACTIVATED], 0, fontname);
+}
+
+/**
+ * gtk_font_chooser_set_font_map:
+ * @fontchooser: a `GtkFontChooser`
+ * @fontmap: (nullable): a `PangoFontMap`
+ *
+ * Sets a custom font map to use for this font chooser widget.
+ *
+ * A custom font map can be used to present application-specific
+ * fonts instead of or in addition to the normal system fonts.
+ *
+ * ```c
+ * FcConfig *config;
+ * PangoFontMap *fontmap;
+ *
+ * config = FcInitLoadConfigAndFonts ();
+ * FcConfigAppFontAddFile (config, my_app_font_file);
+ *
+ * fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
+ * pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config);
+ *
+ * gtk_font_chooser_set_font_map (font_chooser, fontmap);
+ * ```
+ *
+ * Note that other GTK widgets will only be able to use the
+ * application-specific font if it is present in the font map they use:
+ *
+ * ```c
+ * context = gtk_widget_get_pango_context (label);
+ * pango_context_set_font_map (context, fontmap);
+ * ```
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+void
+gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
+ PangoFontMap *fontmap)
+{
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
+ g_return_if_fail (fontmap == NULL || PANGO_IS_FONT_MAP (fontmap));
+
+ if (GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font_map)
+ GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font_map (fontchooser, fontmap);
+}
+
+/**
+ * gtk_font_chooser_get_font_map:
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Gets the custom font map of this font chooser widget,
+ * or %NULL if it does not have one.
+ *
+ * Returns: (nullable) (transfer full): a `PangoFontMap`
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+PangoFontMap *
+gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser)
+{
+ PangoFontMap *fontmap = NULL;
+
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
+
+ if (GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_map)
+ fontmap = GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_map (fontchooser);
+
+ return fontmap;
+}
+
+/**
+ * gtk_font_chooser_set_level: (attributes org.gtk.Method.set_property=level)
+ * @fontchooser: a `GtkFontChooser`
+ * @level: the desired level of granularity
+ *
+ * Sets the desired level of granularity for selecting fonts.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+void
+gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
+ GtkFontChooserLevel level)
+{
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
+
+ g_object_set (fontchooser, "level", level, NULL);
+}
+
+/**
+ * gtk_font_chooser_get_level: (attributes org.gtk.Method.get_property=level)
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Returns the current level of granularity for selecting fonts.
+ *
+ * Returns: the current granularity level
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+GtkFontChooserLevel
+gtk_font_chooser_get_level (GtkFontChooser *fontchooser)
+{
+ GtkFontChooserLevel level;
+
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), 0);
+
+ g_object_get (fontchooser, "level", &level, NULL);
+
+ return level;
+}
+
+/**
+ * gtk_font_chooser_get_font_features: (attributes org.gtk.Method.get_property=font-features)
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Gets the currently-selected font features.
+ *
+ * The format of the returned string is compatible with the
+ * [CSS font-feature-settings property](https://www.w3.org/TR/css-fonts-4/#font-rend-desc).
+ * It can be passed to [func@Pango.AttrFontFeatures.new].
+ *
+ * Returns: the currently selected font features
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+char *
+gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser)
+{
+ char *text;
+
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
+
+ g_object_get (fontchooser, "font-features", &text, NULL);
+
+ return text;
+}
+
+/**
+ * gtk_font_chooser_get_language: (attributes org.gtk.Method.get_property=language)
+ * @fontchooser: a `GtkFontChooser`
+ *
+ * Gets the language that is used for font features.
+ *
+ * Returns: the currently selected language
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+char *
+gtk_font_chooser_get_language (GtkFontChooser *fontchooser)
+{
+ char *text;
+
+ g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
+
+ g_object_get (fontchooser, "language", &text, NULL);
+
+ return text;
+}
+
+/**
+ * gtk_font_chooser_set_language: (attributes org.gtk.Method.set_property=language)
+ * @fontchooser: a `GtkFontChooser`
+ * @language: a language
+ *
+ * Sets the language to use for font features.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] and [class@GtkFontDialogButton]
+ * instead
+ */
+void
+gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
+ const char *language)
+{
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
+
+ g_object_set (fontchooser, "language", language, NULL);
+}
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * 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
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_FONT_CHOOSER_H__
+#define __GTK_FONT_CHOOSER_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GtkFontFilterFunc:
+ * @family: a `PangoFontFamily`
+ * @face: a `PangoFontFace` belonging to @family
+ * @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 [method@Gtk.FontChooser.set_filter_func].
+ *
+ * Returns: %TRUE if the font should be displayed
+ */
+typedef gboolean (*GtkFontFilterFunc) (const PangoFontFamily *family,
+ const PangoFontFace *face,
+ gpointer data);
+
+/**
+ * GtkFontChooserLevel:
+ * @GTK_FONT_CHOOSER_LEVEL_FAMILY: Allow selecting a font family
+ * @GTK_FONT_CHOOSER_LEVEL_STYLE: Allow selecting a specific font face
+ * @GTK_FONT_CHOOSER_LEVEL_SIZE: Allow selecting a specific font size
+ * @GTK_FONT_CHOOSER_LEVEL_VARIATIONS: Allow changing OpenType font variation axes
+ * @GTK_FONT_CHOOSER_LEVEL_FEATURES: Allow selecting specific OpenType font features
+ *
+ * Specifies the granularity of font selection
+ * that is desired in a `GtkFontChooser`.
+ *
+ * This enumeration may be extended in the future; applications should
+ * ignore unknown values.
+ */
+typedef enum {
+ GTK_FONT_CHOOSER_LEVEL_FAMILY = 0,
+ GTK_FONT_CHOOSER_LEVEL_STYLE = 1 << 0,
+ GTK_FONT_CHOOSER_LEVEL_SIZE = 1 << 1,
+ GTK_FONT_CHOOSER_LEVEL_VARIATIONS = 1 << 2,
+ GTK_FONT_CHOOSER_LEVEL_FEATURES = 1 << 3
+} GtkFontChooserLevel;
+
+#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 */
+ PangoFontFamily * (* get_font_family) (GtkFontChooser *fontchooser);
+ PangoFontFace * (* get_font_face) (GtkFontChooser *fontchooser);
+ int (* get_font_size) (GtkFontChooser *fontchooser);
+
+ void (* set_filter_func) (GtkFontChooser *fontchooser,
+ GtkFontFilterFunc filter,
+ gpointer user_data,
+ GDestroyNotify destroy);
+
+ /* Signals */
+ void (* font_activated) (GtkFontChooser *chooser,
+ const char *fontname);
+
+ /* More methods */
+ void (* set_font_map) (GtkFontChooser *fontchooser,
+ PangoFontMap *fontmap);
+ PangoFontMap * (* get_font_map) (GtkFontChooser *fontchooser);
+
+ /*< private >*/
+ /* Padding; remove in GTK-next */
+ gpointer padding[10];
+};
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_font_chooser_get_type (void) G_GNUC_CONST;
+
+GDK_DEPRECATED_IN_4_10
+PangoFontFamily *gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser);
+GDK_DEPRECATED_IN_4_10
+PangoFontFace *gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser);
+GDK_DEPRECATED_IN_4_10
+int gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser);
+
+GDK_DEPRECATED_IN_4_10
+PangoFontDescription *
+ gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
+ const PangoFontDescription *font_desc);
+
+GDK_DEPRECATED_IN_4_10
+char * gtk_font_chooser_get_font (GtkFontChooser *fontchooser);
+
+GDK_DEPRECATED_IN_4_10
+void gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
+ const char *fontname);
+GDK_DEPRECATED_IN_4_10
+char * gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
+ const char *text);
+GDK_DEPRECATED_IN_4_10
+gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
+ gboolean show_preview_entry);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
+ GtkFontFilterFunc filter,
+ gpointer user_data,
+ GDestroyNotify destroy);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
+ PangoFontMap *fontmap);
+GDK_DEPRECATED_IN_4_10
+PangoFontMap * gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
+ GtkFontChooserLevel level);
+GDK_DEPRECATED_IN_4_10
+GtkFontChooserLevel
+ gtk_font_chooser_get_level (GtkFontChooser *fontchooser);
+GDK_DEPRECATED_IN_4_10
+char * gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser);
+GDK_DEPRECATED_IN_4_10
+char * gtk_font_chooser_get_language (GtkFontChooser *fontchooser);
+GDK_DEPRECATED_IN_4_10
+void gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
+ const char *language);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontChooser, g_object_unref)
+
+G_END_DECLS
+
+#endif /* __GTK_FONT_CHOOSER_H__ */
--- /dev/null
+/* 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_FONT_CHOOSER_DIALOG_H__
+#define __GTK_FONT_CHOOSER_DIALOG_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkdialog.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_FONT_CHOOSER_DIALOG (gtk_font_chooser_dialog_get_type ())
+#define GTK_FONT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG, GtkFontChooserDialog))
+#define GTK_IS_FONT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG))
+
+typedef struct _GtkFontChooserDialog GtkFontChooserDialog;
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_font_chooser_dialog_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_4_10
+GtkWidget* gtk_font_chooser_dialog_new (const char *title,
+ GtkWindow *parent);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontChooserDialog, g_object_unref)
+
+G_END_DECLS
+
+#endif /* __GTK_FONT_CHOOSER_DIALOG_H__ */
--- /dev/null
+/* 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_FONT_CHOOSER_PRIVATE_H__
+#define __GTK_FONT_CHOOSER_PRIVATE_H__
+
+#include "gtkfontchooser.h"
+
+#define GTK_FONT_CHOOSER_DEFAULT_FONT_NAME "Sans 10"
+
+G_BEGIN_DECLS
+
+void _gtk_font_chooser_font_activated (GtkFontChooser *chooser,
+ const char *fontname);
+
+G_END_DECLS
+
+#endif /* ! __GTK_FONT_CHOOSER_PRIVATE_H__ */
--- /dev/null
+/* 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_FONT_CHOOSER_WIDGET_H__
+#define __GTK_FONT_CHOOSER_WIDGET_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkwidget.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_IS_FONT_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER_WIDGET))
+
+typedef struct _GtkFontChooserWidget GtkFontChooserWidget;
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_font_chooser_widget_get_type (void) G_GNUC_CONST;
+
+GDK_DEPRECATED_IN_4_10
+GtkWidget* gtk_font_chooser_widget_new (void);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontChooserWidget, g_object_unref)
+
+G_END_DECLS
+
+#endif /* __GTK_FONT_CHOOSER_WIDGET_H__ */
'deprecated/gtkcombobox.c',
'deprecated/gtkcomboboxtext.c',
'deprecated/gtkentrycompletion.c',
+ 'deprecated/gtkfontbutton.c',
+ 'deprecated/gtkfontchooser.c',
'deprecated/gtkiconview.c',
'deprecated/gtkliststore.c',
'deprecated/gtkrender.c',
'deprecated/gtkcombobox.h',
'deprecated/gtkcomboboxtext.h',
'deprecated/gtkentrycompletion.h',
+ 'deprecated/gtkfontbutton.h',
+ 'deprecated/gtkfontchooser.h',
+ 'deprecated/gtkfontchooserdialog.h',
+ 'deprecated/gtkfontchooserwidget.h',
'deprecated/gtkiconview.h',
'deprecated/gtkliststore.h',
'deprecated/gtkrender.h',
#include <gtk/gtkcustomfilter.h>
#include <gtk/gtkflattenlistmodel.h>
#include <gtk/gtkflowbox.h>
-#include <gtk/gtkfontbutton.h>
-#include <gtk/gtkfontchooser.h>
-#include <gtk/gtkfontchooserdialog.h>
-#include <gtk/gtkfontchooserwidget.h>
+#include <gtk/deprecated/gtkfontbutton.h>
+#include <gtk/deprecated/gtkfontchooser.h>
+#include <gtk/deprecated/gtkfontchooserdialog.h>
+#include <gtk/deprecated/gtkfontchooserwidget.h>
#include <gtk/gtkfontdialog.h>
#include <gtk/gtkfontdialogbutton.h>
#include <gtk/gtkframe.h>
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998 David Abilleira Freijeiro <odaf@nexo.es>
- * All rights reserved.
- *
- * Based on gnome-color-picker by Federico Mena <federico@nuclecu.unam.mx>
- *
- * 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, see <http://www.gnu.org/licenses/>.
- */
-/*
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "config.h"
-
-#include "gtkfontbutton.h"
-
-#include "gtkbinlayout.h"
-#include "gtkbox.h"
-#include "gtkfontchooser.h"
-#include "gtkfontchooserdialog.h"
-#include "gtkfontchooserutils.h"
-#include <glib/gi18n-lib.h>
-#include "gtklabel.h"
-#include "gtkmarshalers.h"
-#include "gtkprivate.h"
-#include "gtkseparator.h"
-#include "gtkwidgetprivate.h"
-
-#include <string.h>
-#include <stdio.h>
-
-
-/**
- * GtkFontButton:
- *
- * The `GtkFontButton` allows to open a font chooser dialog to change
- * the font.
- *
- * 
- *
- * It is suitable widget for selecting a font in a preference dialog.
- *
- * # CSS nodes
- *
- * ```
- * fontbutton
- * ╰── button.font
- * ╰── [content]
- * ```
- *
- * `GtkFontButton` has a single CSS node with name fontbutton which
- * contains a button node with the .font style class.
- */
-
-typedef struct _GtkFontButtonClass GtkFontButtonClass;
-
-struct _GtkFontButton
-{
- GtkWidget parent_instance;
-
- char *title;
- char *fontname;
-
- guint use_font : 1;
- guint use_size : 1;
- guint show_preview_entry : 1;
- guint modal : 1;
-
- GtkFontChooserLevel level;
-
- GtkWidget *button;
- GtkWidget *font_dialog;
- GtkWidget *font_label;
- GtkWidget *size_label;
- GtkWidget *font_size_box;
-
- int font_size;
- PangoFontDescription *font_desc;
- PangoFontFamily *font_family;
- PangoFontFace *font_face;
- PangoFontMap *font_map;
- char *font_features;
- PangoLanguage *language;
- char *preview_text;
- GtkFontFilterFunc font_filter;
- gpointer font_filter_data;
- GDestroyNotify font_filter_data_destroy;
-};
-
-struct _GtkFontButtonClass
-{
- GtkWidgetClass parent_class;
-
- void (* font_set) (GtkFontButton *gfp);
- void (* activate) (GtkFontButton *self);
-};
-
-/* Signals */
-enum
-{
- FONT_SET,
- ACTIVATE,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_TITLE,
- PROP_MODAL,
- PROP_USE_FONT,
- PROP_USE_SIZE
-};
-
-/* Prototypes */
-static void gtk_font_button_finalize (GObject *object);
-static void gtk_font_button_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void gtk_font_button_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void gtk_font_button_clicked (GtkButton *button,
- gpointer user_data);
-
-/* Dialog response functions */
-static void response_cb (GtkDialog *dialog,
- int response_id,
- gpointer data);
-static void dialog_destroy (GtkWidget *widget,
- gpointer data);
-
-/* Auxiliary functions */
-static void gtk_font_button_label_use_font (GtkFontButton *gfs);
-static void gtk_font_button_update_font_info (GtkFontButton *gfs);
-
-static void gtk_font_button_set_font_name (GtkFontButton *button,
- const char *fontname);
-static const char *gtk_font_button_get_font_name (GtkFontButton *button);
-static void gtk_font_button_set_level (GtkFontButton *font_button,
- GtkFontChooserLevel level);
-static void gtk_font_button_set_language (GtkFontButton *button,
- const char *language);
-
-static guint font_button_signals[LAST_SIGNAL] = { 0 };
-
-static PangoFontFamily * gtk_font_button_font_chooser_get_font_family (GtkFontChooser *chooser);
-static PangoFontFace * gtk_font_button_font_chooser_get_font_face (GtkFontChooser *chooser);
-static int gtk_font_button_font_chooser_get_font_size (GtkFontChooser *chooser);
-static void gtk_font_button_font_chooser_set_filter_func (GtkFontChooser *chooser,
- GtkFontFilterFunc filter_func,
- gpointer filter_data,
- GDestroyNotify data_destroy);
-static void gtk_font_button_font_chooser_set_font_map (GtkFontChooser *chooser,
- PangoFontMap *font_map);
-static PangoFontMap * gtk_font_button_font_chooser_get_font_map (GtkFontChooser *chooser);
-
-
-static void
-gtk_font_button_font_chooser_iface_init (GtkFontChooserIface *iface)
-{
- iface->get_font_family = gtk_font_button_font_chooser_get_font_family;
- 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_WIDGET,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_FONT_CHOOSER,
- gtk_font_button_font_chooser_iface_init))
-
-static void
-clear_font_data (GtkFontButton *font_button)
-{
- g_clear_object (&font_button->font_family);
- g_clear_object (&font_button->font_face);
- g_clear_pointer (&font_button->font_desc, pango_font_description_free);
- g_clear_pointer (&font_button->fontname, g_free);
- g_clear_pointer (&font_button->font_features, g_free);
-}
-
-static void
-clear_font_filter_data (GtkFontButton *font_button)
-{
- if (font_button->font_filter_data_destroy)
- font_button->font_filter_data_destroy (font_button->font_filter_data);
- font_button->font_filter = NULL;
- font_button->font_filter_data = NULL;
- font_button->font_filter_data_destroy = NULL;
-}
-
-static gboolean
-font_description_style_equal (const PangoFontDescription *a,
- const PangoFontDescription *b)
-{
- return (pango_font_description_get_weight (a) == pango_font_description_get_weight (b) &&
- pango_font_description_get_style (a) == pango_font_description_get_style (b) &&
- pango_font_description_get_stretch (a) == pango_font_description_get_stretch (b) &&
- pango_font_description_get_variant (a) == pango_font_description_get_variant (b));
-}
-
-static void
-gtk_font_button_update_font_data (GtkFontButton *font_button)
-{
- PangoFontFamily **families;
- PangoFontFace **faces;
- int n_families, n_faces, i;
- const char *family;
-
- g_assert (font_button->font_desc != NULL);
-
- font_button->fontname = pango_font_description_to_string (font_button->font_desc);
-
- family = pango_font_description_get_family (font_button->font_desc);
- if (family == NULL)
- return;
-
- n_families = 0;
- families = NULL;
- pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (font_button)),
- &families, &n_families);
- n_faces = 0;
- faces = NULL;
- for (i = 0; i < n_families; i++)
- {
- const char *name = pango_font_family_get_name (families[i]);
-
- if (!g_ascii_strcasecmp (name, family))
- {
- font_button->font_family = g_object_ref (families[i]);
-
- pango_font_family_list_faces (families[i], &faces, &n_faces);
- break;
- }
- }
- g_free (families);
-
- for (i = 0; i < n_faces; i++)
- {
- PangoFontDescription *tmp_desc = pango_font_face_describe (faces[i]);
-
- if (font_description_style_equal (tmp_desc, font_button->font_desc))
- {
- font_button->font_face = g_object_ref (faces[i]);
-
- pango_font_description_free (tmp_desc);
- break;
- }
- else
- pango_font_description_free (tmp_desc);
- }
-
- g_free (faces);
-}
-
-static char *
-gtk_font_button_get_preview_text (GtkFontButton *font_button)
-{
- if (font_button->font_dialog)
- return gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (font_button->font_dialog));
-
- return g_strdup (font_button->preview_text);
-}
-
-static void
-gtk_font_button_set_preview_text (GtkFontButton *font_button,
- const char *preview_text)
-{
- if (font_button->font_dialog)
- {
- gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (font_button->font_dialog),
- preview_text);
- return;
- }
-
- g_free (font_button->preview_text);
- font_button->preview_text = g_strdup (preview_text);
-}
-
-
-static gboolean
-gtk_font_button_get_show_preview_entry (GtkFontButton *font_button)
-{
- if (font_button->font_dialog)
- return gtk_font_chooser_get_show_preview_entry (GTK_FONT_CHOOSER (font_button->font_dialog));
-
- return font_button->show_preview_entry;
-}
-
-static void
-gtk_font_button_set_show_preview_entry (GtkFontButton *font_button,
- gboolean show)
-{
- show = show != FALSE;
-
- if (font_button->show_preview_entry != show)
- {
- font_button->show_preview_entry = show;
- if (font_button->font_dialog)
- gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (font_button->font_dialog), show);
- g_object_notify (G_OBJECT (font_button), "show-preview-entry");
- }
-}
-
-static PangoFontFamily *
-gtk_font_button_font_chooser_get_font_family (GtkFontChooser *chooser)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
-
- return font_button->font_family;
-}
-
-static PangoFontFace *
-gtk_font_button_font_chooser_get_font_face (GtkFontChooser *chooser)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
-
- return font_button->font_face;
-}
-
-static int
-gtk_font_button_font_chooser_get_font_size (GtkFontChooser *chooser)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
-
- return font_button->font_size;
-}
-
-static void
-gtk_font_button_font_chooser_set_filter_func (GtkFontChooser *chooser,
- GtkFontFilterFunc filter_func,
- gpointer filter_data,
- GDestroyNotify data_destroy)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
-
- if (font_button->font_dialog)
- {
- gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (font_button->font_dialog),
- filter_func,
- filter_data,
- data_destroy);
- return;
- }
-
- clear_font_filter_data (font_button);
- font_button->font_filter = filter_func;
- font_button->font_filter_data = filter_data;
- font_button->font_filter_data_destroy = data_destroy;
-}
-
-static void
-gtk_font_button_take_font_desc (GtkFontButton *font_button,
- PangoFontDescription *font_desc)
-{
- GObject *object = G_OBJECT (font_button);
-
- if (font_button->font_desc && font_desc &&
- pango_font_description_equal (font_button->font_desc, font_desc))
- {
- pango_font_description_free (font_desc);
- return;
- }
-
- g_object_freeze_notify (object);
-
- clear_font_data (font_button);
-
- if (font_desc)
- font_button->font_desc = font_desc; /* adopted */
- else
- font_button->font_desc = pango_font_description_from_string (_("Sans 12"));
-
- if (pango_font_description_get_size_is_absolute (font_button->font_desc))
- font_button->font_size = pango_font_description_get_size (font_button->font_desc);
- else
- font_button->font_size = pango_font_description_get_size (font_button->font_desc) / PANGO_SCALE;
-
- gtk_font_button_update_font_data (font_button);
- gtk_font_button_update_font_info (font_button);
-
- if (font_button->font_dialog)
- gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (font_button->font_dialog),
- font_button->font_desc);
-
- g_object_notify (G_OBJECT (font_button), "font");
- g_object_notify (G_OBJECT (font_button), "font-desc");
-
- g_object_thaw_notify (object);
-}
-
-static const PangoFontDescription *
-gtk_font_button_get_font_desc (GtkFontButton *font_button)
-{
- return font_button->font_desc;
-}
-
-static void
-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->font_map, font_map))
- {
- PangoContext *context;
-
- if (!font_map)
- font_map = pango_cairo_font_map_get_default ();
-
- context = gtk_widget_get_pango_context (font_button->font_label);
- pango_context_set_font_map (context, font_map);
- if (font_button->font_dialog)
- gtk_font_chooser_set_font_map (GTK_FONT_CHOOSER (font_button->font_dialog), font_map);
- }
-}
-
-static PangoFontMap *
-gtk_font_button_font_chooser_get_font_map (GtkFontChooser *chooser)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
-
- return font_button->font_map;
-}
-
-static void
-gtk_font_button_font_chooser_notify (GObject *object,
- GParamSpec *pspec,
- gpointer user_data)
-{
- /* We do not forward the notification of the "font" property to the dialog! */
- if (pspec->name == I_("preview-text") ||
- pspec->name == I_("show-preview-entry"))
- g_object_notify_by_pspec (user_data, pspec);
-}
-
-static void
-gtk_font_button_activate (GtkFontButton *self)
-{
- gtk_widget_activate (self->button);
-}
-
-static void
-gtk_font_button_unrealize (GtkWidget *widget)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (widget);
-
- g_clear_pointer ((GtkWindow **) &font_button->font_dialog, gtk_window_destroy);
-
- GTK_WIDGET_CLASS (gtk_font_button_parent_class)->unrealize (widget);
-}
-
-static void
-gtk_font_button_class_init (GtkFontButtonClass *klass)
-{
- GObjectClass *gobject_class;
- GtkWidgetClass *widget_class;
-
- gobject_class = (GObjectClass *) klass;
- widget_class = (GtkWidgetClass *) klass;
-
- gobject_class->finalize = gtk_font_button_finalize;
- gobject_class->set_property = gtk_font_button_set_property;
- gobject_class->get_property = gtk_font_button_get_property;
-
- widget_class->grab_focus = gtk_widget_grab_focus_child;
- widget_class->focus = gtk_widget_focus_child;
- widget_class->unrealize = gtk_font_button_unrealize;
-
- klass->font_set = NULL;
- klass->activate = gtk_font_button_activate;
-
- _gtk_font_chooser_install_properties (gobject_class);
-
- /**
- * GtkFontButton:title: (attributes org.gtk.Property.get=gtk_font_button_get_title org.gtk.Property.set=gtk_font_button_set_title)
- *
- * The title of the font chooser dialog.
- */
- g_object_class_install_property (gobject_class,
- PROP_TITLE,
- g_param_spec_string ("title", NULL, NULL,
- _("Pick a Font"),
- GTK_PARAM_READWRITE));
-
- /**
- * GtkFontButton:use-font: (attributes org.gtk.Property.get=gtk_font_button_get_use_font org.gtk.Property.set=gtk_font_button_set_use_font)
- *
- * Whether the buttons label will be drawn in the selected font.
- */
- g_object_class_install_property (gobject_class,
- PROP_USE_FONT,
- g_param_spec_boolean ("use-font", NULL, NULL,
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- /**
- * GtkFontButton:use-size: (attributes org.gtk.Property.get=gtk_font_button_get_use_size org.gtk.Property.set=gtk_font_button_set_use_size)
- *
- * Whether the buttons label will use the selected font size.
- */
- g_object_class_install_property (gobject_class,
- PROP_USE_SIZE,
- g_param_spec_boolean ("use-size", NULL, NULL,
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- /**
- * GtkFontButton:modal: (attributes org.gtk.Property.get=gtk_font_button_get_modal org.gtk.Property.set=gtk_font_button_set_modal)
- *
- * Whether the font chooser dialog should be modal.
- */
- g_object_class_install_property (gobject_class,
- PROP_MODAL,
- g_param_spec_boolean ("modal", NULL, NULL,
- TRUE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- /**
- * GtkFontButton::font-set:
- * @widget: the object which received the signal
- *
- * Emitted when the user selects a font.
- *
- * When handling this signal, use [method@Gtk.FontChooser.get_font]
- * to find out which font was just selected.
- *
- * Note that this signal is only emitted when the user changes the font.
- * If you need to react to programmatic font changes as well, use
- * the notify::font signal.
- */
- font_button_signals[FONT_SET] = g_signal_new (I_("font-set"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GtkFontButtonClass, font_set),
- NULL, NULL,
- NULL,
- G_TYPE_NONE, 0);
-
- /**
- * GtkFontButton::activate:
- * @widget: the object which received the signal.
- *
- * Emitted to when the font button is activated.
- *
- * The `::activate` signal on `GtkFontButton` is an action signal and
- * emitting it causes the button to present its dialog.
- *
- * Since: 4.4
- */
- font_button_signals[ACTIVATE] =
- g_signal_new (I_ ("activate"),
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GtkFontButtonClass, activate),
- NULL, NULL,
- NULL,
- G_TYPE_NONE, 0);
-
- gtk_widget_class_set_activate_signal (widget_class, font_button_signals[ACTIVATE]);
-
- gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
- gtk_widget_class_set_css_name (widget_class, I_("fontbutton"));
-}
-
-static void
-gtk_font_button_init (GtkFontButton *font_button)
-{
- GtkWidget *box;
-
- font_button->button = gtk_button_new ();
- g_signal_connect (font_button->button, "clicked", G_CALLBACK (gtk_font_button_clicked), font_button);
- font_button->font_label = gtk_label_new (_("Font"));
- gtk_widget_set_hexpand (font_button->font_label, TRUE);
- font_button->size_label = gtk_label_new ("14");
- font_button->font_size_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_append (GTK_BOX (box), font_button->font_label);
-
- gtk_box_append (GTK_BOX (font_button->font_size_box), gtk_separator_new (GTK_ORIENTATION_VERTICAL));
- gtk_box_append (GTK_BOX (font_button->font_size_box), font_button->size_label);
- gtk_box_append (GTK_BOX (box), font_button->font_size_box);
-
- gtk_button_set_child (GTK_BUTTON (font_button->button), box);
- gtk_widget_set_parent (font_button->button, GTK_WIDGET (font_button));
-
- /* Initialize fields */
- font_button->modal = TRUE;
- font_button->use_font = FALSE;
- font_button->use_size = FALSE;
- font_button->show_preview_entry = TRUE;
- font_button->font_dialog = NULL;
- font_button->font_family = NULL;
- font_button->font_face = NULL;
- font_button->font_size = -1;
- font_button->title = g_strdup (_("Pick a Font"));
- font_button->level = GTK_FONT_CHOOSER_LEVEL_FAMILY |
- GTK_FONT_CHOOSER_LEVEL_STYLE |
- GTK_FONT_CHOOSER_LEVEL_SIZE;
- font_button->language = pango_language_get_default ();
-
- gtk_font_button_take_font_desc (font_button, NULL);
-
- gtk_widget_add_css_class (font_button->button, "font");
-}
-
-static void
-gtk_font_button_finalize (GObject *object)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (object);
-
- g_free (font_button->title);
-
- clear_font_data (font_button);
- clear_font_filter_data (font_button);
-
- g_free (font_button->preview_text);
-
- gtk_widget_unparent (font_button->button);
-
- G_OBJECT_CLASS (gtk_font_button_parent_class)->finalize (object);
-}
-
-static void
-gtk_font_button_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (object);
-
- switch (param_id)
- {
- case GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT:
- gtk_font_button_set_preview_text (font_button, g_value_get_string (value));
- break;
- case GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY:
- gtk_font_button_set_show_preview_entry (font_button, g_value_get_boolean (value));
- break;
- case PROP_TITLE:
- gtk_font_button_set_title (font_button, g_value_get_string (value));
- break;
- case PROP_MODAL:
- gtk_font_button_set_modal (font_button, g_value_get_boolean (value));
- break;
- case GTK_FONT_CHOOSER_PROP_FONT_DESC:
- gtk_font_button_take_font_desc (font_button, g_value_dup_boxed (value));
- break;
- case GTK_FONT_CHOOSER_PROP_LANGUAGE:
- gtk_font_button_set_language (font_button, g_value_get_string (value));
- break;
- case GTK_FONT_CHOOSER_PROP_LEVEL:
- gtk_font_button_set_level (font_button, g_value_get_flags (value));
- break;
- case GTK_FONT_CHOOSER_PROP_FONT:
- gtk_font_button_set_font_name (font_button, g_value_get_string (value));
- break;
- case PROP_USE_FONT:
- gtk_font_button_set_use_font (font_button, g_value_get_boolean (value));
- break;
- case PROP_USE_SIZE:
- gtk_font_button_set_use_size (font_button, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-gtk_font_button_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (object);
-
- switch (param_id)
- {
- case GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT:
- g_value_set_string (value, gtk_font_button_get_preview_text (font_button));
- break;
- case GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY:
- g_value_set_boolean (value, gtk_font_button_get_show_preview_entry (font_button));
- break;
- case PROP_TITLE:
- g_value_set_string (value, gtk_font_button_get_title (font_button));
- break;
- case PROP_MODAL:
- g_value_set_boolean (value, gtk_font_button_get_modal (font_button));
- break;
- case GTK_FONT_CHOOSER_PROP_FONT_DESC:
- g_value_set_boxed (value, gtk_font_button_get_font_desc (font_button));
- break;
- case GTK_FONT_CHOOSER_PROP_FONT_FEATURES:
- g_value_set_string (value, font_button->font_features);
- break;
- case GTK_FONT_CHOOSER_PROP_LANGUAGE:
- g_value_set_string (value, pango_language_to_string (font_button->language));
- break;
- case GTK_FONT_CHOOSER_PROP_LEVEL:
- g_value_set_flags (value, font_button->level);
- break;
- case GTK_FONT_CHOOSER_PROP_FONT:
- g_value_set_string (value, gtk_font_button_get_font_name (font_button));
- break;
- case PROP_USE_FONT:
- g_value_set_boolean (value, gtk_font_button_get_use_font (font_button));
- break;
- case PROP_USE_SIZE:
- g_value_set_boolean (value, gtk_font_button_get_use_size (font_button));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-
-/**
- * gtk_font_button_new:
- *
- * Creates a new font picker widget.
- *
- * Returns: a new font picker widget.
- */
-GtkWidget *
-gtk_font_button_new (void)
-{
- return g_object_new (GTK_TYPE_FONT_BUTTON, NULL);
-}
-
-/**
- * gtk_font_button_new_with_font:
- * @fontname: Name of font to display in font chooser dialog
- *
- * Creates a new font picker widget showing the given font.
- *
- * Returns: a new font picker widget.
- */
-GtkWidget *
-gtk_font_button_new_with_font (const char *fontname)
-{
- return g_object_new (GTK_TYPE_FONT_BUTTON, "font", fontname, NULL);
-}
-
-/**
- * gtk_font_button_set_title: (attributes org.gtk.Method.set_property=title)
- * @font_button: a `GtkFontButton`
- * @title: a string containing the font chooser dialog title
- *
- * Sets the title for the font chooser dialog.
- */
-void
-gtk_font_button_set_title (GtkFontButton *font_button,
- const char *title)
-{
- char *old_title;
- g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
-
- old_title = font_button->title;
- font_button->title = g_strdup (title);
- g_free (old_title);
-
- if (font_button->font_dialog)
- gtk_window_set_title (GTK_WINDOW (font_button->font_dialog), font_button->title);
-
- g_object_notify (G_OBJECT (font_button), "title");
-}
-
-/**
- * gtk_font_button_get_title: (attributes org.gtk.Method.get_property=title)
- * @font_button: a `GtkFontButton`
- *
- * Retrieves the title of the font chooser dialog.
- *
- * Returns: an internal copy of the title string
- * which must not be freed.
- */
-const char *
-gtk_font_button_get_title (GtkFontButton *font_button)
-{
- g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), NULL);
-
- return font_button->title;
-}
-
-/**
- * gtk_font_button_set_modal: (attributes org.gtk.Method.set_property=modal)
- * @font_button: a `GtkFontButton`
- * @modal: %TRUE to make the dialog modal
- *
- * Sets whether the dialog should be modal.
- */
-void
-gtk_font_button_set_modal (GtkFontButton *font_button,
- gboolean modal)
-{
- g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
-
- if (font_button->modal == modal)
- return;
-
- font_button->modal = modal;
-
- if (font_button->font_dialog)
- gtk_window_set_modal (GTK_WINDOW (font_button->font_dialog), font_button->modal);
-
- g_object_notify (G_OBJECT (font_button), "modal");
-}
-
-/**
- * gtk_font_button_get_modal: (attributes org.gtk.Method.get_property=modal)
- * @font_button: a `GtkFontButton`
- *
- * Gets whether the dialog is modal.
- *
- * Returns: %TRUE if the dialog is modal
- */
-gboolean
-gtk_font_button_get_modal (GtkFontButton *font_button)
-{
- g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
-
- return font_button->modal;
-}
-
-/**
- * gtk_font_button_get_use_font: (attributes org.gtk.Method.get_property=use-font)
- * @font_button: a `GtkFontButton`
- *
- * Returns whether the selected font is used in the label.
- *
- * Returns: whether the selected font is used in the label.
- */
-gboolean
-gtk_font_button_get_use_font (GtkFontButton *font_button)
-{
- g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
-
- return font_button->use_font;
-}
-
-/**
- * gtk_font_button_set_use_font: (attributes org.gtk.Method.set_property=use-font)
- * @font_button: a `GtkFontButton`
- * @use_font: If %TRUE, font name will be written using font chosen.
- *
- * If @use_font is %TRUE, the font name will be written
- * using the selected font.
- */
-void
-gtk_font_button_set_use_font (GtkFontButton *font_button,
- gboolean use_font)
-{
- g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
-
- use_font = (use_font != FALSE);
-
- if (font_button->use_font != use_font)
- {
- font_button->use_font = use_font;
-
- gtk_font_button_label_use_font (font_button);
-
- g_object_notify (G_OBJECT (font_button), "use-font");
- }
-}
-
-
-/**
- * gtk_font_button_get_use_size: (attributes org.gtk.Method.get_property=use-size)
- * @font_button: a `GtkFontButton`
- *
- * Returns whether the selected size is used in the label.
- *
- * Returns: whether the selected size is used in the label.
- */
-gboolean
-gtk_font_button_get_use_size (GtkFontButton *font_button)
-{
- g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
-
- return font_button->use_size;
-}
-
-/**
- * gtk_font_button_set_use_size: (attributes org.gtk.Method.set_property=use-size)
- * @font_button: a `GtkFontButton`
- * @use_size: If %TRUE, font name will be written using the
- * selected size.
- *
- * If @use_size is %TRUE, the font name will be written using
- * the selected size.
- */
-void
-gtk_font_button_set_use_size (GtkFontButton *font_button,
- gboolean use_size)
-{
- g_return_if_fail (GTK_IS_FONT_BUTTON (font_button));
-
- use_size = (use_size != FALSE);
- if (font_button->use_size != use_size)
- {
- font_button->use_size = use_size;
-
- gtk_font_button_label_use_font (font_button);
-
- g_object_notify (G_OBJECT (font_button), "use-size");
- }
-}
-
-static const char *
-gtk_font_button_get_font_name (GtkFontButton *font_button)
-{
- g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), NULL);
-
- return font_button->fontname;
-}
-
-static void
-gtk_font_button_set_font_name (GtkFontButton *font_button,
- const char *fontname)
-{
- PangoFontDescription *font_desc;
-
- font_desc = pango_font_description_from_string (fontname);
- gtk_font_button_take_font_desc (font_button, font_desc);
-}
-
-static void
-gtk_font_button_clicked (GtkButton *button,
- gpointer user_data)
-{
- GtkFontChooser *font_dialog;
- GtkFontButton *font_button = user_data;
-
- if (!font_button->font_dialog)
- {
- GtkWidget *parent;
-
- parent = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (font_button)));
-
- font_button->font_dialog = gtk_font_chooser_dialog_new (font_button->title, NULL);
- gtk_window_set_hide_on_close (GTK_WINDOW (font_button->font_dialog), TRUE);
- gtk_window_set_modal (GTK_WINDOW (font_button->font_dialog), font_button->modal);
- gtk_window_set_display (GTK_WINDOW (font_button->font_dialog), gtk_widget_get_display (GTK_WIDGET (button)));
-
- font_dialog = GTK_FONT_CHOOSER (font_button->font_dialog);
-
- if (font_button->font_map)
- gtk_font_chooser_set_font_map (font_dialog, font_button->font_map);
-
- gtk_font_chooser_set_show_preview_entry (font_dialog, font_button->show_preview_entry);
- gtk_font_chooser_set_level (GTK_FONT_CHOOSER (font_dialog), font_button->level);
- gtk_font_chooser_set_language (GTK_FONT_CHOOSER (font_dialog), pango_language_to_string (font_button->language));
-
- if (font_button->preview_text)
- {
- gtk_font_chooser_set_preview_text (font_dialog, font_button->preview_text);
- g_free (font_button->preview_text);
- font_button->preview_text = NULL;
- }
-
- if (font_button->font_filter)
- {
- gtk_font_chooser_set_filter_func (font_dialog,
- font_button->font_filter,
- font_button->font_filter_data,
- font_button->font_filter_data_destroy);
- font_button->font_filter = NULL;
- font_button->font_filter_data = NULL;
- font_button->font_filter_data_destroy = NULL;
- }
-
- if (GTK_IS_WINDOW (parent))
- {
- if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (font_dialog)))
- gtk_window_set_transient_for (GTK_WINDOW (font_dialog), GTK_WINDOW (parent));
-
- if (gtk_window_get_modal (GTK_WINDOW (parent)))
- gtk_window_set_modal (GTK_WINDOW (font_dialog), TRUE);
- }
-
- g_signal_connect (font_dialog, "notify",
- G_CALLBACK (gtk_font_button_font_chooser_notify), button);
-
- g_signal_connect (font_dialog, "response",
- G_CALLBACK (response_cb), font_button);
-
- g_signal_connect (font_dialog, "destroy",
- G_CALLBACK (dialog_destroy), font_button);
- }
-
- if (!gtk_widget_get_visible (font_button->font_dialog))
- {
- font_dialog = GTK_FONT_CHOOSER (font_button->font_dialog);
- gtk_font_chooser_set_font_desc (font_dialog, font_button->font_desc);
- }
-
- gtk_window_present (GTK_WINDOW (font_button->font_dialog));
-}
-
-
-static void
-response_cb (GtkDialog *dialog,
- int response_id,
- gpointer data)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (data);
- GtkFontChooser *font_chooser;
- GObject *object;
-
- gtk_widget_hide (font_button->font_dialog);
-
- if (response_id != GTK_RESPONSE_OK)
- return;
-
- font_chooser = GTK_FONT_CHOOSER (font_button->font_dialog);
- object = G_OBJECT (font_chooser);
-
- g_object_freeze_notify (object);
-
- clear_font_data (font_button);
-
- font_button->font_desc = gtk_font_chooser_get_font_desc (font_chooser);
- if (font_button->font_desc)
- font_button->fontname = pango_font_description_to_string (font_button->font_desc);
- font_button->font_family = gtk_font_chooser_get_font_family (font_chooser);
- if (font_button->font_family)
- g_object_ref (font_button->font_family);
- font_button->font_face = gtk_font_chooser_get_font_face (font_chooser);
- if (font_button->font_face)
- g_object_ref (font_button->font_face);
- font_button->font_size = gtk_font_chooser_get_font_size (font_chooser);
- g_free (font_button->font_features);
- font_button->font_features = gtk_font_chooser_get_font_features (font_chooser);
- font_button->language = pango_language_from_string (gtk_font_chooser_get_language (font_chooser));
-
- /* Set label font */
- gtk_font_button_update_font_info (font_button);
-
- g_object_notify (G_OBJECT (font_button), "font");
- g_object_notify (G_OBJECT (font_button), "font-desc");
- g_object_notify (G_OBJECT (font_button), "font-features");
-
- g_object_thaw_notify (object);
-
- /* Emit font_set signal */
- g_signal_emit (font_button, font_button_signals[FONT_SET], 0);
-}
-
-static void
-dialog_destroy (GtkWidget *widget,
- gpointer data)
-{
- GtkFontButton *font_button = GTK_FONT_BUTTON (data);
-
- /* Dialog will get destroyed so reference is not valid now */
- font_button->font_dialog = NULL;
-}
-
-static void
-gtk_font_button_label_use_font (GtkFontButton *font_button)
-{
- if (!font_button->use_font)
- gtk_label_set_attributes (GTK_LABEL (font_button->font_label), NULL);
- else
- {
- PangoFontDescription *desc;
- PangoAttrList *attrs;
-
- desc = pango_font_description_copy (font_button->font_desc);
-
- if (!font_button->use_size)
- pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
-
- attrs = pango_attr_list_new ();
-
- /* Prevent font fallback */
- pango_attr_list_insert (attrs, pango_attr_fallback_new (FALSE));
-
- /* Force current font and features */
- pango_attr_list_insert (attrs, pango_attr_font_desc_new (desc));
- if (font_button->font_features)
- pango_attr_list_insert (attrs, pango_attr_font_features_new (font_button->font_features));
- if (font_button->language)
- pango_attr_list_insert (attrs, pango_attr_language_new (font_button->language));
-
- gtk_label_set_attributes (GTK_LABEL (font_button->font_label), attrs);
-
- pango_attr_list_unref (attrs);
- pango_font_description_free (desc);
- }
-}
-
-static void
-gtk_font_button_update_font_info (GtkFontButton *font_button)
-{
- const char *fam_name;
- const char *face_name;
- char *family_style;
-
- if (font_button->font_family)
- fam_name = pango_font_family_get_name (font_button->font_family);
- else
- fam_name = C_("font", "None");
- if (font_button->font_face)
- face_name = pango_font_face_get_face_name (font_button->font_face);
- else
- face_name = "";
-
- if ((font_button->level & GTK_FONT_CHOOSER_LEVEL_STYLE) != 0)
- family_style = g_strconcat (fam_name, " ", face_name, NULL);
- else
- family_style = g_strdup (fam_name);
-
- gtk_label_set_text (GTK_LABEL (font_button->font_label), family_style);
- g_free (family_style);
-
- if ((font_button->level & GTK_FONT_CHOOSER_LEVEL_SIZE) != 0)
- {
- /* mirror Pango, which doesn't translate this either */
- char *size = g_strdup_printf ("%2.4g%s",
- pango_font_description_get_size (font_button->font_desc) / (double)PANGO_SCALE,
- pango_font_description_get_size_is_absolute (font_button->font_desc) ? "px" : "");
-
- gtk_label_set_text (GTK_LABEL (font_button->size_label), size);
-
- g_free (size);
-
- gtk_widget_show (font_button->font_size_box);
- }
- else
- gtk_widget_hide (font_button->font_size_box);
-
-
- gtk_font_button_label_use_font (font_button);
-}
-
-static void
-gtk_font_button_set_level (GtkFontButton *font_button,
- GtkFontChooserLevel level)
-{
- if (font_button->level == level)
- return;
-
- font_button->level = level;
-
- if (font_button->font_dialog)
- gtk_font_chooser_set_level (GTK_FONT_CHOOSER (font_button->font_dialog), level);
-
- gtk_font_button_update_font_info (font_button);
-
- g_object_notify (G_OBJECT (font_button), "level");
-}
-
-static void
-gtk_font_button_set_language (GtkFontButton *font_button,
- const char *language)
-{
- font_button->language = pango_language_from_string (language);
-
- if (font_button->font_dialog)
- gtk_font_chooser_set_language (GTK_FONT_CHOOSER (font_button->font_dialog), language);
-
- g_object_notify (G_OBJECT (font_button), "language");
-}
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 1998 David Abilleira Freijeiro <odaf@nexo.es>
- * All rights reserved
- * Based on gnome-color-picker by Federico Mena <federico@nuclecu.unam.mx>
- *
- * 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, see <http://www.gnu.org/licenses/>.
- */
-/*
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_FONT_BUTTON_H__
-#define __GTK_FONT_BUTTON_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkbutton.h>
-
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_FONT_BUTTON (gtk_font_button_get_type ())
-#define GTK_FONT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_BUTTON, GtkFontButton))
-#define GTK_IS_FONT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_BUTTON))
-
-typedef struct _GtkFontButton GtkFontButton;
-
-GDK_AVAILABLE_IN_ALL
-GType gtk_font_button_get_type (void) G_GNUC_CONST;
-GDK_AVAILABLE_IN_ALL
-GtkWidget *gtk_font_button_new (void);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *gtk_font_button_new_with_font (const char *fontname);
-
-GDK_AVAILABLE_IN_ALL
-const char * gtk_font_button_get_title (GtkFontButton *font_button);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_button_set_title (GtkFontButton *font_button,
- const char *title);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_font_button_get_modal (GtkFontButton *font_button);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_button_set_modal (GtkFontButton *font_button,
- gboolean modal);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_font_button_get_use_font (GtkFontButton *font_button);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_button_set_use_font (GtkFontButton *font_button,
- gboolean use_font);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_font_button_get_use_size (GtkFontButton *font_button);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_button_set_use_size (GtkFontButton *font_button,
- gboolean use_size);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontButton, g_object_unref)
-
-G_END_DECLS
-
-
-#endif /* __GTK_FONT_BUTTON_H__ */
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * gtkfontchooser.c - 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
- * 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gtkfontchooser.h"
-#include "gtkfontchooserprivate.h"
-#include "gtktypebuiltins.h"
-#include "gtkprivate.h"
-
-/**
- * GtkFontChooser:
- *
- * `GtkFontChooser` is an interface that can be implemented by widgets
- * for choosing fonts.
- *
- * In GTK, the main objects that implement this interface are
- * [class@Gtk.FontChooserWidget], [class@Gtk.FontChooserDialog] and
- * [class@Gtk.FontButton].
- */
-
-enum
-{
- SIGNAL_FONT_ACTIVATED,
- LAST_SIGNAL
-};
-
-static guint chooser_signals[LAST_SIGNAL];
-
-typedef GtkFontChooserIface GtkFontChooserInterface;
-G_DEFINE_INTERFACE (GtkFontChooser, gtk_font_chooser, G_TYPE_OBJECT);
-
-static void
-gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
-{
- /**
- * GtkFontChooser:font: (attributes org.gtk.Property.get=gtk_font_chooser_get_font org.gtk.Property.set=gtk_font_chooser_set_font)
- *
- * The font description as a string, e.g. "Sans Italic 12".
- */
- g_object_interface_install_property
- (iface,
- g_param_spec_string ("font", NULL, NULL,
- GTK_FONT_CHOOSER_DEFAULT_FONT_NAME,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkFontChooser:font-desc: (attributes org.gtk.Property.get=gtk_font_chooser_get_font_desc org.gtk.Property.set=gtk_font_chooser_set_font_desc)
- *
- * The font description as a `PangoFontDescription`.
- */
- g_object_interface_install_property
- (iface,
- g_param_spec_boxed ("font-desc", NULL, NULL,
- PANGO_TYPE_FONT_DESCRIPTION,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkFontChooser:preview-text: (attributes org.gtk.Property.get=gtk_font_chooser_get_preview_text org.gtk.Property.set=gtk_font_chooser_set_preview_text)
- *
- * The string with which to preview the font.
- */
- g_object_interface_install_property
- (iface,
- g_param_spec_string ("preview-text", NULL, NULL,
- pango_language_get_sample_string (NULL),
- GTK_PARAM_READWRITE));
-
- /**
- * GtkFontChooser:show-preview-entry: (attributes org.gtk.Property.get=gtk_font_chooser_get_show_preview_entry org.gtk.Property.set=gtk_font_chooser_set_show_preview_entry)
- *
- * Whether to show an entry to change the preview text.
- */
- g_object_interface_install_property
- (iface,
- g_param_spec_boolean ("show-preview-entry", NULL, NULL,
- TRUE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- /**
- * GtkFontChooser:level: (attributes org.gtk.Property.get=gtk_font_chooser_get_level org.gtk.Property.set=gtk_font_chooser_set_level)
- *
- * The level of granularity to offer for selecting fonts.
- */
- g_object_interface_install_property
- (iface,
- g_param_spec_flags ("level", NULL, NULL,
- GTK_TYPE_FONT_CHOOSER_LEVEL,
- GTK_FONT_CHOOSER_LEVEL_FAMILY |
- GTK_FONT_CHOOSER_LEVEL_STYLE |
- GTK_FONT_CHOOSER_LEVEL_SIZE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- /**
- * GtkFontChooser:font-features: (attributes org.gtk.Property.get=gtk_font_chooser_get_font_features)
- *
- * The selected font features.
- *
- * The format of the string is compatible with
- * CSS and with Pango attributes.
- */
- g_object_interface_install_property
- (iface,
- g_param_spec_string ("font-features", NULL, NULL,
- "",
- GTK_PARAM_READABLE));
-
- /**
- * GtkFontChooser:language: (attributes org.gtk.Property.get=gtk_font_chooser_get_language org.gtk.Property.set=gtk_font_chooser_set_language)
- *
- * The language for which the font features were selected.
- */
- g_object_interface_install_property
- (iface,
- g_param_spec_string ("language", NULL, NULL,
- "",
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- /**
- * GtkFontChooser::font-activated:
- * @self: the object which received the signal
- * @fontname: the font name
- *
- * Emitted when a font is activated.
- *
- * This usually happens when the user double clicks an item,
- * or an item is selected and the user presses one of the keys
- * Space, Shift+Space, Return or Enter.
- */
- chooser_signals[SIGNAL_FONT_ACTIVATED] =
- g_signal_new (I_("font-activated"),
- GTK_TYPE_FONT_CHOOSER,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GtkFontChooserIface, font_activated),
- NULL, NULL,
- NULL,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
-}
-
-/**
- * gtk_font_chooser_get_font_family:
- * @fontchooser: a `GtkFontChooser`
- *
- * Gets the `PangoFontFamily` representing the selected font family.
- *
- * Font families are a collection of font faces.
- *
- * If the selected font is not installed, returns %NULL.
- *
- * Returns: (nullable) (transfer none): A `PangoFontFamily` representing the
- * selected font family
- */
-PangoFontFamily *
-gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser)
-{
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
-
- return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_family (fontchooser);
-}
-
-/**
- * gtk_font_chooser_get_font_face:
- * @fontchooser: a `GtkFontChooser`
- *
- * Gets the `PangoFontFace` representing the selected font group
- * details (i.e. family, slant, weight, width, etc).
- *
- * If the selected font is not installed, returns %NULL.
- *
- * Returns: (nullable) (transfer none): A `PangoFontFace` representing the
- * selected font group details
- */
-PangoFontFace *
-gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser)
-{
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
-
- return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_face (fontchooser);
-}
-
-/**
- * gtk_font_chooser_get_font_size:
- * @fontchooser: a `GtkFontChooser`
- *
- * The selected font size.
- *
- * Returns: A n integer representing the selected font size,
- * or -1 if no font size is selected.
- */
-int
-gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser)
-{
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), -1);
-
- return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_size (fontchooser);
-}
-
-/**
- * gtk_font_chooser_get_font: (attributes org.gtk.Method.get_property=font)
- * @fontchooser: a `GtkFontChooser`
- *
- * Gets the currently-selected font name.
- *
- * Note that this can be a different string than what you set with
- * [method@Gtk.FontChooser.set_font], 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 [method@Pango.FontDescription.equal] if you want to compare two
- * font descriptions.
- *
- * Returns: (nullable) (transfer full): A string with the name
- * of the current font
- */
-char *
-gtk_font_chooser_get_font (GtkFontChooser *fontchooser)
-{
- char *fontname;
-
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
-
- g_object_get (fontchooser, "font", &fontname, NULL);
-
-
- return fontname;
-}
-
-/**
- * gtk_font_chooser_set_font: (attributes org.gtk.Method.set_property=font)
- * @fontchooser: a `GtkFontChooser`
- * @fontname: a font name like “Helvetica 12” or “Times Bold 18”
- *
- * Sets the currently-selected font.
- */
-void
-gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
- const char *fontname)
-{
- g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
- g_return_if_fail (fontname != NULL);
-
- g_object_set (fontchooser, "font", fontname, NULL);
-}
-
-/**
- * gtk_font_chooser_get_font_desc: (attributes org.gtk.Method.get_property=font-desc)
- * @fontchooser: a `GtkFontChooser`
- *
- * Gets the currently-selected font.
- *
- * Note that this can be a different string than what you set with
- * [method@Gtk.FontChooser.set_font], 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 [method@Pango.FontDescription.equal] if you want to compare two
- * font descriptions.
- *
- * Returns: (nullable) (transfer full): A `PangoFontDescription` for the
- * current font
- */
-PangoFontDescription *
-gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser)
-{
- PangoFontDescription *font_desc;
-
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
-
- g_object_get (fontchooser, "font-desc", &font_desc, NULL);
-
- return font_desc;
-}
-
-/**
- * gtk_font_chooser_set_font_desc: (attributes org.gtk.Method.set_property=font-desc)
- * @fontchooser: a `GtkFontChooser`
- * @font_desc: a `PangoFontDescription`
- *
- * Sets the currently-selected font from @font_desc.
- */
-void
-gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
- const PangoFontDescription *font_desc)
-{
- g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
- g_return_if_fail (font_desc != NULL);
-
- g_object_set (fontchooser, "font-desc", font_desc, NULL);
-}
-
-/**
- * gtk_font_chooser_get_preview_text: (attributes org.gtk.Method.get_property=preview-text)
- * @fontchooser: a `GtkFontChooser`
- *
- * Gets the text displayed in the preview area.
- *
- * Returns: (transfer full): the text displayed in the preview area
- */
-char *
-gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser)
-{
- char *text;
-
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
-
- g_object_get (fontchooser, "preview-text", &text, NULL);
-
- return text;
-}
-
-/**
- * gtk_font_chooser_set_preview_text: (attributes org.gtk.Method.set_property=preview-text)
- * @fontchooser: a `GtkFontChooser`
- * @text: (transfer none): the text to display in the preview area
- *
- * Sets the text displayed in the preview area.
- *
- * The @text is used to show how the selected font looks.
- */
-void
-gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
- const char *text)
-{
- g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
- g_return_if_fail (text != NULL);
-
- g_object_set (fontchooser, "preview-text", text, NULL);
-}
-
-/**
- * gtk_font_chooser_get_show_preview_entry: (attributes org.gtk.Method.get_property=show-preview-entry)
- * @fontchooser: a `GtkFontChooser`
- *
- * Returns whether the preview entry is shown or not.
- *
- * Returns: %TRUE if the preview entry is shown or %FALSE if it is hidden.
- */
-gboolean
-gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser)
-{
- gboolean show;
-
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), FALSE);
-
- g_object_get (fontchooser, "show-preview-entry", &show, NULL);
-
- return show;
-}
-
-/**
- * gtk_font_chooser_set_show_preview_entry: (attributes org.gtk.Method.set_property=show-preview-entry)
- * @fontchooser: a `GtkFontChooser`
- * @show_preview_entry: whether to show the editable preview entry or not
- *
- * Shows or hides the editable preview entry.
- */
-void
-gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
- gboolean show_preview_entry)
-{
- g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
-
- show_preview_entry = show_preview_entry != FALSE;
- g_object_set (fontchooser, "show-preview-entry", show_preview_entry, NULL);
-}
-
-/**
- * gtk_font_chooser_set_filter_func:
- * @fontchooser: a `GtkFontChooser`
- * @filter: (nullable): a `GtkFontFilterFunc`
- * @user_data: (closure): data to pass to @filter
- * @destroy: function to call to free @data when it is no longer needed
- *
- * Adds a filter function that decides which fonts to display
- * in the font chooser.
- */
-void
-gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
- GtkFontFilterFunc filter,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
-
- GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_filter_func (fontchooser,
- filter,
- user_data,
- destroy);
-}
-
-void
-_gtk_font_chooser_font_activated (GtkFontChooser *chooser,
- const char *fontname)
-{
- g_return_if_fail (GTK_IS_FONT_CHOOSER (chooser));
-
- g_signal_emit (chooser, chooser_signals[SIGNAL_FONT_ACTIVATED], 0, fontname);
-}
-
-/**
- * gtk_font_chooser_set_font_map:
- * @fontchooser: a `GtkFontChooser`
- * @fontmap: (nullable): a `PangoFontMap`
- *
- * Sets a custom font map to use for this font chooser widget.
- *
- * A custom font map can be used to present application-specific
- * fonts instead of or in addition to the normal system fonts.
- *
- * ```c
- * FcConfig *config;
- * PangoFontMap *fontmap;
- *
- * config = FcInitLoadConfigAndFonts ();
- * FcConfigAppFontAddFile (config, my_app_font_file);
- *
- * fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
- * pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config);
- *
- * gtk_font_chooser_set_font_map (font_chooser, fontmap);
- * ```
- *
- * Note that other GTK widgets will only be able to use the
- * application-specific font if it is present in the font map they use:
- *
- * ```c
- * context = gtk_widget_get_pango_context (label);
- * pango_context_set_font_map (context, fontmap);
- * ```
- */
-void
-gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
- PangoFontMap *fontmap)
-{
- g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
- g_return_if_fail (fontmap == NULL || PANGO_IS_FONT_MAP (fontmap));
-
- if (GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font_map)
- GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font_map (fontchooser, fontmap);
-}
-
-/**
- * gtk_font_chooser_get_font_map:
- * @fontchooser: a `GtkFontChooser`
- *
- * Gets the custom font map of this font chooser widget,
- * or %NULL if it does not have one.
- *
- * Returns: (nullable) (transfer full): a `PangoFontMap`
- */
-PangoFontMap *
-gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser)
-{
- PangoFontMap *fontmap = NULL;
-
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
-
- if (GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_map)
- fontmap = GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_map (fontchooser);
-
- return fontmap;
-}
-
-/**
- * gtk_font_chooser_set_level: (attributes org.gtk.Method.set_property=level)
- * @fontchooser: a `GtkFontChooser`
- * @level: the desired level of granularity
- *
- * Sets the desired level of granularity for selecting fonts.
- */
-void
-gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
- GtkFontChooserLevel level)
-{
- g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
-
- g_object_set (fontchooser, "level", level, NULL);
-}
-
-/**
- * gtk_font_chooser_get_level: (attributes org.gtk.Method.get_property=level)
- * @fontchooser: a `GtkFontChooser`
- *
- * Returns the current level of granularity for selecting fonts.
- *
- * Returns: the current granularity level
- */
-GtkFontChooserLevel
-gtk_font_chooser_get_level (GtkFontChooser *fontchooser)
-{
- GtkFontChooserLevel level;
-
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), 0);
-
- g_object_get (fontchooser, "level", &level, NULL);
-
- return level;
-}
-
-/**
- * gtk_font_chooser_get_font_features: (attributes org.gtk.Method.get_property=font-features)
- * @fontchooser: a `GtkFontChooser`
- *
- * Gets the currently-selected font features.
- *
- * The format of the returned string is compatible with the
- * [CSS font-feature-settings property](https://www.w3.org/TR/css-fonts-4/#font-rend-desc).
- * It can be passed to [func@Pango.AttrFontFeatures.new].
- *
- * Returns: the currently selected font features
- */
-char *
-gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser)
-{
- char *text;
-
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
-
- g_object_get (fontchooser, "font-features", &text, NULL);
-
- return text;
-}
-
-/**
- * gtk_font_chooser_get_language: (attributes org.gtk.Method.get_property=language)
- * @fontchooser: a `GtkFontChooser`
- *
- * Gets the language that is used for font features.
- *
- * Returns: the currently selected language
- */
-char *
-gtk_font_chooser_get_language (GtkFontChooser *fontchooser)
-{
- char *text;
-
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
-
- g_object_get (fontchooser, "language", &text, NULL);
-
- return text;
-}
-
-/**
- * gtk_font_chooser_set_language: (attributes org.gtk.Method.set_property=language)
- * @fontchooser: a `GtkFontChooser`
- * @language: a language
- *
- * Sets the language to use for font features.
- */
-void
-gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
- const char *language)
-{
- g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
-
- g_object_set (fontchooser, "language", language, NULL);
-}
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * 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
- * 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_FONT_CHOOSER_H__
-#define __GTK_FONT_CHOOSER_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkwidget.h>
-
-G_BEGIN_DECLS
-
-/**
- * GtkFontFilterFunc:
- * @family: a `PangoFontFamily`
- * @face: a `PangoFontFace` belonging to @family
- * @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 [method@Gtk.FontChooser.set_filter_func].
- *
- * Returns: %TRUE if the font should be displayed
- */
-typedef gboolean (*GtkFontFilterFunc) (const PangoFontFamily *family,
- const PangoFontFace *face,
- gpointer data);
-
-/**
- * GtkFontChooserLevel:
- * @GTK_FONT_CHOOSER_LEVEL_FAMILY: Allow selecting a font family
- * @GTK_FONT_CHOOSER_LEVEL_STYLE: Allow selecting a specific font face
- * @GTK_FONT_CHOOSER_LEVEL_SIZE: Allow selecting a specific font size
- * @GTK_FONT_CHOOSER_LEVEL_VARIATIONS: Allow changing OpenType font variation axes
- * @GTK_FONT_CHOOSER_LEVEL_FEATURES: Allow selecting specific OpenType font features
- *
- * Specifies the granularity of font selection
- * that is desired in a `GtkFontChooser`.
- *
- * This enumeration may be extended in the future; applications should
- * ignore unknown values.
- */
-typedef enum {
- GTK_FONT_CHOOSER_LEVEL_FAMILY = 0,
- GTK_FONT_CHOOSER_LEVEL_STYLE = 1 << 0,
- GTK_FONT_CHOOSER_LEVEL_SIZE = 1 << 1,
- GTK_FONT_CHOOSER_LEVEL_VARIATIONS = 1 << 2,
- GTK_FONT_CHOOSER_LEVEL_FEATURES = 1 << 3
-} GtkFontChooserLevel;
-
-#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 */
- PangoFontFamily * (* get_font_family) (GtkFontChooser *fontchooser);
- PangoFontFace * (* get_font_face) (GtkFontChooser *fontchooser);
- int (* get_font_size) (GtkFontChooser *fontchooser);
-
- void (* set_filter_func) (GtkFontChooser *fontchooser,
- GtkFontFilterFunc filter,
- gpointer user_data,
- GDestroyNotify destroy);
-
- /* Signals */
- void (* font_activated) (GtkFontChooser *chooser,
- const char *fontname);
-
- /* More methods */
- void (* set_font_map) (GtkFontChooser *fontchooser,
- PangoFontMap *fontmap);
- PangoFontMap * (* get_font_map) (GtkFontChooser *fontchooser);
-
- /*< private >*/
- /* Padding; remove in GTK-next */
- gpointer padding[10];
-};
-
-GDK_AVAILABLE_IN_ALL
-GType gtk_font_chooser_get_type (void) G_GNUC_CONST;
-
-GDK_AVAILABLE_IN_ALL
-PangoFontFamily *gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser);
-GDK_AVAILABLE_IN_ALL
-PangoFontFace *gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser);
-GDK_AVAILABLE_IN_ALL
-int gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser);
-
-GDK_AVAILABLE_IN_ALL
-PangoFontDescription *
- gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
- const PangoFontDescription *font_desc);
-
-GDK_AVAILABLE_IN_ALL
-char * gtk_font_chooser_get_font (GtkFontChooser *fontchooser);
-
-GDK_AVAILABLE_IN_ALL
-void gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
- const char *fontname);
-GDK_AVAILABLE_IN_ALL
-char * gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
- const char *text);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
- gboolean show_preview_entry);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
- GtkFontFilterFunc filter,
- gpointer user_data,
- GDestroyNotify destroy);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
- PangoFontMap *fontmap);
-GDK_AVAILABLE_IN_ALL
-PangoFontMap * gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
- GtkFontChooserLevel level);
-GDK_AVAILABLE_IN_ALL
-GtkFontChooserLevel
- gtk_font_chooser_get_level (GtkFontChooser *fontchooser);
-GDK_AVAILABLE_IN_ALL
-char * gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser);
-GDK_AVAILABLE_IN_ALL
-char * gtk_font_chooser_get_language (GtkFontChooser *fontchooser);
-GDK_AVAILABLE_IN_ALL
-void gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
- const char *language);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontChooser, g_object_unref)
-
-G_END_DECLS
-
-#endif /* __GTK_FONT_CHOOSER_H__ */
#include <string.h>
#include "gtkfontchooserdialogprivate.h"
-#include "gtkfontchooser.h"
-#include "gtkfontchooserwidget.h"
+#include "deprecated/gtkfontchooser.h"
+#include "deprecated/gtkfontchooserwidget.h"
#include "gtkfontchooserwidgetprivate.h"
#include "gtkfontchooserutils.h"
#include "gtkbox.h"
#include "gtkactionable.h"
#include "gtkeventcontrollerkey.h"
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
typedef struct _GtkFontChooserDialogClass GtkFontChooserDialogClass;
struct _GtkFontChooserDialog
* The `GtkFontChooserDialog` implementation of the `GtkBuildable`
* interface exposes the buttons with the names “select_button”
* and “cancel_button”.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] instead
*/
static void gtk_font_chooser_dialog_buildable_interface_init (GtkBuildableIface *iface);
* Creates a new `GtkFontChooserDialog`.
*
* Returns: a new `GtkFontChooserDialog`
+ *
+ * Deprecated: 4.10: Use [class@Gtk.FontDialog] instead
*/
GtkWidget*
gtk_font_chooser_dialog_new (const char *title,
+++ /dev/null
-/* 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_FONT_CHOOSER_DIALOG_H__
-#define __GTK_FONT_CHOOSER_DIALOG_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkdialog.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_FONT_CHOOSER_DIALOG (gtk_font_chooser_dialog_get_type ())
-#define GTK_FONT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG, GtkFontChooserDialog))
-#define GTK_IS_FONT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG))
-
-typedef struct _GtkFontChooserDialog GtkFontChooserDialog;
-
-GDK_AVAILABLE_IN_ALL
-GType gtk_font_chooser_dialog_get_type (void) G_GNUC_CONST;
-GDK_AVAILABLE_IN_ALL
-GtkWidget* gtk_font_chooser_dialog_new (const char *title,
- GtkWindow *parent);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontChooserDialog, g_object_unref)
-
-G_END_DECLS
-
-#endif /* __GTK_FONT_CHOOSER_DIALOG_H__ */
#ifndef __GTK_FONT_CHOOSER_DIALOG_PRIVATE_H__
#define __GTK_FONT_CHOOSER_DIALOG_PRIVATE_H__
-#include "gtkfontchooserdialog.h"
+#include "deprecated/gtkfontchooserdialog.h"
#include "gtkfilter.h"
G_BEGIN_DECLS
+++ /dev/null
-/* 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_FONT_CHOOSER_PRIVATE_H__
-#define __GTK_FONT_CHOOSER_PRIVATE_H__
-
-#include "gtkfontchooser.h"
-
-#define GTK_FONT_CHOOSER_DEFAULT_FONT_NAME "Sans 10"
-
-G_BEGIN_DECLS
-
-void _gtk_font_chooser_font_activated (GtkFontChooser *chooser,
- const char *fontname);
-
-G_END_DECLS
-
-#endif /* ! __GTK_FONT_CHOOSER_PRIVATE_H__ */
#include "gtkfontchooserutils.h"
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
static GtkFontChooser *
get_delegate (GtkFontChooser *receiver)
{
#ifndef __GTK_FONT_CHOOSER_UTILS_H__
#define __GTK_FONT_CHOOSER_UTILS_H__
-#include "gtkfontchooserprivate.h"
+#include "deprecated/gtkfontchooserprivate.h"
G_BEGIN_DECLS
#include <glib/gprintf.h>
#include <string.h>
-#include "gtkfontchooserwidget.h"
+#include "deprecated/gtkfontchooserwidget.h"
#include "gtkfontchooserwidgetprivate.h"
#include "gtkadjustment.h"
#include "gtkfilter.h"
#include "gtkframe.h"
#include "gtkgrid.h"
-#include "gtkfontchooser.h"
+#include "deprecated/gtkfontchooser.h"
#include "gtkfontchooserutils.h"
#include <glib/gi18n-lib.h>
#include "gtklabel.h"
#include "language-names.h"
#include "open-type-layout.h"
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
/**
* GtkFontChooserWidget:
*
* # CSS nodes
*
* `GtkFontChooserWidget` has a single CSS node with name fontchooser.
+ *
+ * Deprecated: 4.10: Direct use of `GtkFontChooserWidget` is deprecated.
*/
typedef struct _GtkFontChooserWidgetClass GtkFontChooserWidgetClass;
* Creates a new `GtkFontChooserWidget`.
*
* Returns: a new `GtkFontChooserWidget`
+ *
+ * Deprecated: 4.10: Direct use of `GtkFontChooserWidget` is deprecated.
*/
GtkWidget *
gtk_font_chooser_widget_new (void)
+++ /dev/null
-/* 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_FONT_CHOOSER_WIDGET_H__
-#define __GTK_FONT_CHOOSER_WIDGET_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkwidget.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_IS_FONT_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER_WIDGET))
-
-typedef struct _GtkFontChooserWidget GtkFontChooserWidget;
-
-GDK_AVAILABLE_IN_ALL
-GType gtk_font_chooser_widget_get_type (void) G_GNUC_CONST;
-
-GDK_AVAILABLE_IN_ALL
-GtkWidget* gtk_font_chooser_widget_new (void);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontChooserWidget, g_object_unref)
-
-G_END_DECLS
-
-#endif /* __GTK_FONT_CHOOSER_WIDGET_H__ */
#ifndef __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__
#define __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__
-#include "gtkfontchooserwidget.h"
+#include "deprecated/gtkfontchooserwidget.h"
#include "gtkfilter.h"
G_BEGIN_DECLS
#include "gtkfontdialog.h"
-#include "gtkfontchooser.h"
+#include "deprecated/gtkfontchooser.h"
#include "gtkfontchooserdialogprivate.h"
#include "gtkbutton.h"
#include "gtkdialogerror.h"
PangoLanguage *language;
} FontResult;
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
response_cb (GTask *task,
int response)
g_object_unref (task);
}
+G_GNUC_END_IGNORE_DEPRECATIONS
static void
dialog_response (GtkDialog *dialog,
response_cb (task, response);
}
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *
create_font_chooser (GtkFontDialog *self,
GtkWindow *parent,
return window;
}
+G_GNUC_END_IGNORE_DEPRECATIONS
/* }}} */
/* {{{ Async API */
'gtkfixedlayout.c',
'gtkflattenlistmodel.c',
'gtkflowbox.c',
- 'gtkfontbutton.c',
- 'gtkfontchooser.c',
'gtkfontchooserdialog.c',
'gtkfontchooserutils.c',
'gtkfontchooserwidget.c',
'gtkfixedlayout.h',
'gtkflattenlistmodel.h',
'gtkflowbox.h',
- 'gtkfontbutton.h',
- 'gtkfontchooser.h',
- 'gtkfontchooserdialog.h',
- 'gtkfontchooserwidget.h',
'gtkfontdialog.h',
'gtkfontdialogbutton.h',
'gtkframe.h',
#include <gtk/gtk.h>
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
static gboolean
monospace_filter (const PangoFontFamily *family,
const PangoFontFace *face,