[gtk+/gtk-style-context: 220/260] GtkWidget: Add the style-updated signal
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 220/260] GtkWidget: Add the style-updated signal
- Date: Wed, 20 Oct 2010 10:39:55 +0000 (UTC)
commit 83f009296569f4ab66a61c677300b2bfc47c6a27
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Sep 11 12:36:54 2010 +0200
GtkWidget: Add the style-updated signal
This signal is emitted whenever the widget's style changes.
gtk/gtkwidget.c | 34 ++++++++++++++++++++++++++++++++++
gtk/gtkwidget.h | 2 ++
2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b358f57..18649b9 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -389,6 +389,7 @@ enum {
KEYNAV_FAILED,
DRAG_FAILED,
DAMAGE_EVENT,
+ STYLE_UPDATED,
LAST_SIGNAL
};
@@ -477,6 +478,7 @@ static gboolean gtk_widget_real_query_tooltip (GtkWidget *widget,
gint y,
gboolean keyboard_tip,
GtkTooltip *tooltip);
+static void gtk_widget_real_style_updated (GtkWidget *widget);
static gboolean gtk_widget_real_show_help (GtkWidget *widget,
GtkWidgetHelpType help_type);
@@ -807,6 +809,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->can_activate_accel = gtk_widget_real_can_activate_accel;
klass->grab_broken_event = NULL;
klass->query_tooltip = gtk_widget_real_query_tooltip;
+ klass->style_updated = gtk_widget_real_style_updated;
klass->show_help = gtk_widget_real_show_help;
@@ -1460,6 +1463,15 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_TYPE_NONE, 1,
GTK_TYPE_STYLE);
+ widget_signals[STYLE_UPDATED] =
+ g_signal_new (I_("style-updated"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GtkWidgetClass, style_updated),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
/**
* GtkWidget::direction-changed:
* @widget: the object on which the signal is emitted
@@ -6278,6 +6290,17 @@ gtk_widget_real_query_tooltip (GtkWidget *widget,
return FALSE;
}
+static void
+gtk_widget_real_style_updated (GtkWidget *widget)
+{
+ GtkStyleContext *context;
+
+ context = g_object_get_qdata (G_OBJECT (widget),
+ quark_style_context);
+ if (context)
+ gtk_style_context_invalidate (context);
+}
+
static gboolean
gtk_widget_real_show_help (GtkWidget *widget,
GtkWidgetHelpType help_type)
@@ -13341,6 +13364,15 @@ gtk_widget_get_path (GtkWidget *widget)
return path;
}
+static void
+style_context_changed (GtkStyleContext *context,
+ gpointer user_data)
+{
+ GtkWidget *widget = user_data;
+
+ g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
+}
+
GtkStyleContext *
gtk_widget_get_style_context (GtkWidget *widget)
{
@@ -13362,6 +13394,8 @@ gtk_widget_get_style_context (GtkWidget *widget)
"direction", gtk_widget_get_direction (widget),
NULL);
+ g_signal_connect (context, "changed",
+ G_CALLBACK (style_context_changed), widget);
g_object_set_qdata_full (G_OBJECT (widget),
quark_style_context, context,
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index bcb5674..df90d42 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -380,6 +380,8 @@ struct _GtkWidgetClass
void (* adjust_size_allocation) (GtkWidget *widget,
GtkAllocation *allocation);
+ void (* style_updated) (GtkWidget *widget);
+
/*< private >*/
/* Signals without a C default handler class slot:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]