[libgda/LIBGDA_5.0] Unified query favorites in GdaSql and GdaBrowser
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_5.0] Unified query favorites in GdaSql and GdaBrowser
- Date: Sun, 22 Jan 2012 22:40:22 +0000 (UTC)
commit a9d3723cdc06f74361e664d3bf5ad810cd1ced57
Author: Vivien Malerba <malerba gnome-db org>
Date: Sat Jan 21 17:13:40 2012 +0100
Unified query favorites in GdaSql and GdaBrowser
GdaSql now uses the same favorites infrastructure as GdaBrowser, while
still being able to load and delete previous saved query buffers
tools/Makefile.am | 2 +
tools/browser/Makefile.am | 2 -
tools/browser/browser-connection-priv.h | 2 +-
tools/browser/browser-connection.c | 8 +-
tools/browser/browser-connection.h | 4 +-
tools/browser/browser-favorites.h | 141 ----
tools/browser/common/Makefile.am | 6 +-
tools/browser/common/favorites-actions.c | 177 +++++
tools/browser/common/favorites-actions.h | 44 ++
tools/browser/common/ui-formgrid.c | 11 +-
tools/browser/data-manager/data-console.c | 22 +-
.../browser/data-manager/data-favorite-selector.c | 39 +-
.../browser/data-manager/data-favorite-selector.h | 2 +-
.../data-manager/data-manager-perspective.c | 7 +-
tools/browser/data-manager/data-source.h | 1 -
tools/browser/doc/gda-browser-sections.txt | 44 +-
tools/browser/doc/gda-browser.types | 4 +-
tools/browser/favorites-test.c | 82 +-
.../ldap-browser/ldap-browser-perspective.c | 15 +-
tools/browser/ldap-browser/ldap-classes-page.c | 10 +-
tools/browser/ldap-browser/ldap-entries-page.c | 10 +-
.../browser/ldap-browser/ldap-favorite-selector.c | 47 +-
.../browser/ldap-browser/ldap-favorite-selector.h | 2 +-
tools/browser/mgr-favorites.c | 36 +-
tools/browser/mgr-favorites.h | 2 +-
tools/browser/query-exec/query-console-page.c | 32 +-
tools/browser/query-exec/query-exec-perspective.c | 4 +-
tools/browser/query-exec/query-favorite-selector.c | 57 +-
tools/browser/query-exec/query-favorite-selector.h | 2 +-
tools/browser/schema-browser/favorite-selector.c | 25 +-
tools/browser/schema-browser/favorite-selector.h | 2 +-
tools/browser/schema-browser/objects-index.c | 2 +-
tools/browser/schema-browser/objects-index.h | 2 +-
tools/browser/schema-browser/relations-diagram.c | 34 +-
.../schema-browser/schema-browser-perspective.c | 18 +-
tools/browser/schema-browser/table-info.c | 10 +-
tools/gda-sql.c | 338 +++++----
tools/gda-sql.h | 14 +-
.../browser-favorites.c => tools-favorites.c} | 763 ++++++++++----------
tools/tools-favorites.h | 130 ++++
40 files changed, 1191 insertions(+), 962 deletions(-)
---
diff --git a/tools/Makefile.am b/tools/Makefile.am
index fcc3fa1..beebc41 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -31,6 +31,8 @@ gda_list_config_5_0_LDADD = \
gda_sql_5_0_SOURCES = \
config-info.h \
config-info.c \
+ tools-favorites.h \
+ tools-favorites.c \
tools-utils.h \
tools-utils.c \
gda-sql.c \
diff --git a/tools/browser/Makefile.am b/tools/browser/Makefile.am
index 9c707b5..319e10b 100644
--- a/tools/browser/Makefile.am
+++ b/tools/browser/Makefile.am
@@ -69,8 +69,6 @@ libbrowser_la_SOURCES=\
browser-connection.c \
browser-connection.h \
browser-connection-priv.h \
- browser-favorites.c \
- browser-favorites.h \
browser-variable.c \
browser-variable.h \
browser-virtual-connection.c \
diff --git a/tools/browser/browser-connection-priv.h b/tools/browser/browser-connection-priv.h
index 8d0c03e..560be16 100644
--- a/tools/browser/browser-connection-priv.h
+++ b/tools/browser/browser-connection-priv.h
@@ -51,7 +51,7 @@ struct _BrowserConnectionPrivate {
GdaMetaStruct *c_mstruct; /* last GdaMetaStruct up to date, ready to be passed as @mstruct */
GdaMetaStruct *mstruct; /* public GdaMetaStruct: once it has been created and is no more modified */
- BrowserFavorites *bfav;
+ ToolsFavorites *bfav;
gboolean busy;
gchar *busy_reason;
diff --git a/tools/browser/browser-connection.c b/tools/browser/browser-connection.c
index 18d9725..ea93c30 100644
--- a/tools/browser/browser-connection.c
+++ b/tools/browser/browser-connection.c
@@ -737,7 +737,7 @@ clear_dsn_info (BrowserConnection *bcnc)
}
static void
-fav_changed_cb (G_GNUC_UNUSED BrowserFavorites *bfav, BrowserConnection *bcnc)
+fav_changed_cb (G_GNUC_UNUSED ToolsFavorites *bfav, BrowserConnection *bcnc)
{
g_signal_emit (bcnc, browser_connection_signals [FAV_CHANGED], 0);
}
@@ -1258,14 +1258,14 @@ browser_connection_rollback (BrowserConnection *bcnc, GError **error)
*
* Get @bcnc's favorites handler
*
- * Returns: (transfer none): the #BrowserFavorites used by @bcnc
+ * Returns: (transfer none): the #ToolsFavorites used by @bcnc
*/
-BrowserFavorites *
+ToolsFavorites *
browser_connection_get_favorites (BrowserConnection *bcnc)
{
g_return_val_if_fail (BROWSER_IS_CONNECTION (bcnc), NULL);
if (!bcnc->priv->bfav && !BROWSER_IS_VIRTUAL_CONNECTION (bcnc)) {
- bcnc->priv->bfav = browser_favorites_new (gda_connection_get_meta_store (bcnc->priv->cnc));
+ bcnc->priv->bfav = tools_favorites_new (gda_connection_get_meta_store (bcnc->priv->cnc));
g_signal_connect (bcnc->priv->bfav, "favorites-changed",
G_CALLBACK (fav_changed_cb), bcnc);
}
diff --git a/tools/browser/browser-connection.h b/tools/browser/browser-connection.h
index e6f8cff..868f091 100644
--- a/tools/browser/browser-connection.h
+++ b/tools/browser/browser-connection.h
@@ -20,7 +20,7 @@
#define __BROWSER_CONNECTION_H_
#include <libgda/libgda.h>
-#include "browser-favorites.h"
+#include "../tools-favorites.h"
#include "decl.h"
#include "support.h"
#ifdef HAVE_LDAP
@@ -87,7 +87,7 @@ GdaMetaStruct *browser_connection_get_meta_struct (BrowserConnection
GdaMetaStore *browser_connection_get_meta_store (BrowserConnection *bcnc);
const gchar *browser_connection_get_dictionary_file (BrowserConnection *bcnc);
-BrowserFavorites *browser_connection_get_favorites (BrowserConnection *bcnc);
+ToolsFavorites *browser_connection_get_favorites (BrowserConnection *bcnc);
gchar **browser_connection_get_completions (BrowserConnection *bcnc, const gchar *sql,
gint start, gint end);
diff --git a/tools/browser/common/Makefile.am b/tools/browser/common/Makefile.am
index 4924ee3..30c40fd 100644
--- a/tools/browser/common/Makefile.am
+++ b/tools/browser/common/Makefile.am
@@ -34,7 +34,11 @@ libcommon_la_SOURCES = \
fk-declare.c \
fk-declare.h \
widget-overlay.c \
- widget-overlay.h
+ widget-overlay.h \
+ favorites-actions.c \
+ favorites-actions.h \
+ ../../tools-favorites.h \
+ ../../tools-favorites.c
$(OBJECTS): marshal.c marshal.h
diff --git a/tools/browser/common/favorites-actions.c b/tools/browser/common/favorites-actions.c
new file mode 100644
index 0000000..779f972
--- /dev/null
+++ b/tools/browser/common/favorites-actions.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2009 - 2010 Murray Cumming <murrayc murrayc com>
+ * Copyright (C) 2009 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2010 David King <davidk openismus com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <string.h>
+#include <glib/gi18n-lib.h>
+#include "favorites-actions.h"
+#include "../browser-connection.h"
+#include <libgda/gda-sql-builder.h>
+#include <sql-parser/gda-sql-parser.h>
+
+static gint
+actions_sort_func (ToolsFavoriteAction *act1, ToolsFavoriteAction *act2)
+{
+ return act2->nb_bound - act1->nb_bound;
+}
+
+/**
+ * tools_favorites_get_actions
+ * @bfav: a #ToolsFavorites
+ * @bcnc: a #BrowserConnection
+ * @set: a #GdaSet
+ *
+ * Get a list of #ToolsFavoriteAction which can be executed with the data in @set.
+ *
+ * Returns: a new list of #ToolsFavoriteAction, free list with tools_favorites_free_actions()
+ */
+GSList *
+tools_favorites_get_actions (ToolsFavorites *bfav, BrowserConnection *bcnc, GdaSet *set)
+{
+ GSList *fav_list, *list, *retlist = NULL;
+ g_return_val_if_fail (TOOLS_IS_FAVORITES (bfav), NULL);
+ g_return_val_if_fail (BROWSER_IS_CONNECTION (bcnc), NULL);
+ g_return_val_if_fail (!set || GDA_IS_SET (set), NULL);
+
+ fav_list = tools_favorites_list (bfav, 0, TOOLS_FAVORITES_ACTIONS, -1, NULL);
+ if (! fav_list)
+ return NULL;
+
+ for (list = fav_list; list; list = list->next) {
+ ToolsFavoritesAttributes *fa = (ToolsFavoritesAttributes*) list->data;
+ ToolsFavoritesAttributes qfa;
+ if (! g_str_has_prefix (fa->contents, "QUERY")) {
+ g_warning ("Malformed action contents '%s', please report error to "
+ "http://bugzilla.gnome.org/ for the \"libgda\" product",
+ fa->contents);
+ continue;
+ }
+ if (tools_favorites_get (bfav, atoi (fa->contents + 5), &qfa, NULL)) {
+ GdaSet *params;
+ GSList *plist;
+ GdaBatch *batch;
+ GdaStatement *stmt = NULL;
+ GdaSqlParser *parser;
+ const gchar *remain;
+ const GSList *stmt_list;
+ gint nb_bound = 0;
+
+ parser = browser_connection_create_parser (bcnc);
+ batch = gda_sql_parser_parse_string_as_batch (parser, qfa.contents, &remain, NULL);
+ g_object_unref (parser);
+ if (!batch) {
+ tools_favorites_reset_attributes (&qfa);
+ continue;
+ }
+ stmt_list = gda_batch_get_statements (batch);
+ for (plist = (GSList*) stmt_list; plist; plist = plist->next) {
+ if (! gda_statement_is_useless (GDA_STATEMENT (plist->data))) {
+ if (stmt)
+ break;
+ else
+ stmt = g_object_ref (GDA_STATEMENT (plist->data));
+ }
+ }
+ g_object_unref (batch);
+ if (!stmt || plist) {
+ tools_favorites_reset_attributes (&qfa);
+ continue;
+ }
+
+ if (! gda_statement_get_parameters (stmt, ¶ms, NULL) || !params) {
+ g_object_unref (stmt);
+ tools_favorites_reset_attributes (&qfa);
+ continue;
+ }
+ browser_connection_define_ui_plugins_for_stmt (bcnc, stmt, params);
+
+ for (plist = params->holders; plist; plist = plist->next) {
+ /* try to find holder in @set */
+ GdaHolder *req_holder, *in_holder;
+ req_holder = GDA_HOLDER (plist->data);
+ in_holder = gda_set_get_holder (set, gda_holder_get_id (req_holder));
+ if (in_holder && gda_holder_set_bind (req_holder, in_holder, NULL)) {
+ /* bound this holder to the oune found */
+ nb_bound++;
+ }
+ }
+
+ if (nb_bound > 0) {
+ /* at least 1 holder was found=> keep the action */
+ ToolsFavoriteAction *act;
+ act = g_new0 (ToolsFavoriteAction, 1);
+ retlist = g_slist_insert_sorted (retlist, act,
+ (GCompareFunc) actions_sort_func);
+ act->params = g_object_ref (params);
+ act->id = fa->id;
+ act->name = g_strdup (fa->name);
+ act->stmt = g_object_ref (stmt);
+ act->nb_bound = nb_bound;
+
+ /*g_print ("Action identified: ID=%d Bound=%d name=[%s] SQL=[%s]\n",
+ act->id, act->nb_bound,
+ act->name, qfa.contents);*/
+ }
+
+ g_object_unref (stmt);
+ g_object_unref (params);
+ tools_favorites_reset_attributes (&qfa);
+ }
+ }
+ tools_favorites_free_list (fav_list);
+
+ return retlist;
+}
+
+/**
+ * tools_favorites_free_action
+ * @action: (allow-none): a #ToolsFavoriteAction, or %NULL
+ *
+ * Frees @action
+ */
+void
+tools_favorites_free_action (ToolsFavoriteAction *action)
+{
+ if (! action)
+ return;
+ g_free (action->name);
+ if (action->stmt)
+ g_object_unref (action->stmt);
+ if (action->params)
+ g_object_unref (action->params);
+ g_free (action);
+}
+
+/**
+ * tools_favorites_free_actions_list
+ * @actions_list: (allow-none): a list of #ToolsFavoriteAction, or %NULL
+ *
+ * Free a list of #ToolsFavoriteAction (frees the list and each #ToolsFavoriteAction)
+ */
+void
+tools_favorites_free_actions_list (GSList *actions_list)
+{
+ GSList *list;
+ if (!actions_list)
+ return;
+
+ for (list = actions_list; list; list = list->next)
+ tools_favorites_free_action ((ToolsFavoriteAction*) list->data);
+ g_slist_free (actions_list);
+}
diff --git a/tools/browser/common/favorites-actions.h b/tools/browser/common/favorites-actions.h
new file mode 100644
index 0000000..4375179
--- /dev/null
+++ b/tools/browser/common/favorites-actions.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2009 - 2011 Vivien Malerba <malerba gnome-db org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef __FAVORITES_H_
+#define __FAVORITES_H_
+
+#include <libgda/libgda.h>
+#include "../decl.h"
+#include "../../tools-favorites.h"
+
+G_BEGIN_DECLS
+
+typedef struct {
+ gint id;
+ gchar *name;
+ GdaStatement *stmt;
+ GdaSet *params;
+ gint nb_bound; /* number of GdaHolders in @params which are bound
+ * to another GdaHolder */
+} ToolsFavoriteAction;
+
+GSList *tools_favorites_get_actions (ToolsFavorites *bfav, BrowserConnection *bcnc, GdaSet *set);
+void tools_favorites_free_action (ToolsFavoriteAction *action);
+void tools_favorites_free_actions_list (GSList *actions_list);
+
+G_END_DECLS
+
+#endif
diff --git a/tools/browser/common/ui-formgrid.c b/tools/browser/common/ui-formgrid.c
index 27cb0ea..e2dc590 100644
--- a/tools/browser/common/ui-formgrid.c
+++ b/tools/browser/common/ui-formgrid.c
@@ -29,6 +29,7 @@
#include "../browser-stock-icons.h"
#include "widget-overlay.h"
#include <libgda/gda-data-model-extra.h>
+#include "favorites-actions.h"
#ifdef HAVE_LDAP
#include "../ldap-browser/ldap-browser-perspective.h"
#endif
@@ -494,7 +495,7 @@ form_grid_populate_popup_cb (GtkWidget *wid, GtkMenu *menu, UiFormGrid *formgrid
/* actions */
GSList *actions_list, *list;
- actions_list = browser_favorites_get_actions (browser_connection_get_favorites (bcnc),
+ actions_list = tools_favorites_get_actions (browser_connection_get_favorites (bcnc),
bcnc, GDA_SET (iter));
if (actions_list) {
GtkWidget *mitem, *submenu;
@@ -505,12 +506,12 @@ form_grid_populate_popup_cb (GtkWidget *wid, GtkMenu *menu, UiFormGrid *formgrid
submenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mitem), submenu);
for (list = actions_list; list; list = list->next) {
- BrowserFavoriteAction *act = (BrowserFavoriteAction*) list->data;
+ ToolsFavoriteAction *act = (ToolsFavoriteAction*) list->data;
mitem = gtk_menu_item_new_with_label (act->name);
gtk_widget_show (mitem);
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), mitem);
g_object_set_data_full (G_OBJECT (mitem), "action", act,
- (GDestroyNotify) browser_favorites_free_action);
+ (GDestroyNotify) tools_favorites_free_action);
g_signal_connect (mitem, "activate",
G_CALLBACK (execute_action_mitem_cb), formgrid);
}
@@ -788,13 +789,13 @@ statement_executed_cb (G_GNUC_UNUSED BrowserConnection *bcnc,
static void
execute_action_mitem_cb (GtkMenuItem *menuitem, UiFormGrid *formgrid)
{
- BrowserFavoriteAction *act;
+ ToolsFavoriteAction *act;
GtkWidget *dlg;
gchar *tmp;
gint response;
GtkWidget *toplevel;
- act = (BrowserFavoriteAction*) g_object_get_data (G_OBJECT (menuitem), "action");
+ act = (ToolsFavoriteAction*) g_object_get_data (G_OBJECT (menuitem), "action");
toplevel = gtk_widget_get_toplevel ((GtkWidget*) formgrid);
tmp = g_strdup_printf (_("Set or confirm the parameters to execute\n"
"action '%s'"), act->name);
diff --git a/tools/browser/data-manager/data-console.c b/tools/browser/data-manager/data-console.c
index 27734f1..d069793 100644
--- a/tools/browser/data-manager/data-console.c
+++ b/tools/browser/data-manager/data-console.c
@@ -498,10 +498,10 @@ void
data_console_set_fav_id (DataConsole *dconsole, gint fav_id, GError **error)
{
g_return_if_fail (IS_DATA_CONSOLE (dconsole));
- BrowserFavoritesAttributes fav;
+ ToolsFavoritesAttributes fav;
if ((fav_id >=0) &&
- browser_favorites_get (browser_connection_get_favorites (dconsole->priv->bcnc),
+ tools_favorites_get (browser_connection_get_favorites (dconsole->priv->bcnc),
fav_id, &fav, error)) {
gchar *str, *tmp;
tmp = g_markup_printf_escaped (_("'%s' data manager"), fav.name);
@@ -512,7 +512,7 @@ data_console_set_fav_id (DataConsole *dconsole, gint fav_id, GError **error)
dconsole->priv->fav_id = fav.id;
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
}
else {
gchar *str;
@@ -540,12 +540,12 @@ real_save_clicked_cb (GtkWidget *button, DataConsole *dconsole)
str = xml_spec_editor_get_xml_text (XML_SPEC_EDITOR (dconsole->priv->xml_sped));
GError *lerror = NULL;
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = dconsole->priv->fav_id;
- fav.type = BROWSER_FAVORITES_DATA_MANAGERS;
+ fav.type = TOOLS_FAVORITES_DATA_MANAGERS;
fav.name = gtk_editable_get_chars (GTK_EDITABLE (dconsole->priv->name_entry), 0, -1);
if (!*fav.name) {
g_free (fav.name);
@@ -556,7 +556,7 @@ real_save_clicked_cb (GtkWidget *button, DataConsole *dconsole)
gtk_widget_hide (dconsole->priv->popup_container);
bfav = browser_connection_get_favorites (dconsole->priv->bcnc);
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_DATA_MANAGERS, G_MAXINT, &lerror)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_DATA_MANAGERS, G_MAXINT, &lerror)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel (button),
"<b>%s:</b>\n%s",
_("Could not save data manager"),
@@ -594,11 +594,11 @@ save_clicked_cb (GtkWidget *button, DataConsole *dconsole)
gtk_box_pack_start (GTK_BOX (hbox), wid, FALSE, FALSE, 5);
dconsole->priv->name_entry = wid;
if (dconsole->priv->fav_id > 0) {
- BrowserFavoritesAttributes fav;
- if (browser_favorites_get (browser_connection_get_favorites (dconsole->priv->bcnc),
+ ToolsFavoritesAttributes fav;
+ if (tools_favorites_get (browser_connection_get_favorites (dconsole->priv->bcnc),
dconsole->priv->fav_id, &fav, NULL)) {
gtk_entry_set_text (GTK_ENTRY (wid), fav.name);
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
}
}
diff --git a/tools/browser/data-manager/data-favorite-selector.c b/tools/browser/data-manager/data-favorite-selector.c
index 9fcdefa..73ab8b2 100644
--- a/tools/browser/data-manager/data-favorite-selector.c
+++ b/tools/browser/data-manager/data-favorite-selector.c
@@ -28,7 +28,6 @@
#include "../support.h"
#include "marshal.h"
#include "../cc-gray-bar.h"
-#include "../browser-favorites.h"
#include <gdk/gdkkeysyms.h>
#include <libgda-ui/internal/popup-container.h>
@@ -64,7 +63,7 @@ static void data_favorite_selector_init (DataFavoriteSelector *tsel,
DataFavoriteSelectorClass *klass);
static void data_favorite_selector_dispose (GObject *object);
-static void favorites_changed_cb (BrowserFavorites *bfav, DataFavoriteSelector *tsel);
+static void favorites_changed_cb (ToolsFavorites *bfav, DataFavoriteSelector *tsel);
enum {
SELECTION_CHANGED,
@@ -187,15 +186,15 @@ key_press_event_cb (GtkTreeView *treeview, GdkEventKey *event, DataFavoriteSelec
select = gtk_tree_view_get_selection (treeview);
if (gtk_tree_selection_get_selected (select, &model, &iter)) {
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *lerror = NULL;
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
gtk_tree_model_get (model, &iter,
COLUMN_ID, &(fav.id), -1);
bfav = browser_connection_get_favorites (tsel->priv->bcnc);
- if (!browser_favorites_delete (bfav, 0, &fav, NULL)) {
+ if (!tools_favorites_delete (bfav, 0, &fav, NULL)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*)tsel),
_("Could not remove favorite: %s"),
lerror && lerror->message ? lerror->message : _("No detail"));
@@ -235,13 +234,13 @@ selection_changed_cb (GtkTreeView *treeview, G_GNUC_UNUSED GtkTreePath *path,
static gboolean
prop_save_timeout (DataFavoriteSelector *tsel)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = tsel->priv->properties_id;
- fav.type = BROWSER_FAVORITES_DATA_MANAGERS;
+ fav.type = TOOLS_FAVORITES_DATA_MANAGERS;
fav.name = (gchar*) gtk_entry_get_text (GTK_ENTRY (tsel->priv->properties_name));
fav.descr = NULL;
@@ -253,7 +252,7 @@ prop_save_timeout (DataFavoriteSelector *tsel)
fav.contents = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
bfav = browser_connection_get_favorites (tsel->priv->bcnc);
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_DATA_MANAGERS, tsel->priv->properties_position, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_DATA_MANAGERS, tsel->priv->properties_position, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tsel),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
@@ -466,7 +465,7 @@ data_favorite_selector_new (BrowserConnection *bcnc)
/* create tree managers */
tsel->priv->tree = gda_tree_new ();
- manager = mgr_favorites_new (bcnc, BROWSER_FAVORITES_DATA_MANAGERS, ORDER_KEY_DATA_MANAGERS);
+ manager = mgr_favorites_new (bcnc, TOOLS_FAVORITES_DATA_MANAGERS, ORDER_KEY_DATA_MANAGERS);
gda_tree_add_manager (tsel->priv->tree, manager);
g_object_unref (manager);
@@ -591,20 +590,20 @@ static gboolean
tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
GtkSelectionData *selection_data, DataFavoriteSelector *tsel)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
gint pos;
gboolean retval = TRUE;
gint id;
bfav = browser_connection_get_favorites (tsel->priv->bcnc);
- id = browser_favorites_find (bfav, 0, (gchar*) gtk_selection_data_get_data (selection_data),
+ id = tools_favorites_find (bfav, 0, (gchar*) gtk_selection_data_get_data (selection_data),
&fav, NULL);
if (id < 0) {
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = -1;
- fav.type = BROWSER_FAVORITES_DATA_MANAGERS;
+ fav.type = TOOLS_FAVORITES_DATA_MANAGERS;
fav.name = _("Unnamed data manager");
fav.descr = NULL;
fav.contents = (gchar*) gtk_selection_data_get_data (selection_data);
@@ -613,7 +612,7 @@ tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
pos = atoi (path);
/*g_print ("%s() path => %s, pos: %d\n", __FUNCTION__, path, pos);*/
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_DATA_MANAGERS, pos, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_DATA_MANAGERS, pos, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tsel),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
@@ -623,7 +622,7 @@ tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
}
if (id >= 0)
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
return retval;
}
@@ -664,7 +663,7 @@ tree_store_drag_get_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
}
static void
-favorites_changed_cb (G_GNUC_UNUSED BrowserFavorites *bfav, DataFavoriteSelector *tsel)
+favorites_changed_cb (G_GNUC_UNUSED ToolsFavorites *bfav, DataFavoriteSelector *tsel)
{
if (! gda_tree_update_all (tsel->priv->tree, NULL)) {
if (tsel->priv->idle_update_favorites == 0)
diff --git a/tools/browser/data-manager/data-favorite-selector.h b/tools/browser/data-manager/data-favorite-selector.h
index 2c496c9..12be294 100644
--- a/tools/browser/data-manager/data-favorite-selector.h
+++ b/tools/browser/data-manager/data-favorite-selector.h
@@ -43,7 +43,7 @@ struct _DataFavoriteSelectorClass {
GtkBoxClass parent_class;
void (*selection_changed) (DataFavoriteSelector *sel, gint fav_id,
- BrowserFavoritesType fav_type, const gchar *fav_contents);
+ ToolsFavoritesType fav_type, const gchar *fav_contents);
};
GType data_favorite_selector_get_type (void) G_GNUC_CONST;
diff --git a/tools/browser/data-manager/data-manager-perspective.c b/tools/browser/data-manager/data-manager-perspective.c
index 1545480..521e415 100644
--- a/tools/browser/data-manager/data-manager-perspective.c
+++ b/tools/browser/data-manager/data-manager-perspective.c
@@ -21,7 +21,6 @@
#include <glib/gi18n-lib.h>
#include "data-manager-perspective.h"
#include "data-console.h"
-#include "../browser-favorites.h"
#include "../browser-window.h"
#include "../browser-page.h"
#include "data-favorite-selector.h"
@@ -129,7 +128,7 @@ data_manager_perspective_init (DataManagerPerspective *perspective)
gtk_orientable_set_orientation (GTK_ORIENTABLE (perspective), GTK_ORIENTATION_VERTICAL);
}
-static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, BrowserFavoritesType fav_type,
+static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, ToolsFavoritesType fav_type,
const gchar *selection, DataManagerPerspective *perspective);
static void close_button_clicked_cb (GtkWidget *wid, GtkWidget *page_widget);
@@ -231,7 +230,7 @@ add_new_data_console (BrowserPerspective *bpers, gint fav_id)
}
static void
-fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gint fav_id, BrowserFavoritesType fav_type,
+fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gint fav_id, ToolsFavoritesType fav_type,
const gchar *selection, DataManagerPerspective *perspective)
{
/* find or create page for this favorite */
@@ -239,7 +238,7 @@ fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gint fav_id, BrowserF
gint current_page, npages, i;
DataConsole *page_to_reuse = NULL;
- if (fav_type != BROWSER_FAVORITES_DATA_MANAGERS)
+ if (fav_type != TOOLS_FAVORITES_DATA_MANAGERS)
return;
/* change current page if possible */
diff --git a/tools/browser/data-manager/data-source.h b/tools/browser/data-manager/data-source.h
index b78ef10..5f971fd 100644
--- a/tools/browser/data-manager/data-source.h
+++ b/tools/browser/data-manager/data-source.h
@@ -21,7 +21,6 @@
#define __DATA_SOURCE_H_
#include <libgda-ui/libgda-ui.h>
-#include "browser-favorites.h"
#include "decl.h"
G_BEGIN_DECLS
diff --git a/tools/browser/doc/gda-browser-sections.txt b/tools/browser/doc/gda-browser-sections.txt
index 9800d33..817ab7e 100644
--- a/tools/browser/doc/gda-browser-sections.txt
+++ b/tools/browser/doc/gda-browser-sections.txt
@@ -122,32 +122,32 @@ BROWSER_CONNECTION_CLASS
<SECTION>
<FILE>browser-favorites</FILE>
-BrowserFavoritesPrivate
-BrowserFavoritesType
-BROWSER_FAVORITES_NB_TYPES
-BrowserFavoritesAttributes
-<TITLE>BrowserFavorites</TITLE>
-BrowserFavorites
-browser_favorites_new
-browser_favorites_type_to_string
-browser_favorites_add
-browser_favorites_list
-browser_favorites_delete
-browser_favorites_free_list
-browser_favorites_reset_attributes
-browser_favorites_find
-browser_favorites_get
+ToolsFavoritesPrivate
+ToolsFavoritesType
+TOOLS_FAVORITES_NB_TYPES
+ToolsFavoritesAttributes
+<TITLE>ToolsFavorites</TITLE>
+ToolsFavorites
+tools_favorites_new
+tools_favorites_type_to_string
+tools_favorites_add
+tools_favorites_list
+tools_favorites_delete
+tools_favorites_free_list
+tools_favorites_reset_attributes
+tools_favorites_find
+tools_favorites_get
<SUBSECTION>
-BrowserFavoriteAction
-browser_favorites_get_actions
-browser_favorites_free_action
-browser_favorites_free_actions_list
+ToolsFavoriteAction
+tools_favorites_get_actions
+tools_favorites_free_action
+tools_favorites_free_actions_list
<SUBSECTION Standard>
-BROWSER_FAVORITES
+TOOLS_FAVORITES
BROWSER_IS_FAVORITES
BROWSER_TYPE_FAVORITES
-browser_favorites_get_type
-BROWSER_FAVORITES_CLASS
+tools_favorites_get_type
+TOOLS_FAVORITES_CLASS
</SECTION>
<SECTION>
diff --git a/tools/browser/doc/gda-browser.types b/tools/browser/doc/gda-browser.types
index aafc8f2..4157c5e 100644
--- a/tools/browser/doc/gda-browser.types
+++ b/tools/browser/doc/gda-browser.types
@@ -1,6 +1,6 @@
#include <browser-core.h>
#include <browser-connection.h>
-#include <browser-favorites.h>
+#include <common/favorites-actions.h>
#include <browser-window.h>
#include <browser-page.h>
#include <cc-gray-bar.h>
@@ -12,7 +12,7 @@
#include <mgr-favorites.h>
browser_core_get_type
browser_connection_get_type
-browser_favorites_get_type
+tools_favorites_get_type
browser_window_get_type
browser_perspective_get_type
browser_page_get_type
diff --git a/tools/browser/favorites-test.c b/tools/browser/favorites-test.c
index 5adeade..69b4367 100644
--- a/tools/browser/favorites-test.c
+++ b/tools/browser/favorites-test.c
@@ -21,7 +21,7 @@
#include <string.h>
static void
-dump_favorite (BrowserFavoritesAttributes *f)
+dump_favorite (ToolsFavoritesAttributes *f)
{
g_print ("Favorite: ID=>%d\n", f->id);
g_print (" Type=>%d\n", f->type);
@@ -59,13 +59,13 @@ dump_favorites_in_db (GdaConnection *cnc)
g_object_unref (model);
}
-static void test1 (GdaConnection *cnc, BrowserFavorites *bfav);
-static void test2 (GdaConnection *cnc, BrowserFavorites *bfav);
-static void test3 (GdaConnection *cnc, BrowserFavorites *bfav);
+static void test1 (GdaConnection *cnc, ToolsFavorites *bfav);
+static void test2 (GdaConnection *cnc, ToolsFavorites *bfav);
+static void test3 (GdaConnection *cnc, ToolsFavorites *bfav);
int
main (int argc, char *argv[])
{
- BrowserFavorites *bfav;
+ ToolsFavorites *bfav;
GdaConnection *cnc;
GError *error = NULL;
@@ -79,7 +79,7 @@ main (int argc, char *argv[])
error && error->message ? error->message : "No detail");
exit (1);
}
- bfav = browser_favorites_new (gda_connection_get_meta_store (cnc));
+ bfav = tools_favorites_new (gda_connection_get_meta_store (cnc));
test1 (cnc, bfav);
test2 (cnc, bfav);
test3 (cnc, bfav);
@@ -91,17 +91,17 @@ main (int argc, char *argv[])
}
static void
-test1 (GdaConnection *cnc, BrowserFavorites *bfav)
+test1 (GdaConnection *cnc, ToolsFavorites *bfav)
{
gint favid, i;
GError *error = NULL;
- BrowserFavoritesAttributes fav_array[]= {
- {-1, BROWSER_FAVORITES_TABLES, "table1", "fav1-descr", "fav1 contents"},
- {-1, BROWSER_FAVORITES_DIAGRAMS, "diagram1", "fav2-descr", "fav2 contents"}
+ ToolsFavoritesAttributes fav_array[]= {
+ {-1, TOOLS_FAVORITES_TABLES, "table1", "fav1-descr", "fav1 contents"},
+ {-1, TOOLS_FAVORITES_DIAGRAMS, "diagram1", "fav2-descr", "fav2 contents"}
};
for (i = 0; i < G_N_ELEMENTS (fav_array); i++) {
- BrowserFavoritesAttributes *f = (BrowserFavoritesAttributes*) &(fav_array[i]);
- favid = browser_favorites_add (bfav, 0, f, -1, 0, &error);
+ ToolsFavoritesAttributes *f = (ToolsFavoritesAttributes*) &(fav_array[i]);
+ favid = tools_favorites_add (bfav, 0, f, -1, 0, &error);
if (!favid < 0) {
g_print ("Could not create favorite: %s\n",
error && error->message ? error->message : "No detail");
@@ -111,15 +111,15 @@ test1 (GdaConnection *cnc, BrowserFavorites *bfav)
//dump_favorites_in_db (cnc);
GSList *favlist, *list;
- favlist = browser_favorites_list (bfav, 0, BROWSER_FAVORITES_TABLES, -1, &error);
+ favlist = tools_favorites_list (bfav, 0, TOOLS_FAVORITES_TABLES, -1, &error);
if (!favlist && error) {
g_print ("Could not list favorites: %s\n",
error && error->message ? error->message : "No detail");
exit (1);
}
for (i = 0, list = favlist; (i < G_N_ELEMENTS (fav_array)) && list; i++, list = list -> next) {
- BrowserFavoritesAttributes *f1 = (BrowserFavoritesAttributes*) &(fav_array[i]);
- BrowserFavoritesAttributes *f2 = (BrowserFavoritesAttributes*) list->data;
+ ToolsFavoritesAttributes *f1 = (ToolsFavoritesAttributes*) &(fav_array[i]);
+ ToolsFavoritesAttributes *f2 = (ToolsFavoritesAttributes*) list->data;
if (f2->id == 0) {
g_print ("ID should not be 0:\n");
dump_favorite (f1);
@@ -140,26 +140,26 @@ test1 (GdaConnection *cnc, BrowserFavorites *bfav)
g_print ("Wrong number of favorites reported\n");
exit (1);
}
- browser_favorites_free_list (favlist);
+ tools_favorites_free_list (favlist);
}
static void
-test2 (GdaConnection *cnc, BrowserFavorites *bfav)
+test2 (GdaConnection *cnc, ToolsFavorites *bfav)
{
gint favid, i;
GError *error = NULL;
- BrowserFavoritesAttributes fav_array[]= {
- {-1, BROWSER_FAVORITES_TABLES, "table2", "fav1-descr", "fav1 contents SEPARATE"},
- {-1, BROWSER_FAVORITES_DIAGRAMS, "diagram2", "fav2-descr", "fav2 contents SEPARATE"},
- {-1, BROWSER_FAVORITES_TABLES, "table2", "Another description for table2", "fav1 contents SEPARATE"},
+ ToolsFavoritesAttributes fav_array[]= {
+ {-1, TOOLS_FAVORITES_TABLES, "table2", "fav1-descr", "fav1 contents SEPARATE"},
+ {-1, TOOLS_FAVORITES_DIAGRAMS, "diagram2", "fav2-descr", "fav2 contents SEPARATE"},
+ {-1, TOOLS_FAVORITES_TABLES, "table2", "Another description for table2", "fav1 contents SEPARATE"},
};
- BrowserFavoritesAttributes res_fav_array[]= {
- {-1, BROWSER_FAVORITES_TABLES, "table2", "Another description for table2", "fav1 contents SEPARATE"},
- {-1, BROWSER_FAVORITES_DIAGRAMS, "diagram2", "fav2-descr", "fav2 contents SEPARATE"},
+ ToolsFavoritesAttributes res_fav_array[]= {
+ {-1, TOOLS_FAVORITES_TABLES, "table2", "Another description for table2", "fav1 contents SEPARATE"},
+ {-1, TOOLS_FAVORITES_DIAGRAMS, "diagram2", "fav2-descr", "fav2 contents SEPARATE"},
};
for (i = 0; i < G_N_ELEMENTS (fav_array); i++) {
- BrowserFavoritesAttributes *f = (BrowserFavoritesAttributes*) &(fav_array[i]);
- favid = browser_favorites_add (bfav, 0, f, 1, 0, &error);
+ ToolsFavoritesAttributes *f = (ToolsFavoritesAttributes*) &(fav_array[i]);
+ favid = tools_favorites_add (bfav, 0, f, 1, 0, &error);
if (!favid < 0) {
g_print ("Could not create favorite: %s\n",
error && error->message ? error->message : "No detail");
@@ -169,15 +169,15 @@ test2 (GdaConnection *cnc, BrowserFavorites *bfav)
dump_favorites_in_db (cnc);
GSList *favlist, *list;
- favlist = browser_favorites_list (bfav, 0, BROWSER_FAVORITES_TABLES, 1, &error);
+ favlist = tools_favorites_list (bfav, 0, TOOLS_FAVORITES_TABLES, 1, &error);
if (!favlist && error) {
g_print ("Could not list favorites: %s\n",
error && error->message ? error->message : "No detail");
exit (1);
}
for (i = 0, list = favlist; (i < G_N_ELEMENTS (res_fav_array)) && list; i++, list = list -> next) {
- BrowserFavoritesAttributes *f1 = (BrowserFavoritesAttributes*) &(res_fav_array[i]);
- BrowserFavoritesAttributes *f2 = (BrowserFavoritesAttributes*) list->data;
+ ToolsFavoritesAttributes *f1 = (ToolsFavoritesAttributes*) &(res_fav_array[i]);
+ ToolsFavoritesAttributes *f2 = (ToolsFavoritesAttributes*) list->data;
if (f2->id == 0) {
g_print ("ID should not be 0:\n");
dump_favorite (f1);
@@ -198,23 +198,23 @@ test2 (GdaConnection *cnc, BrowserFavorites *bfav)
g_print ("Wrong number of favorites reported\n");
exit (1);
}
- browser_favorites_free_list (favlist);
+ tools_favorites_free_list (favlist);
}
static void
-test3 (GdaConnection *cnc, BrowserFavorites *bfav)
+test3 (GdaConnection *cnc, ToolsFavorites *bfav)
{
gint favid, i;
GError *error = NULL;
- BrowserFavoritesAttributes fav_array[]= {
- {-1, BROWSER_FAVORITES_DIAGRAMS, "diagram2", "fav2-descr", "fav2 contents SEPARATE"},
+ ToolsFavoritesAttributes fav_array[]= {
+ {-1, TOOLS_FAVORITES_DIAGRAMS, "diagram2", "fav2-descr", "fav2 contents SEPARATE"},
};
- BrowserFavoritesAttributes res_fav_array[]= {
- {-1, BROWSER_FAVORITES_TABLES, "table2", "Another description for table2", "fav1 contents SEPARATE"},
+ ToolsFavoritesAttributes res_fav_array[]= {
+ {-1, TOOLS_FAVORITES_TABLES, "table2", "Another description for table2", "fav1 contents SEPARATE"},
};
for (i = 0; i < G_N_ELEMENTS (fav_array); i++) {
- BrowserFavoritesAttributes *f = (BrowserFavoritesAttributes*) &(fav_array[i]);
- favid = browser_favorites_delete (bfav, 0, f, &error);
+ ToolsFavoritesAttributes *f = (ToolsFavoritesAttributes*) &(fav_array[i]);
+ favid = tools_favorites_delete (bfav, 0, f, &error);
if (!favid < 0) {
g_print ("Could not delete favorite: %s\n",
error && error->message ? error->message : "No detail");
@@ -224,15 +224,15 @@ test3 (GdaConnection *cnc, BrowserFavorites *bfav)
dump_favorites_in_db (cnc);
GSList *favlist, *list;
- favlist = browser_favorites_list (bfav, 0, BROWSER_FAVORITES_TABLES, 1, &error);
+ favlist = tools_favorites_list (bfav, 0, TOOLS_FAVORITES_TABLES, 1, &error);
if (!favlist && error) {
g_print ("Could not list favorites: %s\n",
error && error->message ? error->message : "No detail");
exit (1);
}
for (i = 0, list = favlist; (i < G_N_ELEMENTS (res_fav_array)) && list; i++, list = list -> next) {
- BrowserFavoritesAttributes *f1 = (BrowserFavoritesAttributes*) &(res_fav_array[i]);
- BrowserFavoritesAttributes *f2 = (BrowserFavoritesAttributes*) list->data;
+ ToolsFavoritesAttributes *f1 = (ToolsFavoritesAttributes*) &(res_fav_array[i]);
+ ToolsFavoritesAttributes *f2 = (ToolsFavoritesAttributes*) list->data;
if (f2->id == 0) {
g_print ("ID should not be 0:\n");
dump_favorite (f1);
@@ -253,5 +253,5 @@ test3 (GdaConnection *cnc, BrowserFavorites *bfav)
g_print ("Wrong number of favorites reported\n");
exit (1);
}
- browser_favorites_free_list (favlist);
+ tools_favorites_free_list (favlist);
}
diff --git a/tools/browser/ldap-browser/ldap-browser-perspective.c b/tools/browser/ldap-browser/ldap-browser-perspective.c
index ed0832c..1434c2b 100644
--- a/tools/browser/ldap-browser/ldap-browser-perspective.c
+++ b/tools/browser/ldap-browser/ldap-browser-perspective.c
@@ -25,7 +25,6 @@
#include "ldap-search-page.h"
#include "../support.h"
#include "../browser-page.h"
-#include "../browser-favorites.h"
#include "ldap-favorite-selector.h"
#include "../browser-stock-icons.h"
@@ -127,7 +126,7 @@ close_button_clicked_cb (G_GNUC_UNUSED GtkWidget *wid, GtkWidget *page_widget)
gtk_widget_destroy (page_widget);
}
-static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, BrowserFavoritesType fav_type,
+static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, ToolsFavoritesType fav_type,
const gchar *selection, LdapBrowserPerspective *bpers);
/**
* ldap_browser_perspective_new
@@ -185,13 +184,13 @@ ldap_browser_perspective_new (BrowserWindow *bwin)
static void
fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gint fav_id,
- BrowserFavoritesType fav_type,
+ ToolsFavoritesType fav_type,
const gchar *selection, LdapBrowserPerspective *bpers)
{
- if (fav_type == BROWSER_FAVORITES_LDAP_DN) {
+ if (fav_type == TOOLS_FAVORITES_LDAP_DN) {
ldap_browser_perspective_display_ldap_entry (bpers, selection);
}
- if (fav_type == BROWSER_FAVORITES_LDAP_CLASS) {
+ if (fav_type == TOOLS_FAVORITES_LDAP_CLASS) {
ldap_browser_perspective_display_ldap_class (bpers, selection);
}
#ifdef GDA_DEBUG_NO
@@ -329,7 +328,7 @@ ldab_search_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspective *bpers)
static const GtkToggleActionEntry ui_toggle_actions [] =
{
- { "LdapBrowserFavoritesShow", NULL, N_("_Show favorites"), "F9", N_("Show or hide favorites"), G_CALLBACK (favorites_toggle_cb), FALSE }
+ { "LdapToolsFavoritesShow", NULL, N_("_Show favorites"), "F9", N_("Show or hide favorites"), G_CALLBACK (favorites_toggle_cb), FALSE }
};
static GtkActionEntry ui_actions[] = {
@@ -346,7 +345,7 @@ static const gchar *ui_actions_info =
"<ui>"
" <menubar name='MenuBar'>"
" <menu name='Display' action='Display'>"
- " <menuitem name='LdapBrowserFavoritesShow' action='LdapBrowserFavoritesShow'/>"
+ " <menuitem name='LdapToolsFavoritesShow' action='LdapToolsFavoritesShow'/>"
" </menu>"
" <placeholder name='MenuExtension'>"
" <menu name='LDAP' action='LDAP'>"
@@ -374,7 +373,7 @@ ldap_browser_perspective_get_actions_group (BrowserPerspective *bpers)
gtk_action_group_add_toggle_actions (agroup, ui_toggle_actions, G_N_ELEMENTS (ui_toggle_actions),
bpers);
GtkAction *action;
- action = gtk_action_group_get_action (agroup, "LdapBrowserFavoritesShow");
+ action = gtk_action_group_get_action (agroup, "LdapToolsFavoritesShow");
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
LDAP_BROWSER_PERSPECTIVE (bpers)->priv->favorites_shown);
diff --git a/tools/browser/ldap-browser/ldap-classes-page.c b/tools/browser/ldap-browser/ldap-classes-page.c
index 0713d08..3e6eb32 100644
--- a/tools/browser/ldap-browser/ldap-classes-page.c
+++ b/tools/browser/ldap-browser/ldap-classes-page.c
@@ -458,20 +458,20 @@ ldap_classes_page_set_current_class (LdapClassesPage *ldap_classes_page, const g
static void
action_add_to_fav_cb (G_GNUC_UNUSED GtkAction *action, LdapClassesPage *ebrowser)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
classes_view_get_current_class (CLASSES_VIEW (ebrowser->priv->classes_view));
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = -1;
- fav.type = BROWSER_FAVORITES_LDAP_CLASS;
+ fav.type = TOOLS_FAVORITES_LDAP_CLASS;
fav.name = ldap_classes_page_to_selection (ebrowser);
fav.descr = NULL;
fav.contents = ldap_classes_page_to_selection (ebrowser);
bfav = browser_connection_get_favorites (ebrowser->priv->bcnc);
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_LDAP, G_MAXINT, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_LDAP, G_MAXINT, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) ebrowser),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
diff --git a/tools/browser/ldap-browser/ldap-entries-page.c b/tools/browser/ldap-browser/ldap-entries-page.c
index d13e5f1..0b00578 100644
--- a/tools/browser/ldap-browser/ldap-entries-page.c
+++ b/tools/browser/ldap-browser/ldap-entries-page.c
@@ -463,21 +463,21 @@ ldap_entries_page_set_current_dn (LdapEntriesPage *ldap_entries_page, const gcha
static void
action_add_to_fav_cb (G_GNUC_UNUSED GtkAction *action, LdapEntriesPage *ebrowser)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
const gchar *cn;
hierarchy_view_get_current_dn (HIERARCHY_VIEW (ebrowser->priv->entries_view), &cn);
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = -1;
- fav.type = BROWSER_FAVORITES_LDAP_DN;
+ fav.type = TOOLS_FAVORITES_LDAP_DN;
fav.name = ldap_entries_page_to_selection (ebrowser);
fav.descr = (gchar*) cn;
fav.contents = ldap_entries_page_to_selection (ebrowser);
bfav = browser_connection_get_favorites (ebrowser->priv->bcnc);
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_LDAP, G_MAXINT, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_LDAP, G_MAXINT, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) ebrowser),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
diff --git a/tools/browser/ldap-browser/ldap-favorite-selector.c b/tools/browser/ldap-browser/ldap-favorite-selector.c
index 553cbb0..bd05538 100644
--- a/tools/browser/ldap-browser/ldap-favorite-selector.c
+++ b/tools/browser/ldap-browser/ldap-favorite-selector.c
@@ -27,7 +27,6 @@
#include "../support.h"
#include "marshal.h"
#include "../cc-gray-bar.h"
-#include "../browser-favorites.h"
#include <gdk/gdkkeysyms.h>
#include <libgda-ui/internal/popup-container.h>
@@ -51,7 +50,7 @@ static void ldap_favorite_selector_init (LdapFavoriteSelector *fsel,
LdapFavoriteSelectorClass *klass);
static void ldap_favorite_selector_dispose (GObject *object);
-static void favorites_changed_cb (BrowserFavorites *bfav, LdapFavoriteSelector *fsel);
+static void favorites_changed_cb (ToolsFavorites *bfav, LdapFavoriteSelector *fsel);
enum {
SELECTION_CHANGED,
@@ -176,15 +175,15 @@ favorite_delete_selected (LdapFavoriteSelector *fsel)
select = gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->priv->treeview));
if (gtk_tree_selection_get_selected (select, &model, &iter)) {
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *lerror = NULL;
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
gtk_tree_model_get (model, &iter,
COLUMN_ID, &(fav.id), -1);
bfav = browser_connection_get_favorites (fsel->priv->bcnc);
- if (!browser_favorites_delete (bfav, 0, &fav, NULL)) {
+ if (!tools_favorites_delete (bfav, 0, &fav, NULL)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*)fsel),
_("Could not remove favorite: %s"),
lerror && lerror->message ? lerror->message : _("No detail"));
@@ -217,7 +216,7 @@ selection_changed_cb (GtkTreeView *treeview, G_GNUC_UNUSED GtkTreePath *path,
if (gtk_tree_selection_get_selected (select, &model, &iter)) {
gchar *str;
gint fav_id;
- BrowserFavoritesType fav_type;
+ ToolsFavoritesType fav_type;
gtk_tree_model_get (model, &iter,
COLUMN_ID, &fav_id,
COLUMN_FAVTYPE, &fav_type,
@@ -231,21 +230,21 @@ selection_changed_cb (GtkTreeView *treeview, G_GNUC_UNUSED GtkTreePath *path,
static gboolean
prop_save_timeout (LdapFavoriteSelector *fsel)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
gboolean allok;
bfav = browser_connection_get_favorites (fsel->priv->bcnc);
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = fsel->priv->properties_id;
- fav.type = BROWSER_FAVORITES_LDAP_DN;
+ fav.type = TOOLS_FAVORITES_LDAP_DN;
fav.name = (gchar*) gtk_entry_get_text (GTK_ENTRY (fsel->priv->properties_name));
fav.descr = (gchar*) gtk_entry_get_text (GTK_ENTRY (fsel->priv->properties_descr));
fav.contents = (gchar*) gtk_entry_get_text (GTK_ENTRY (fsel->priv->properties_name));
- allok = browser_favorites_add (bfav, 0, &fav, ORDER_KEY_LDAP,
+ allok = tools_favorites_add (bfav, 0, &fav, ORDER_KEY_LDAP,
fsel->priv->properties_position, &error);
if (! allok) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) fsel),
@@ -446,22 +445,22 @@ ldap_favorite_selector_new (BrowserConnection *bcnc)
fsel->priv->bcnc = g_object_ref (bcnc);
signame = g_strdup_printf ("favorites-changed::%s",
- browser_favorites_type_to_string (BROWSER_FAVORITES_LDAP_DN));
+ tools_favorites_type_to_string (TOOLS_FAVORITES_LDAP_DN));
g_signal_connect (browser_connection_get_favorites (fsel->priv->bcnc), signame,
G_CALLBACK (favorites_changed_cb), fsel);
g_free (signame);
signame = g_strdup_printf ("favorites-changed::%s",
- browser_favorites_type_to_string (BROWSER_FAVORITES_LDAP_CLASS));
+ tools_favorites_type_to_string (TOOLS_FAVORITES_LDAP_CLASS));
g_signal_connect (browser_connection_get_favorites (fsel->priv->bcnc), signame,
G_CALLBACK (favorites_changed_cb), fsel);
g_free (signame);
/* create tree managers */
fsel->priv->tree = gda_tree_new ();
- manager = mgr_favorites_new (bcnc, BROWSER_FAVORITES_LDAP_DN, ORDER_KEY_LDAP);
+ manager = mgr_favorites_new (bcnc, TOOLS_FAVORITES_LDAP_DN, ORDER_KEY_LDAP);
gda_tree_add_manager (fsel->priv->tree, manager);
g_object_unref (manager);
- manager = mgr_favorites_new (bcnc, BROWSER_FAVORITES_LDAP_CLASS, ORDER_KEY_LDAP);
+ manager = mgr_favorites_new (bcnc, TOOLS_FAVORITES_LDAP_CLASS, ORDER_KEY_LDAP);
gda_tree_add_manager (fsel->priv->tree, manager);
g_object_unref (manager);
@@ -572,20 +571,20 @@ static gboolean
tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
GtkSelectionData *selection_ldap, LdapFavoriteSelector *fsel)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
gint pos;
gboolean retval = TRUE;
gint id;
bfav = browser_connection_get_favorites (fsel->priv->bcnc);
- id = browser_favorites_find (bfav, 0, (gchar*) gtk_selection_data_get_data (selection_ldap),
+ id = tools_favorites_find (bfav, 0, (gchar*) gtk_selection_data_get_data (selection_ldap),
&fav, NULL);
if (id < 0) {
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = -1;
- fav.type = BROWSER_FAVORITES_LDAP_DN;
+ fav.type = TOOLS_FAVORITES_LDAP_DN;
fav.name = (gchar*) gtk_selection_data_get_data (selection_ldap);
fav.descr = NULL;
fav.contents = (gchar*) gtk_selection_data_get_data (selection_ldap);
@@ -594,7 +593,7 @@ tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
pos = atoi (path);
/*g_print ("%s() path => %s, pos: %d\n", __FUNCTION__, path, pos);*/
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_LDAP, pos, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_LDAP, pos, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) fsel),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
@@ -604,7 +603,7 @@ tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
}
if (id >= 0)
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
return retval;
}
@@ -645,7 +644,7 @@ tree_store_drag_get_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
}
static void
-favorites_changed_cb (G_GNUC_UNUSED BrowserFavorites *bfav, LdapFavoriteSelector *fsel)
+favorites_changed_cb (G_GNUC_UNUSED ToolsFavorites *bfav, LdapFavoriteSelector *fsel)
{
if (! gda_tree_update_all (fsel->priv->tree, NULL)) {
if (fsel->priv->idle_update_favorites == 0)
diff --git a/tools/browser/ldap-browser/ldap-favorite-selector.h b/tools/browser/ldap-browser/ldap-favorite-selector.h
index 8b1a5ff..9bf0d1f 100644
--- a/tools/browser/ldap-browser/ldap-favorite-selector.h
+++ b/tools/browser/ldap-browser/ldap-favorite-selector.h
@@ -43,7 +43,7 @@ struct _LdapFavoriteSelectorClass {
GtkBoxClass parent_class;
void (*selection_changed) (LdapFavoriteSelector *sel, gint fav_id,
- BrowserFavoritesType fav_type, const gchar *fav_contents);
+ ToolsFavoritesType fav_type, const gchar *fav_contents);
};
GType ldap_favorite_selector_get_type (void) G_GNUC_CONST;
diff --git a/tools/browser/mgr-favorites.c b/tools/browser/mgr-favorites.c
index 172400c..90bfb33 100644
--- a/tools/browser/mgr-favorites.c
+++ b/tools/browser/mgr-favorites.c
@@ -39,7 +39,7 @@ icon_resolution_data_free (IconResolutionData *data)
struct _MgrFavoritesPriv {
BrowserConnection *bcnc;
- BrowserFavoritesType fav_type;
+ ToolsFavoritesType fav_type;
gint order_key;
GSList *icons_resol_list; /* list of IconResolutionData pointers */
@@ -211,14 +211,14 @@ mgr_favorites_get_property (GObject *object,
* mgr_favorites_new
* @bcnc: a #BrowserConnection object
* @type: the type of favorites to handle
- * @order_key: ordering key, see browser_favorites_add()
+ * @order_key: ordering key, see tools_favorites_add()
*
* Creates a new #GdaTreeManager object which will add one tree node for each favorite of the @type type
*
* Returns: a new #GdaTreeManager object
*/
GdaTreeManager*
-mgr_favorites_new (BrowserConnection *bcnc, BrowserFavoritesType type, gint order_key)
+mgr_favorites_new (BrowserConnection *bcnc, ToolsFavoritesType type, gint order_key)
{
MgrFavorites *mgr;
g_return_val_if_fail (BROWSER_IS_CONNECTION (bcnc), NULL);
@@ -372,14 +372,14 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
ehash = hash_for_existing_nodes (children_nodes);
bcnc = mgr->priv->bcnc;
- fav_list = browser_favorites_list (browser_connection_get_favorites (bcnc),
+ fav_list = tools_favorites_list (browser_connection_get_favorites (bcnc),
0, mgr->priv->fav_type,
mgr->priv->order_key, &lerror);
if (fav_list) {
GSList *list;
gint pos;
for (list = fav_list, pos = 0; list; list = list->next, pos ++) {
- BrowserFavoritesAttributes *fav = (BrowserFavoritesAttributes *) list->data;
+ ToolsFavoritesAttributes *fav = (ToolsFavoritesAttributes *) list->data;
GdaTreeNode* snode = NULL;
GValue *av;
@@ -392,7 +392,7 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
g_object_ref (G_OBJECT (snode));
}
- if (fav->type == BROWSER_FAVORITES_TABLES) {
+ if (fav->type == TOOLS_FAVORITES_TABLES) {
if (!snode) {
GdaQuarkList *ql;
const gchar *fname = NULL;
@@ -439,7 +439,7 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
gda_quark_list_free (ql);
}
}
- else if (fav->type == BROWSER_FAVORITES_DIAGRAMS) {
+ else if (fav->type == TOOLS_FAVORITES_DIAGRAMS) {
if (!snode) {
snode = gda_tree_manager_create_node (manager, node, NULL);
@@ -475,7 +475,7 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
gda_tree_node_set_node_attribute (snode, "markup", av, NULL);
gda_value_free (av);
}
- else if (fav->type == BROWSER_FAVORITES_QUERIES) {
+ else if (fav->type == TOOLS_FAVORITES_QUERIES) {
if (!snode) {
snode = gda_tree_manager_create_node (manager, node, NULL);
@@ -496,23 +496,23 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
gboolean is_action = FALSE;
GSList *favlist;
GdkPixbuf *pixbuf;
- favlist = browser_favorites_list (browser_connection_get_favorites (bcnc),
- 0, BROWSER_FAVORITES_ACTIONS,
+ favlist = tools_favorites_list (browser_connection_get_favorites (bcnc),
+ 0, TOOLS_FAVORITES_ACTIONS,
-1, NULL);
if (favlist) {
gchar *tmp;
tmp = g_strdup_printf ("QUERY%d", fav->id);
GSList *list;
for (list = favlist; list; list = list->next) {
- BrowserFavoritesAttributes *afav;
- afav = (BrowserFavoritesAttributes*) list->data;
+ ToolsFavoritesAttributes *afav;
+ afav = (ToolsFavoritesAttributes*) list->data;
if (!strcmp (afav->contents, tmp)) {
is_action = TRUE;
break;
}
}
g_free (tmp);
- browser_favorites_free_list (favlist);
+ tools_favorites_free_list (favlist);
}
if (is_action)
pixbuf = browser_get_pixbuf_icon (BROWSER_ICON_ACTION);
@@ -541,7 +541,7 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
av, NULL);
gda_value_free (av);
}
- else if (fav->type == BROWSER_FAVORITES_DATA_MANAGERS) {
+ else if (fav->type == TOOLS_FAVORITES_DATA_MANAGERS) {
if (!snode) {
snode = gda_tree_manager_create_node (manager, node, NULL);
@@ -585,7 +585,7 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
gda_value_free (av);
}
#ifdef HAVE_LDAP
- else if (fav->type == BROWSER_FAVORITES_LDAP_DN) {
+ else if (fav->type == TOOLS_FAVORITES_LDAP_DN) {
if (!snode) {
/* favorite ID */
snode = gda_tree_manager_create_node (manager, node, NULL);
@@ -675,7 +675,7 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
av, NULL);
gda_value_free (av);
}
- else if (fav->type == BROWSER_FAVORITES_LDAP_CLASS) {
+ else if (fav->type == TOOLS_FAVORITES_LDAP_CLASS) {
if (!snode) {
/* favorite ID */
snode = gda_tree_manager_create_node (manager, node, NULL);
@@ -743,7 +743,7 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
if (snode)
nodes_list = g_slist_prepend (nodes_list, snode);
}
- browser_favorites_free_list (fav_list);
+ tools_favorites_free_list (fav_list);
}
else if (lerror) {
if (out_error)
@@ -765,7 +765,7 @@ mgr_favorites_update_children (GdaTreeManager *manager, GdaTreeNode *node, const
gchar *str;
GValue *value;
- if (mgr->priv->fav_type & BROWSER_FAVORITES_TABLES) {
+ if (mgr->priv->fav_type & TOOLS_FAVORITES_TABLES) {
str = g_strdup_printf ("<i>%s</i>", _("No favorite:\ndrag item to\ndefine one"));
snode = gda_tree_manager_create_node (manager, node, str);
g_value_take_string ((value = gda_value_new (G_TYPE_STRING)), str);
diff --git a/tools/browser/mgr-favorites.h b/tools/browser/mgr-favorites.h
index b5399f3..3fde52c 100644
--- a/tools/browser/mgr-favorites.h
+++ b/tools/browser/mgr-favorites.h
@@ -52,7 +52,7 @@ struct _MgrFavoritesClass {
*/
GType mgr_favorites_get_type (void) G_GNUC_CONST;
-GdaTreeManager* mgr_favorites_new (BrowserConnection *bcnc, BrowserFavoritesType type,
+GdaTreeManager* mgr_favorites_new (BrowserConnection *bcnc, ToolsFavoritesType type,
gint order_key);
/* name of the attribute which stores the favorite name */
diff --git a/tools/browser/query-exec/query-console-page.c b/tools/browser/query-exec/query-console-page.c
index 660be25..a29381d 100644
--- a/tools/browser/query-exec/query-console-page.c
+++ b/tools/browser/query-exec/query-console-page.c
@@ -697,7 +697,7 @@ static void
sql_favorite_clicked_cb (G_GNUC_UNUSED GtkButton *button, QueryConsolePage *tconsole)
{
GtkWidget *menu, *mitem;
- BrowserFavorites *bfav;
+ ToolsFavorites *bfav;
if (tconsole->priv->favorites_menu)
gtk_widget_destroy (tconsole->priv->favorites_menu);
@@ -712,8 +712,8 @@ sql_favorite_clicked_cb (G_GNUC_UNUSED GtkButton *button, QueryConsolePage *tcon
bfav = browser_connection_get_favorites (tconsole->priv->bcnc);
if (tconsole->priv->fav_id >= 0) {
- BrowserFavoritesAttributes fav;
- if (browser_favorites_get (bfav, tconsole->priv->fav_id, &fav, NULL)) {
+ ToolsFavoritesAttributes fav;
+ if (tools_favorites_get (bfav, tconsole->priv->fav_id, &fav, NULL)) {
gchar *str;
str = g_strdup_printf (_("Modify favorite '%s'"), fav.name);
mitem = gtk_menu_item_new_with_label (str);
@@ -726,12 +726,12 @@ sql_favorite_clicked_cb (G_GNUC_UNUSED GtkButton *button, QueryConsolePage *tcon
GINT_TO_POINTER (tconsole->priv->fav_id));
gtk_widget_show (mitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
}
}
GSList *allfav;
- allfav = browser_favorites_list (bfav, 0, BROWSER_FAVORITES_QUERIES, ORDER_KEY_QUERIES, NULL);
+ allfav = tools_favorites_list (bfav, 0, TOOLS_FAVORITES_QUERIES, ORDER_KEY_QUERIES, NULL);
if (allfav) {
GtkWidget *submenu;
GSList *list;
@@ -743,8 +743,8 @@ sql_favorite_clicked_cb (G_GNUC_UNUSED GtkButton *button, QueryConsolePage *tcon
submenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mitem), submenu);
for (list = allfav; list; list = list->next) {
- BrowserFavoritesAttributes *fav;
- fav = (BrowserFavoritesAttributes*) list->data;
+ ToolsFavoritesAttributes *fav;
+ fav = (ToolsFavoritesAttributes*) list->data;
if (fav->id == tconsole->priv->fav_id)
continue;
gchar *str;
@@ -760,7 +760,7 @@ sql_favorite_clicked_cb (G_GNUC_UNUSED GtkButton *button, QueryConsolePage *tcon
gtk_widget_show (mitem);
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), mitem);
}
- browser_favorites_free_list (allfav);
+ tools_favorites_free_list (allfav);
}
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
@@ -777,8 +777,8 @@ fav_form_name_activated_cb (G_GNUC_UNUSED GtkWidget *form, GtkWidget *dlg)
static void
sql_favorite_new_mitem_cb (G_GNUC_UNUSED GtkMenuItem *mitem, QueryConsolePage *tconsole)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
GdaSet *set;
@@ -803,14 +803,14 @@ sql_favorite_new_mitem_cb (G_GNUC_UNUSED GtkMenuItem *mitem, QueryConsolePage *t
memset (&fav, 0, sizeof (fav));
fav.id = -1;
- fav.type = BROWSER_FAVORITES_QUERIES;
+ fav.type = TOOLS_FAVORITES_QUERIES;
fav.contents = query_editor_get_all_text (tconsole->priv->editor);
cvalue = gda_set_get_holder_value (set, _("Favorite's name"));
fav.name = (gchar*) g_value_get_string (cvalue);
bfav = browser_connection_get_favorites (tconsole->priv->bcnc);
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_QUERIES, G_MAXINT, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_QUERIES, G_MAXINT, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tconsole),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
@@ -828,19 +828,19 @@ sql_favorite_new_mitem_cb (G_GNUC_UNUSED GtkMenuItem *mitem, QueryConsolePage *t
static void
sql_favorite_modify_mitem_cb (G_GNUC_UNUSED GtkMenuItem *mitem, QueryConsolePage *tconsole)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
memset (&fav, 0, sizeof (fav));
fav.id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (mitem), "favid"));
- fav.type = BROWSER_FAVORITES_QUERIES;
+ fav.type = TOOLS_FAVORITES_QUERIES;
fav.contents = query_editor_get_all_text (tconsole->priv->editor);
fav.name = g_object_get_data (G_OBJECT (mitem), "favname");
bfav = browser_connection_get_favorites (tconsole->priv->bcnc);
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_QUERIES, G_MAXINT, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_QUERIES, G_MAXINT, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tconsole),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
diff --git a/tools/browser/query-exec/query-exec-perspective.c b/tools/browser/query-exec/query-exec-perspective.c
index 74d9d45..e2d50f1 100644
--- a/tools/browser/query-exec/query-exec-perspective.c
+++ b/tools/browser/query-exec/query-exec-perspective.c
@@ -133,7 +133,7 @@ query_exec_perspective_init (QueryExecPerspective *perspective)
gtk_orientable_set_orientation (GTK_ORIENTABLE (perspective), GTK_ORIENTATION_VERTICAL);
}
-static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, BrowserFavoritesType fav_type,
+static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, ToolsFavoritesType fav_type,
const gchar *selection, QueryExecPerspective *perspective);
static void close_button_clicked_cb (GtkWidget *wid, GtkWidget *page_widget);
@@ -207,7 +207,7 @@ query_exec_perspective_new (BrowserWindow *bwin)
static void
fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gint fav_id,
- G_GNUC_UNUSED BrowserFavoritesType fav_type, const gchar *selection,
+ G_GNUC_UNUSED ToolsFavoritesType fav_type, const gchar *selection,
QueryExecPerspective *perspective)
{
GtkNotebook *nb;
diff --git a/tools/browser/query-exec/query-favorite-selector.c b/tools/browser/query-exec/query-favorite-selector.c
index 0db69be..a323f25 100644
--- a/tools/browser/query-exec/query-favorite-selector.c
+++ b/tools/browser/query-exec/query-favorite-selector.c
@@ -28,7 +28,6 @@
#include "../support.h"
#include "marshal.h"
#include "../cc-gray-bar.h"
-#include "../browser-favorites.h"
#include <gdk/gdkkeysyms.h>
#include <libgda-ui/internal/popup-container.h>
#include "query-editor.h"
@@ -54,7 +53,7 @@ static void query_favorite_selector_init (QueryFavoriteSelector *tsel,
QueryFavoriteSelectorClass *klass);
static void query_favorite_selector_dispose (GObject *object);
-static void favorites_changed_cb (BrowserFavorites *bfav, QueryFavoriteSelector *tsel);
+static void favorites_changed_cb (ToolsFavorites *bfav, QueryFavoriteSelector *tsel);
enum {
SELECTION_CHANGED,
@@ -177,15 +176,15 @@ favorite_delete_selected (QueryFavoriteSelector *tsel)
select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tsel->priv->treeview));
if (gtk_tree_selection_get_selected (select, &model, &iter)) {
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *lerror = NULL;
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
gtk_tree_model_get (model, &iter,
COLUMN_ID, &(fav.id), -1);
bfav = browser_connection_get_favorites (tsel->priv->bcnc);
- if (!browser_favorites_delete (bfav, 0, &fav, NULL)) {
+ if (!tools_favorites_delete (bfav, 0, &fav, NULL)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*)tsel),
_("Could not remove favorite: %s"),
lerror && lerror->message ? lerror->message : _("No detail"));
@@ -197,9 +196,9 @@ favorite_delete_selected (QueryFavoriteSelector *tsel)
gint id;
gchar *tmp;
tmp = g_strdup_printf ("QUERY%d", fav.id);
- id = browser_favorites_find (bfav, 0, tmp, &fav, NULL);
+ id = tools_favorites_find (bfav, 0, tmp, &fav, NULL);
if (id >= 0) {
- browser_favorites_delete (bfav, 0, &fav, NULL);
+ tools_favorites_delete (bfav, 0, &fav, NULL);
/*g_print ("ACTION_DELETED %d: %s\n", fav.id, tmp);*/
}
g_free (tmp);
@@ -244,21 +243,21 @@ selection_changed_cb (GtkTreeView *treeview, G_GNUC_UNUSED GtkTreePath *path,
static gboolean
prop_save_timeout (QueryFavoriteSelector *tsel)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
gboolean allok, actiondel = TRUE;
bfav = browser_connection_get_favorites (tsel->priv->bcnc);
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = tsel->priv->properties_id;
- fav.type = BROWSER_FAVORITES_QUERIES;
+ fav.type = TOOLS_FAVORITES_QUERIES;
fav.name = (gchar*) gtk_entry_get_text (GTK_ENTRY (tsel->priv->properties_name));
fav.descr = NULL;
fav.contents = query_editor_get_all_text (QUERY_EDITOR (tsel->priv->properties_text));
- allok = browser_favorites_add (bfav, 0, &fav, ORDER_KEY_QUERIES,
+ allok = tools_favorites_add (bfav, 0, &fav, ORDER_KEY_QUERIES,
tsel->priv->properties_position, &error);
if (! allok) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tsel),
@@ -275,11 +274,11 @@ prop_save_timeout (QueryFavoriteSelector *tsel)
is_action = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tsel->priv->properties_action));
if (is_action) {
fav.id = -1;
- fav.type = BROWSER_FAVORITES_ACTIONS;
+ fav.type = TOOLS_FAVORITES_ACTIONS;
fav.name = (gchar*) gtk_entry_get_text (GTK_ENTRY (tsel->priv->properties_name));
fav.descr = NULL;
fav.contents = g_strdup_printf ("QUERY%d", qid);
- allok = browser_favorites_add (bfav, 0, &fav, -1,
+ allok = tools_favorites_add (bfav, 0, &fav, -1,
tsel->priv->properties_position, &error);
if (! allok) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tsel),
@@ -300,9 +299,9 @@ prop_save_timeout (QueryFavoriteSelector *tsel)
gint id;
gchar *tmp;
tmp = g_strdup_printf ("QUERY%d", tsel->priv->properties_id);
- id = browser_favorites_find (bfav, 0, tmp, &fav, NULL);
+ id = tools_favorites_find (bfav, 0, tmp, &fav, NULL);
if (id >= 0) {
- browser_favorites_delete (bfav, 0, &fav, NULL);
+ tools_favorites_delete (bfav, 0, &fav, NULL);
/*g_print ("ACTION_DELETED %d: %s\n", fav.id, tmp);*/
}
g_free (tmp);
@@ -434,11 +433,11 @@ properties_activated_cb (GtkMenuItem *mitem, QueryFavoriteSelector *tsel)
if (tsel->priv->properties_id >= 0) {
gint id;
gchar *tmp;
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
bfav = browser_connection_get_favorites (tsel->priv->bcnc);
tmp = g_strdup_printf ("QUERY%d", tsel->priv->properties_id);
- id = browser_favorites_find (bfav, 0, tmp, &fav, NULL);
+ id = tools_favorites_find (bfav, 0, tmp, &fav, NULL);
if (id >= 0) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tsel->priv->properties_action),
TRUE);
@@ -547,7 +546,7 @@ query_favorite_selector_new (BrowserConnection *bcnc)
/* create tree managers */
tsel->priv->tree = gda_tree_new ();
- manager = mgr_favorites_new (bcnc, BROWSER_FAVORITES_QUERIES, ORDER_KEY_QUERIES);
+ manager = mgr_favorites_new (bcnc, TOOLS_FAVORITES_QUERIES, ORDER_KEY_QUERIES);
gda_tree_add_manager (tsel->priv->tree, manager);
g_object_unref (manager);
@@ -679,20 +678,20 @@ static gboolean
tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
GtkSelectionData *selection_data, QueryFavoriteSelector *tsel)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
gint pos;
gboolean retval = TRUE;
gint id;
bfav = browser_connection_get_favorites (tsel->priv->bcnc);
- id = browser_favorites_find (bfav, 0, (gchar*) gtk_selection_data_get_data (selection_data),
+ id = tools_favorites_find (bfav, 0, (gchar*) gtk_selection_data_get_data (selection_data),
&fav, NULL);
if (id < 0) {
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = -1;
- fav.type = BROWSER_FAVORITES_QUERIES;
+ fav.type = TOOLS_FAVORITES_QUERIES;
fav.name = _("Unnamed query");
fav.descr = NULL;
fav.contents = (gchar*) gtk_selection_data_get_data (selection_data);
@@ -701,7 +700,7 @@ tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
pos = atoi (path);
/*g_print ("%s() path => %s, pos: %d\n", __FUNCTION__, path, pos);*/
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_QUERIES, pos, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_QUERIES, pos, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tsel),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
@@ -711,7 +710,7 @@ tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
}
if (id >= 0)
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
return retval;
}
@@ -753,7 +752,7 @@ tree_store_drag_get_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
}
static void
-favorites_changed_cb (G_GNUC_UNUSED BrowserFavorites *bfav, QueryFavoriteSelector *tsel)
+favorites_changed_cb (G_GNUC_UNUSED ToolsFavorites *bfav, QueryFavoriteSelector *tsel)
{
if (! gda_tree_update_all (tsel->priv->tree, NULL)) {
if (tsel->priv->idle_update_favorites == 0)
diff --git a/tools/browser/query-exec/query-favorite-selector.h b/tools/browser/query-exec/query-favorite-selector.h
index 6811cd1..123e21a 100644
--- a/tools/browser/query-exec/query-favorite-selector.h
+++ b/tools/browser/query-exec/query-favorite-selector.h
@@ -43,7 +43,7 @@ struct _QueryFavoriteSelectorClass {
GtkBoxClass parent_class;
void (*selection_changed) (QueryFavoriteSelector *sel, gint fav_id,
- BrowserFavoritesType fav_type, const gchar *fav_contents);
+ ToolsFavoritesType fav_type, const gchar *fav_contents);
};
GType query_favorite_selector_get_type (void) G_GNUC_CONST;
diff --git a/tools/browser/schema-browser/favorite-selector.c b/tools/browser/schema-browser/favorite-selector.c
index 398a13b..ec7b26d 100644
--- a/tools/browser/schema-browser/favorite-selector.c
+++ b/tools/browser/schema-browser/favorite-selector.c
@@ -27,7 +27,6 @@
#include "../support.h"
#include "marshal.h"
#include "../cc-gray-bar.h"
-#include "../browser-favorites.h"
#include <gdk/gdkkeysyms.h>
struct _FavoriteSelectorPrivate {
@@ -42,7 +41,7 @@ static void favorite_selector_init (FavoriteSelector *tsel,
FavoriteSelectorClass *klass);
static void favorite_selector_dispose (GObject *object);
-static void favorites_changed_cb (BrowserFavorites *bfav, FavoriteSelector *tsel);
+static void favorites_changed_cb (ToolsFavorites *bfav, FavoriteSelector *tsel);
enum {
SELECTION_CHANGED,
@@ -156,15 +155,15 @@ key_press_event_cb (GtkTreeView *treeview, GdkEventKey *event, FavoriteSelector
select = gtk_tree_view_get_selection (treeview);
if (gtk_tree_selection_get_selected (select, &model, &iter)) {
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *lerror = NULL;
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
gtk_tree_model_get (model, &iter,
COLUMN_ID, &(fav.id), -1);
bfav = browser_connection_get_favorites (tsel->priv->bcnc);
- if (!browser_favorites_delete (bfav, 0, &fav, NULL)) {
+ if (!tools_favorites_delete (bfav, 0, &fav, NULL)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*)tsel),
_("Could not remove favorite: %s"),
lerror && lerror->message ? lerror->message : _("No detail"));
@@ -229,7 +228,7 @@ favorite_selector_new (BrowserConnection *bcnc)
/* create tree managers */
tsel->priv->tree = gda_tree_new ();
- manager = mgr_favorites_new (bcnc, BROWSER_FAVORITES_TABLES | BROWSER_FAVORITES_DIAGRAMS,
+ manager = mgr_favorites_new (bcnc, TOOLS_FAVORITES_TABLES | TOOLS_FAVORITES_DIAGRAMS,
ORDER_KEY_SCHEMA);
gda_tree_add_manager (tsel->priv->tree, manager);
g_object_unref (manager);
@@ -330,14 +329,14 @@ static gboolean
tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
GtkSelectionData *selection_data, FavoriteSelector *tsel)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
gint pos;
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = -1;
- fav.type = BROWSER_FAVORITES_TABLES;
+ fav.type = TOOLS_FAVORITES_TABLES;
fav.name = NULL;
fav.descr = NULL;
fav.contents = (gchar*) gtk_selection_data_get_data (selection_data);
@@ -346,7 +345,7 @@ tree_store_drag_drop_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
/*g_print ("%s() path => %s, pos: %d\n", __FUNCTION__, path, pos);*/
bfav = browser_connection_get_favorites (tsel->priv->bcnc);
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_SCHEMA, pos, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_SCHEMA, pos, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tsel),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
@@ -394,7 +393,7 @@ tree_store_drag_get_cb (G_GNUC_UNUSED GdauiTreeStore *store, const gchar *path,
}
static void
-favorites_changed_cb (G_GNUC_UNUSED BrowserFavorites *bfav, FavoriteSelector *tsel)
+favorites_changed_cb (G_GNUC_UNUSED ToolsFavorites *bfav, FavoriteSelector *tsel)
{
if (! gda_tree_update_all (tsel->priv->tree, NULL)) {
if (tsel->priv->idle_update_favorites == 0)
diff --git a/tools/browser/schema-browser/favorite-selector.h b/tools/browser/schema-browser/favorite-selector.h
index 8790242..d78d4c6 100644
--- a/tools/browser/schema-browser/favorite-selector.h
+++ b/tools/browser/schema-browser/favorite-selector.h
@@ -43,7 +43,7 @@ struct _FavoriteSelectorClass {
GtkBoxClass parent_class;
void (*selection_changed) (FavoriteSelector *sel, gint fav_id,
- BrowserFavoritesType fav_type, const gchar *fav_contents);
+ ToolsFavoritesType fav_type, const gchar *fav_contents);
};
GType favorite_selector_get_type (void) G_GNUC_CONST;
diff --git a/tools/browser/schema-browser/objects-index.c b/tools/browser/schema-browser/objects-index.c
index 4b3982f..bd62960 100644
--- a/tools/browser/schema-browser/objects-index.c
+++ b/tools/browser/schema-browser/objects-index.c
@@ -137,7 +137,7 @@ cloud_object_selected_cb (G_GNUC_UNUSED ObjectsCloud *sel, G_GNUC_UNUSED Objects
{
/* FIXME: adjust with sel->priv->type */
g_signal_emit (index, objects_index_signals [SELECTION_CHANGED], 0,
- BROWSER_FAVORITES_TABLES, sel_contents);
+ TOOLS_FAVORITES_TABLES, sel_contents);
}
/**
diff --git a/tools/browser/schema-browser/objects-index.h b/tools/browser/schema-browser/objects-index.h
index 2a66dcf..6de2f59 100644
--- a/tools/browser/schema-browser/objects-index.h
+++ b/tools/browser/schema-browser/objects-index.h
@@ -44,7 +44,7 @@ struct _ObjectsIndexClass {
/* signals */
void (*selection_changed) (ObjectsIndex *sel,
- BrowserFavoritesType fav_type, const gchar *fav_contents);
+ ToolsFavoritesType fav_type, const gchar *fav_contents);
};
GType objects_index_get_type (void) G_GNUC_CONST;
diff --git a/tools/browser/schema-browser/relations-diagram.c b/tools/browser/schema-browser/relations-diagram.c
index 54759aa..460b059 100644
--- a/tools/browser/schema-browser/relations-diagram.c
+++ b/tools/browser/schema-browser/relations-diagram.c
@@ -218,12 +218,12 @@ real_save_clicked_cb (GtkWidget *button, RelationsDiagram *diagram)
str = browser_canvas_serialize_items (BROWSER_CANVAS (diagram->priv->canvas));
GError *lerror = NULL;
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = diagram->priv->fav_id;
- fav.type = BROWSER_FAVORITES_DIAGRAMS;
+ fav.type = TOOLS_FAVORITES_DIAGRAMS;
fav.name = gtk_editable_get_chars (GTK_EDITABLE (diagram->priv->name_entry), 0, -1);
if (!*fav.name) {
g_free (fav.name);
@@ -234,7 +234,7 @@ real_save_clicked_cb (GtkWidget *button, RelationsDiagram *diagram)
gtk_widget_hide (diagram->priv->popup_container);
bfav = browser_connection_get_favorites (diagram->priv->bcnc);
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_SCHEMA, G_MAXINT, &lerror)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_SCHEMA, G_MAXINT, &lerror)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel (button),
"<b>%s:</b>\n%s",
_("Could not save diagram"),
@@ -272,11 +272,11 @@ save_clicked_cb (GtkWidget *button, RelationsDiagram *diagram)
gtk_box_pack_start (GTK_BOX (hbox), wid, FALSE, FALSE, 5);
diagram->priv->name_entry = wid;
if (diagram->priv->fav_id > 0) {
- BrowserFavoritesAttributes fav;
- if (browser_favorites_get (browser_connection_get_favorites (diagram->priv->bcnc),
+ ToolsFavoritesAttributes fav;
+ if (tools_favorites_get (browser_connection_get_favorites (diagram->priv->bcnc),
diagram->priv->fav_id, &fav, NULL)) {
gtk_entry_set_text (GTK_ENTRY (wid), fav.name);
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
}
}
@@ -360,10 +360,10 @@ GtkWidget *
relations_diagram_new_with_fav_id (BrowserConnection *bcnc, gint fav_id, GError **error)
{
RelationsDiagram *diagram = NULL;
- BrowserFavoritesAttributes fav;
+ ToolsFavoritesAttributes fav;
xmlDocPtr doc = NULL;
- if (! browser_favorites_get (browser_connection_get_favorites (bcnc),
+ if (! tools_favorites_get (browser_connection_get_favorites (bcnc),
fav_id, &fav, error))
return FALSE;
@@ -439,7 +439,7 @@ relations_diagram_new_with_fav_id (BrowserConnection *bcnc, gint fav_id, GError
}
out:
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
if (doc)
xmlFreeDoc (doc);
return (GtkWidget*) diagram;
@@ -454,10 +454,10 @@ static void
relations_diagram_set_fav_id (RelationsDiagram *diagram, gint fav_id, GError **error)
{
g_return_if_fail (IS_RELATIONS_DIAGRAM (diagram));
- BrowserFavoritesAttributes fav;
+ ToolsFavoritesAttributes fav;
if ((fav_id >=0) &&
- browser_favorites_get (browser_connection_get_favorites (diagram->priv->bcnc),
+ tools_favorites_get (browser_connection_get_favorites (diagram->priv->bcnc),
fav_id, &fav, error)) {
gchar *str, *tmp;
tmp = g_markup_printf_escaped (_("'%s' diagram"), fav.name);
@@ -468,7 +468,7 @@ relations_diagram_set_fav_id (RelationsDiagram *diagram, gint fav_id, GError **e
diagram->priv->fav_id = fav.id;
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
}
else {
gchar *str;
@@ -557,11 +557,11 @@ relations_diagram_page_get_tab_label (BrowserPage *page, GtkWidget **out_close_b
diagram = RELATIONS_DIAGRAM (page);
if (diagram->priv->fav_id > 0) {
- BrowserFavoritesAttributes fav;
- if (browser_favorites_get (browser_connection_get_favorites (diagram->priv->bcnc),
+ ToolsFavoritesAttributes fav;
+ if (tools_favorites_get (browser_connection_get_favorites (diagram->priv->bcnc),
diagram->priv->fav_id, &fav, NULL)) {
tab_name = g_strdup (fav.name);
- browser_favorites_reset_attributes (&fav);
+ tools_favorites_reset_attributes (&fav);
}
}
if (!tab_name)
diff --git a/tools/browser/schema-browser/schema-browser-perspective.c b/tools/browser/schema-browser/schema-browser-perspective.c
index 2d9a6d4..c01827f 100644
--- a/tools/browser/schema-browser/schema-browser-perspective.c
+++ b/tools/browser/schema-browser/schema-browser-perspective.c
@@ -122,9 +122,9 @@ schema_browser_perspective_init (SchemaBrowserPerspective *perspective)
gtk_orientable_set_orientation (GTK_ORIENTABLE (perspective), GTK_ORIENTATION_VERTICAL);
}
-static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, BrowserFavoritesType fav_type,
+static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, ToolsFavoritesType fav_type,
const gchar *selection, SchemaBrowserPerspective *bpers);
-static void objects_index_selection_changed_cb (GtkWidget *widget, BrowserFavoritesType fav_type,
+static void objects_index_selection_changed_cb (GtkWidget *widget, ToolsFavoritesType fav_type,
const gchar *selection, SchemaBrowserPerspective *bpers);
/**
* schema_browser_perspective_new
@@ -193,7 +193,7 @@ close_button_clicked_cb (G_GNUC_UNUSED GtkWidget *wid, GtkWidget *page_widget)
}
static void
-objects_index_selection_changed_cb (GtkWidget *widget, BrowserFavoritesType fav_type,
+objects_index_selection_changed_cb (GtkWidget *widget, ToolsFavoritesType fav_type,
const gchar *selection, SchemaBrowserPerspective *bpers)
{
fav_selection_changed_cb (widget, -1, fav_type, selection, bpers);
@@ -201,10 +201,10 @@ objects_index_selection_changed_cb (GtkWidget *widget, BrowserFavoritesType fav_
static void
-fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gint fav_id, BrowserFavoritesType fav_type,
+fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gint fav_id, ToolsFavoritesType fav_type,
const gchar *selection, SchemaBrowserPerspective *bpers)
{
- if (fav_type == BROWSER_FAVORITES_TABLES) {
+ if (fav_type == TOOLS_FAVORITES_TABLES) {
GdaQuarkList *ql;
const gchar *type;
const gchar *schema = NULL, *table = NULL, *short_name = NULL;
@@ -248,7 +248,7 @@ fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gint fav_id, BrowserF
if (ql)
gda_quark_list_free (ql);
}
- else if (fav_type == BROWSER_FAVORITES_DIAGRAMS) {
+ else if (fav_type == TOOLS_FAVORITES_DIAGRAMS) {
#ifdef HAVE_GOOCANVAS
schema_browser_perspective_display_diagram (bpers, fav_id);
#else
@@ -304,7 +304,7 @@ favorites_toggle_cb (GtkToggleAction *action, BrowserPerspective *bpers)
static const GtkToggleActionEntry ui_toggle_actions [] =
{
- { "SchemaBrowserFavoritesShow", NULL, N_("_Show favorites"), "F9", N_("Show or hide favorites"), G_CALLBACK (favorites_toggle_cb), FALSE }
+ { "SchemaToolsFavoritesShow", NULL, N_("_Show favorites"), "F9", N_("Show or hide favorites"), G_CALLBACK (favorites_toggle_cb), FALSE }
};
static GtkActionEntry ui_actions[] = {
@@ -319,7 +319,7 @@ static const gchar *ui_actions_info =
"<ui>"
" <menubar name='MenuBar'>"
" <menu name='Display' action='Display'>"
- " <menuitem name='SchemaBrowserFavoritesShow' action='SchemaBrowserFavoritesShow'/>"
+ " <menuitem name='SchemaToolsFavoritesShow' action='SchemaToolsFavoritesShow'/>"
" </menu>"
#ifdef HAVE_GOOCANVAS
" <placeholder name='MenuExtension'>"
@@ -346,7 +346,7 @@ schema_browser_perspective_get_actions_group (BrowserPerspective *perspective)
G_N_ELEMENTS (ui_toggle_actions),
bpers);
GtkAction *action;
- action = gtk_action_group_get_action (agroup, "SchemaBrowserFavoritesShow");
+ action = gtk_action_group_get_action (agroup, "SchemaToolsFavoritesShow");
if (bpers->priv->favorites)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
bpers->priv->favorites_shown);
diff --git a/tools/browser/schema-browser/table-info.c b/tools/browser/schema-browser/table-info.c
index bb7a05a..fa27fc0 100644
--- a/tools/browser/schema-browser/table-info.c
+++ b/tools/browser/schema-browser/table-info.c
@@ -450,19 +450,19 @@ table_info_get_connection (TableInfo *tinfo)
static void
action_add_to_fav_cb (G_GNUC_UNUSED GtkAction *action, TableInfo *tinfo)
{
- BrowserFavorites *bfav;
- BrowserFavoritesAttributes fav;
+ ToolsFavorites *bfav;
+ ToolsFavoritesAttributes fav;
GError *error = NULL;
- memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&fav, 0, sizeof (ToolsFavoritesAttributes));
fav.id = -1;
- fav.type = BROWSER_FAVORITES_TABLES;
+ fav.type = TOOLS_FAVORITES_TABLES;
fav.name = NULL;
fav.descr = NULL;
fav.contents = table_info_to_selection (tinfo);
bfav = browser_connection_get_favorites (tinfo->priv->bcnc);
- if (! browser_favorites_add (bfav, 0, &fav, ORDER_KEY_SCHEMA, G_MAXINT, &error)) {
+ if (! tools_favorites_add (bfav, 0, &fav, ORDER_KEY_SCHEMA, G_MAXINT, &error)) {
browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tinfo),
_("Could not add favorite: %s"),
error && error->message ? error->message : _("No detail"));
diff --git a/tools/gda-sql.c b/tools/gda-sql.c
index a9bdd9b..ca5bc54 100644
--- a/tools/gda-sql.c
+++ b/tools/gda-sql.c
@@ -2453,7 +2453,7 @@ build_internal_commands_list (void)
commands->commands = g_slist_prepend (commands->commands, c);
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
+ c->group = _("Query buffer & query favorites");
c->name = g_strdup_printf (_("%s [<FILE>]"), "e");
c->description = _("Edit the query buffer (or file) with external editor");
c->args = NULL;
@@ -2465,9 +2465,9 @@ build_internal_commands_list (void)
commands->commands = g_slist_prepend (commands->commands, c);
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
+ c->group = _("Query buffer & query favorites");
c->name = g_strdup_printf (_("%s [<FILE>]"), "qr");
- c->description = _("Reset the query buffer (fill buffer with contents of file)");
+ c->description = _("Reset the query buffer (or load file into query buffer)");
c->args = NULL;
c->command_func = (GdaInternalCommandFunc) extra_command_reset_buffer;
c->user_data = NULL;
@@ -2477,7 +2477,7 @@ build_internal_commands_list (void)
commands->commands = g_slist_prepend (commands->commands, c);
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
+ c->group = _("Query buffer & query favorites");
c->name = "qp";
c->description = _("Show the contents of the query buffer");
c->args = NULL;
@@ -2489,9 +2489,9 @@ build_internal_commands_list (void)
commands->commands = g_slist_prepend (commands->commands, c);
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
- c->name = g_strdup_printf (_("%s [<QUERY_BUFFER_NAME>]"), "g");
- c->description = _("Execute contents of query buffer, or named query buffer");
+ c->group = _("Query buffer & query favorites");
+ c->name = g_strdup_printf (_("%s [<FAVORITE_NAME>]"), "g");
+ c->description = _("Execute contents of query buffer, or execute specified query favorite");
c->args = NULL;
c->command_func = (GdaInternalCommandFunc) extra_command_exec_buffer;
c->user_data = NULL;
@@ -2501,7 +2501,7 @@ build_internal_commands_list (void)
commands->commands = g_slist_prepend (commands->commands, c);
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
+ c->group = _("Query buffer & query favorites");
c->name = g_strdup_printf (_("%s <FILE>"), "qw");
c->description = _("Write query buffer to file");
c->args = NULL;
@@ -2513,9 +2513,9 @@ build_internal_commands_list (void)
commands->commands = g_slist_prepend (commands->commands, c);
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
- c->name = g_strdup_printf (_("%s <QUERY_BUFFER_NAME>"), "qs");
- c->description = _("Save query buffer to dictionary");
+ c->group = _("Query buffer & query favorites");
+ c->name = g_strdup_printf (_("%s <FAVORITE_NAME>"), "qs");
+ c->description = _("Save query buffer as favorite");
c->args = NULL;
c->command_func = (GdaInternalCommandFunc) extra_command_query_buffer_to_dict;
c->user_data = NULL;
@@ -2525,9 +2525,9 @@ build_internal_commands_list (void)
commands->commands = g_slist_prepend (commands->commands, c);
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
- c->name = g_strdup_printf (_("%s <QUERY_BUFFER_NAME>"), "ql");
- c->description = _("Load query buffer from dictionary");
+ c->group = _("Query buffer & query favorites");
+ c->name = g_strdup_printf (_("%s <FAVORITE_NAME>"), "ql");
+ c->description = _("Load a query favorite into query buffer");
c->args = NULL;
c->command_func = (GdaInternalCommandFunc) extra_command_query_buffer_from_dict;
c->user_data = NULL;
@@ -2537,9 +2537,9 @@ build_internal_commands_list (void)
commands->commands = g_slist_prepend (commands->commands, c);
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
- c->name = g_strdup_printf (_("%s <QUERY_BUFFER_NAME>"), "qd");
- c->description = _("Delete query buffer from dictionary");
+ c->group = _("Query buffer & query favorites");
+ c->name = g_strdup_printf (_("%s <FAVORITE_NAME>"), "qd");
+ c->description = _("Delete a query favorite");
c->args = NULL;
c->command_func = (GdaInternalCommandFunc) extra_command_query_buffer_delete_dict;
c->user_data = NULL;
@@ -2549,9 +2549,9 @@ build_internal_commands_list (void)
commands->commands = g_slist_prepend (commands->commands, c);
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
+ c->group = _("Query buffer & query favorites");
c->name = g_strdup_printf (_("%s"), "qa");
- c->description = _("List all saved query buffers in dictionary");
+ c->description = _("List all query favorites");
c->args = NULL;
c->command_func = (GdaInternalCommandFunc) extra_command_query_buffer_list_dict;
c->user_data = NULL;
@@ -2574,7 +2574,7 @@ build_internal_commands_list (void)
/*
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
+ c->group = _("Query buffer & query favorites");
c->name = g_strdup_printf (_("%s <FILE> <TABLE> <BLOB_COLUMN> <ROW_CONDITION>"), "lo_update");
c->description = _("Import a blob into the database");
c->args = NULL;
@@ -2586,7 +2586,7 @@ build_internal_commands_list (void)
*/
c = g_new0 (GdaInternalCommand, 1);
- c->group = _("Query buffer");
+ c->group = _("Query buffer & query favorites");
c->name = g_strdup_printf (_("%s [<NAME>|<TABLE> <COLUMN> <ROW_CONDITION>] <FILE>"), "export");
c->description = _("Export internal parameter or table's value to the FILE file");
c->args = NULL;
@@ -3754,14 +3754,6 @@ extra_command_write_buffer (SqlConsole *console, G_GNUC_UNUSED GdaConnection *cn
}
#define QUERY_BUFFERS_TABLE_NAME "gda_sql_query_buffers"
-#define QUERY_BUFFERS_TABLE_DESC \
- "<table name=\"" QUERY_BUFFERS_TABLE_NAME "\"> " \
- " <column name=\"id\" type=\"gint\" pkey=\"TRUE\" autoinc=\"TRUE\"/>" \
- " <column name=\"name\"/>" \
- " <column name=\"sql\"/>" \
- "</table>"
-#define QUERY_BUFFERS_TABLE_INSERT \
- "INSERT INTO " QUERY_BUFFERS_TABLE_NAME " (name, sql) VALUES (##name::string, ##sql::string)"
#define QUERY_BUFFERS_TABLE_SELECT \
"SELECT name, sql FROM " QUERY_BUFFERS_TABLE_NAME " ORDER BY name"
#define QUERY_BUFFERS_TABLE_SELECT_ONE \
@@ -3774,6 +3766,7 @@ extra_command_query_buffer_list_dict (SqlConsole *console, G_GNUC_UNUSED GdaConn
GError **error, G_GNUC_UNUSED gpointer data)
{
GdaInternalCommandResult *res = NULL;
+ GdaDataModel *retmodel;
if (console) {
GdaInternalCommandResult *res;
@@ -3789,35 +3782,91 @@ extra_command_query_buffer_list_dict (SqlConsole *console, G_GNUC_UNUSED GdaConn
return NULL;
}
- /* Meta store's init */
+ /* initialize returned data model */
+ retmodel = gda_data_model_array_new_with_g_types (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ gda_data_model_set_column_title (retmodel, 0, _("Favorite name"));
+ gda_data_model_set_column_title (retmodel, 1, _("Comments"));
+ gda_data_model_set_column_title (retmodel, 2, _("SQL"));
+
GdaMetaStore *mstore;
mstore = gda_connection_get_meta_store (main_data->current->cnc);
- if (!gda_meta_store_schema_add_custom_object (mstore, QUERY_BUFFERS_TABLE_DESC, NULL)) {
- g_set_error (error, 0, 0, "%s",
- _("Can't initialize dictionary to store query buffers"));
+
+ /* Use tools favorites */
+ if (! main_data->current->favorites)
+ main_data->current->favorites = tools_favorites_new (mstore);
+
+ GSList *favlist, *list;
+ GError *lerror = NULL;
+ favlist = tools_favorites_list (main_data->current->favorites, 0, TOOLS_FAVORITES_QUERIES,
+ ORDER_KEY_QUERIES, &lerror);
+ if (lerror) {
+ g_propagate_error (error, lerror);
+ g_object_unref (retmodel);
return NULL;
}
-
- /* actual list retrieval */
- static GdaStatement *sel_stmt = NULL;
- GdaDataModel *model;
- if (!sel_stmt) {
- sel_stmt = gda_sql_parser_parse_string (main_data->current->parser,
- QUERY_BUFFERS_TABLE_SELECT, NULL, NULL);
- g_assert (sel_stmt);
+ for (list = favlist; list; list = list->next) {
+ ToolsFavoritesAttributes *att = (ToolsFavoritesAttributes*) list->data;
+ gint i;
+ GValue *value = NULL;
+ i = gda_data_model_append_row (retmodel, error);
+ if (i == -1)
+ goto cleanloop;
+ g_value_set_string ((value = gda_value_new (G_TYPE_STRING)), att->name);
+ if (! gda_data_model_set_value_at (retmodel, 0, i, value, error))
+ goto cleanloop;
+ g_value_set_string (value, att->descr);
+ if (! gda_data_model_set_value_at (retmodel, 1, i, value, error))
+ goto cleanloop;
+ g_value_set_string (value, att->contents);
+ if (! gda_data_model_set_value_at (retmodel, 2, i, value, error))
+ goto cleanloop;
+ gda_value_free (value);
+ continue;
+ cleanloop:
+ gda_value_free (value);
+ tools_favorites_free_list (favlist);
+ g_object_unref (retmodel);
+ return NULL;
}
+ if (favlist)
+ tools_favorites_free_list (favlist);
+ /* Use query buffer which used to be stored differently in previous versions of GdaSql:
+ * in the "gda_sql_query_buffers" table */
+ GdaStatement *sel_stmt = NULL;
+ GdaDataModel *model;
+ sel_stmt = gda_sql_parser_parse_string (main_data->current->parser,
+ QUERY_BUFFERS_TABLE_SELECT, NULL, NULL);
+ g_assert (sel_stmt);
GdaConnection *store_cnc;
store_cnc = gda_meta_store_get_internal_connection (mstore);
- model = gda_connection_statement_execute_select (store_cnc, sel_stmt, NULL, error);
- if (!model)
- return NULL;
+ model = gda_connection_statement_execute_select (store_cnc, sel_stmt, NULL, NULL);
+ g_object_unref (sel_stmt);
+ if (model) {
+ gint r, nrows;
+ nrows = gda_data_model_get_n_rows (model);
+ for (r = 0; r < nrows; r++) {
+ const GValue *cvalue = NULL;
+ gint i;
+ i = gda_data_model_append_row (retmodel, NULL);
+ if (i == -1)
+ break;
+ cvalue = gda_data_model_get_value_at (model, 0, r, NULL);
+ if (!cvalue)
+ break;
+ gda_data_model_set_value_at (retmodel, 0, i, cvalue, NULL);
- gda_data_model_set_column_title (model, 0, _("Query buffer name"));
- gda_data_model_set_column_title (model, 1, _("SQL"));
+ cvalue = gda_data_model_get_value_at (model, 1, r, NULL);
+ if (!cvalue)
+ break;
+ gda_data_model_set_value_at (retmodel, 2, i, cvalue, NULL);
+ }
+ g_object_unref (model);
+ }
+
res = g_new0 (GdaInternalCommandResult, 1);
res->type = GDA_INTERNAL_COMMAND_RESULT_DATA_MODEL;
- res->u.model = model;
+ res->u.model = retmodel;
return res;
}
@@ -3844,6 +3893,7 @@ extra_command_query_buffer_to_dict (SqlConsole *console, G_GNUC_UNUSED GdaConnec
if (!main_data->current->query_buffer)
main_data->current->query_buffer = g_string_new ("");
+
if (*main_data->current->query_buffer->str != 0) {
/* find a suitable name */
gchar *qname;
@@ -3855,53 +3905,25 @@ extra_command_query_buffer_to_dict (SqlConsole *console, G_GNUC_UNUSED GdaConnec
return NULL;
}
- /* Meta store's init */
+ /* Use tools favorites */
GdaMetaStore *mstore;
mstore = gda_connection_get_meta_store (main_data->current->cnc);
- if (!gda_meta_store_schema_add_custom_object (mstore, QUERY_BUFFERS_TABLE_DESC, NULL)) {
- g_set_error (error, 0, 0, "%s",
- _("Can't initialize dictionary to store query buffers"));
- g_free (qname);
- return NULL;
- }
-
- /* actual store of the statement */
- static GdaStatement *ins_stmt = NULL, *del_stmt;
- static GdaSet *ins_params = NULL;
- if (!ins_stmt) {
- ins_stmt = gda_sql_parser_parse_string (main_data->current->parser,
- QUERY_BUFFERS_TABLE_INSERT, NULL, NULL);
- g_assert (ins_stmt);
- g_assert (gda_statement_get_parameters (ins_stmt, &ins_params, NULL));
-
- del_stmt = gda_sql_parser_parse_string (main_data->current->parser,
- QUERY_BUFFERS_TABLE_DELETE, NULL, NULL);
- g_assert (del_stmt);
- }
-
- if (! gda_set_set_holder_value (ins_params, error, "name", qname) ||
- ! gda_set_set_holder_value (ins_params, error, "sql", main_data->current->query_buffer->str)) {
+ if (! main_data->current->favorites)
+ main_data->current->favorites = tools_favorites_new (mstore);
+
+ ToolsFavoritesAttributes att;
+ att.id = -1;
+ att.type = TOOLS_FAVORITES_QUERIES;
+ att.name = qname;
+ att.descr = NULL;
+ att.contents = main_data->current->query_buffer->str;
+
+ if (! tools_favorites_add (main_data->current->favorites, 0,
+ &att, ORDER_KEY_QUERIES, G_MAXINT, error)) {
g_free (qname);
return NULL;
}
g_free (qname);
-
- GdaConnection *store_cnc;
- gboolean intrans;
- store_cnc = gda_meta_store_get_internal_connection (mstore);
- intrans = gda_connection_begin_transaction (store_cnc, NULL,
- GDA_TRANSACTION_ISOLATION_UNKNOWN, NULL);
-
- if ((gda_connection_statement_execute_non_select (store_cnc, del_stmt, ins_params,
- NULL, error) == -1) ||
- (gda_connection_statement_execute_non_select (store_cnc, ins_stmt, ins_params,
- NULL, error) == -1)) {
- if (intrans)
- gda_connection_rollback_transaction (store_cnc, NULL, NULL);
- return NULL;
- }
- if (intrans)
- gda_connection_commit_transaction (store_cnc, NULL, NULL);
res = g_new0 (GdaInternalCommandResult, 1);
res->type = GDA_INTERNAL_COMMAND_RESULT_EMPTY;
@@ -3937,46 +3959,58 @@ extra_command_query_buffer_from_dict (SqlConsole *console, G_GNUC_UNUSED GdaConn
main_data->current->query_buffer = g_string_new ("");
if (args[0] && *args[0]) {
- /* Meta store's init */
+ /* Use tools favorites */
GdaMetaStore *mstore;
mstore = gda_connection_get_meta_store (main_data->current->cnc);
- if (!gda_meta_store_schema_add_custom_object (mstore, QUERY_BUFFERS_TABLE_DESC, NULL)) {
- g_set_error (error, 0, 0, "%s",
- _("Can't initialize dictionary to store query buffers"));
- return NULL;
- }
-
- /* query retrieval */
- static GdaStatement *sel_stmt = NULL;
- static GdaSet *sel_params = NULL;
- GdaDataModel *model;
- const GValue *cvalue;
- if (!sel_stmt) {
- sel_stmt = gda_sql_parser_parse_string (main_data->current->parser,
- QUERY_BUFFERS_TABLE_SELECT_ONE, NULL, NULL);
- g_assert (sel_stmt);
- g_assert (gda_statement_get_parameters (sel_stmt, &sel_params, NULL));
+ if (! main_data->current->favorites)
+ main_data->current->favorites = tools_favorites_new (mstore);
+
+ ToolsFavoritesAttributes att;
+ gint favid;
+ favid = tools_favorites_find_by_name (main_data->current->favorites, 0, TOOLS_FAVORITES_QUERIES,
+ args[0], &att, NULL);
+ if (favid >= 0) {
+ g_string_assign (main_data->current->query_buffer, att.contents);
+ res = g_new0 (GdaInternalCommandResult, 1);
+ res->type = GDA_INTERNAL_COMMAND_RESULT_EMPTY;
}
+ else {
+ /* query retrieval */
+ static GdaStatement *sel_stmt = NULL;
+ static GdaSet *sel_params = NULL;
+ GdaDataModel *model;
+ const GValue *cvalue;
+ GError *lerror = NULL;
- if (! gda_set_set_holder_value (sel_params, error, "name", args[0]))
- return NULL;
+ g_set_error (&lerror, 0, 0, "%s", _("Could not find favorite"));
+ if (!sel_stmt) {
+ sel_stmt = gda_sql_parser_parse_string (main_data->current->parser,
+ QUERY_BUFFERS_TABLE_SELECT_ONE, NULL, NULL);
+ g_assert (sel_stmt);
+ g_assert (gda_statement_get_parameters (sel_stmt, &sel_params, NULL));
+ }
- GdaConnection *store_cnc;
- store_cnc = gda_meta_store_get_internal_connection (mstore);
- model = gda_connection_statement_execute_select (store_cnc, sel_stmt, sel_params, error);
- if (!model)
- return NULL;
-
- if ((gda_data_model_get_n_rows (model) == 1) &&
- (cvalue = gda_data_model_get_value_at (model, 0, 0, NULL))) {
- g_string_assign (main_data->current->query_buffer, g_value_get_string (cvalue));
- res = g_new0 (GdaInternalCommandResult, 1);
- res->type = GDA_INTERNAL_COMMAND_RESULT_EMPTY;
+ if (! gda_set_set_holder_value (sel_params, error, "name", args[0])) {
+ g_propagate_error (error, lerror);
+ return NULL;
+ }
+
+ GdaConnection *store_cnc;
+ store_cnc = gda_meta_store_get_internal_connection (mstore);
+ model = gda_connection_statement_execute_select (store_cnc, sel_stmt, sel_params, NULL);
+ if (!model) {
+ g_propagate_error (error, lerror);
+ return NULL;
+ }
+
+ if ((gda_data_model_get_n_rows (model) == 1) &&
+ (cvalue = gda_data_model_get_value_at (model, 0, 0, NULL))) {
+ g_string_assign (main_data->current->query_buffer, g_value_get_string (cvalue));
+ res = g_new0 (GdaInternalCommandResult, 1);
+ res->type = GDA_INTERNAL_COMMAND_RESULT_EMPTY;
+ }
+ g_object_unref (model);
}
- else
- g_set_error (error, 0, 0,
- _("Could not find query buffer named '%s'"), args[0]);
- g_object_unref (model);
}
else
g_set_error (error, 0, 0, "%s",
@@ -4009,33 +4043,47 @@ extra_command_query_buffer_delete_dict (SqlConsole *console, G_GNUC_UNUSED GdaCo
main_data->current->query_buffer = g_string_new ("");
if (args[0] && *args[0]) {
- /* Meta store's init */
+ /* Use tools favorites */
GdaMetaStore *mstore;
mstore = gda_connection_get_meta_store (main_data->current->cnc);
- if (!gda_meta_store_schema_add_custom_object (mstore, QUERY_BUFFERS_TABLE_DESC, NULL)) {
- g_set_error (error, 0, 0, "%s",
- _("Can't initialize dictionary to store query buffers"));
- return NULL;
- }
-
- /* query retrieval */
- static GdaStatement *del_stmt = NULL;
- static GdaSet *del_params = NULL;
- if (!del_stmt) {
- del_stmt = gda_sql_parser_parse_string (main_data->current->parser,
- QUERY_BUFFERS_TABLE_DELETE, NULL, NULL);
- g_assert (del_stmt);
- g_assert (gda_statement_get_parameters (del_stmt, &del_params, NULL));
- }
+ if (! main_data->current->favorites)
+ main_data->current->favorites = tools_favorites_new (mstore);
- if (! gda_set_set_holder_value (del_params, error, "name", args[0]))
- return NULL;
+ ToolsFavoritesAttributes att;
+ GError *lerror = NULL;
+ att.id = -1;
+ att.type = TOOLS_FAVORITES_QUERIES;
+ att.name = args[0];
+ att.descr = NULL;
+ att.contents = NULL;
+
+ if (! tools_favorites_delete (main_data->current->favorites, 0,
+ &att, &lerror)) {
+ /* query retrieval */
+ static GdaStatement *del_stmt = NULL;
+ static GdaSet *del_params = NULL;
+ if (!del_stmt) {
+ del_stmt = gda_sql_parser_parse_string (main_data->current->parser,
+ QUERY_BUFFERS_TABLE_DELETE, NULL, NULL);
+ g_assert (del_stmt);
+ g_assert (gda_statement_get_parameters (del_stmt, &del_params, NULL));
+ }
- GdaConnection *store_cnc;
- store_cnc = gda_meta_store_get_internal_connection (mstore);
- if (gda_connection_statement_execute_non_select (store_cnc, del_stmt, del_params,
- NULL, error) == -1)
- return NULL;
+ if (! gda_set_set_holder_value (del_params, NULL, "name", args[0])) {
+ g_propagate_error (error, lerror);
+ return NULL;
+ }
+
+ GdaConnection *store_cnc;
+ store_cnc = gda_meta_store_get_internal_connection (mstore);
+ if (gda_connection_statement_execute_non_select (store_cnc, del_stmt, del_params,
+ NULL, NULL) > 0)
+ g_clear_error (&lerror);
+ else {
+ g_propagate_error (error, lerror);
+ return NULL;
+ }
+ }
res = g_new0 (GdaInternalCommandResult, 1);
res->type = GDA_INTERNAL_COMMAND_RESULT_EMPTY;
}
diff --git a/tools/gda-sql.h b/tools/gda-sql.h
index f29ee26..9809140 100644
--- a/tools/gda-sql.h
+++ b/tools/gda-sql.h
@@ -26,6 +26,7 @@
#include <libgda/libgda.h>
#include <tools/gda-threader.h>
#include <sql-parser/gda-sql-parser.h>
+#include "tools-favorites.h"
G_BEGIN_DECLS
@@ -33,13 +34,14 @@ G_BEGIN_DECLS
* structure representing an opened connection
*/
typedef struct {
- gchar *name;
- GdaConnection *cnc;
- GdaSqlParser *parser;
- GString *query_buffer;
+ gchar *name;
+ GdaConnection *cnc;
+ GdaSqlParser *parser;
+ GString *query_buffer;
+ ToolsFavorites *favorites;
- GdaThreader *threader;
- guint meta_job_id;
+ GdaThreader *threader;
+ guint meta_job_id;
} ConnectionSetting;
typedef enum {
diff --git a/tools/browser/browser-favorites.c b/tools/tools-favorites.c
similarity index 60%
rename from tools/browser/browser-favorites.c
rename to tools/tools-favorites.c
index a86326a..2c108d1 100644
--- a/tools/browser/browser-favorites.c
+++ b/tools/tools-favorites.c
@@ -20,14 +20,12 @@
#include <string.h>
#include <glib/gi18n-lib.h>
-#include "browser-favorites.h"
+#include "tools-favorites.h"
#include <libgda/thread-wrapper/gda-thread-wrapper.h>
-#include "support.h"
-#include "marshal.h"
#include <libgda/gda-sql-builder.h>
#include <sql-parser/gda-sql-parser.h>
-struct _BrowserFavoritesPrivate {
+struct _ToolsFavoritesPrivate {
GdaMetaStore *store;
GdaConnection *store_cnc;
};
@@ -36,9 +34,9 @@ struct _BrowserFavoritesPrivate {
/*
* Main static functions
*/
-static void browser_favorites_class_init (BrowserFavoritesClass *klass);
-static void browser_favorites_init (BrowserFavorites *bfav);
-static void browser_favorites_dispose (GObject *object);
+static void tools_favorites_class_init (ToolsFavoritesClass *klass);
+static void tools_favorites_init (ToolsFavorites *bfav);
+static void tools_favorites_dispose (GObject *object);
/* get a pointer to the parents to be able to call their destructor */
static GObjectClass *parent_class = NULL;
@@ -49,74 +47,74 @@ enum {
LAST_SIGNAL
};
-gint browser_favorites_signals [LAST_SIGNAL] = { 0 };
+gint tools_favorites_signals [LAST_SIGNAL] = { 0 };
GType
-browser_favorites_get_type (void)
+tools_favorites_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0)) {
static GStaticMutex registering = G_STATIC_MUTEX_INIT;
static const GTypeInfo info = {
- sizeof (BrowserFavoritesClass),
+ sizeof (ToolsFavoritesClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
- (GClassInitFunc) browser_favorites_class_init,
+ (GClassInitFunc) tools_favorites_class_init,
NULL,
NULL,
- sizeof (BrowserFavorites),
+ sizeof (ToolsFavorites),
0,
- (GInstanceInitFunc) browser_favorites_init,
+ (GInstanceInitFunc) tools_favorites_init,
0
};
g_static_mutex_lock (®istering);
if (type == 0)
- type = g_type_register_static (G_TYPE_OBJECT, "BrowserFavorites", &info, 0);
+ type = g_type_register_static (G_TYPE_OBJECT, "ToolsFavorites", &info, 0);
g_static_mutex_unlock (®istering);
}
return type;
}
static void
-browser_favorites_class_init (BrowserFavoritesClass *klass)
+tools_favorites_class_init (ToolsFavoritesClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
- browser_favorites_signals [FAV_CHANGED] =
+ tools_favorites_signals [FAV_CHANGED] =
g_signal_new ("favorites-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_DETAILED,
- G_STRUCT_OFFSET (BrowserFavoritesClass, favorites_changed),
+ G_STRUCT_OFFSET (ToolsFavoritesClass, favorites_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE,
0);
klass->favorites_changed = NULL;
- object_class->dispose = browser_favorites_dispose;
+ object_class->dispose = tools_favorites_dispose;
}
static void
-browser_favorites_init (BrowserFavorites *bfav)
+tools_favorites_init (ToolsFavorites *bfav)
{
- bfav->priv = g_new0 (BrowserFavoritesPrivate, 1);
+ bfav->priv = g_new0 (ToolsFavoritesPrivate, 1);
bfav->priv->store = NULL;
bfav->priv->store_cnc = NULL;
}
static void
-browser_favorites_dispose (GObject *object)
+tools_favorites_dispose (GObject *object)
{
- BrowserFavorites *bfav;
+ ToolsFavorites *bfav;
g_return_if_fail (object != NULL);
- g_return_if_fail (BROWSER_IS_FAVORITES (object));
+ g_return_if_fail (TOOLS_IS_FAVORITES (object));
- bfav = BROWSER_FAVORITES (object);
+ bfav = TOOLS_FAVORITES (object);
if (bfav->priv) {
if (bfav->priv->store)
g_object_unref (bfav->priv->store);
@@ -132,50 +130,50 @@ browser_favorites_dispose (GObject *object)
}
/**
- * browser_favorites_new
+ * tools_favorites_new
*
- * Creates a new #BrowserFavorites object
+ * Creates a new #ToolsFavorites object
*
* Returns: the new object
*/
-BrowserFavorites*
-browser_favorites_new (GdaMetaStore *store)
+ToolsFavorites*
+tools_favorites_new (GdaMetaStore *store)
{
- BrowserFavorites *bfav;
+ ToolsFavorites *bfav;
g_return_val_if_fail (GDA_IS_META_STORE (store), NULL);
- bfav = BROWSER_FAVORITES (g_object_new (BROWSER_TYPE_FAVORITES, NULL));
+ bfav = TOOLS_FAVORITES (g_object_new (TOOLS_TYPE_FAVORITES, NULL));
bfav->priv->store = g_object_ref (store);
return bfav;
}
#define FAVORITES_TABLE_NAME "gda_sql_favorites"
-#define FAVORITES_TABLE_DESC \
- "<table name=\"" FAVORITES_TABLE_NAME "\"> " \
- " <column name=\"id\" type=\"gint\" pkey=\"TRUE\" autoinc=\"TRUE\"/>" \
- " <column name=\"session\" type=\"gint\"/>" \
- " <column name=\"type\"/>" \
- " <column name=\"name\" nullok=\"TRUE\"/>" \
- " <column name=\"contents\"/>" \
- " <column name=\"descr\" nullok=\"TRUE\"/>" \
- " <unique>" \
- " <column name=\"session\"/>" \
- " <column name=\"type\"/>" \
- " <column name=\"contents\"/>" \
- " </unique>" \
+#define FAVORITES_TABLE_DESC \
+ "<table name=\"" FAVORITES_TABLE_NAME "\"> " \
+ " <column name=\"id\" type=\"gint\" pkey=\"TRUE\" autoinc=\"TRUE\"/>" \
+ " <column name=\"session\" type=\"gint\"/>" \
+ " <column name=\"type\"/>" \
+ " <column name=\"name\" nullok=\"TRUE\"/>" \
+ " <column name=\"contents\"/>" \
+ " <column name=\"descr\" nullok=\"TRUE\"/>" \
+ " <unique>" \
+ " <column name=\"session\"/>" \
+ " <column name=\"type\"/>" \
+ " <column name=\"contents\"/>" \
+ " </unique>" \
"</table>"
#define FAVORDER_TABLE_NAME "gda_sql_favorder"
-#define FAVORDER_TABLE_DESC \
- "<table name=\"" FAVORDER_TABLE_NAME "\"> " \
- " <column name=\"order_key\" type=\"gint\" pkey=\"TRUE\"/>" \
- " <column name=\"fav_id\" type=\"gint\" pkey=\"TRUE\"/>" \
- " <column name=\"rank\" type=\"gint\"/>" \
+#define FAVORDER_TABLE_DESC \
+ "<table name=\"" FAVORDER_TABLE_NAME "\"> " \
+ " <column name=\"order_key\" type=\"gint\" pkey=\"TRUE\"/>" \
+ " <column name=\"fav_id\" type=\"gint\" pkey=\"TRUE\"/>" \
+ " <column name=\"rank\" type=\"gint\"/>" \
"</table>"
static gboolean
-meta_store_addons_init (BrowserFavorites *bfav, GError **error)
+meta_store_addons_init (ToolsFavorites *bfav, GError **error)
{
GError *lerror = NULL;
if (bfav->priv->store_cnc)
@@ -205,28 +203,28 @@ meta_store_addons_init (BrowserFavorites *bfav, GError **error)
}
/**
- * browser_favorites_type_to_string:
- * @type: a #BrowserFavoritesType
+ * tools_favorites_type_to_string:
+ * @type: a #ToolsFavoritesType
*
* Returns: a string representing @type
*/
const gchar *
-browser_favorites_type_to_string (BrowserFavoritesType type)
+tools_favorites_type_to_string (ToolsFavoritesType type)
{
switch (type) {
- case BROWSER_FAVORITES_TABLES:
+ case TOOLS_FAVORITES_TABLES:
return "TABLE";
- case BROWSER_FAVORITES_DIAGRAMS:
+ case TOOLS_FAVORITES_DIAGRAMS:
return "DIAGRAM";
- case BROWSER_FAVORITES_QUERIES:
+ case TOOLS_FAVORITES_QUERIES:
return "QUERY";
- case BROWSER_FAVORITES_DATA_MANAGERS:
+ case TOOLS_FAVORITES_DATA_MANAGERS:
return "DATAMAN";
- case BROWSER_FAVORITES_ACTIONS:
+ case TOOLS_FAVORITES_ACTIONS:
return "ACTION";
- case BROWSER_FAVORITES_LDAP_DN:
+ case TOOLS_FAVORITES_LDAP_DN:
return "LDAP_DN";
- case BROWSER_FAVORITES_LDAP_CLASS:
+ case TOOLS_FAVORITES_LDAP_CLASS:
return "LDAP_CLASS";
default:
g_warning ("Unknown type of favorite");
@@ -235,26 +233,26 @@ browser_favorites_type_to_string (BrowserFavoritesType type)
return "";
}
-static BrowserFavoritesType
+static ToolsFavoritesType
favorite_string_to_type (const gchar *str)
{
if (*str == 'T')
- return BROWSER_FAVORITES_TABLES;
+ return TOOLS_FAVORITES_TABLES;
else if (*str == 'D') {
if (str[1] == 'I')
- return BROWSER_FAVORITES_DIAGRAMS;
+ return TOOLS_FAVORITES_DIAGRAMS;
else
- return BROWSER_FAVORITES_DATA_MANAGERS;
+ return TOOLS_FAVORITES_DATA_MANAGERS;
}
else if (*str == 'Q')
- return BROWSER_FAVORITES_QUERIES;
+ return TOOLS_FAVORITES_QUERIES;
else if (*str == 'A')
- return BROWSER_FAVORITES_ACTIONS;
+ return TOOLS_FAVORITES_ACTIONS;
else if (*str == 'L') {
if (strlen (str) == 7)
- return BROWSER_FAVORITES_LDAP_DN;
+ return TOOLS_FAVORITES_LDAP_DN;
else
- return BROWSER_FAVORITES_LDAP_CLASS;
+ return TOOLS_FAVORITES_LDAP_CLASS;
}
else
g_warning ("Unknown type '%s' of favorite", str);
@@ -262,7 +260,7 @@ favorite_string_to_type (const gchar *str)
}
static gint
-find_favorite_position (BrowserFavorites *bfav, gint fav_id, gint order_key)
+find_favorite_position (ToolsFavorites *bfav, gint fav_id, gint order_key)
{
GdaSqlBuilder *b;
GdaStatement *stmt;
@@ -274,17 +272,17 @@ find_favorite_position (BrowserFavorites *bfav, gint fav_id, gint order_key)
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "rank"), 0);
+ gda_sql_builder_add_id (b, "rank"), 0);
gda_sql_builder_select_add_target (b, FAVORDER_TABLE_NAME, NULL);
gda_sql_builder_set_where (b,
gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_AND,
- gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "fav_id"),
- gda_sql_builder_add_param (b, "favid", G_TYPE_INT, FALSE), 0),
- gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "order_key"),
- gda_sql_builder_add_param (b, "okey", G_TYPE_INT, FALSE), 0),
- 0));
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (b, "fav_id"),
+ gda_sql_builder_add_param (b, "favid", G_TYPE_INT, FALSE), 0),
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (b, "order_key"),
+ gda_sql_builder_add_param (b, "okey", G_TYPE_INT, FALSE), 0),
+ 0));
stmt = gda_sql_builder_get_statement (b, NULL);
g_object_unref (G_OBJECT (b));
@@ -313,17 +311,94 @@ find_favorite_position (BrowserFavorites *bfav, gint fav_id, gint order_key)
return pos;
}
+static gint
+find_favorite_by_name (ToolsFavorites *bfav, guint session_id, const gchar *name, ToolsFavoritesType type,
+ ToolsFavoritesAttributes *out_existing_fav, GError **error)
+{
+ GdaSqlBuilder *b;
+ GdaStatement *stmt;
+ GdaSet *params = NULL;
+ GdaDataModel *model;
+ gint favid = -1;
+
+ if (out_existing_fav)
+ memset (out_existing_fav, 0, sizeof (ToolsFavoritesAttributes));
+ g_return_val_if_fail (name, -1);
+
+ b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
+ gda_sql_builder_add_field_value_id (b,
+ gda_sql_builder_add_id (b, "id"), 0);
+ gda_sql_builder_add_field_value_id (b,
+ gda_sql_builder_add_id (b, "type"), 0);
+ gda_sql_builder_add_field_value_id (b,
+ gda_sql_builder_add_id (b, "name"), 0);
+ gda_sql_builder_add_field_value_id (b,
+ gda_sql_builder_add_id (b, "descr"), 0);
+ gda_sql_builder_add_field_value_id (b,
+ gda_sql_builder_add_id (b, "contents"), 0);
+ gda_sql_builder_select_add_target (b, FAVORITES_TABLE_NAME, NULL);
+ gda_sql_builder_set_where (b,
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_AND,
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (b, "session"),
+ gda_sql_builder_add_param (b, "session", G_TYPE_INT, FALSE), 0),
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (b, "name"),
+ gda_sql_builder_add_param (b, "name", G_TYPE_INT, FALSE), 0),
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (b, "type"),
+ gda_sql_builder_add_param (b, "type", G_TYPE_STRING, FALSE), 0)));
+
+ stmt = gda_sql_builder_get_statement (b, error);
+ g_object_unref (G_OBJECT (b));
+ if (!stmt)
+ return -1;
+ params = gda_set_new_inline (3,
+ "session", G_TYPE_INT, session_id,
+ "type", G_TYPE_STRING, tools_favorites_type_to_string (type),
+ "name", G_TYPE_STRING, name);
+ model = gda_connection_statement_execute_select (bfav->priv->store_cnc, stmt, params, error);
+ g_object_unref (stmt);
+ g_object_unref (params);
+
+ if (model && gda_data_model_get_n_rows (model) == 1) {
+ const GValue *cvalue;
+ cvalue = gda_data_model_get_value_at (model, 0, 0, NULL);
+ if (cvalue && (G_VALUE_TYPE (cvalue) == G_TYPE_INT))
+ favid = g_value_get_int (cvalue);
+
+ if (out_existing_fav) {
+ out_existing_fav->id = favid;
+ cvalue = gda_data_model_get_value_at (model, 1, 0, error);
+ if (cvalue)
+ out_existing_fav->type = favorite_string_to_type (g_value_get_string (cvalue));
+ cvalue = gda_data_model_get_value_at (model, 2, 0, error);
+ if (cvalue && (G_VALUE_TYPE (cvalue) == G_TYPE_STRING))
+ out_existing_fav->name = g_value_dup_string (cvalue);
+ cvalue = gda_data_model_get_value_at (model, 3, 0, error);
+ if (cvalue && (G_VALUE_TYPE (cvalue) == G_TYPE_STRING))
+ out_existing_fav->descr = g_value_dup_string (cvalue);
+ cvalue = gda_data_model_get_value_at (model, 4, 0, error);
+ if (cvalue && (G_VALUE_TYPE (cvalue) == G_TYPE_STRING))
+ out_existing_fav->contents = g_value_dup_string (cvalue);
+ }
+ }
+ if (model)
+ g_object_unref (model);
+ return favid;
+}
+
/*
* Find a favorite ID from its ID or from its contents
*
* Returns: the ID or -1 if not found (and sets ERROR).
*
- * if @out_existing_fav is not %NULL, then its attributes are set, use browser_favorites_reset_attributes()
+ * if @out_existing_fav is not %NULL, then its attributes are set, use tools_favorites_reset_attributes()
* to free.
*/
static gint
-find_favorite (BrowserFavorites *bfav, guint session_id, gint id, const gchar *contents,
- BrowserFavoritesAttributes *out_existing_fav, GError **error)
+find_favorite (ToolsFavorites *bfav, guint session_id, gint id, const gchar *contents,
+ ToolsFavoritesAttributes *out_existing_fav, GError **error)
{
GdaSqlBuilder *b;
GdaStatement *stmt;
@@ -332,39 +407,39 @@ find_favorite (BrowserFavorites *bfav, guint session_id, gint id, const gchar *c
gint favid = -1;
if (out_existing_fav)
- memset (out_existing_fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (out_existing_fav, 0, sizeof (ToolsFavoritesAttributes));
g_return_val_if_fail ((id >= 0) || contents, -1);
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "id"), 0);
+ gda_sql_builder_add_id (b, "id"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "type"), 0);
+ gda_sql_builder_add_id (b, "type"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "name"), 0);
+ gda_sql_builder_add_id (b, "name"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "descr"), 0);
+ gda_sql_builder_add_id (b, "descr"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "contents"), 0);
+ gda_sql_builder_add_id (b, "contents"), 0);
gda_sql_builder_select_add_target (b, FAVORITES_TABLE_NAME, NULL);
if (id >= 0) {
/* lookup from ID */
gda_sql_builder_set_where (b,
- gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "id"),
- gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE), 0));
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (b, "id"),
+ gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE), 0));
}
else {
/* lookup using session and contents */
gda_sql_builder_set_where (b,
- gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_AND,
- gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "session"),
- gda_sql_builder_add_param (b, "session", G_TYPE_INT, FALSE), 0),
- gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "contents"),
- gda_sql_builder_add_param (b, "contents", G_TYPE_INT, FALSE), 0), 0));
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_AND,
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (b, "session"),
+ gda_sql_builder_add_param (b, "session", G_TYPE_INT, FALSE), 0),
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (b, "contents"),
+ gda_sql_builder_add_param (b, "contents", G_TYPE_INT, FALSE), 0), 0));
}
stmt = gda_sql_builder_get_statement (b, error);
g_object_unref (G_OBJECT (b));
@@ -413,7 +488,7 @@ find_favorite (BrowserFavorites *bfav, guint session_id, gint id, const gchar *c
* Reorders the favorites for @order_key, making sure @id is at position @new_pos
*/
static gboolean
-favorites_reorder (BrowserFavorites *bfav, gint order_key, gint id, gint new_pos, GError **error)
+favorites_reorder (ToolsFavorites *bfav, gint order_key, gint id, gint new_pos, GError **error)
{
GdaSqlBuilder *b;
GdaStatement *stmt;
@@ -429,8 +504,8 @@ favorites_reorder (BrowserFavorites *bfav, gint order_key, gint id, gint new_pos
gda_sql_builder_select_add_target (b, FAVORDER_TABLE_NAME, NULL);
gda_sql_builder_set_where (b, gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "order_key"),
- gda_sql_builder_add_param (b, "orderkey", G_TYPE_INT, FALSE), 0));
+ gda_sql_builder_add_id (b, "order_key"),
+ gda_sql_builder_add_param (b, "orderkey", G_TYPE_INT, FALSE), 0));
gda_sql_builder_select_order_by (b,
gda_sql_builder_add_id (b, "rank"), TRUE, NULL);
stmt = gda_sql_builder_get_statement (b, error);
@@ -459,16 +534,16 @@ favorites_reorder (BrowserFavorites *bfav, gint order_key, gint id, gint new_pos
b = gda_sql_builder_new (GDA_SQL_STATEMENT_UPDATE);
gda_sql_builder_set_table (b, FAVORDER_TABLE_NAME);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "rank"),
- gda_sql_builder_add_param (b, "rank", G_TYPE_INT, FALSE));
+ gda_sql_builder_add_id (b, "rank"),
+ gda_sql_builder_add_param (b, "rank", G_TYPE_INT, FALSE));
const GdaSqlBuilderId id_cond1 = gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "fav_id"),
- gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE),
- 0);
+ gda_sql_builder_add_id (b, "fav_id"),
+ gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE),
+ 0);
const GdaSqlBuilderId id_cond2 = gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "order_key"),
- gda_sql_builder_add_param (b, "orderkey", G_TYPE_INT, FALSE),
- 0);
+ gda_sql_builder_add_id (b, "order_key"),
+ gda_sql_builder_add_param (b, "orderkey", G_TYPE_INT, FALSE),
+ 0);
gda_sql_builder_set_where (b, gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_AND, id_cond1, id_cond2, 0));
stmt = gda_sql_builder_get_statement (b, error);
if (!stmt) {
@@ -508,10 +583,10 @@ favorites_reorder (BrowserFavorites *bfav, gint order_key, gint id, gint new_pos
}
/**
- * browser_favorites_add
- * @bfav: a #BrowserFavorites object
+ * tools_favorites_add
+ * @bfav: a #ToolsFavorites object
* @session_id: session ID (0)
- * @fav: a pointer to a #BrowserFavoritesAttributes structure
+ * @fav: a pointer to a #ToolsFavoritesAttributes structure
* @order_key: ordering key or -1 for none
* @pos: position (ignored if @order_key < 0)
* @error: a place to store errors, or %NULL
@@ -520,7 +595,7 @@ favorites_reorder (BrowserFavorites *bfav, gint order_key, gint id, gint new_pos
* NOTE:
* <itemizedlist>
* <listitem><para>if @fav->id is < 0 then it's either an update or an insert (depending if fav->contents exists)
- * and if it's not it is an UPDATE </para></listitem>
+ * and if it's not it is an INSERT </para></listitem>
* <listitem><para>@fav->type can't be 0</para></listitem>
* <listitem><para>@fav->contents can't be %NULL</para></listitem>
* </itemizedlist>
@@ -530,17 +605,17 @@ favorites_reorder (BrowserFavorites *bfav, gint order_key, gint id, gint new_pos
* if @order_key is negative, then no ordering is done and @pos is ignored.
*/
gboolean
-browser_favorites_add (BrowserFavorites *bfav, guint session_id,
- BrowserFavoritesAttributes *fav,
- gint order_key, gint pos,
- GError **error)
+tools_favorites_add (ToolsFavorites *bfav, guint session_id,
+ ToolsFavoritesAttributes *fav,
+ gint order_key, gint pos,
+ GError **error)
{
GdaConnection *store_cnc;
GdaSet *params = NULL;
gint favid = -1;
- BrowserFavoritesAttributes efav; /* existing favorite */
+ ToolsFavoritesAttributes efav; /* existing favorite */
- g_return_val_if_fail (BROWSER_IS_FAVORITES (bfav), FALSE);
+ g_return_val_if_fail (TOOLS_IS_FAVORITES (bfav), FALSE);
g_return_val_if_fail (fav, FALSE);
g_return_val_if_fail (fav->contents, FALSE);
@@ -573,7 +648,7 @@ browser_favorites_add (BrowserFavorites *bfav, guint session_id,
params = gda_set_new_inline (8,
"session", G_TYPE_INT, session_id,
"id", G_TYPE_INT, fav->id,
- "type", G_TYPE_STRING, browser_favorites_type_to_string (rtype),
+ "type", G_TYPE_STRING, tools_favorites_type_to_string (rtype),
"name", G_TYPE_STRING, fav->name ? fav->name : efav.name,
"contents", G_TYPE_STRING, fav->contents,
"rank", G_TYPE_INT, pos,
@@ -590,20 +665,20 @@ browser_favorites_add (BrowserFavorites *bfav, guint session_id,
gda_sql_builder_set_table (builder, FAVORITES_TABLE_NAME);
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "session"),
- gda_sql_builder_add_param (builder, "session", G_TYPE_INT, FALSE));
+ gda_sql_builder_add_id (builder, "session"),
+ gda_sql_builder_add_param (builder, "session", G_TYPE_INT, FALSE));
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "type"),
- gda_sql_builder_add_param (builder, "type", G_TYPE_INT, FALSE));
+ gda_sql_builder_add_id (builder, "type"),
+ gda_sql_builder_add_param (builder, "type", G_TYPE_INT, FALSE));
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "name"),
- gda_sql_builder_add_param (builder, "name", G_TYPE_STRING, TRUE));
+ gda_sql_builder_add_id (builder, "name"),
+ gda_sql_builder_add_param (builder, "name", G_TYPE_STRING, TRUE));
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "contents"),
- gda_sql_builder_add_param (builder, "contents", G_TYPE_STRING, FALSE));
+ gda_sql_builder_add_id (builder, "contents"),
+ gda_sql_builder_add_param (builder, "contents", G_TYPE_STRING, FALSE));
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "descr"),
- gda_sql_builder_add_param (builder, "descr", G_TYPE_STRING, TRUE));
+ gda_sql_builder_add_id (builder, "descr"),
+ gda_sql_builder_add_param (builder, "descr", G_TYPE_STRING, TRUE));
stmt = gda_sql_builder_get_statement (builder, error);
g_object_unref (G_OBJECT (builder));
if (!stmt)
@@ -627,30 +702,30 @@ browser_favorites_add (BrowserFavorites *bfav, guint session_id,
gda_sql_builder_set_table (builder, FAVORITES_TABLE_NAME);
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "name"),
- gda_sql_builder_add_param (builder, "name", G_TYPE_STRING, TRUE));
+ gda_sql_builder_add_id (builder, "name"),
+ gda_sql_builder_add_param (builder, "name", G_TYPE_STRING, TRUE));
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "contents"),
- gda_sql_builder_add_param (builder, "contents", G_TYPE_STRING, FALSE));
+ gda_sql_builder_add_id (builder, "contents"),
+ gda_sql_builder_add_param (builder, "contents", G_TYPE_STRING, FALSE));
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "descr"),
- gda_sql_builder_add_param (builder, "descr", G_TYPE_STRING, TRUE));
+ gda_sql_builder_add_id (builder, "descr"),
+ gda_sql_builder_add_param (builder, "descr", G_TYPE_STRING, TRUE));
gda_sql_builder_set_where (builder,
gda_sql_builder_add_cond (builder, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (builder, "id"),
- gda_sql_builder_add_param (builder, "id", G_TYPE_INT, FALSE),
- 0));
+ gda_sql_builder_add_id (builder, "id"),
+ gda_sql_builder_add_param (builder, "id", G_TYPE_INT, FALSE),
+ 0));
if (fav->id == favid) {
/* alter name and description only if fav->id was OK */
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "name"),
- gda_sql_builder_add_param (builder, "name", G_TYPE_STRING,
- TRUE));
+ gda_sql_builder_add_id (builder, "name"),
+ gda_sql_builder_add_param (builder, "name", G_TYPE_STRING,
+ TRUE));
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "descr"),
- gda_sql_builder_add_param (builder, "descr", G_TYPE_STRING,
- TRUE));
+ gda_sql_builder_add_id (builder, "descr"),
+ gda_sql_builder_add_param (builder, "descr", G_TYPE_STRING,
+ TRUE));
}
stmt = gda_sql_builder_get_statement (builder, error);
@@ -664,7 +739,7 @@ browser_favorites_add (BrowserFavorites *bfav, guint session_id,
g_object_unref (stmt);
fav->id = favid;
}
- browser_favorites_reset_attributes (&efav);
+ tools_favorites_reset_attributes (&efav);
if (order_key >= 0) {
GdaSqlBuilder *builder;
@@ -682,15 +757,15 @@ browser_favorites_add (BrowserFavorites *bfav, guint session_id,
builder = gda_sql_builder_new (GDA_SQL_STATEMENT_DELETE);
gda_sql_builder_set_table (builder, FAVORDER_TABLE_NAME);
gda_sql_builder_set_where (builder,
- gda_sql_builder_add_cond (builder, GDA_SQL_OPERATOR_TYPE_AND,
- gda_sql_builder_add_cond (builder, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (builder, "fav_id"),
- gda_sql_builder_add_param (builder, "id", G_TYPE_INT, FALSE),
- 0),
- gda_sql_builder_add_cond (builder, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (builder, "order_key"),
- gda_sql_builder_add_param (builder, "orderkey", G_TYPE_INT, FALSE),
- 0), 0));
+ gda_sql_builder_add_cond (builder, GDA_SQL_OPERATOR_TYPE_AND,
+ gda_sql_builder_add_cond (builder, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (builder, "fav_id"),
+ gda_sql_builder_add_param (builder, "id", G_TYPE_INT, FALSE),
+ 0),
+ gda_sql_builder_add_cond (builder, GDA_SQL_OPERATOR_TYPE_EQ,
+ gda_sql_builder_add_id (builder, "order_key"),
+ gda_sql_builder_add_param (builder, "orderkey", G_TYPE_INT, FALSE),
+ 0), 0));
stmt = gda_sql_builder_get_statement (builder, error);
g_object_unref (G_OBJECT (builder));
if (!stmt)
@@ -704,14 +779,14 @@ browser_favorites_add (BrowserFavorites *bfav, guint session_id,
builder = gda_sql_builder_new (GDA_SQL_STATEMENT_INSERT);
gda_sql_builder_set_table (builder, FAVORDER_TABLE_NAME);
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "fav_id"),
- gda_sql_builder_add_param (builder, "id", G_TYPE_INT, FALSE));
+ gda_sql_builder_add_id (builder, "fav_id"),
+ gda_sql_builder_add_param (builder, "id", G_TYPE_INT, FALSE));
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "rank"),
- gda_sql_builder_add_param (builder, "rank", G_TYPE_INT, FALSE));
+ gda_sql_builder_add_id (builder, "rank"),
+ gda_sql_builder_add_param (builder, "rank", G_TYPE_INT, FALSE));
gda_sql_builder_add_field_value_id (builder,
- gda_sql_builder_add_id (builder, "order_key"),
- gda_sql_builder_add_param (builder, "orderkey", G_TYPE_STRING, TRUE));
+ gda_sql_builder_add_id (builder, "order_key"),
+ gda_sql_builder_add_param (builder, "orderkey", G_TYPE_STRING, TRUE));
stmt = gda_sql_builder_get_statement (builder, error);
g_object_unref (G_OBJECT (builder));
if (!stmt)
@@ -736,8 +811,8 @@ browser_favorites_add (BrowserFavorites *bfav, guint session_id,
if (params)
g_object_unref (params);
gda_lockable_unlock (GDA_LOCKABLE (store_cnc));
- g_signal_emit (bfav, browser_favorites_signals [FAV_CHANGED],
- g_quark_from_string (browser_favorites_type_to_string (rtype)));
+ g_signal_emit (bfav, tools_favorites_signals [FAV_CHANGED],
+ g_quark_from_string (tools_favorites_type_to_string (rtype)));
return TRUE;
err:
@@ -749,44 +824,44 @@ browser_favorites_add (BrowserFavorites *bfav, guint session_id,
}
/**
- * browser_favorites_free_list
- * @fav_list: a list of #BrowserFavoritesAttributes
+ * tools_favorites_free_list
+ * @fav_list: a list of #ToolsFavoritesAttributes
*
- * Frees all the #BrowserFavoritesAttributes of the @fav_list list, and frees the list
+ * Frees all the #ToolsFavoritesAttributes of the @fav_list list, and frees the list
* itself.
*/
void
-browser_favorites_free_list (GSList *fav_list)
+tools_favorites_free_list (GSList *fav_list)
{
GSList *list;
if (!fav_list)
return;
for (list = fav_list; list; list = list->next) {
- BrowserFavoritesAttributes *fav = (BrowserFavoritesAttributes*) list->data;
- browser_favorites_reset_attributes (fav);
+ ToolsFavoritesAttributes *fav = (ToolsFavoritesAttributes*) list->data;
+ tools_favorites_reset_attributes (fav);
g_free (fav);
}
g_slist_free (fav_list);
}
/**
- * browser_favorites_reset_attributes
- * @fav: a pointer to a #BrowserFavoritesAttributes
+ * tools_favorites_reset_attributes
+ * @fav: a pointer to a #ToolsFavoritesAttributes
*
* Resets @fav with empty attributes; it does not free @fav.
*/
void
-browser_favorites_reset_attributes (BrowserFavoritesAttributes *fav)
+tools_favorites_reset_attributes (ToolsFavoritesAttributes *fav)
{
g_free (fav->name);
g_free (fav->descr);
g_free (fav->contents);
- memset (fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (fav, 0, sizeof (ToolsFavoritesAttributes));
}
/**
- * browser_favorites_list
- * @bfav: a #BrowserFavorites
+ * tools_favorites_list
+ * @bfav: a #ToolsFavorites
* @session_id: 0 for now
* @type: filter the type of attributes to be listed
* @order_key: a key to order the listed favorites, such as #ORDER_KEY_SCHEMA
@@ -794,12 +869,12 @@ browser_favorites_reset_attributes (BrowserFavoritesAttributes *fav)
*
* Extract some favorites.
*
- * Returns: a new list of #BrowserFavoritesAttributes pointers. The list has to
- * be freed using browser_favorites_free_list()
+ * Returns: a new list of #ToolsFavoritesAttributes pointers. The list has to
+ * be freed using tools_favorites_free_list()
*/
GSList *
-browser_favorites_list (BrowserFavorites *bfav, guint session_id, BrowserFavoritesType type,
- gint order_key, GError **error)
+tools_favorites_list (ToolsFavorites *bfav, guint session_id, ToolsFavoritesType type,
+ gint order_key, GError **error)
{
GdaSqlBuilder *b;
GdaSet *params = NULL;
@@ -810,10 +885,10 @@ browser_favorites_list (BrowserFavorites *bfav, guint session_id, BrowserFavorit
guint and_cond_ids [3];
int and_cond_size = 0;
- guint or_cond_ids [BROWSER_FAVORITES_NB_TYPES];
+ guint or_cond_ids [TOOLS_FAVORITES_NB_TYPES];
int or_cond_size = 0;
- g_return_val_if_fail (BROWSER_IS_FAVORITES (bfav), NULL);
+ g_return_val_if_fail (TOOLS_IS_FAVORITES (bfav), NULL);
g_return_val_if_fail ((type != 0) || (order_key >= 0), NULL);
if (! meta_store_addons_init (bfav, error))
@@ -821,56 +896,56 @@ browser_favorites_list (BrowserFavorites *bfav, guint session_id, BrowserFavorit
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "fav.contents"), 0);
+ gda_sql_builder_add_id (b, "fav.contents"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "fav.descr"), 0);
+ gda_sql_builder_add_id (b, "fav.descr"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "fav.name"), 0);
+ gda_sql_builder_add_id (b, "fav.name"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "fav.type"), 0);
+ gda_sql_builder_add_id (b, "fav.type"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "fav.id"), 0);
+ gda_sql_builder_add_id (b, "fav.id"), 0);
t1 = gda_sql_builder_select_add_target (b, FAVORITES_TABLE_NAME, "fav");
if (order_key > 0) {
t2 = gda_sql_builder_select_add_target (b, FAVORDER_TABLE_NAME, "o");
gda_sql_builder_select_join_targets (b, t1, t2, GDA_SQL_SELECT_JOIN_LEFT,
gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "fav.id"),
- gda_sql_builder_add_id (b, "o.fav_id"),
- 0));
+ gda_sql_builder_add_id (b, "fav.id"),
+ gda_sql_builder_add_id (b, "o.fav_id"),
+ 0));
gda_sql_builder_select_order_by (b,
gda_sql_builder_add_id (b, "o.rank"), TRUE, NULL);
and_cond_ids [and_cond_size] = gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "o.order_key"),
- gda_sql_builder_add_param (b, "okey", G_TYPE_INT, FALSE),
- 0);
+ gda_sql_builder_add_id (b, "o.order_key"),
+ gda_sql_builder_add_param (b, "okey", G_TYPE_INT, TRUE),
+ 0);
and_cond_size++;
}
and_cond_ids [and_cond_size] = gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "fav.session"),
- gda_sql_builder_add_param (b, "session", G_TYPE_INT, FALSE), 0);
+ gda_sql_builder_add_id (b, "fav.session"),
+ gda_sql_builder_add_param (b, "session", G_TYPE_INT, FALSE), 0);
and_cond_size++;
gint i;
gint flag;
- for (i = 0, flag = 1; i < BROWSER_FAVORITES_NB_TYPES; i++, flag <<= 1) {
+ for (i = 0, flag = 1; i < TOOLS_FAVORITES_NB_TYPES; i++, flag <<= 1) {
if (type & flag) {
gchar *str;
- str = g_strdup_printf ("'%s'", browser_favorites_type_to_string (flag));
+ str = g_strdup_printf ("'%s'", tools_favorites_type_to_string (flag));
or_cond_ids [or_cond_size] = gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "fav.type"),
- gda_sql_builder_add_id (b, str),
- 0);
+ gda_sql_builder_add_id (b, "fav.type"),
+ gda_sql_builder_add_id (b, str),
+ 0);
g_free (str);
or_cond_size++;
}
}
if (or_cond_size >= 1) {
and_cond_ids [and_cond_size] = gda_sql_builder_add_cond_v (b, GDA_SQL_OPERATOR_TYPE_OR,
- or_cond_ids, or_cond_size);
+ or_cond_ids, or_cond_size);
and_cond_size++;
}
@@ -923,8 +998,8 @@ browser_favorites_list (BrowserFavorites *bfav, guint session_id, BrowserFavorit
if (type)
id = gda_data_model_get_value_at (model, 4, i, error);
if (id) {
- BrowserFavoritesAttributes *fav;
- fav = g_new0 (BrowserFavoritesAttributes, 1);
+ ToolsFavoritesAttributes *fav;
+ fav = g_new0 (ToolsFavoritesAttributes, 1);
fav->id = g_value_get_int (id);
fav->type = favorite_string_to_type (g_value_get_string (type));
if (G_VALUE_TYPE (descr) == G_TYPE_STRING)
@@ -935,7 +1010,7 @@ browser_favorites_list (BrowserFavorites *bfav, guint session_id, BrowserFavorit
fav_list = g_slist_prepend (fav_list, fav);
}
else {
- browser_favorites_free_list (fav_list);
+ tools_favorites_free_list (fav_list);
fav_list = NULL;
goto out;
}
@@ -952,10 +1027,10 @@ browser_favorites_list (BrowserFavorites *bfav, guint session_id, BrowserFavorit
/**
- * browser_favorites_delete
- * @bfav: a #BrowserFavorites
+ * tools_favorites_delete
+ * @bfav: a #ToolsFavorites
* @session_id: 0 for now
- * @fav: a pointer to a #BrowserFavoritesAttributes definning which favorite to delete
+ * @fav: a pointer to a #ToolsFavoritesAttributes definning which favorite to delete
* @error: a place to store errors, or %NULL
*
* Delete a favorite
@@ -963,21 +1038,21 @@ browser_favorites_list (BrowserFavorites *bfav, guint session_id, BrowserFavorit
* Returns: %TRUE if no error occurred.
*/
gboolean
-browser_favorites_delete (BrowserFavorites *bfav, guint session_id,
- BrowserFavoritesAttributes *fav, GError **error)
+tools_favorites_delete (ToolsFavorites *bfav, guint session_id,
+ ToolsFavoritesAttributes *fav, GError **error)
{
GdaSqlBuilder *b;
GdaSet *params = NULL;
GdaStatement *stmt;
gboolean retval = FALSE;
- gint favid;
- BrowserFavoritesAttributes efav;
+ gint favid = -1;
+ ToolsFavoritesAttributes efav;
- g_return_val_if_fail (BROWSER_IS_FAVORITES (bfav), FALSE);
+ g_return_val_if_fail (TOOLS_IS_FAVORITES (bfav), FALSE);
g_return_val_if_fail (fav, FALSE);
- g_return_val_if_fail ((fav->id >= 0) || fav->contents, FALSE);
+ g_return_val_if_fail ((fav->id >= 0) || fav->contents || fav->name , FALSE);
- memset (&efav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (&efav, 0, sizeof (ToolsFavoritesAttributes));
if (! meta_store_addons_init (bfav, error))
return FALSE;
@@ -995,25 +1070,42 @@ browser_favorites_delete (BrowserFavorites *bfav, guint session_id,
return FALSE;
}
- favid = find_favorite (bfav, session_id, fav->id, fav->contents, &efav, error);
- if (favid < 0)
+ GError *lerror = NULL;
+ if ((fav->id >= 0) || fav->contents) {
+ favid = find_favorite (bfav, session_id, fav->id, fav->contents, &efav, &lerror);
+ if (lerror) {
+ g_propagate_error (error, lerror);
+ goto out;
+ }
+ }
+ if ((favid < 0) && fav->name) {
+ favid = find_favorite_by_name (bfav, session_id, fav->name, fav->type,
+ &efav, &lerror);
+ if (lerror) {
+ g_propagate_error (error, lerror);
+ goto out;
+ }
+ }
+ if (favid < 0) {
+ g_set_error (error, 0, 0,
+ "%s", _("Could not find favorite"));
goto out;
+ }
/* remove entry from favorites' list */
b = gda_sql_builder_new (GDA_SQL_STATEMENT_DELETE);
gda_sql_builder_set_table (b, FAVORITES_TABLE_NAME);
gda_sql_builder_set_where (b, gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "id"),
- gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE),
- 0));
+ gda_sql_builder_add_id (b, "id"),
+ gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE),
+ 0));
stmt = gda_sql_builder_get_statement (b, error);
g_object_unref (G_OBJECT (b));
if (!stmt)
goto out;
- params = gda_set_new_inline (1,
- "id", G_TYPE_INT, favid);
+ params = gda_set_new_inline (1, "id", G_TYPE_INT, favid);
if (gda_connection_statement_execute_non_select (bfav->priv->store_cnc, stmt, params, NULL, error) == -1) {
g_object_unref (stmt);
@@ -1025,9 +1117,9 @@ browser_favorites_delete (BrowserFavorites *bfav, guint session_id,
b = gda_sql_builder_new (GDA_SQL_STATEMENT_DELETE);
gda_sql_builder_set_table (b, FAVORDER_TABLE_NAME);
gda_sql_builder_set_where (b, gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "fav_id"),
- gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE),
- 0));
+ gda_sql_builder_add_id (b, "fav_id"),
+ gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE),
+ 0));
stmt = gda_sql_builder_get_statement (b, error);
g_object_unref (G_OBJECT (b));
@@ -1052,9 +1144,9 @@ browser_favorites_delete (BrowserFavorites *bfav, guint session_id,
gda_lockable_unlock (GDA_LOCKABLE (bfav->priv->store_cnc));
if (retval)
- g_signal_emit (bfav, browser_favorites_signals [FAV_CHANGED],
- g_quark_from_string (browser_favorites_type_to_string (efav.type)));
- browser_favorites_reset_attributes (&efav);
+ g_signal_emit (bfav, tools_favorites_signals [FAV_CHANGED],
+ g_quark_from_string (tools_favorites_type_to_string (efav.type)));
+ tools_favorites_reset_attributes (&efav);
if (params)
g_object_unref (G_OBJECT (params));
@@ -1062,43 +1154,73 @@ browser_favorites_delete (BrowserFavorites *bfav, guint session_id,
}
/**
- * browser_favorites_find
- * @bfav: a #BrowserFavorites
+ * tools_favorites_find
+ * @bfav: a #ToolsFavorites
* @session_id: 0 for now
* @contents: the favorite's contents
- * @out_fav: (allow-none): a #BrowserFavoritesAttributes to be filled with the favorite's attributes, or %NULL
+ * @out_fav: (allow-none): a #ToolsFavoritesAttributes to be filled with the favorite's attributes, or %NULL
* @error: a place to store errors, or %NULL
*
* Get all the information about a favorite from its id: fills the @out_fav
- * pointed structure. Use browser_favorites_reset_attributes() to reset @out_fav's contents.
+ * pointed structure. Use tools_favorites_reset_attributes() to reset @out_fav's contents.
*
* Retuns: the requested's favorite ID, or -1 if not found
*/
gint
-browser_favorites_find (BrowserFavorites *bfav, guint session_id, const gchar *contents,
- BrowserFavoritesAttributes *out_fav, GError **error)
+tools_favorites_find (ToolsFavorites *bfav, guint session_id, const gchar *contents,
+ ToolsFavoritesAttributes *out_fav, GError **error)
{
- g_return_val_if_fail (BROWSER_IS_FAVORITES (bfav), -1);
+ g_return_val_if_fail (TOOLS_IS_FAVORITES (bfav), -1);
g_return_val_if_fail (contents, -1);
+ if (! meta_store_addons_init (bfav, error))
+ return -1;
return find_favorite (bfav, session_id, -1, contents, out_fav, error);
}
/**
- * browser_favorites_get
- * @bfav: a #BrowserFavorites
+ * tools_favorites_find_by_name:
+ * @bfav: a #ToolsFavorites
+ * @session_id: 0 for now
+ * @type: the favorite's type
+ * @name: the favorite's name
+ * @out_fav: (allow-none): a #ToolsFavoritesAttributes to be filled with the favorite's attributes, or %NULL
+ * @error: a place to store errors, or %NULL
+ *
+ * Get all the information about a favorite from its id: fills the @out_fav
+ * pointed structure. Use tools_favorites_reset_attributes() to reset @out_fav's contents.
+ *
+ * Retuns: the requested's favorite ID, or -1 if not found
+ */
+gint
+tools_favorites_find_by_name (ToolsFavorites *bfav, guint session_id, ToolsFavoritesType type, const gchar *name,
+ ToolsFavoritesAttributes *out_fav, GError **error)
+{
+ g_return_val_if_fail (TOOLS_IS_FAVORITES (bfav), -1);
+ g_return_val_if_fail (name, -1);
+
+ if (! meta_store_addons_init (bfav, error))
+ return -1;
+ return find_favorite_by_name (bfav, session_id, name, type, out_fav, error);
+}
+
+
+
+/**
+ * tools_favorites_get
+ * @bfav: a #ToolsFavorites
* @fav_id: the favorite's ID
- * @out_fav: a #BrowserFavoritesAttributes to be filled with the favorite's attributes
+ * @out_fav: a #ToolsFavoritesAttributes to be filled with the favorite's attributes
* @error: a place to store errors, or %NULL
*
* Get all the information about a favorite from its id: fills the @out_fav
- * pointed structure. Use browser_favorites_reset_attributes() to reset @out_fav's contents.
+ * pointed structure. Use tools_favorites_reset_attributes() to reset @out_fav's contents.
*
* Retuns: %TRUE if no error occurred.
*/
gboolean
-browser_favorites_get (BrowserFavorites *bfav, gint fav_id,
- BrowserFavoritesAttributes *out_fav, GError **error)
+tools_favorites_get (ToolsFavorites *bfav, gint fav_id,
+ ToolsFavoritesAttributes *out_fav, GError **error)
{
GdaSqlBuilder *b;
GdaStatement *stmt;
@@ -1106,29 +1228,29 @@ browser_favorites_get (BrowserFavorites *bfav, gint fav_id,
GdaDataModel *model;
gboolean retval = FALSE;
- g_return_val_if_fail (BROWSER_IS_FAVORITES (bfav), FALSE);
+ g_return_val_if_fail (TOOLS_IS_FAVORITES (bfav), FALSE);
g_return_val_if_fail (out_fav, FALSE);
g_return_val_if_fail (fav_id >= 0, FALSE);
- memset (out_fav, 0, sizeof (BrowserFavoritesAttributes));
+ memset (out_fav, 0, sizeof (ToolsFavoritesAttributes));
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "id"), 0);
+ gda_sql_builder_add_id (b, "id"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "type"), 0);
+ gda_sql_builder_add_id (b, "type"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "name"), 0);
+ gda_sql_builder_add_id (b, "name"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "descr"), 0);
+ gda_sql_builder_add_id (b, "descr"), 0);
gda_sql_builder_add_field_value_id (b,
- gda_sql_builder_add_id (b, "contents"), 0);
+ gda_sql_builder_add_id (b, "contents"), 0);
gda_sql_builder_select_add_target (b, FAVORITES_TABLE_NAME, NULL);
gda_sql_builder_set_where (b,
gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- gda_sql_builder_add_id (b, "id"),
- gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE), 0));
+ gda_sql_builder_add_id (b, "id"),
+ gda_sql_builder_add_param (b, "id", G_TYPE_INT, FALSE), 0));
stmt = gda_sql_builder_get_statement (b, error);
g_object_unref (G_OBJECT (b));
if (!stmt)
@@ -1167,154 +1289,3 @@ browser_favorites_get (BrowserFavorites *bfav, gint fav_id,
g_object_unref (G_OBJECT (model));
return retval;
}
-
-static gint
-actions_sort_func (BrowserFavoriteAction *act1, BrowserFavoriteAction *act2)
-{
- return act2->nb_bound - act1->nb_bound;
-}
-
-/**
- * browser_favorites_get_actions
- * @bfav: a #BrowserFavorites
- * @bcnc: a #BrowserConnection
- * @set: a #GdaSet
- *
- * Get a list of #BrowserFavoriteAction which can be executed with the data in @set.
- *
- * Returns: a new list of #BrowserFavoriteAction, free list with browser_favorites_free_actions()
- */
-GSList *
-browser_favorites_get_actions (BrowserFavorites *bfav, BrowserConnection *bcnc, GdaSet *set)
-{
- GSList *fav_list, *list, *retlist = NULL;
- g_return_val_if_fail (BROWSER_IS_FAVORITES (bfav), NULL);
- g_return_val_if_fail (BROWSER_IS_CONNECTION (bcnc), NULL);
- g_return_val_if_fail (!set || GDA_IS_SET (set), NULL);
-
- fav_list = browser_favorites_list (bfav, 0, BROWSER_FAVORITES_ACTIONS, -1, NULL);
- if (! fav_list)
- return NULL;
-
- for (list = fav_list; list; list = list->next) {
- BrowserFavoritesAttributes *fa = (BrowserFavoritesAttributes*) list->data;
- BrowserFavoritesAttributes qfa;
- if (! g_str_has_prefix (fa->contents, "QUERY")) {
- g_warning ("Malformed action contents '%s', please report error to "
- "http://bugzilla.gnome.org/ for the \"libgda\" product",
- fa->contents);
- continue;
- }
- if (browser_favorites_get (bfav, atoi (fa->contents + 5), &qfa, NULL)) {
- GdaSet *params;
- GSList *plist;
- GdaBatch *batch;
- GdaStatement *stmt = NULL;
- GdaSqlParser *parser;
- const gchar *remain;
- const GSList *stmt_list;
- gint nb_bound = 0;
-
- parser = browser_connection_create_parser (bcnc);
- batch = gda_sql_parser_parse_string_as_batch (parser, qfa.contents, &remain, NULL);
- g_object_unref (parser);
- if (!batch) {
- browser_favorites_reset_attributes (&qfa);
- continue;
- }
- stmt_list = gda_batch_get_statements (batch);
- for (plist = (GSList*) stmt_list; plist; plist = plist->next) {
- if (! gda_statement_is_useless (GDA_STATEMENT (plist->data))) {
- if (stmt)
- break;
- else
- stmt = g_object_ref (GDA_STATEMENT (plist->data));
- }
- }
- g_object_unref (batch);
- if (!stmt || plist) {
- browser_favorites_reset_attributes (&qfa);
- continue;
- }
-
- if (! gda_statement_get_parameters (stmt, ¶ms, NULL) || !params) {
- g_object_unref (stmt);
- browser_favorites_reset_attributes (&qfa);
- continue;
- }
- browser_connection_define_ui_plugins_for_stmt (bcnc, stmt, params);
-
- for (plist = params->holders; plist; plist = plist->next) {
- /* try to find holder in @set */
- GdaHolder *req_holder, *in_holder;
- req_holder = GDA_HOLDER (plist->data);
- in_holder = gda_set_get_holder (set, gda_holder_get_id (req_holder));
- if (in_holder && gda_holder_set_bind (req_holder, in_holder, NULL)) {
- /* bound this holder to the oune found */
- nb_bound++;
- }
- }
-
- if (nb_bound > 0) {
- /* at least 1 holder was found=> keep the action */
- BrowserFavoriteAction *act;
- act = g_new0 (BrowserFavoriteAction, 1);
- retlist = g_slist_insert_sorted (retlist, act,
- (GCompareFunc) actions_sort_func);
- act->params = g_object_ref (params);
- act->id = fa->id;
- act->name = g_strdup (fa->name);
- act->stmt = g_object_ref (stmt);
- act->nb_bound = nb_bound;
-
- /*g_print ("Action identified: ID=%d Bound=%d name=[%s] SQL=[%s]\n",
- act->id, act->nb_bound,
- act->name, qfa.contents);*/
- }
-
- g_object_unref (stmt);
- g_object_unref (params);
- browser_favorites_reset_attributes (&qfa);
- }
- }
- browser_favorites_free_list (fav_list);
-
- return retlist;
-}
-
-/**
- * browser_favorites_free_action
- * @action: (allow-none): a #BrowserFavoriteAction, or %NULL
- *
- * Frees @action
- */
-void
-browser_favorites_free_action (BrowserFavoriteAction *action)
-{
- if (! action)
- return;
- g_free (action->name);
- if (action->stmt)
- g_object_unref (action->stmt);
- if (action->params)
- g_object_unref (action->params);
- g_free (action);
-}
-
-/**
- * browser_favorites_free_actions_list
- * @actions_list: (allow-none): a list of #BrowserFavoriteAction, or %NULL
- *
- * Free a list of #BrowserFavoriteAction (frees the list and each #BrowserFavoriteAction)
- */
-void
-browser_favorites_free_actions_list (GSList *actions_list)
-{
- GSList *list;
- if (!actions_list)
- return;
-
- for (list = actions_list; list; list = list->next)
- browser_favorites_free_action ((BrowserFavoriteAction*) list->data);
- g_slist_free (actions_list);
-}
diff --git a/tools/tools-favorites.h b/tools/tools-favorites.h
new file mode 100644
index 0000000..41aacfb
--- /dev/null
+++ b/tools/tools-favorites.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2009 - 2011 Vivien Malerba <malerba gnome-db org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef __TOOLS_FAVORITES_H_
+#define __TOOLS_FAVORITES_H_
+
+#include <libgda/libgda.h>
+
+G_BEGIN_DECLS
+
+#define TOOLS_TYPE_FAVORITES (tools_favorites_get_type())
+#define TOOLS_FAVORITES(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, tools_favorites_get_type(), ToolsFavorites)
+#define TOOLS_FAVORITES_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, tools_favorites_get_type (), ToolsFavoritesClass)
+#define TOOLS_IS_FAVORITES(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, tools_favorites_get_type ())
+
+typedef struct _ToolsFavorites ToolsFavorites;
+typedef struct _ToolsFavoritesClass ToolsFavoritesClass;
+typedef struct _ToolsFavoritesPrivate ToolsFavoritesPrivate;
+
+/**
+ * ToolsFavoritesType:
+ * @TOOLS_FAVORITES_TABLES: a database's table favorite
+ * @TOOLS_FAVORITES_DIAGRAMS: a diagram favorite
+ * @TOOLS_FAVORITES_QUERIES:
+ * @TOOLS_FAVORITES_DATA_MANAGERS:
+ * @TOOLS_FAVORITES_ACTIONS:
+ *
+ * Enum to identify favorite's types.
+ */
+typedef enum {
+ TOOLS_FAVORITES_TABLES = 1 << 0,
+ TOOLS_FAVORITES_DIAGRAMS = 1 << 1,
+ TOOLS_FAVORITES_QUERIES = 1 << 2,
+ TOOLS_FAVORITES_DATA_MANAGERS = 1 << 3,
+ TOOLS_FAVORITES_ACTIONS = 1 << 4,
+ TOOLS_FAVORITES_LDAP_DN = 1 << 5,
+ TOOLS_FAVORITES_LDAP_CLASS = 1 << 6
+} ToolsFavoritesType;
+#define TOOLS_FAVORITES_NB_TYPES 7
+
+#define ORDER_KEY_SCHEMA 1
+#define ORDER_KEY_QUERIES 2
+#define ORDER_KEY_DATA_MANAGERS 3
+#define ORDER_KEY_LDAP 4
+
+/**
+ * ToolsFavoritesAttributes:
+ * @id: the favorite ID, or <0 if not saved
+ * @type: the favorite's type
+ * @name: the favorite's name
+ * @descr: the favorite's description
+ * @contents: the favorite's contents, depending on the favorite type
+ */
+typedef struct {
+ gint id;
+ ToolsFavoritesType type;
+ gchar *name;
+ gchar *descr;
+ gchar *contents;
+} ToolsFavoritesAttributes;
+
+/* struct for the object's data */
+struct _ToolsFavorites
+{
+ GObject object;
+ ToolsFavoritesPrivate *priv;
+};
+
+/* struct for the object's class */
+struct _ToolsFavoritesClass
+{
+ GObjectClass parent_class;
+
+ void (*favorites_changed) (ToolsFavorites *bfav);
+};
+
+/**
+ * SECTION:tools-favorites
+ * @short_description: Favorites management
+ * @title: ToolsFavorites
+ * @stability: Stable
+ * @see_also:
+ *
+ * Each connection uses a single #ToolsFavorites object to manage its favorites,
+ * see tools_connection_get_favorites().
+ */
+
+GType tools_favorites_get_type (void) G_GNUC_CONST;
+
+ToolsFavorites *tools_favorites_new (GdaMetaStore *store);
+const gchar *tools_favorites_type_to_string (ToolsFavoritesType type);
+gboolean tools_favorites_add (ToolsFavorites *bfav, guint session_id,
+ ToolsFavoritesAttributes *fav,
+ gint order_key, gint pos,
+ GError **error);
+GSList *tools_favorites_list (ToolsFavorites *bfav, guint session_id,
+ ToolsFavoritesType type, gint order_key, GError **error);
+
+gboolean tools_favorites_delete (ToolsFavorites *bfav, guint session_id,
+ ToolsFavoritesAttributes *fav, GError **error);
+void tools_favorites_free_list (GSList *fav_list);
+void tools_favorites_reset_attributes (ToolsFavoritesAttributes *fav);
+
+gint tools_favorites_find (ToolsFavorites *bfav, guint session_id, const gchar *contents,
+ ToolsFavoritesAttributes *out_fav, GError **error);
+gint tools_favorites_find_by_name (ToolsFavorites *bfav, guint session_id,
+ ToolsFavoritesType type, const gchar *name,
+ ToolsFavoritesAttributes *out_fav, GError **error);
+gboolean tools_favorites_get (ToolsFavorites *bfav, gint fav_id,
+ ToolsFavoritesAttributes *out_fav, GError **error);
+
+G_END_DECLS
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]