[libgda/gtk3] GdaBrowser: display foreign key policy if known



commit 3896fd9c6946794004867d62aa08db6c2d8e1860
Author: Vivien Malerba <malerba gnome-db org>
Date:   Tue Jan 25 21:27:21 2011 +0100

    GdaBrowser: display foreign key policy if known

 tools/browser/schema-browser/table-columns.c |   44 ++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/tools/browser/schema-browser/table-columns.c b/tools/browser/schema-browser/table-columns.c
index 67fdf48..647a44c 100644
--- a/tools/browser/schema-browser/table-columns.c
+++ b/tools/browser/schema-browser/table-columns.c
@@ -146,6 +146,7 @@ static gboolean key_press_event (GtkWidget *text_view, GdkEventKey *event, Table
 static gboolean event_after (GtkWidget *text_view, GdkEvent *ev, TableColumns *tcolumns);
 static gboolean motion_notify_event (GtkWidget *text_view, GdkEventMotion *event, TableColumns *tcolumns);
 static gboolean visibility_notify_event (GtkWidget *text_view, GdkEventVisibility *event, TableColumns *tcolumns);
+static const gchar *fk_policy_to_string (GdaMetaForeignKeyPolicy policy);
 
 static void
 meta_changed_cb (G_GNUC_UNUSED BrowserConnection *bcnc, GdaMetaStruct *mstruct, TableColumns *tcolumns)
@@ -287,6 +288,26 @@ meta_changed_cb (G_GNUC_UNUSED BrowserConnection *bcnc, GdaMetaStruct *mstruct,
 						}
 					}
 				}
+
+				GdaMetaForeignKeyPolicy policy;
+				policy = GDA_META_TABLE_FOREIGN_KEY_ON_UPDATE_POLICY (fk);
+				if (policy != GDA_META_FOREIGN_KEY_UNKNOWN) {
+					gtk_text_buffer_insert (tbuffer, &current, "\n", -1);
+					/* To translators: the UPDATE is an SQL operation type */
+					gtk_text_buffer_insert (tbuffer, &current, _("Policy on UPDATE"), -1);
+					gtk_text_buffer_insert (tbuffer, &current, ": ", -1);
+					gtk_text_buffer_insert (tbuffer, &current,
+								fk_policy_to_string (policy), -1);
+				}
+				policy = GDA_META_TABLE_FOREIGN_KEY_ON_DELETE_POLICY (fk);
+				if (policy != GDA_META_FOREIGN_KEY_UNKNOWN) {
+					gtk_text_buffer_insert (tbuffer, &current, "\n", -1);
+					/* To translators: the DELETE is an SQL operation type */
+					gtk_text_buffer_insert (tbuffer, &current, _("Policy on DELETE"), -1);
+					gtk_text_buffer_insert (tbuffer, &current, ": ", -1);
+					gtk_text_buffer_insert (tbuffer, &current,
+								fk_policy_to_string (policy), -1);
+				}
 				
 				gtk_text_buffer_insert (tbuffer, &current, "\n\n", -1);
 			}
@@ -401,6 +422,29 @@ meta_changed_cb (G_GNUC_UNUSED BrowserConnection *bcnc, GdaMetaStruct *mstruct,
 	}
 }
 
+static const gchar *
+fk_policy_to_string (GdaMetaForeignKeyPolicy policy)
+{
+	switch (policy) {
+	default:
+		g_assert_not_reached ();
+	case GDA_META_FOREIGN_KEY_UNKNOWN:
+		return _("Unknown");
+	case GDA_META_FOREIGN_KEY_NONE:
+		return _("not enforced");
+	case GDA_META_FOREIGN_KEY_NO_ACTION:
+		return _("stop with error");
+	case GDA_META_FOREIGN_KEY_RESTRICT:
+		return _("stop with error, not deferrable");
+	case GDA_META_FOREIGN_KEY_CASCADE:
+		return _("cascade changes");
+	case GDA_META_FOREIGN_KEY_SET_NULL:
+		return _("set to NULL");
+	case GDA_META_FOREIGN_KEY_SET_DEFAULT:
+		return _("set to default value");
+	}
+}
+
 /**
  * table_columns_new
  *



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