[anjuta/class-inheritance-yap] class-inheritance: Fixed styling and font size mismatch.



commit f2d50a49336f46b14e2e143487ccb9adea2ed630
Author: Naba Kumar <naba gnome org>
Date:   Sat Jul 9 12:55:51 2011 +0300

    class-inheritance: Fixed styling and font size mismatch.

 plugins/class-inheritance/class-callbacks.c |  119 ++++++++++++++------------
 plugins/class-inheritance/class-inherit.c   |   67 +++++++++-------
 plugins/class-inheritance/plugin.h          |    2 +-
 3 files changed, 103 insertions(+), 85 deletions(-)
---
diff --git a/plugins/class-inheritance/class-callbacks.c b/plugins/class-inheritance/class-callbacks.c
index 0051bea..a707626 100644
--- a/plugins/class-inheritance/class-callbacks.c
+++ b/plugins/class-inheritance/class-callbacks.c
@@ -81,23 +81,23 @@ on_expanded_class_title_event (GooCanvasItem *item, GdkEvent *event,
 		
 	case GDK_ENTER_NOTIFY:		/* mouse entered in title's area */
 		g_object_set (G_OBJECT (item),
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_PRELIGHT_BG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_PRELIGHT_BG],
 		                     NULL);
 		g_object_set (G_OBJECT (text_item),
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_PRELIGHT_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_PRELIGHT_FG],
 		                     NULL);
 		return TRUE;
 
 	case GDK_LEAVE_NOTIFY:		/* mouse exited title's area */
 		g_object_set (G_OBJECT (item),
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_BG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_BG],
 		                     NULL);
 		g_object_set (G_OBJECT (text_item),
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_FG],
 		                     NULL);
 		return TRUE;
 	default:
@@ -120,8 +120,8 @@ create_class_item_tooltip (ClsNode *cls_node, const gchar *tooltip_text)
 	text_item =
 		goo_canvas_text_new (group, tooltip_text, 0, 0, -1,
 		                     GOO_CANVAS_ANCHOR_CENTER,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_ITEM_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_ITEM_FG],
 		                     NULL);
 	
 	g_object_get (text_item, "text_width", &text_width_value,
@@ -162,17 +162,17 @@ create_class_item_tooltip (ClsNode *cls_node, const gchar *tooltip_text)
 	fore_canvas_item =
 		goo_canvas_polyline_new (group, TRUE, 0,
 		                     "points", points,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_ITEM_BG],
-		                     "outline_color_gdk",
-		                     &cls_node->plugin->style[STYLE_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_ITEM_BG],
+		                     "stroke_color_rgba",
+		                     cls_node->plugin->style[STYLE_FG],
 		                     NULL);
 	/* shadow */
 	canvas_item =
 		goo_canvas_polyline_new (group, TRUE, 0,
 		                     "points", points,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_BG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_BG],
 		                     NULL);
 	goo_canvas_points_unref (points);
 
