[libgda/LIBGDA_4.2] Added gdaui_[gs]et_default_path()



commit 4620adf753eb4cbcb8a33b545d03e8f12f150a14
Author: Vivien Malerba <malerba gnome-db org>
Date:   Mon Jun 6 20:49:17 2011 +0200

    Added gdaui_[gs]et_default_path()

 doc/C/libgda-4.0-docs.sgml                         |    3 ++
 doc/C/libgda-ui-sections.txt                       |    2 +
 libgda-ui/data-entries/plugins/common-pict.c       |   13 +++++--
 .../data-entries/plugins/gdaui-entry-filesel.c     |    9 +++--
 libgda-ui/gdaui-decl.h                             |    9 +----
 libgda-ui/gdaui-init.c                             |   37 ++++++++++++++++++++
 libgda-ui/gdaui-raw-grid.c                         |   13 +++----
 libgda-ui/gdaui-rt-editor.c                        |    8 +++--
 libgda-ui/libgda-ui.h                              |   16 +++++++--
 libgda-ui/libgda-ui.symbols                        |    2 +
 libgda/libgda.symbols                              |    1 -
 tools/browser/canvas/browser-canvas.c              |    8 +++--
 tools/browser/common/gdaui-data-import.c           |    9 ++---
 tools/browser/ldap-browser/entry-properties.c      |    4 ++
 14 files changed, 98 insertions(+), 36 deletions(-)
---
diff --git a/doc/C/libgda-4.0-docs.sgml b/doc/C/libgda-4.0-docs.sgml
index 4bc0ca4..36a9011 100644
--- a/doc/C/libgda-4.0-docs.sgml
+++ b/doc/C/libgda-4.0-docs.sgml
@@ -1855,6 +1855,9 @@ g_object_unref (eng);
     <index id="index-4-2-8" role="4.2.8">
       <title>Index of new symbols in 4.2.8</title>
     </index>
+    <index id="index-4-2-9" role="4.2.9">
+      <title>Index of new symbols in 4.2.9</title>
+    </index>
     <index id="index-deprecated" role="deprecated">
       <title>Index of deprecated symbols</title>
     </index>
diff --git a/doc/C/libgda-ui-sections.txt b/doc/C/libgda-ui-sections.txt
index 21cae09..13656e3 100644
--- a/doc/C/libgda-ui-sections.txt
+++ b/doc/C/libgda-ui-sections.txt
@@ -2,6 +2,8 @@
 <FILE>libgdaui</FILE>
 <TITLE>LibgdaUI Initialization</TITLE>
 gdaui_init
+gdaui_get_default_path
+gdaui_set_default_path
 <SUBSECTION Standard>
 </SECTION>
 
diff --git a/libgda-ui/data-entries/plugins/common-pict.c b/libgda-ui/data-entries/plugins/common-pict.c
index 23cd2bd..943fbb7 100644
--- a/libgda-ui/data-entries/plugins/common-pict.c
+++ b/libgda-ui/data-entries/plugins/common-pict.c
@@ -1,5 +1,5 @@
-/* common-pict.c
- * Copyright (C) 2006 - 2007 Vivien Malerba <malerba gnome-db org>
+/*
+ * Copyright (C) 2006 - 2011 Vivien Malerba <malerba gnome-db org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <libgda/gda-quark-list.h>
 #include <libgda/gda-blob-op.h>
+#include <libgda-ui/libgda-ui.h>
 
 /*
  * Fills in @bindata->data and @bindata->data_length with the contents of @value.
@@ -345,7 +346,9 @@ file_load_cb (GtkWidget *button, PictMenuData *menudata)
 	filter = gtk_file_filter_new ();
 	gtk_file_filter_add_pixbuf_formats (filter);
 	gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dlg), filter);
-	
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlg),
+					     gdaui_get_default_path ());	
+
 	if (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_ACCEPT) {
 		char *filename;
 		gsize length;
@@ -353,6 +356,7 @@ file_load_cb (GtkWidget *button, PictMenuData *menudata)
 		gchar *data;
 
 		filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
+		gdaui_set_default_path (gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dlg)));
 
 		if (g_file_get_contents (filename, &data, &length, &error)) {
 			if (menudata->bindata->data) {
@@ -466,6 +470,8 @@ file_save_cb (GtkWidget *button, PictMenuData *menudata)
 					   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 					   GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
 					   NULL);
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlg),
+					     gdaui_get_default_path ());
 
 	gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dlg), expander);
 	if (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_ACCEPT) {
@@ -476,6 +482,7 @@ file_save_cb (GtkWidget *button, PictMenuData *menudata)
 
 		format = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
 		filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
+		gdaui_set_default_path (gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dlg)));
 
 		if (format == 0) {
 			/* save data AS IS */
