[goffice] GocCanvas: add style context.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GocCanvas: add style context.
- Date: Sun, 24 Mar 2013 13:48:03 +0000 (UTC)
commit 137ed291216692f9c84f48b13ba68ff53bfd723d
Author: Morten Welinder <terra gnome org>
Date: Sun Mar 24 09:47:27 2013 -0400
GocCanvas: add style context.
ChangeLog | 5 ++++
NEWS | 1 +
goffice/canvas/goc-canvas.c | 14 +++++++++---
goffice/canvas/goc-item.c | 44 +++++++++++++++++++++++++++++++++++++++++++
goffice/canvas/goc-item.h | 10 ++++++++-
5 files changed, 69 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b0fd208..7301395 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-23 Morten Welinder <terra gnome org>
+
+ * goffice/canvas/goc-item.c (goc_item_get_style_context): New
+ function.
+
2013-03-22 Morten Welinder <terra gnome org>
* goffice/gtk/go-optionmenu.c (go_option_menu_position): Plug
diff --git a/NEWS b/NEWS
index ea8554c..97165b4 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Morten:
* Rewrite font selector. [#695031]
* Fix GOComboColor signal problem. [#696022]
* Plug leaks.
+ * Enhance canvas with posibility of css.
--------------------------------------------------------------------------
goffice 0.10.1:
diff --git a/goffice/canvas/goc-canvas.c b/goffice/canvas/goc-canvas.c
index 94d20bd..1fd1b52 100644
--- a/goffice/canvas/goc-canvas.c
+++ b/goffice/canvas/goc-canvas.c
@@ -322,12 +322,18 @@ goc_canvas_init (GocCanvas *canvas)
#endif
}
-GSF_CLASS (GocCanvas, goc_canvas,
- goc_canvas_class_init, goc_canvas_init,
#ifdef GOFFICE_WITH_GTK
- GTK_TYPE_LAYOUT)
+#define CANVAS_BASE_TYPE GTK_TYPE_LAYOUT
#else
- G_TYPE_OBJECT)
+#define CANVAS_BASE_TYPE G_TYPE_OBJECT
+#endif
+
+
+GSF_CLASS (GocCanvas, goc_canvas,
+ goc_canvas_class_init, goc_canvas_init,
+ CANVAS_BASE_TYPE)
+#if 0
+;
#endif
/**
diff --git a/goffice/canvas/goc-item.c b/goffice/canvas/goc-item.c
index ab33fcf..367db02 100644
--- a/goffice/canvas/goc-item.c
+++ b/goffice/canvas/goc-item.c
@@ -117,6 +117,10 @@ enum {
static GObjectClass *item_parent_class;
+static GParamSpecPool *style_property_spec_pool;
+static GQuark quark_property_parser;
+static GQuark quark_style_context;
+
static gboolean
goc_item_button_pressed (GocItem *item, int button, double x, double y)
{
@@ -278,6 +282,10 @@ goc_item_class_init (GocItemClass *item_klass)
item_klass->key_pressed = goc_item_key_pressed;
item_klass->key_released = goc_item_key_released;
#endif
+
+ style_property_spec_pool = g_param_spec_pool_new (FALSE);
+ quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
+ quark_style_context = g_quark_from_static_string ("GocItem::style-context");
}
static void
@@ -832,3 +840,39 @@ _goc_item_transform (GocItem const *item, cairo_t *cr, gboolean scaled)
}
cairo_transform (cr, &m);
}
+
+#ifdef GOFFICE_WITH_GTK
+/**
+ * goc_item_get_style_context:
+ * @item: #GocItem
+ *
+ * Returns: (transfer none): The style context to use for the item.
+ */
+GtkStyleContext *
+goc_item_get_style_context (const GocItem *item)
+{
+ GtkStyleContext *context;
+ g_return_val_if_fail (GOC_IS_ITEM (item), NULL);
+
+ context = g_object_get_qdata (G_OBJECT (item), quark_style_context);
+ if (!context) {
+ GtkWidgetPath *path;
+
+ path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path,
+ G_TYPE_FROM_INSTANCE (item));
+
+ context = gtk_style_context_new ();
+ gtk_style_context_set_path (context, path);
+ gtk_style_context_set_parent (context,
+ gtk_widget_get_style_context (GTK_WIDGET (item->canvas)));
+
+ g_object_set_qdata_full (G_OBJECT (item),
+ quark_style_context,
+ context,
+ g_object_unref);
+ }
+
+ return context;
+}
+#endif
diff --git a/goffice/canvas/goc-item.h b/goffice/canvas/goc-item.h
index e7f7590..5dfb00c 100644
--- a/goffice/canvas/goc-item.h
+++ b/goffice/canvas/goc-item.h
@@ -38,6 +38,10 @@ struct _GocItem {
cairo_operator_t op;
cairo_matrix_t transform; /* not used for now */
gboolean transformed; /* TRUE if the matrix is not identity */
+
+ /* FIXME: Next development release needs to add style context and
+ room for expansion. */
+
gpointer priv;
};
@@ -65,8 +69,8 @@ struct _GocItemClass {
gboolean (*key_pressed) (GocItem *item, GdkEventKey* ev);
gboolean (*key_released) (GocItem *item, GdkEventKey* ev);
GdkWindow* (*get_window) (GocItem *item);
- /* <private> */
#endif
+ /* <private> */
void (*reserved1) (void);
void (*reserved2) (void);
void (*reserved3) (void);
@@ -117,6 +121,10 @@ void goc_item_set_operator (GocItem *item, cairo_operator_t op);
cairo_operator_t goc_item_get_operator (GocItem *item);
void goc_item_set_transform (GocItem *item, cairo_matrix_t *m);
+#ifdef GOFFICE_WITH_GTK
+GtkStyleContext *goc_item_get_style_context (const GocItem *item);
+#endif
+
G_END_DECLS
#endif /* GOC_ITEM_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]