@@ -253,12 +253,12 @@ on_expanded_class_item_event (GooCanvasItem *item, GdkEvent *event,
 		
 	case GDK_ENTER_NOTIFY:		/* mouse entered in item's area */
 		g_object_set (node_item->canvas_node_item,
-		                     "fill_color_gdk",
-		                     &node_item->cls_node->plugin->style[STYLE_ITEM_PRELIGHT_BG],
+		                     "fill_color_rgba",
+		                     node_item->cls_node->plugin->style[STYLE_ITEM_PRELIGHT_BG],
 		                     NULL);
 		g_object_set (text_item,
-		                     "fill_color_gdk",
-		                     &node_item->cls_node->plugin->style[STYLE_ITEM_PRELIGHT_FG],
+		                     "fill_color_rgba",
+		                     node_item->cls_node->plugin->style[STYLE_ITEM_PRELIGHT_FG],
 		                     NULL);
 		/* Show tooltip */
 		if (!node_item->tooltip)
@@ -274,12 +274,12 @@ on_expanded_class_item_event (GooCanvasItem *item, GdkEvent *event,
 
 	case GDK_LEAVE_NOTIFY:		/* mouse exited item's area */
 		g_object_set (node_item->canvas_node_item,
-		                     "fill_color_gdk",
-		                     &node_item->cls_node->plugin->style[STYLE_ITEM_BG],
+		                     "fill_color_rgba",
+		                     node_item->cls_node->plugin->style[STYLE_ITEM_BG],
 		                     NULL);
 		g_object_set (text_item,
-		                     "fill_color_gdk",
-		                     &node_item->cls_node->plugin->style[STYLE_ITEM_FG],
+		                     "fill_color_rgba",
+		                     node_item->cls_node->plugin->style[STYLE_ITEM_FG],
 		                     NULL);
 		/* Hide tooltip */
 		if (node_item->tooltip_timeout)
@@ -318,23 +318,23 @@ on_expanded_class_more_event (GooCanvasItem *item, GdkEvent *event,
 		
 	case GDK_ENTER_NOTIFY:		/* mouse entered in more's area */
 		g_object_set (item,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_PRELIGHT_BG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_PRELIGHT_BG],
 		                     NULL);
 		g_object_set (text_item,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_PRELIGHT_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_PRELIGHT_FG],
 		                     NULL);
 		return TRUE;
 
 	case GDK_LEAVE_NOTIFY:		/* mouse exited item's area */
 		g_object_set (item,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_BG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_BG],
 		                     NULL);
 		g_object_set (text_item,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_FG],
 		                     NULL);
 		return TRUE;
 	default:
@@ -371,24 +371,24 @@ on_collapsed_class_event (GooCanvasItem *item, GdkEvent *event, gpointer data)
 	case GDK_ENTER_NOTIFY:		/* mouse entered in item's area */
 		/* Make the outline wide */
 		g_object_set (item,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_ITEM_PRELIGHT_BG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_ITEM_PRELIGHT_BG],
 		                     NULL);
 		g_object_set (text_item,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_ITEM_PRELIGHT_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_ITEM_PRELIGHT_FG],
 		                     NULL);
 		return TRUE;
 
 	case GDK_LEAVE_NOTIFY:		/* mouse exited item's area */
 		/* Make the outline thin */
 		g_object_set (item,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_BG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_BG],
 		                     NULL);
 		g_object_set (text_item,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_FG],
 		                     NULL);
 		return TRUE;
 	default:
@@ -408,6 +408,17 @@ on_update_menu_item_selected (GtkMenuItem *item,
 	cls_inherit_update (plugin);
 }
 
+static guint
+gdk_color_to_rgba (GdkColor *color)
+{
+	guint rgba = 0;
+	rgba |= (color->red) >> 8; rgba <<= 8;
+	rgba |= (color->green) >> 8; rgba <<= 8;
+	rgba |= (color->blue) >> 8; rgba <<= 8;
+	rgba |= 0xFF;
+	return rgba;
+}
+
 /*----------------------------------------------------------------------------
  * callback for theme/colors changes
  */