diff --git a/libgda-ui/data-entries/plugins/gdaui-entry-filesel.c b/libgda-ui/data-entries/plugins/gdaui-entry-filesel.c
index e7ca003..728ffe7 100644
--- a/libgda-ui/data-entries/plugins/gdaui-entry-filesel.c
+++ b/libgda-ui/data-entries/plugins/gdaui-entry-filesel.c
@@ -1,6 +1,5 @@
-/* gdaui-entry-filesel.c
- *
- * Copyright (C) 2005 - 2010 Vivien Malerba
+/*
+ * Copyright (C) 2005 - 2011 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
@@ -21,6 +20,7 @@
 #include <glib/gi18n-lib.h>
 #include "gdaui-entry-filesel.h"
 #include <libgda/gda-data-handler.h>
+#include <libgda-ui/libgda-ui.h>
 
 /* 
  * Main static functions 
@@ -201,6 +201,8 @@ button_clicked_cb (G_GNUC_UNUSED GtkWidget *button, GdauiEntryFilesel *filesel)
 					   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 					   GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT,
 					   NULL);
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlg),
+					     gdaui_get_default_path ());
 		
 	result = gtk_dialog_run (GTK_DIALOG (dlg));
 	if (result == GTK_RESPONSE_ACCEPT) {
@@ -209,6 +211,7 @@ button_clicked_cb (G_GNUC_UNUSED GtkWidget *button, GdauiEntryFilesel *filesel)
 		file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
 		gtk_entry_set_text (GTK_ENTRY (filesel->priv->entry), file);
 		g_free (file);
+		gdaui_set_default_path (gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dlg)));
 	}
 	gtk_widget_destroy (dlg);
 }
diff --git a/libgda-ui/gdaui-decl.h b/libgda-ui/gdaui-decl.h
index 5cfb529..2170e56 100644
--- a/libgda-ui/gdaui-decl.h
+++ b/libgda-ui/gdaui-decl.h
@@ -1,6 +1,5 @@
-/* gdaui-decl.h
- *
- * Copyright (C) 2003 - 2009 Vivien Malerba <malerba gnome-db org>
+/*
+ * Copyright (C) 2003 - 2011 Vivien Malerba <malerba gnome-db org>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -43,8 +42,4 @@ typedef struct _GdauiDataProxyIface  GdauiDataProxyIface;
 #define GDAUI_COLOR_NORMAL_INVALID "#ff6a6a"
 #define GDAUI_COLOR_PRELIGHT_INVALID "#ff7b7b"
 
-#define GDAUI_REFERER_ACTIVE   "#e0ffe0"
-#define GDAUI_REFERER_INACTIVE "#ffe0e0"
-#define GDAUI_REFERER_UNKNOWN  "#e0e0ff"
-
 #endif
diff --git a/libgda-ui/gdaui-init.c b/libgda-ui/gdaui-init.c
index 3523cb7..7fa556f 100644
--- a/libgda-ui/gdaui-init.c
+++ b/libgda-ui/gdaui-init.c
@@ -735,3 +735,40 @@ get_spec_with_isocodes (const gchar *file)
 
 	return retval;
 }
+
+static gchar *gdaui_path = NULL;
+
+/**
+ * gdaui_get_default_path:
+ *
+ * Get the default path used when saving a file, or when showing a #GtkFileChooser file chooser.
+ * When the application starts, the default path will be the same as the onde returned by
+ * g_get_current_dir().
+ *
+ * Returns: (transfer none): the default path, or %NULL
+ *
+ * Since: 4.2.9
+ */
+const gchar *
+gdaui_get_default_path (void)
+{
+	if (! gdaui_path)
+		gdaui_path = g_get_current_dir ();
+	return gdaui_path;
+}
+
+/**
+ * gdaui_set_default_path:
+ *
+ * Define the default path used when saving a file, or when showing a #GtkFileChooser file chooser.
+ *
+ * Since: 4.2.9
+ */
+void
+gdaui_set_default_path (const gchar *path)
+{
+	g_free (gdaui_path);
+	gdaui_path = NULL;
+	if (path)
+		gdaui_path = g_strdup (path);
+}
diff --git a/libgda-ui/gdaui-raw-grid.c b/libgda-ui/gdaui-raw-grid.c
index 82a1fd7..2fd445e 100644
--- a/libgda-ui/gdaui-raw-grid.c
+++ b/libgda-ui/gdaui-raw-grid.c
@@ -21,13 +21,9 @@
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n-lib.h>
 #include <libgda/libgda.h>
