[anjuta-extras] symbol-db: Fixes bgo #612089 - Styles choosen for class-inheritance is broken for some themes
- From: Naba Kumar <naba src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta-extras] symbol-db: Fixes bgo #612089 - Styles choosen for class-inheritance is broken for some themes
- Date: Sun, 28 Mar 2010 18:56:39 +0000 (UTC)
commit 62c62afc4d021b18bd2a5a4141254beea38d7fc9
Author: Naba Kumar <naba gnome org>
Date: Sun Mar 28 21:50:03 2010 +0300
symbol-db: Fixes bgo #612089 - Styles choosen for class-inheritance is broken for some themes
plugins/class-inheritance/class-callbacks.c | 101 ++++++++++++++++++++------
plugins/class-inheritance/class-inherit.c | 52 +++++++-------
plugins/class-inheritance/class-inherit.h | 1 -
plugins/class-inheritance/plugin.h | 17 +++++
4 files changed, 121 insertions(+), 50 deletions(-)
---
diff --git a/plugins/class-inheritance/class-callbacks.c b/plugins/class-inheritance/class-callbacks.c
index a10a9f6..4628420 100644
--- a/plugins/class-inheritance/class-callbacks.c
+++ b/plugins/class-inheritance/class-callbacks.c
@@ -65,6 +65,8 @@ gint
on_expanded_class_title_event (GnomeCanvasItem *item, GdkEvent *event,
ClsNode *cls_node)
{
+ GnomeCanvasItem *text_item;
+ text_item = g_object_get_data (G_OBJECT (item), "__text__");
switch (event->type)
{
case GDK_BUTTON_PRESS: /* single click */
@@ -77,17 +79,25 @@ on_expanded_class_title_event (GnomeCanvasItem *item, GdkEvent *event,
}
break;
- case GDK_ENTER_NOTIFY: /* mouse entered in item's area */
+ case GDK_ENTER_NOTIFY: /* mouse entered in title's area */
gnome_canvas_item_set (item,
"fill_color_gdk",
- &cls_node->canvas->style->bg[GTK_STATE_PRELIGHT],
+ &cls_node->plugin->style[STYLE_TITLE_PRELIGHT_BG],
+ NULL);
+ gnome_canvas_item_set (text_item,
+ "fill_color_gdk",
+ &cls_node->plugin->style[STYLE_TITLE_PRELIGHT_FG],
NULL);
return TRUE;
- case GDK_LEAVE_NOTIFY: /* mouse exited item's area */
+ case GDK_LEAVE_NOTIFY: /* mouse exited title's area */
gnome_canvas_item_set (item,
"fill_color_gdk",
- &cls_node->canvas->style->bg[GTK_STATE_ACTIVE],
+ &cls_node->plugin->style[STYLE_TITLE_BG],
+ NULL);
+ gnome_canvas_item_set (text_item,
+ "fill_color_gdk",
+ &cls_node->plugin->style[STYLE_TITLE_FG],
NULL);
return TRUE;
default:
@@ -97,19 +107,14 @@ on_expanded_class_title_event (GnomeCanvasItem *item, GdkEvent *event,
}
static GnomeCanvasItem*
-create_class_item_tooltip (GtkWidget *canvas, const gchar *tooltip_text)
+create_class_item_tooltip (ClsNode *cls_node, const gchar *tooltip_text)
{
- GtkWidget *styler;
GnomeCanvasItem *group, *canvas_item, *text_item;
gdouble text_width_value, text_height_value;
- styler = gtk_label_new (NULL);
- gtk_widget_set_name (styler, "gtk-tooltip");
- gtk_widget_ensure_style (styler);
-
group =
gnome_canvas_item_new (gnome_canvas_root
- (GNOME_CANVAS (canvas)),
+ (GNOME_CANVAS (cls_node->canvas)),
gnome_canvas_group_get_type (),
NULL);
@@ -120,7 +125,7 @@ create_class_item_tooltip (GtkWidget *canvas, const gchar *tooltip_text)
"justification", GTK_JUSTIFY_LEFT,
"anchor", GTK_ANCHOR_CENTER,
"fill_color_gdk",
- &canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_ITEM_FG],
NULL);
g_object_get (text_item, "text_width", &text_width_value,
@@ -163,7 +168,7 @@ create_class_item_tooltip (GtkWidget *canvas, const gchar *tooltip_text)
gnome_canvas_polygon_get_type (),
"points", points,
"fill_color_gdk",
- &styler->style->base[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_ITEM_BG],
NULL);
/* border */
canvas_item =
@@ -171,7 +176,7 @@ create_class_item_tooltip (GtkWidget *canvas, const gchar *tooltip_text)
gnome_canvas_line_get_type (),
"points", points,
"fill_color_gdk",
- &canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_ITEM_FG],
NULL);
/* shadow */
canvas_item =
@@ -179,7 +184,7 @@ create_class_item_tooltip (GtkWidget *canvas, const gchar *tooltip_text)
gnome_canvas_polygon_get_type (),
"points", points,
"fill_color_gdk",
- &canvas->style->dark[GTK_STATE_ACTIVE],
+ &cls_node->plugin->style[STYLE_TITLE_BG],
NULL);
gnome_canvas_points_unref (points);
@@ -209,7 +214,7 @@ on_canvas_item_show_tooltip_timeout (ClsNodeItem *node_item)
tooltip = g_strdup_printf (_("Args: %s"), node_item->args);
node_item->tooltip =
- create_class_item_tooltip (node_item->cls_node->canvas, tooltip);
+ create_class_item_tooltip (node_item->cls_node, tooltip);
g_free (tooltip);
g_object_get (node_item->cls_node->canvas_group, "x", &x, "y", &y, NULL);
@@ -231,6 +236,9 @@ on_expanded_class_item_event (GnomeCanvasItem *item, GdkEvent *event,
{
AnjutaClassInheritance *plugin;
ClsNodeItem *node_item;
+ GnomeCanvasItem *text_item;
+
+ text_item = g_object_get_data (G_OBJECT (item), "__text__");
node_item = (ClsNodeItem*)data;
plugin = node_item->cls_node->plugin;
@@ -258,7 +266,11 @@ on_expanded_class_item_event (GnomeCanvasItem *item, GdkEvent *event,
case GDK_ENTER_NOTIFY: /* mouse entered in item's area */
gnome_canvas_item_set (node_item->canvas_node_item,
"fill_color_gdk",
- &node_item->cls_node->canvas->style->base[GTK_STATE_SELECTED],
+ &node_item->cls_node->plugin->style[STYLE_ITEM_PRELIGHT_BG],
+ NULL);
+ gnome_canvas_item_set (text_item,
+ "fill_color_gdk",
+ &node_item->cls_node->plugin->style[STYLE_ITEM_PRELIGHT_FG],
NULL);
/* Show tooltip */
if (!node_item->tooltip)
@@ -275,7 +287,11 @@ on_expanded_class_item_event (GnomeCanvasItem *item, GdkEvent *event,
case GDK_LEAVE_NOTIFY: /* mouse exited item's area */
gnome_canvas_item_set (node_item->canvas_node_item,
"fill_color_gdk",
- &node_item->cls_node->canvas->style->base[GTK_STATE_NORMAL],
+ &node_item->cls_node->plugin->style[STYLE_ITEM_BG],
+ NULL);
+ gnome_canvas_item_set (text_item,
+ "fill_color_gdk",
+ &node_item->cls_node->plugin->style[STYLE_ITEM_FG],
NULL);
/* Hide tooltip */
if (node_item->tooltip_timeout)
@@ -296,6 +312,8 @@ gint
on_expanded_class_more_event (GnomeCanvasItem *item, GdkEvent *event,
ClsNode *cls_node)
{
+ GnomeCanvasItem *text_item;
+ text_item = g_object_get_data (G_OBJECT (item), "__text__");
switch (event->type)
{
case GDK_2BUTTON_PRESS: /* double click */
@@ -310,17 +328,25 @@ on_expanded_class_more_event (GnomeCanvasItem *item, GdkEvent *event,
}
break;
- case GDK_ENTER_NOTIFY: /* mouse entered in item's area */
+ case GDK_ENTER_NOTIFY: /* mouse entered in more's area */
gnome_canvas_item_set (item,
"fill_color_gdk",
- &cls_node->canvas->style->bg[GTK_STATE_PRELIGHT],
+ &cls_node->plugin->style[STYLE_TITLE_PRELIGHT_BG],
+ NULL);
+ gnome_canvas_item_set (text_item,
+ "fill_color_gdk",
+ &cls_node->plugin->style[STYLE_TITLE_PRELIGHT_FG],
NULL);
return TRUE;
case GDK_LEAVE_NOTIFY: /* mouse exited item's area */
gnome_canvas_item_set (item,
"fill_color_gdk",
- &cls_node->canvas->style->bg[GTK_STATE_ACTIVE],
+ &cls_node->plugin->style[STYLE_TITLE_BG],
+ NULL);
+ gnome_canvas_item_set (text_item,
+ "fill_color_gdk",
+ &cls_node->plugin->style[STYLE_TITLE_FG],
NULL);
return TRUE;
default:
@@ -335,6 +361,8 @@ on_collapsed_class_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{
AnjutaClassInheritance *plugin;
ClsNode *cls_node;
+ GnomeCanvasItem *text_item;
+ text_item = g_object_get_data (G_OBJECT (item), "__text__");
cls_node = (ClsNode*)data;
plugin = cls_node->plugin;
@@ -356,7 +384,11 @@ on_collapsed_class_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
/* Make the outline wide */
gnome_canvas_item_set (item,
"fill_color_gdk",
- &plugin->canvas->style->base[GTK_STATE_SELECTED],
+ &cls_node->plugin->style[STYLE_ITEM_PRELIGHT_BG],
+ NULL);
+ gnome_canvas_item_set (text_item,
+ "fill_color_gdk",
+ &cls_node->plugin->style[STYLE_ITEM_PRELIGHT_FG],
NULL);
return TRUE;
@@ -364,7 +396,11 @@ on_collapsed_class_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
/* Make the outline thin */
gnome_canvas_item_set (item,
"fill_color_gdk",
- &plugin->canvas->style->base[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_BG],
+ NULL);
+ gnome_canvas_item_set (text_item,
+ "fill_color_gdk",
+ &cls_node->plugin->style[STYLE_FG],
NULL);
return TRUE;
default:
@@ -391,5 +427,22 @@ void
on_style_set (GtkWidget *widget, GtkStyle *previous_style,
AnjutaClassInheritance *plugin)
{
- cls_inherit_update (plugin);
+ GtkStyle *style = plugin->canvas->style;
+
+ plugin->style[STYLE_BG] = style->base[GTK_STATE_NORMAL];
+ plugin->style[STYLE_FG] = style->text[GTK_STATE_NORMAL];
+ plugin->style[STYLE_TITLE_FG] = style->fg[GTK_STATE_ACTIVE];
+ plugin->style[STYLE_TITLE_BG] = style->bg[GTK_STATE_ACTIVE];
+ plugin->style[STYLE_TITLE_PRELIGHT_FG] = style->fg[GTK_STATE_PRELIGHT];
+ plugin->style[STYLE_TITLE_PRELIGHT_BG] = style->bg[GTK_STATE_PRELIGHT];
+ plugin->style[STYLE_ITEM_FG] = style->text[GTK_STATE_NORMAL];
+ plugin->style[STYLE_ITEM_BG] = style->base[GTK_STATE_NORMAL];
+ plugin->style[STYLE_ITEM_PRELIGHT_FG] = style->text[GTK_STATE_SELECTED];
+ plugin->style[STYLE_ITEM_PRELIGHT_BG] = style->base[GTK_STATE_SELECTED];
+
+ /* Use text background (normally white) for canvas background */
+ style->bg[GTK_STATE_NORMAL] = plugin->style[STYLE_BG];
+
+ /* FIXME: */
+ /* cls_inherit_update (plugin); */
}
diff --git a/plugins/class-inheritance/class-inherit.c b/plugins/class-inheritance/class-inherit.c
index 1eac3fb..bba6fca 100644
--- a/plugins/class-inheritance/class-inherit.c
+++ b/plugins/class-inheritance/class-inherit.c
@@ -567,7 +567,7 @@ cls_node_draw_expanded (ClsNode *cls_node)
"x2", (gdouble) cls_node->width,
"y2", (gdouble) item_height,
"fill_color_gdk",
- &cls_node->canvas->style->bg[GTK_STATE_ACTIVE],
+ &cls_node->plugin->style[STYLE_TITLE_BG],
NULL);
g_signal_connect (GTK_OBJECT (canvas_item), "event",
@@ -577,7 +577,7 @@ cls_node_draw_expanded (ClsNode *cls_node)
/* Arrow on the right of class title */
create_canvas_arrow_item (GNOME_CANVAS_GROUP (cls_node->canvas_group),
CLS_ARROW_DIR_DOWN,
- &cls_node->canvas->style->fg[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_TITLE_FG],
cls_node->width - item_height,
0, cls_node->width, item_height);
/* Class title text */
@@ -590,9 +590,10 @@ cls_node_draw_expanded (ClsNode *cls_node)
"x", (gdouble) 20.0,
"y", (gdouble) (j + 0.5) * item_height,
"fill_color_gdk",
- &cls_node->canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_TITLE_FG],
"anchor", GTK_ANCHOR_W,
NULL);
+ g_object_set_data (G_OBJECT (canvas_item), "__text__", text_item);
g_signal_connect (GTK_OBJECT (text_item), "event",
G_CALLBACK (on_canvas_event_proxy),
canvas_item);
@@ -612,7 +613,7 @@ cls_node_draw_expanded (ClsNode *cls_node)
"x2", (gdouble) cls_node->width,
"y2", (gdouble) (j + 1) * item_height,
"fill_color_gdk",
- &cls_node->canvas->style->base[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_ITEM_BG],
NULL);
g_signal_connect (GTK_OBJECT (node_item->canvas_node_item),
"event",
@@ -629,9 +630,11 @@ cls_node_draw_expanded (ClsNode *cls_node)
"x", (gdouble) 20.0,
"y", (gdouble) (j + 0.5) * item_height,
"fill_color_gdk",
- &cls_node->canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_ITEM_FG],
"anchor", GTK_ANCHOR_W,
NULL);
+ g_object_set_data (G_OBJECT (node_item->canvas_node_item),
+ "__text__", text_item);
g_signal_connect (GTK_OBJECT (text_item), "event",
G_CALLBACK (on_canvas_event_proxy),
node_item->canvas_node_item);
@@ -647,7 +650,7 @@ cls_node_draw_expanded (ClsNode *cls_node)
NULL);
if (node_item->order == 0 || j == 1) /* Variables and methods border */
create_canvas_line_item (GNOME_CANVAS_GROUP (cls_node->canvas_group),
- &cls_node->canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_FG],
0, j * item_height,
cls_node->width, j * item_height);
j++;
@@ -666,7 +669,7 @@ cls_node_draw_expanded (ClsNode *cls_node)
"x2", (gdouble) cls_node->width,
"y2", (gdouble) (j + 1) * item_height,
"fill_color_gdk",
- &cls_node->canvas->style->bg[GTK_STATE_ACTIVE],
+ &cls_node->plugin->style[STYLE_TITLE_BG],
NULL);
g_signal_connect (GTK_OBJECT (canvas_item), "event",
@@ -683,15 +686,16 @@ cls_node_draw_expanded (ClsNode *cls_node)
"x", (gdouble) 20.0,
"y", (gdouble) (j + 0.5) * item_height,
"fill_color_gdk",
- &cls_node->canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_TITLE_FG],
"anchor", GTK_ANCHOR_W,
NULL);
+ g_object_set_data (G_OBJECT (canvas_item), "__text__", text_item);
g_signal_connect (GTK_OBJECT (text_item), "event",
G_CALLBACK (on_canvas_event_proxy),
canvas_item);
create_canvas_line_item (GNOME_CANVAS_GROUP (cls_node->canvas_group),
- &cls_node->canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_FG],
0, j * item_height,
cls_node->width, j * item_height);
}
@@ -704,7 +708,7 @@ cls_node_draw_expanded (ClsNode *cls_node)
"x2", (gdouble) cls_node->width,
"y2", (gdouble) cls_node->height,
"outline_color_gdk",
- &cls_node->canvas->style->text[GTK_STATE_ACTIVE],
+ &cls_node->plugin->style[STYLE_FG],
"width_units", 1.0,
NULL);
}
@@ -740,9 +744,9 @@ cls_node_draw_collapsed (ClsNode *cls_node)
"x2", (gdouble) cls_node->width,
"y2", (gdouble) cls_node->height,
"fill_color_gdk",
- &cls_node->canvas->style->base[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_BG],
"outline_color_gdk",
- &cls_node->canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_FG],
"width_units", 1.0,
NULL);
g_signal_connect (GTK_OBJECT (item), "event",
@@ -759,9 +763,10 @@ cls_node_draw_collapsed (ClsNode *cls_node)
"x", (gdouble) 0.0,
"y", (gdouble) cls_node->height/2,
"fill_color_gdk",
- &cls_node->canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node->plugin->style[STYLE_FG],
"anchor", GTK_ANCHOR_W,
NULL );
+ g_object_set_data (G_OBJECT (item), "__text__", text_item);
g_signal_connect (GTK_OBJECT (text_item), "event",
G_CALLBACK (on_canvas_event_proxy), item);
@@ -837,7 +842,7 @@ cls_node_draw_edge (ClsNode *cls_node_to, ClsNodeEdge *cls_edge, ClsNode *cls_no
gnome_canvas_bpath_get_type(),
"bpath", path_def,
"outline_color_gdk",
- &cls_node_from->canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node_from->plugin->style[STYLE_FG],
"width_pixels", 2,
NULL);
}
@@ -883,7 +888,7 @@ cls_node_draw_edge (ClsNode *cls_node_to, ClsNodeEdge *cls_edge, ClsNode *cls_no
gnome_canvas_line_get_type(),
"points", points,
"fill_color_gdk",
- &cls_node_from->canvas->style->text[GTK_STATE_NORMAL],
+ &cls_node_from->plugin->style[STYLE_FG],
"last_arrowhead", TRUE,
"arrow_shape_a", 10.0,
"arrow_shape_b", 10.0,
@@ -1169,22 +1174,19 @@ cls_inherit_init (AnjutaClassInheritance *plugin)
CANVAS_MIN_SIZE/2,
CANVAS_MIN_SIZE/2);
gtk_container_add (GTK_CONTAINER (s_window), plugin->canvas);
-
- /* Use text background (normally white) for canvas background */
- gtk_widget_modify_bg (plugin->canvas, GTK_STATE_NORMAL,
- &plugin->canvas->style->base[GTK_STATE_NORMAL]);
+
+ /* Initialize styles */
+ gtk_widget_ensure_style (plugin->canvas);
+ on_style_set (plugin->canvas, NULL, plugin);
g_signal_connect (G_OBJECT (plugin->canvas), "event",
G_CALLBACK (on_canvas_event),
plugin);
- /*
- g_signal_connect (G_OBJECT (plugin->canvas),
- "style_set",
- G_CALLBACK (on_style_set),
- plugin);
- */
+ g_signal_connect (G_OBJECT (plugin->canvas), "style_set",
+ G_CALLBACK (on_style_set), plugin);
plugin->widget = gtk_vbox_new (FALSE, 2);
+
/* --packing-- */
/* vbox */
gtk_box_pack_start (GTK_BOX (plugin->widget), s_window, TRUE, TRUE, TRUE);
diff --git a/plugins/class-inheritance/class-inherit.h b/plugins/class-inheritance/class-inherit.h
index 8cc6308..0d50e64 100644
--- a/plugins/class-inheritance/class-inherit.h
+++ b/plugins/class-inheritance/class-inherit.h
@@ -72,7 +72,6 @@ typedef struct
/* Used during update scan */
gboolean marked_for_deletion;
-
} ClsNode;
typedef struct {
diff --git a/plugins/class-inheritance/plugin.h b/plugins/class-inheritance/plugin.h
index 270c3f1..f1b72a4 100644
--- a/plugins/class-inheritance/plugin.h
+++ b/plugins/class-inheritance/plugin.h
@@ -41,6 +41,20 @@ extern GType class_inheritance_get_type (GTypeModule *module);
typedef struct _AnjutaClassInheritance AnjutaClassInheritance;
typedef struct _AnjutaClassInheritanceClass AnjutaClassInheritanceClass;
+enum {
+ STYLE_BG,
+ STYLE_FG,
+ STYLE_TITLE_BG,
+ STYLE_TITLE_FG,
+ STYLE_TITLE_PRELIGHT_FG,
+ STYLE_TITLE_PRELIGHT_BG,
+ STYLE_ITEM_BG,
+ STYLE_ITEM_FG,
+ STYLE_ITEM_PRELIGHT_FG,
+ STYLE_ITEM_PRELIGHT_BG,
+ N_STYLES
+};
+
struct _AnjutaClassInheritance {
AnjutaPlugin parent;
@@ -59,6 +73,9 @@ struct _AnjutaClassInheritance {
gchar *top_dir;
guint root_watch_id;
gint uiid;
+
+ /* Style colors */
+ GdkColor style[N_STYLES];
};
struct _AnjutaClassInheritanceClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]