@@ -415,24 +426,22 @@ void
 on_style_set (GtkWidget *widget, GtkStyle  *previous_style,
 			  AnjutaClassInheritance *plugin)
 {
-#if 0
-	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];
+	GtkStyle *style = gtk_widget_get_style (plugin->canvas);
+
+	plugin->style[STYLE_BG] = gdk_color_to_rgba (&style->base[GTK_STATE_NORMAL]);
+	plugin->style[STYLE_FG] = gdk_color_to_rgba (&style->text[GTK_STATE_NORMAL]);
+	plugin->style[STYLE_TITLE_FG] = gdk_color_to_rgba (&style->fg[GTK_STATE_ACTIVE]);
+	plugin->style[STYLE_TITLE_BG] = gdk_color_to_rgba (&style->bg[GTK_STATE_ACTIVE]);
+	plugin->style[STYLE_TITLE_PRELIGHT_FG] = gdk_color_to_rgba (&style->fg[GTK_STATE_PRELIGHT]);
+	plugin->style[STYLE_TITLE_PRELIGHT_BG] = gdk_color_to_rgba (&style->bg[GTK_STATE_PRELIGHT]);
+	plugin->style[STYLE_ITEM_FG] = gdk_color_to_rgba (&style->text[GTK_STATE_NORMAL]);
+	plugin->style[STYLE_ITEM_BG] = gdk_color_to_rgba (&style->base[GTK_STATE_NORMAL]);
+	plugin->style[STYLE_ITEM_PRELIGHT_FG] = gdk_color_to_rgba (&style->text[GTK_STATE_SELECTED]);
+	plugin->style[STYLE_ITEM_PRELIGHT_BG] = gdk_color_to_rgba (&style->base[GTK_STATE_SELECTED]);
 	
 	/* Use text background (normally white) for canvas background */
-	style->bg[GTK_STATE_NORMAL] = plugin->style[STYLE_BG];
+	/* FIXME: style->bg[GTK_STATE_NORMAL] = plugin->style[STYLE_BG]; */
 
 	/* FIXME: */
 	/* cls_inherit_update (plugin); */
-#endif
 }