-#include "gdaui-raw-grid.h"
-#include "gdaui-data-proxy.h"
-#include "gdaui-data-filter.h"
-#include "gdaui-data-selector.h"
+#include <libgda-ui.h>
 #include "internal/utility.h"
 #include "marshallers/gdaui-marshal.h"
-#include "gdaui-easy.h"
 #include "data-entries/gdaui-data-cell-renderer-combo.h"
 #include "data-entries/gdaui-data-cell-renderer-info.h"
 #include <libgda/binreloc/gda-binreloc.h>
@@ -850,7 +846,7 @@ create_columns_data (GdauiRawGrid *grid)
 
 /* keep track of the columns shown and hidden */
 static void
-column_visibility_changed (GtkTreeViewColumn *column, GParamSpec *pspec, ColumnData *cdata)
+column_visibility_changed (GtkTreeViewColumn *column, G_GNUC_UNUSED GParamSpec *pspec, ColumnData *cdata)
 {
 	cdata->hidden = !gtk_tree_view_column_get_visible (column);
 }
@@ -1780,7 +1776,7 @@ static GtkWidget *new_check_menu_item (const gchar *label,
 				       gpointer user_data);
 
 static void
-hidden_column_mitem_toggled_cb (GtkCheckMenuItem *check, GdauiRawGrid *grid)
+hidden_column_mitem_toggled_cb (GtkCheckMenuItem *check, G_GNUC_UNUSED GdauiRawGrid *grid)
 {
 	ColumnData *cdata;
 	gboolean act;
@@ -1993,6 +1989,8 @@ menu_save_as_cb (G_GNUC_UNUSED GtkWidget *widget, GdauiRawGrid *grid)
 	g_object_set_data (G_OBJECT (dialog), "filename", filename);
 	gtk_box_pack_start (GTK_BOX (hbox), filename, TRUE, TRUE, 0);
 	gtk_widget_show (filename);
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filename),
+					     gdaui_get_default_path ());
 
 	str = g_strdup_printf ("<b>%s:</b>", _("Details"));
 	label = gtk_label_new ("");
@@ -2138,6 +2136,7 @@ save_as_response_cb (GtkDialog *dialog, gint response_id, GdauiRawGrid *grid)
 
 		types = g_object_get_data (G_OBJECT (dialog), "types");
 		filename = g_object_get_data (G_OBJECT (dialog), "filename");
+		gdaui_set_default_path (gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (filename)));
 		selection_only = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
 							       (g_object_get_data (G_OBJECT (dialog), "sel_only")));
 		null_as_empty = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
diff --git a/libgda-ui/gdaui-rt-editor.c b/libgda-ui/gdaui-rt-editor.c
index f8ddee1..1fe2ea6 100644
--- a/libgda-ui/gdaui-rt-editor.c
+++ b/libgda-ui/gdaui-rt-editor.c
@@ -1,5 +1,4 @@
-/* gdaui-rt-editor.c
- *
+/*
  * Copyright (C) 2010 - 2011 Vivien Malerba <malerba gnome-db org>
  *
  * This Library is free software; you can redistribute it and/or
@@ -19,13 +18,13 @@
  */
 
 #include <string.h>
