[gtk+/gtk-style-context: 17/191] GtkWidget: Add gtk_widget_get_style_context().
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 17/191] GtkWidget: Add gtk_widget_get_style_context().
- Date: Tue, 17 Aug 2010 13:49:38 +0000 (UTC)
commit 12dc06b1c8f85feb04993ea2c586bd509d0add66
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Mar 10 00:55:48 2010 +0100
GtkWidget: Add gtk_widget_get_style_context().
There will be one GtkStyleContext per widget, at the moment its
lifetime is tied to the widget's, but it could be narrowed down
to GTK_WIDGET_REALIZED.
gtk/gtkwidget.c | 23 +++++++++++++++++++++++
gtk/gtkwidget.h | 4 ++++
2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b27207c..35d48a6 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -54,6 +54,7 @@
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtkextendedlayout.h"
+#include "gtkstylecontext.h"
#include "gtkalias.h"
/**
@@ -389,6 +390,7 @@ static GQuark quark_mnemonic_labels = 0;
static GQuark quark_tooltip_markup = 0;
static GQuark quark_has_tooltip = 0;
static GQuark quark_tooltip_window = 0;
+static GQuark quark_style_context = 0;
GParamSpecPool *_gtk_widget_child_property_pool = NULL;
GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL;
@@ -485,6 +487,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
quark_tooltip_markup = g_quark_from_static_string ("gtk-tooltip-markup");
quark_has_tooltip = g_quark_from_static_string ("gtk-has-tooltip");
quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window");
+ quark_style_context = g_quark_from_static_string ("gtk-style-context");
style_property_spec_pool = g_param_spec_pool_new (FALSE);
_gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
@@ -11487,5 +11490,25 @@ gtk_widget_send_focus_change (GtkWidget *widget,
return res;
}
+GtkStyleContext *
+gtk_widget_get_style_context (GtkWidget *widget)
+{
+ GtkStyleContext *context;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ context = g_object_get_qdata (G_OBJECT (widget),
+ quark_style_context);
+
+ if (G_UNLIKELY (!context))
+ {
+ context = g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL);
+ g_object_set_qdata_full (widget, quark_style_context, context,
+ (GDestroyNotify) g_object_unref);
+ }
+
+ return context;
+}
+
#define __GTK_WIDGET_C__
#include "gtkaliasdef.c"
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 760d7ce..d6bdcd2 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -37,6 +37,7 @@
#include <gtk/gtkadjustment.h>
#include <gtk/gtkstyle.h>
#include <gtk/gtksettings.h>
+#include <gtk/gtkstylecontext.h>
#include <atk/atk.h>
G_BEGIN_DECLS
@@ -1345,6 +1346,9 @@ void _gtk_widget_buildable_finish_accelerator (GtkWidget *widget,
GtkWidget *toplevel,
gpointer user_data);
+GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget);
+
+
G_END_DECLS
#endif /* __GTK_WIDGET_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]