diff --git a/plugins/class-inheritance/class-inherit.c b/plugins/class-inheritance/class-inherit.c
index d4adfa3..faeaaab 100644
--- a/plugins/class-inheritance/class-inherit.c
+++ b/plugins/class-inheritance/class-inherit.c
@@ -73,7 +73,7 @@ typedef struct {
 static GooCanvasItem*
 create_canvas_arrow_item (GooCanvasItem *canvas_group,
                           CanvasArrowDir direction,
-                          const GdkColor *fill_color,
+                          guint fill_color,
                           /* Bounding box */
                           gint x1, gint y1, gint x2, gint y2)
 {
@@ -94,14 +94,14 @@ create_canvas_arrow_item (GooCanvasItem *canvas_group,
 
 	item = goo_canvas_polyline_new (canvas_group, TRUE, 0,
 	                            "points", triangle,
-	                            "fill_color_gdk", fill_color,
+	                            "fill_color_rgba", fill_color,
 	                            NULL);
 	goo_canvas_points_unref (triangle);
 	return item;
 }
 
 static GooCanvasItem*
-create_canvas_line_item (GooCanvasItem *canvas_group, GdkColor *fill_color,
+create_canvas_line_item (GooCanvasItem *canvas_group, guint fill_color,
                           gint x1, gint y1, gint x2, gint y2)
 {
 	GooCanvasItem *item;
@@ -116,7 +116,7 @@ create_canvas_line_item (GooCanvasItem *canvas_group, GdkColor *fill_color,
 	item = 
 		goo_canvas_polyline_new (canvas_group, TRUE, 0,
 		                     "points", points,
-		                     "fill_color_gdk",
+		                     "fill_color_rgba",
 		                     fill_color,
 		                     NULL);
 	goo_canvas_points_unref (points);
@@ -576,8 +576,8 @@ cls_node_draw_expanded (ClsNode *cls_node)
 		goo_canvas_rect_new (cls_node->canvas_group,
 		                     0.0, 0.0, (gdouble) cls_node->width,
 		                     (gdouble) item_height,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_BG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_BG],
 		                     NULL);
 	
 	g_signal_connect (G_OBJECT (canvas_item), "event",
@@ -587,7 +587,7 @@ cls_node_draw_expanded (ClsNode *cls_node)
 	/* Arrow on the right of class title */
 	create_canvas_arrow_item (cls_node->canvas_group,
 	                          CLS_ARROW_DIR_DOWN,
-	                          &cls_node->plugin->style[STYLE_TITLE_FG],
+	                          cls_node->plugin->style[STYLE_TITLE_FG],
 	                          cls_node->width - item_height,
 	                          0, cls_node->width, item_height);
 	/* Class title text */
@@ -596,8 +596,10 @@ cls_node_draw_expanded (ClsNode *cls_node)
 		                     cls_node->sym_name, (gdouble) 20.0,
 		                     (gdouble) (j + 0.5) * item_height,
 		                     -1, GOO_CANVAS_ANCHOR_CENTER,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_TITLE_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_TITLE_FG],
+		                     "font_desc",
+		                     gtk_widget_get_style (cls_node->canvas)->font_desc,
 		                     NULL);
 	g_object_set_data (G_OBJECT (canvas_item), "__text__", text_item);
 	g_signal_connect (G_OBJECT (text_item), "event",
@@ -616,8 +618,8 @@ cls_node_draw_expanded (ClsNode *cls_node)
 			                     0.0, (gdouble) j * item_height,
 			                     (gdouble) cls_node->width,
 			                     (gdouble) item_height,
-			                     "fill_color_gdk",
-			                     &cls_node->plugin->style[STYLE_ITEM_BG],
+			                     "fill_color_rgba",
+			                     cls_node->plugin->style[STYLE_ITEM_BG],
 			                     NULL);
 		g_signal_connect (G_OBJECT (node_item->canvas_node_item),
 			              "event",
@@ -631,8 +633,10 @@ cls_node_draw_expanded (ClsNode *cls_node)
 			                     (gdouble) 20.0,
 			                     (gdouble) (j + 0.5) * item_height,
 			                     -1, GOO_CANVAS_ANCHOR_CENTER,
-			                     "fill_color_gdk",
-			                     &cls_node->plugin->style[STYLE_ITEM_FG],
+			                     "fill_color_rgba",
+			                     cls_node->plugin->style[STYLE_ITEM_FG],
+			                     "font_desc",
+			                     gtk_widget_get_style (cls_node->canvas)->font_desc,
 			                     NULL);
 		g_object_set_data (G_OBJECT (node_item->canvas_node_item),
 		                   "__text__", text_item);
@@ -648,7 +652,7 @@ cls_node_draw_expanded (ClsNode *cls_node)
 			                     NULL);
 		if (node_item->order == 0 || j == 1) /* Variables and methods border */
 				create_canvas_line_item (cls_node->canvas_group,
-				                         &cls_node->plugin->style[STYLE_FG],
+				                         cls_node->plugin->style[STYLE_FG],
 				                         0, j * item_height,
 				                         cls_node->width, j * item_height);
 		j++;
@@ -664,8 +668,8 @@ cls_node_draw_expanded (ClsNode *cls_node)
 			                     0.0, (gdouble) j * item_height,
 			                     (gdouble) cls_node->width,
 			                     (gdouble) item_height,
-			                     "fill_color_gdk",
-			                     &cls_node->plugin->style[STYLE_TITLE_BG],
+			                     "fill_color_rgba",
+			                     cls_node->plugin->style[STYLE_TITLE_BG],
 			                     NULL);
 		
 		g_signal_connect (G_OBJECT (canvas_item), "event",
@@ -680,8 +684,10 @@ cls_node_draw_expanded (ClsNode *cls_node)
 			                     (gdouble) (j + 0.5) * item_height,
 			                     -1,
 			                     GOO_CANVAS_ANCHOR_CENTER,
-			                     "fill_color_gdk",
-			                     &cls_node->plugin->style[STYLE_TITLE_FG],
+			                     "fill_color_rgba",
+			                     cls_node->plugin->style[STYLE_TITLE_FG],
+			                     "font_desc",
+			                     gtk_widget_get_style (cls_node->canvas)->font_desc,
 			                     NULL);
 		g_object_set_data (G_OBJECT (canvas_item), "__text__", text_item);
 		g_signal_connect (G_OBJECT (text_item), "event",
@@ -689,7 +695,7 @@ cls_node_draw_expanded (ClsNode *cls_node)
 			              canvas_item);
 
 		create_canvas_line_item (cls_node->canvas_group,
-		                         &cls_node->plugin->style[STYLE_FG],
+		                         cls_node->plugin->style[STYLE_FG],
 		                         0, j * item_height,
 		                         cls_node->width, j * item_height);
 	}