-#include "gdaui-rt-editor.h"
 #include <glib/gi18n-lib.h>
 #include <gdk-pixbuf/gdk-pixdata.h>
 #include "bullet.h"
 #include "bulleth.h"
 #define MAX_BULLETS 2
 //gchar * bullet_strings[] = {"â?¢", "â?¦"};
+#include <libgda-ui.h>
 
 GdkPixbuf *bullet_pix[MAX_BULLETS] = {NULL};
 gchar     *lists_tokens[MAX_BULLETS] = {"- ", " - "};
@@ -675,6 +674,8 @@ add_image_cb (G_GNUC_UNUSED GtkAction *action, GdauiRtEditor *rte)
                                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                            GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                                            NULL);
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlg),
+					     gdaui_get_default_path ());
         filter = gtk_file_filter_new ();
         gtk_file_filter_add_pixbuf_formats (filter);
         gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dlg), filter);
@@ -684,6 +685,7 @@ add_image_cb (G_GNUC_UNUSED GtkAction *action, GdauiRtEditor *rte)
                 GError *error = NULL;
 
                 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
+		gdaui_set_default_path (gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dlg)));
 
 		GdkPixbuf *pixbuf;
 		pixbuf = gdk_pixbuf_new_from_file (filename, &error);
diff --git a/libgda-ui/libgda-ui.h b/libgda-ui/libgda-ui.h
index 05cbf64..ae6433a 100644
--- a/libgda-ui/libgda-ui.h
+++ b/libgda-ui/libgda-ui.h
@@ -1,5 +1,5 @@
-/* GDA library
- * Copyright (C) 2009 - 2010 The GNOME Foundation.
+/*
+ * Copyright (C) 2009 - 2011 The GNOME Foundation.
  *
  * AUTHORS:
  *      Vivien Malerba <malerba gnome-db org>
@@ -48,7 +48,17 @@
 
 G_BEGIN_DECLS
 
-void gdaui_init (void);
+/**
+ * SECTION:libgdaui
+ * @short_description: Library initialization and information
+ * @title: Library initialization
+ * @stability: Stable
+ * @see_also:
+ */
+
+void         gdaui_init (void);
+const gchar *gdaui_get_default_path (void);
+void         gdaui_set_default_path (const gchar *path);
 
 G_END_DECLS
 
diff --git a/libgda-ui/libgda-ui.symbols b/libgda-ui/libgda-ui.symbols
index 97ec1d8..81731ba 100644
--- a/libgda-ui/libgda-ui.symbols
+++ b/libgda-ui/libgda-ui.symbols
@@ -135,6 +135,7 @@
 	gdaui_formatted_entry_set_insert_func
 	gdaui_form_get_type
 	gdaui_form_new
+	gdaui_get_default_path
 	gdaui_grid_get_type
 	gdaui_grid_new
 	gdaui_grid_set_sample_size
@@ -172,6 +173,7 @@
 	gdaui_server_operation_get_type
 	gdaui_server_operation_new
 	gdaui_server_operation_new_in_dialog
+	gdaui_set_default_path
 	gdaui_tree_store_get_iter
 	gdaui_tree_store_get_node
 	gdaui_tree_store_get_type
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index 53c5ef7..29f3ad6 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -849,7 +849,6 @@
 	gda_transaction_status_add_event_sql
 	gda_transaction_status_add_event_sub
 	gda_transaction_status_add_event_svp
-	gda_transaction_status_dump
 	gda_transaction_status_event_type_get_type
 	gda_transaction_status_find
 	gda_transaction_status_find_current
