[libgda] Browser: avoid displaying the same table several times in the canvas
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Subject: [libgda] Browser: avoid displaying the same table several times in the canvas
- Date: Mon, 29 Jun 2009 20:05:27 +0000 (UTC)
commit 392ce0226e9035063f5d0a206bafa244206acc6e
Author: Vivien Malerba <malerba gnome-db org>
Date: Thu Jun 25 21:05:07 2009 +0200
Browser: avoid displaying the same table several times in the canvas
tools/browser/canvas/browser-canvas-db-relations.c | 6 +++++-
tools/browser/canvas/browser-canvas.c | 4 ++--
tools/browser/schema-browser/table-relations.c | 10 ++++++++++
3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/tools/browser/canvas/browser-canvas-db-relations.c b/tools/browser/canvas/browser-canvas-db-relations.c
index ea50309..4e71463 100644
--- a/tools/browser/canvas/browser-canvas-db-relations.c
+++ b/tools/browser/canvas/browser-canvas-db-relations.c
@@ -429,10 +429,14 @@ browser_canvas_db_relations_add_table (BrowserCanvasDbRelations *canvas,
gdouble x = 0, y = 0;
GooCanvasItem *table_item;
+ table_item = g_hash_table_lookup (canvas->priv->hash_tables, mtable);
+ if (table_item)
+ return BROWSER_CANVAS_TABLE (table_item);
+
table_item = browser_canvas_table_new (goo_canvas_get_root_item (goocanvas),
mtable, x, y, NULL);
g_hash_table_insert (canvas->priv->hash_tables, mtable, table_item);
- g_hash_table_insert (canvas->priv->hash_tables,table_item, mtable);
+ g_hash_table_insert (canvas->priv->hash_tables, table_item, mtable);
canvas->priv->all_items = g_slist_prepend (canvas->priv->all_items, table_item);
g_object_set (G_OBJECT (table_item),
"popup_menu_func", canvas_entity_popup_func, NULL);
diff --git a/tools/browser/canvas/browser-canvas.c b/tools/browser/canvas/browser-canvas.c
index dfcae3d..15d2911 100644
--- a/tools/browser/canvas/browser-canvas.c
+++ b/tools/browser/canvas/browser-canvas.c
@@ -1,6 +1,6 @@
/* browser-canvas.c
*
- * Copyright (C) 2007 - 2008 Vivien Malerba
+ * Copyright (C) 2007 - 2009 Vivien Malerba
*
* This Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
@@ -390,7 +390,7 @@ popup_export_cb (GtkMenuItem *mitem, BrowserCanvas *canvas)
cairo_set_line_width (cr, goo_canvas_get_default_line_width (canvas->priv->goocanvas));
cairo_translate (cr, MARGIN - bounds.x1, MARGIN - bounds.y1);
- goo_canvas_render (GOO_CANVAS (canvas), cr, NULL, 0.8);
+ goo_canvas_render (canvas->priv->goocanvas, cr, NULL, 0.8);
cairo_show_page (cr);
diff --git a/tools/browser/schema-browser/table-relations.c b/tools/browser/schema-browser/table-relations.c
index c04dd2f..1328335 100644
--- a/tools/browser/schema-browser/table-relations.c
+++ b/tools/browser/schema-browser/table-relations.c
@@ -37,6 +37,7 @@ struct _TableRelationsPrivate {
BrowserConnection *bcnc;
TableInfo *tinfo;
GtkWidget *canvas;
+ gboolean all_schemas;
};
static void table_relations_class_init (TableRelationsClass *klass);
@@ -73,6 +74,7 @@ static void
table_relations_init (TableRelations *trels, TableRelationsClass *klass)
{
trels->priv = g_new0 (TableRelationsPrivate, 1);
+ trels->priv->all_schemas = FALSE;
}
static void
@@ -138,6 +140,9 @@ meta_changed_cb (BrowserConnection *bcnc, GdaMetaStruct *mstruct, TableRelations
GSList *list;
for (list = table->reverse_fk_list; list; list = list->next) {
GdaMetaTableForeignKey *fkey = (GdaMetaTableForeignKey*) list->data;
+ if (! trels->priv->all_schemas &&
+ ! strcmp (fkey->meta_table->obj_short_name, fkey->meta_table->obj_full_name))
+ continue;
g_value_set_string (tname, fkey->meta_table->obj_name);
g_value_set_string (tschema, fkey->meta_table->obj_schema);
browser_canvas_db_relations_add_table (BROWSER_CANVAS_DB_RELATIONS (trels->priv->canvas),
@@ -147,6 +152,11 @@ meta_changed_cb (BrowserConnection *bcnc, GdaMetaStruct *mstruct, TableRelations
for (list = table->fk_list; list; list = list->next) {
GdaMetaTableForeignKey *fkey = (GdaMetaTableForeignKey*) list->data;
+
+ if (! trels->priv->all_schemas &&
+ ! strcmp (fkey->depend_on->obj_short_name, fkey->depend_on->obj_full_name))
+ continue;
+
g_value_set_string (tname, fkey->depend_on->obj_name);
g_value_set_string (tschema, fkey->depend_on->obj_schema);
browser_canvas_db_relations_add_table (BROWSER_CANVAS_DB_RELATIONS (trels->priv->canvas),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]