[gtk+] GtkFontChooser: Add a ::font-activated signal
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkFontChooser: Add a ::font-activated signal
- Date: Wed, 24 Aug 2011 04:51:13 +0000 (UTC)
commit f7bf35052eed0cb4409079abe847a0af791d00a9
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Aug 24 00:49:16 2011 -0400
GtkFontChooser: Add a ::font-activated signal
This signal gets emitted when a font in the list is activated.
gtk/gtkfontchooser.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
gtk/gtkfontchooser.h | 3 +++
2 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkfontchooser.c b/gtk/gtkfontchooser.c
index 733758f..648bf8f 100644
--- a/gtk/gtkfontchooser.c
+++ b/gtk/gtkfontchooser.c
@@ -141,6 +141,13 @@ enum {
PREVIEW_TITLE_COLUMN
};
+enum {
+ SIGNAL_FONT_ACTIVATED,
+ N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = { 0, };
+
static void gtk_font_chooser_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -199,6 +206,26 @@ gtk_font_chooser_class_init (GtkFontChooserClass *klass)
TRUE,
GTK_PARAM_READWRITE));
+ /**
+ * GtkFontChooserWidget::font-activated:
+ * @self: the object which received the signal
+ * @fontname: the font name
+ *
+ * Emitted when a font is activated from the widget's list.
+ * 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.
+ */
+ signals[SIGNAL_FONT_ACTIVATED] =
+ g_signal_new ("font-activated",
+ GTK_TYPE_FONT_CHOOSER,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GtkFontChooserClass, font_activated),
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+
g_type_class_add_private (klass, sizeof (GtkFontChooserPrivate));
}
@@ -396,6 +423,21 @@ set_range_marks (GtkFontChooserPrivate *priv,
}
static void
+row_activated_cb (GtkTreeView *view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
+{
+ GtkFontChooser *self = user_data;
+ gchar *fontname;
+
+ fontname = gtk_font_chooser_get_font_name (self);
+
+ g_signal_emit (self, signals[SIGNAL_FONT_ACTIVATED], 0, fontname);
+ g_free (fontname);
+}
+
+static void
cursor_changed_cb (GtkTreeView *treeview,
gpointer user_data)
{
@@ -642,7 +684,10 @@ gtk_font_chooser_init (GtkFontChooser *fontchooser)
g_signal_connect (priv->family_face_list, "cursor-changed",
G_CALLBACK (cursor_changed_cb), fontchooser);
- /* Zoom on preview scroll*/
+ g_signal_connect (priv->family_face_list, "row-activated",
+ G_CALLBACK (row_activated_cb), fontchooser);
+
+ /* Zoom on preview scroll */
g_signal_connect (priv->preview, "scroll-event",
G_CALLBACK (zoom_preview_cb), fontchooser);
@@ -1070,6 +1115,7 @@ gtk_font_chooser_get_font_name (GtkFontChooser *fontchooser)
font_name = g_strdup_printf ("%s %d", font_desc_name, fontchooser->priv->size / PANGO_SCALE);
g_free (font_desc_name);
+
return font_name;
}
diff --git a/gtk/gtkfontchooser.h b/gtk/gtkfontchooser.h
index d346837..4dd3907 100644
--- a/gtk/gtkfontchooser.h
+++ b/gtk/gtkfontchooser.h
@@ -51,6 +51,9 @@ struct _GtkFontChooserClass
{
GtkBoxClass parent_class;
+ void (* font_activated) (GtkFontChooser *chooser,
+ const gchar *fontname);
+
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]