@@ -700,8 +706,8 @@ cls_node_draw_expanded (ClsNode *cls_node)
 	                     (gdouble) 0.0,
 	                     (gdouble) cls_node->width,
 	                     (gdouble) cls_node->height,
-	                     "outline_color_gdk",
-	                     &cls_node->plugin->style[STYLE_FG],
+	                     "stroke_color_rgba",
+	                     cls_node->plugin->style[STYLE_FG],
 	                     NULL);
 }
 
@@ -732,10 +738,10 @@ cls_node_draw_collapsed (ClsNode *cls_node)
 		                     (gdouble) 0.0,
 		                     (gdouble) cls_node->width,
 		                     (gdouble) cls_node->height,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_BG],
-		                     "outline_color_gdk",
-		                     &cls_node->plugin->style[STYLE_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_BG],
+		                     "stroke_color_rgba",
+		                     cls_node->plugin->style[STYLE_FG],
 		                     NULL);
 	g_signal_connect (G_OBJECT (item), "event",
 					  G_CALLBACK (on_collapsed_class_event),
@@ -749,8 +755,10 @@ cls_node_draw_collapsed (ClsNode *cls_node)
 		                     (gdouble) cls_node->height/2,
 		                     -1,
 		                     GOO_CANVAS_ANCHOR_CENTER,
-		                     "fill_color_gdk",
-		                     &cls_node->plugin->style[STYLE_FG],
+		                     "fill_color_rgba",
+		                     cls_node->plugin->style[STYLE_FG],
+		                     "font_desc",
+		                     gtk_widget_get_style (cls_node->canvas)->font_desc,
 		                     NULL );
 	g_object_set_data (G_OBJECT (item), "__text__", text_item);
 	g_signal_connect (G_OBJECT (text_item), "event",
@@ -837,8 +845,8 @@ cls_node_draw_edge (ClsNode *cls_node_to, ClsNodeEdge *cls_edge, ClsNode *cls_no
 					                 "arrow_shape_a", (gdouble) 8.0,
 					                 "arrow_shape_b", (gdouble) 10.0,
 					                 "arrow_shape_c", (gdouble) 3.0,
-					                 "fill_color_gdk",
-					                 &cls_node_from->plugin->style[STYLE_FG],
+					                 "fill_color_rgba",
+					                 cls_node_from->plugin->style[STYLE_FG],
 					                 "points", points,
 					                 NULL);
 		goo_canvas_item_lower (cls_edge->canvas_line, NULL);
@@ -903,6 +911,7 @@ cls_inherit_draw (AnjutaClassInheritance *plugin)
 	ClsBox bounds;
 
 	gvLayout (plugin->gvc, plugin->graph, "dot");
+	/* test: gvRenderFilename (plugin->gvc, plugin->graph, "png", "/tmp/anjuta-ci-0.png"); */
 
 	/* set the size of the canvas. We need this to set the scrolling.. */
 	bounds.x1 = 0;
diff --git a/plugins/class-inheritance/plugin.h b/plugins/class-inheritance/plugin.h
index 4e310fd..c3ce842 100644
--- a/plugins/class-inheritance/plugin.h
+++ b/plugins/class-inheritance/plugin.h
@@ -76,7 +76,7 @@ struct _AnjutaClassInheritance {
 	gint uiid;
 	
 	/* Style colors */
-	GdkColor style[N_STYLES];
+	guint style[N_STYLES];
 
 	/* Search queries */
 	IAnjutaSymbolQuery *query_project;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]