diff --git a/tools/browser/canvas/browser-canvas.c b/tools/browser/canvas/browser-canvas.c
index 5006407..46503e4 100644
--- a/tools/browser/canvas/browser-canvas.c
+++ b/tools/browser/canvas/browser-canvas.c
@@ -1,6 +1,5 @@
-/* browser-canvas.c
- *
- * Copyright (C) 2007 - 2009 Vivien Malerba
+/*
+ * Copyright (C) 2007 - 2011 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
@@ -509,6 +508,8 @@ popup_export_cb (G_GNUC_UNUSED GtkMenuItem *mitem, BrowserCanvas *canvas)
 					   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 					   GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
 					   NULL);
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlg),
+					     gdaui_get_default_path ());
 	filter = gtk_file_filter_new ();
 	gtk_file_filter_set_name (filter, _("PNG Image"));
 	gtk_file_filter_add_mime_type (filter, "image/png");
@@ -525,6 +526,7 @@ popup_export_cb (G_GNUC_UNUSED GtkMenuItem *mitem, BrowserCanvas *canvas)
 		gchar *lcfilename;
 		cairo_surface_t *surface = NULL;
 
+		gdaui_set_default_path (gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dlg)));
 		filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
 		if (filename) {
 			GooCanvasBounds bounds;
diff --git a/tools/browser/common/gdaui-data-import.c b/tools/browser/common/gdaui-data-import.c
index 643df28..3fedced 100644
--- a/tools/browser/common/gdaui-data-import.c
+++ b/tools/browser/common/gdaui-data-import.c
@@ -21,12 +21,7 @@
 #include "gdaui-data-import.h"
 #include <libgda/libgda.h>
 #include <glib/gi18n-lib.h>
-#include <libgda-ui/gdaui-combo.h>
-#include <libgda-ui/gdaui-grid.h>
-#include <libgda-ui/gdaui-raw-grid.h>
-#include <libgda-ui/gdaui-data-proxy.h>
-#include <libgda-ui/gdaui-data-proxy-info.h>
-#include <libgda-ui/gdaui-data-selector.h>
+#include <libgda-ui/libgda-ui.h>
 #include <libgda/binreloc/gda-binreloc.h>
 
 static void gdaui_data_import_class_init (GdauiDataImportClass *class);
@@ -144,6 +139,7 @@ gdaui_data_import_init (GdauiDataImport * import)
 	gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_SHRINK | GTK_FILL, 0, 0, 0);
 
 	entry = gtk_file_chooser_button_new (_("File to import data from"), GTK_FILE_CHOOSER_ACTION_OPEN);
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (entry), gdaui_get_default_path ());
 	import->priv->file_chooser = entry;
 	filter = gtk_file_filter_new ();
 	gtk_file_filter_set_name (filter, _("Comma separated values"));
@@ -425,6 +421,7 @@ spec_changed_cb (GtkWidget *wid, GdauiDataImport *import)
 			      GDAUI_DATA_PROXY_INFO_CURRENT_ROW, NULL);
 		gtk_box_pack_start (GTK_BOX (import->priv->preview_box), import->priv->preview_grid, TRUE, TRUE, 0);
 		gtk_widget_show (import->priv->preview_grid);
+		gdaui_set_default_path (gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (import->priv->file_chooser)));
 	}
 	else 
 		gtk_widget_show (import->priv->no_data_label);
diff --git a/tools/browser/ldap-browser/entry-properties.c b/tools/browser/ldap-browser/entry-properties.c
index 43367e7..52f5a44 100644
--- a/tools/browser/ldap-browser/entry-properties.c
+++ b/tools/browser/ldap-browser/entry-properties.c
@@ -27,6 +27,7 @@
 #include "entry-properties.h"
 #include "marshal.h"
 #include <time.h>
+#include <libgda-ui/libgda-ui.h>
 
 struct _EntryPropertiesPrivate {
 	BrowserConnection *bcnc;
@@ -220,6 +221,8 @@ data_save_cb (GtkWidget *mitem, EntryProperties *eprop)
 					      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 					      GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
 					      NULL);
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
+					     gdaui_get_default_path ());
 	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
 		char *filename;
 		GValue *binvalue;
@@ -237,6 +240,7 @@ data_save_cb (GtkWidget *mitem, EntryProperties *eprop)
 					    lerror && lerror->message ? lerror->message : _("No detail"));
 			g_clear_error (&lerror);
 		}
+		gdaui_set_default_path (gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)));
 		g_free (filename);
 	}
 	gtk_widget_destroy (dialog);



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