[libgda] GdaBrowser: transaction status in query exec history
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgda] GdaBrowser: transaction status in query exec history
- Date: Sun, 13 Sep 2009 13:26:16 +0000 (UTC)
commit b1a5b4fdd2769ae49453d3b7dbb43e23b4a2f2b8
Author: Vivien Malerba <malerba gnome-db org>
Date: Sat Sep 12 14:28:03 2009 +0200
GdaBrowser: transaction status in query exec history
history items for statements executed while in
a transaction can be identified by the left
margin which is bigger.
tools/browser/browser-connection.c | 13 +++++++++++++
tools/browser/browser-connection.h | 1 +
tools/browser/doc/gda-browser-sections.txt | 1 +
tools/browser/query-exec/query-console.c | 8 ++++++++
tools/browser/query-exec/query-editor.c | 8 +++-----
tools/browser/query-exec/query-editor.h | 1 +
6 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/tools/browser/browser-connection.c b/tools/browser/browser-connection.c
index 2aeb4a5..6deda85 100644
--- a/tools/browser/browser-connection.c
+++ b/tools/browser/browser-connection.c
@@ -637,6 +637,19 @@ browser_connection_get_dictionary_file (BrowserConnection *bcnc)
}
/**
+ * browser_connection_get_transaction_status
+ * @bcnc: a #BrowserConnection
+ *
+ * Retuns: the #GdaTransactionStatus of the connection, or %NULL
+ */
+GdaTransactionStatus *
+browser_connection_get_transaction_status (BrowserConnection *bcnc)
+{
+ g_return_val_if_fail (BROWSER_IS_CONNECTION (bcnc), NULL);
+ return gda_connection_get_transaction_status (bcnc->priv->cnc);
+}
+
+/**
* browser_connection_get_favorites
* @bcnc: a #BrowserConnection
*
diff --git a/tools/browser/browser-connection.h b/tools/browser/browser-connection.h
index c9b03db..90a51df 100644
--- a/tools/browser/browser-connection.h
+++ b/tools/browser/browser-connection.h
@@ -64,6 +64,7 @@ void browser_connection_update_meta_data (BrowserConnection
GdaMetaStruct *browser_connection_get_meta_struct (BrowserConnection *bcnc);
GdaMetaStore *browser_connection_get_meta_store (BrowserConnection *bcnc);
const gchar *browser_connection_get_dictionary_file (BrowserConnection *bcnc);
+GdaTransactionStatus *browser_connection_get_transaction_status (BrowserConnection *bcnc);
BrowserFavorites *browser_connection_get_favorites (BrowserConnection *bcnc);
diff --git a/tools/browser/doc/gda-browser-sections.txt b/tools/browser/doc/gda-browser-sections.txt
index 6df6895..678f2a8 100644
--- a/tools/browser/doc/gda-browser-sections.txt
+++ b/tools/browser/doc/gda-browser-sections.txt
@@ -154,6 +154,7 @@ browser_connection_create_parser
browser_connection_render_pretty_sql
browser_connection_execute_statement
browser_connection_execution_get_result
+browser_connection_get_transaction_status
<SUBSECTION Standard>
BROWSER_CONNECTION
BROWSER_IS_CONNECTION
diff --git a/tools/browser/query-exec/query-console.c b/tools/browser/query-exec/query-console.c
index 27c565d..9ae295d 100644
--- a/tools/browser/query-exec/query-console.c
+++ b/tools/browser/query-exec/query-console.c
@@ -60,6 +60,7 @@ static void execution_batch_free (ExecutionBatch *ebatch);
typedef struct {
GdaStatement *stmt /* no ref held here */;
+ gboolean within_transaction;
GError *exec_error;
GObject *result;
guint exec_id; /* 0 when execution not requested */
@@ -868,6 +869,8 @@ sql_execute_clicked_cb (GtkButton *button, QueryConsole *tconsole)
ebatch->statements = g_slist_prepend (ebatch->statements, estmt);
if (list == stmt_list) {
+ estmt->within_transaction =
+ browser_connection_get_transaction_status (tconsole->priv->bcnc) ? TRUE : FALSE;
estmt->exec_id = browser_connection_execute_statement (tconsole->priv->bcnc,
estmt->stmt,
tconsole->priv->params,
@@ -919,6 +922,9 @@ query_exec_fetch_cb (QueryConsole *tconsole)
history = query_editor_history_item_new (sqlst->sql,
estmt->result, estmt->exec_error);
gda_sql_statement_free (sqlst);
+
+ history->within_transaction = estmt->within_transaction;
+
if (estmt->exec_error) {
browser_show_error (GTK_WINDOW (gtk_widget_get_toplevel ((GtkWidget*) tconsole)),
_("Error executing query:\n%s"),
@@ -944,6 +950,8 @@ query_exec_fetch_cb (QueryConsole *tconsole)
/* more to do ? */
if (tconsole->priv->current_exec->statements) {
estmt = (ExecutionStatement*) tconsole->priv->current_exec->statements->data;
+ estmt->within_transaction =
+ browser_connection_get_transaction_status (tconsole->priv->bcnc) ? TRUE : FALSE;
estmt->exec_id = browser_connection_execute_statement (tconsole->priv->bcnc,
estmt->stmt,
tconsole->priv->params,
diff --git a/tools/browser/query-exec/query-editor.c b/tools/browser/query-exec/query-editor.c
index 08695e7..79bb52e 100644
--- a/tools/browser/query-exec/query-editor.c
+++ b/tools/browser/query-exec/query-editor.c
@@ -335,11 +335,7 @@ text_view_expose_event (GtkTextView *tv, GdkEventExpose *event, QueryEditor *edi
redraw_rect.height = visible_rect.height;
gc = GTK_WIDGET (tv)->style->bg_gc[GTK_WIDGET_STATE (GTK_WIDGET (tv))];
-
- if (tv->hadjustment)
- margin = gtk_text_view_get_left_margin (tv) - (int) tv->hadjustment->value;
- else
- margin = gtk_text_view_get_left_margin (tv);
+ margin = gtk_text_view_get_left_margin (tv);
gdk_draw_rectangle (event->window,
gc,
@@ -962,6 +958,8 @@ query_editor_add_history_item (QueryEditor *editor, QueryEditorHistoryItem *hist
"scale", 0.75,
"foreground", "gray",
"foreground-set", TRUE, NULL);
+ if (hist_item->within_transaction)
+ g_object_set (G_OBJECT (tag), "left-margin", 15, NULL);
hdata->tag = g_object_ref (tag);
g_hash_table_insert (editor->priv->hash, tag, hist_item_data_ref (hdata));
diff --git a/tools/browser/query-exec/query-editor.h b/tools/browser/query-exec/query-editor.h
index c5bdb39..d18e703 100644
--- a/tools/browser/query-exec/query-editor.h
+++ b/tools/browser/query-exec/query-editor.h
@@ -46,6 +46,7 @@ typedef struct {
gchar *sql;
GObject *result;
GError *exec_error;
+ gboolean within_transaction;
gint ref_count;
} QueryEditorHistoryItem;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]