[libgda] GdaBrowser: each perspective's page can now have its own menus and toolbars
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgda] GdaBrowser: each perspective's page can now have its own menus and toolbars
- Date: Sun, 23 Aug 2009 20:20:12 +0000 (UTC)
commit c8cdda2cb369b16445814bc425fde4124bd5e280
Author: Vivien Malerba <malerba gnome-db org>
Date: Thu Aug 20 15:07:10 2009 +0200
GdaBrowser: each perspective's page can now have its own menus and toolbars
* added the BrowserPage interface to let each "page" specify its menus
and toolbars
* added the browser_window_customize_perspective_ui() method to be
used by perspectives
* used this new mechanism to add a favorite to a table which information
are displayed
tools/browser/Makefile.am | 2 +
tools/browser/browser-page.c | 99 +++++++++++++++++
tools/browser/browser-page.h | 52 +++++++++
tools/browser/browser-perspective.h | 8 +-
tools/browser/browser-window.c | 82 ++++++++++++++-
tools/browser/browser-window.h | 4 +
tools/browser/decl.h | 3 +
tools/browser/schema-browser/favorite-selector.c | 1 -
.../schema-browser/schema-browser-perspective.c | 26 +++++-
tools/browser/schema-browser/table-info.c | 115 +++++++++++++++++---
10 files changed, 370 insertions(+), 22 deletions(-)
---
diff --git a/tools/browser/Makefile.am b/tools/browser/Makefile.am
index 92b314c..ed63432 100644
--- a/tools/browser/Makefile.am
+++ b/tools/browser/Makefile.am
@@ -39,6 +39,8 @@ gda_browser_4_0_SOURCES=\
support.h \
browser-core.c \
browser-core.h \
+ browser-page.c \
+ browser-page.h \
browser-perspective.c \
browser-perspective.h \
browser-spinner.c \
diff --git a/tools/browser/browser-page.c b/tools/browser/browser-page.c
new file mode 100644
index 0000000..1867ae4
--- /dev/null
+++ b/tools/browser/browser-page.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2009 The GNOME Foundation.
+ *
+ * AUTHORS:
+ * Vivien Malerba <malerba gnome-db org>
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this Library; see the file COPYING.LIB. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "browser-page.h"
+
+static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
+static void browser_page_class_init (gpointer g_class);
+
+GType
+browser_page_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo info = {
+ sizeof (BrowserPageIface),
+ (GBaseInitFunc) browser_page_class_init,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ (GInstanceInitFunc) NULL
+ };
+
+ g_static_rec_mutex_lock (&init_mutex);
+ if (type == 0) {
+ type = g_type_register_static (G_TYPE_INTERFACE, "BrowserPage", &info, 0);
+ g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
+ }
+ g_static_rec_mutex_unlock (&init_mutex);
+ }
+ return type;
+}
+
+static void
+browser_page_class_init (gpointer g_class)
+{
+ static gboolean initialized = FALSE;
+
+ g_static_rec_mutex_lock (&init_mutex);
+ if (! initialized) {
+ initialized = TRUE;
+ }
+ g_static_rec_mutex_unlock (&init_mutex);
+}
+
+/**
+ * browser_page_get_actions_group
+ * @pers:
+ * @instance: a GtkWidget which has been returned by a previous call to browser_page_create()
+ *
+ * Returns: a new #GtkActionGroup
+ */
+GtkActionGroup *
+browser_page_get_actions_group (BrowserPage *pers)
+{
+ g_return_val_if_fail (IS_BROWSER_PAGE (pers), NULL);
+
+ if (BROWSER_PAGE_GET_CLASS (pers)->i_get_actions_group)
+ return (BROWSER_PAGE_GET_CLASS (pers)->i_get_actions_group) (pers);
+ else
+ return NULL;
+}
+
+/**
+ * browser_page_get_actions_ui
+ *
+ */
+const gchar *
+browser_page_get_actions_ui (BrowserPage *pers)
+{
+ g_return_val_if_fail (IS_BROWSER_PAGE (pers), NULL);
+
+ if (BROWSER_PAGE_GET_CLASS (pers)->i_get_actions_ui)
+ return (BROWSER_PAGE_GET_CLASS (pers)->i_get_actions_ui) (pers);
+ else
+ return NULL;
+}
diff --git a/tools/browser/browser-page.h b/tools/browser/browser-page.h
new file mode 100644
index 0000000..ce507fa
--- /dev/null
+++ b/tools/browser/browser-page.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2009 The GNOME Foundation.
+ *
+ * AUTHORS:
+ * Vivien Malerba <malerba gnome-db org>
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this Library; see the file COPYING.LIB. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __BROWSER_PAGE_H__
+#define __BROWSER_PAGE_H__
+
+#include <gtk/gtk.h>
+#include "decl.h"
+
+G_BEGIN_DECLS
+
+#define BROWSER_PAGE_TYPE (browser_page_get_type())
+#define BROWSER_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, BROWSER_PAGE_TYPE, BrowserPage))
+#define IS_BROWSER_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, BROWSER_PAGE_TYPE))
+#define BROWSER_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), BROWSER_PAGE_TYPE, BrowserPageIface))
+
+/* struct for the interface */
+struct _BrowserPageIface {
+ GTypeInterface g_iface;
+
+ /* virtual table */
+ GtkActionGroup *(* i_get_actions_group) (BrowserPage *page);
+ const gchar *(* i_get_actions_ui) (BrowserPage *page);
+};
+
+GType browser_page_get_type (void) G_GNUC_CONST;
+
+GtkActionGroup *browser_page_get_actions_group (BrowserPage *page);
+const gchar *browser_page_get_actions_ui (BrowserPage *page);
+
+G_END_DECLS
+
+#endif
diff --git a/tools/browser/browser-perspective.h b/tools/browser/browser-perspective.h
index 9944475..9c44e37 100644
--- a/tools/browser/browser-perspective.h
+++ b/tools/browser/browser-perspective.h
@@ -38,14 +38,14 @@ struct _BrowserPerspectiveIface {
GTypeInterface g_iface;
/* virtual table */
- GtkActionGroup *(* i_get_actions_group) (BrowserPerspective *factory);
- const gchar *(* i_get_actions_ui) (BrowserPerspective *factory);
+ GtkActionGroup *(* i_get_actions_group) (BrowserPerspective *perspective);
+ const gchar *(* i_get_actions_ui) (BrowserPerspective *perspective);
};
GType browser_perspective_get_type (void) G_GNUC_CONST;
-GtkActionGroup *browser_perspective_get_actions_group (BrowserPerspective *factory);
-const gchar *browser_perspective_get_actions_ui (BrowserPerspective *factory);
+GtkActionGroup *browser_perspective_get_actions_group (BrowserPerspective *perspective);
+const gchar *browser_perspective_get_actions_ui (BrowserPerspective *perspective);
G_END_DECLS
diff --git a/tools/browser/browser-window.c b/tools/browser/browser-window.c
index 60f8220..99ccdf8 100644
--- a/tools/browser/browser-window.c
+++ b/tools/browser/browser-window.c
@@ -40,6 +40,10 @@ typedef struct {
BrowserPerspectiveFactory *factory;
gint page_number; /* in reference to bwin->perspectives_nb */
BrowserPerspective *perspective_widget;
+
+ GtkActionGroup *customized_actions;
+ guint customized_merge_id;
+ gchar *customized_ui;
} PerspectiveData;
#define PERSPECTIVE_DATA(x) ((PerspectiveData*)(x))
PerspectiveData *perspective_data_new (BrowserWindow *bwin, BrowserPerspectiveFactory *factory);
@@ -63,6 +67,7 @@ struct _BrowserWindowPrivate {
BrowserConnection *bcnc;
GtkNotebook *perspectives_nb; /* notebook used to switch between tabs, for the selector part */
GSList *perspectives; /* list of PerspectiveData pointers, owned here */
+ PerspectiveData *current_perspective;
guint ui_manager_merge_id; /* for current perspective */
GtkWidget *spinner;
@@ -376,6 +381,7 @@ browser_window_new (BrowserConnection *bcnc, BrowserPerspectiveFactory *factory)
if (ui_info)
bwin->priv->ui_manager_merge_id = gtk_ui_manager_add_ui_from_string (bwin->priv->ui_manager,
ui_info, -1, NULL);
+ bwin->priv->current_perspective = pers;
/* insert perspective into window */
bwin->priv->perspectives_nb = (GtkNotebook*) gtk_notebook_new ();
@@ -451,6 +457,16 @@ perspective_toggle_cb (GtkRadioAction *action, GtkRadioAction *current, BrowserW
pf = BROWSER_PERSPECTIVE_FACTORY (g_object_get_data (G_OBJECT (action), "pers"));
g_assert (pf);
+ /* current perspective's cleanups */
+ if (bwin->priv->current_perspective) {
+ pers = bwin->priv->current_perspective;
+ if (pers->customized_merge_id) {
+ gtk_ui_manager_remove_ui (bwin->priv->ui_manager, pers->customized_merge_id);
+ pers->customized_merge_id = 0;
+ }
+ bwin->priv->current_perspective = NULL;
+ }
+
/* check if perspective already exists */
for (list = bwin->priv->perspectives, pers = NULL; list; list = list->next) {
if (PERSPECTIVE_DATA (list->data)->factory == pf) {
@@ -476,7 +492,6 @@ perspective_toggle_cb (GtkRadioAction *action, GtkRadioAction *current, BrowserW
gtk_notebook_set_current_page (bwin->priv->perspectives_nb, pers->page_number);
-
/* menus and toolbar handling */
if (bwin->priv->ui_manager_merge_id > 0) {
gtk_ui_manager_remove_ui (bwin->priv->ui_manager, bwin->priv->ui_manager_merge_id);
@@ -488,6 +503,13 @@ perspective_toggle_cb (GtkRadioAction *action, GtkRadioAction *current, BrowserW
if (ui_info)
bwin->priv->ui_manager_merge_id = gtk_ui_manager_add_ui_from_string (bwin->priv->ui_manager,
ui_info, -1, NULL);
+
+ /* current perspective's customizations */
+ bwin->priv->current_perspective = pers;
+ if (pers->customized_ui)
+ pers->customized_merge_id = gtk_ui_manager_add_ui_from_string (bwin->priv->ui_manager,
+ pers->customized_ui,
+ -1, NULL);
}
static void
@@ -812,6 +834,9 @@ perspective_data_free (PerspectiveData *pers)
{
if (pers->perspective_widget)
g_object_unref (pers->perspective_widget);
+ if (pers->customized_actions)
+ g_object_unref (pers->customized_actions);
+ g_free (pers->customized_ui);
g_free (pers);
}
@@ -845,3 +870,58 @@ browser_window_pop_status (BrowserWindow *bwin, const gchar *context)
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (bwin->priv->statusbar), context);
gtk_statusbar_pop (GTK_STATUSBAR (bwin->priv->statusbar), cid);
}
+
+/**
+ * browser_window_push_perspective_ui
+ *
+ * Customizes a UI specific to the @bpers perspective. Any
+ * previous customization is removed, replaced by the new requested one.
+ *
+ * If @actions_group is %NULL then any it simply removes the customization.
+ */
+void
+browser_window_customize_perspective_ui (BrowserWindow *bwin, BrowserPerspective *bpers,
+ GtkActionGroup *actions_group,
+ const gchar *ui_info)
+{
+ PerspectiveData *pdata = NULL;
+ GSList *list;
+
+ g_return_if_fail (BROWSER_IS_WINDOW (bwin));
+ g_return_if_fail (IS_BROWSER_PERSPECTIVE (bpers));
+
+ for (list = bwin->priv->perspectives; list; list = list->next) {
+ if (PERSPECTIVE_DATA (list->data)->perspective_widget == bpers) {
+ pdata = PERSPECTIVE_DATA (list->data);
+ break;
+ }
+ }
+ if (! pdata)
+ return;
+
+ /* cleanups */
+ if (pdata->customized_merge_id) {
+ gtk_ui_manager_remove_ui (bwin->priv->ui_manager, pdata->customized_merge_id);
+ pdata->customized_merge_id = 0;
+ gtk_ui_manager_ensure_update (bwin->priv->ui_manager);
+ }
+ if (pdata->customized_actions) {
+ gtk_ui_manager_remove_action_group (bwin->priv->ui_manager, pdata->customized_actions);
+ g_object_unref (pdata->customized_actions);
+ pdata->customized_actions = NULL;
+ }
+ g_free (pdata->customized_ui);
+ pdata->customized_ui = NULL;
+
+ if (actions_group) {
+ g_return_if_fail (GTK_IS_ACTION_GROUP (actions_group));
+ gtk_ui_manager_insert_action_group (bwin->priv->ui_manager, actions_group, 0);
+ pdata->customized_actions = g_object_ref (actions_group);
+ }
+ if (ui_info) {
+ pdata->customized_ui = g_strdup (ui_info);
+ pdata->customized_merge_id = gtk_ui_manager_add_ui_from_string (bwin->priv->ui_manager,
+ pdata->customized_ui,
+ -1, NULL);
+ }
+}
diff --git a/tools/browser/browser-window.h b/tools/browser/browser-window.h
index 5465879..73d8491 100644
--- a/tools/browser/browser-window.h
+++ b/tools/browser/browser-window.h
@@ -55,6 +55,10 @@ BrowserConnection *browser_window_get_connection (BrowserWindow *bwin);
guint browser_window_push_status (BrowserWindow *bwin, const gchar *context, const gchar *text);
void browser_window_pop_status (BrowserWindow *bwin, const gchar *context);
+void browser_window_customize_perspective_ui (BrowserWindow *bwin, BrowserPerspective *bpers,
+ GtkActionGroup *actions_group,
+ const gchar *ui_info);
+
G_END_DECLS
#endif
diff --git a/tools/browser/decl.h b/tools/browser/decl.h
index 401fa75..ceebe93 100644
--- a/tools/browser/decl.h
+++ b/tools/browser/decl.h
@@ -35,6 +35,9 @@ typedef struct _BrowserData BrowserData;
typedef struct _BrowserPerspectiveIface BrowserPerspectiveIface;
typedef struct _BrowserPerspective BrowserPerspective;
+typedef struct _BrowserPageIface BrowserPageIface;
+typedef struct _BrowserPage BrowserPage;
+
typedef struct {
const gchar *perspective_name;
BrowserPerspective *(*perspective_create) (BrowserWindow *);
diff --git a/tools/browser/schema-browser/favorite-selector.c b/tools/browser/schema-browser/favorite-selector.c
index 6d8e003..3aa24aa 100644
--- a/tools/browser/schema-browser/favorite-selector.c
+++ b/tools/browser/schema-browser/favorite-selector.c
@@ -176,7 +176,6 @@ key_press_event_cb (GtkTreeView *treeview, GdkEventKey *event, FavoriteSelector
return TRUE;
}
- TO_IMPLEMENT;
return FALSE; /* not handled */
}
diff --git a/tools/browser/schema-browser/schema-browser-perspective.c b/tools/browser/schema-browser/schema-browser-perspective.c
index 78e99f7..6fcb1f0 100644
--- a/tools/browser/schema-browser/schema-browser-perspective.c
+++ b/tools/browser/schema-browser/schema-browser-perspective.c
@@ -25,6 +25,7 @@
#include "../browser-window.h"
#include "table-info.h"
#include "../support.h"
+#include "../browser-page.h"
#ifdef HAVE_GOOCANVAS
#include "relations-diagram.h"
#endif
@@ -110,7 +111,8 @@ static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, BrowserFav
const gchar *selection, SchemaBrowserPerspective *bpers);
static void objects_index_selection_changed_cb (GtkWidget *widget, BrowserFavoritesType fav_type,
const gchar *selection, SchemaBrowserPerspective *bpers);
-
+static void nb_switch_page_cb (GtkNotebook *nb, GtkNotebookPage *page, gint page_num,
+ SchemaBrowserPerspective *perspective);
/**
* schema_browser_perspective_new
*
@@ -142,6 +144,8 @@ schema_browser_perspective_new (BrowserWindow *bwin)
gtk_paned_add2 (GTK_PANED (paned), nb);
gtk_notebook_set_scrollable (GTK_NOTEBOOK (nb), TRUE);
gtk_notebook_popup_enable (GTK_NOTEBOOK (nb));
+ g_signal_connect (G_OBJECT (nb), "switch-page",
+ G_CALLBACK (nb_switch_page_cb), perspective);
wid = objects_index_new (bcnc);
g_signal_connect (wid, "selection-changed",
@@ -163,6 +167,26 @@ schema_browser_perspective_new (BrowserWindow *bwin)
}
static void
+nb_switch_page_cb (GtkNotebook *nb, GtkNotebookPage *page, gint page_num,
+ SchemaBrowserPerspective *perspective)
+{
+ GtkWidget *page_contents;
+ GtkActionGroup *actions = NULL;
+ const gchar *ui = NULL;
+
+ page_contents = gtk_notebook_get_nth_page (nb, page_num);
+ if (IS_BROWSER_PAGE (page_contents)) {
+ actions = browser_page_get_actions_group (BROWSER_PAGE (page_contents));
+ ui = browser_page_get_actions_ui (BROWSER_PAGE (page_contents));
+ }
+ browser_window_customize_perspective_ui (perspective->priv->bwin,
+ BROWSER_PERSPECTIVE (perspective), actions,
+ ui);
+ if (actions)
+ g_object_unref (actions);
+}
+
+static void
close_button_clicked_cb (GtkWidget *wid, GtkWidget *page_widget)
{
gtk_widget_destroy (page_widget);
diff --git a/tools/browser/schema-browser/table-info.c b/tools/browser/schema-browser/table-info.c
index 9de12ba..042edfe 100644
--- a/tools/browser/schema-browser/table-info.c
+++ b/tools/browser/schema-browser/table-info.c
@@ -32,6 +32,7 @@
#include "table-relations.h"
#endif
#include "schema-browser-perspective.h"
+#include "../browser-page.h"
struct _TableInfoPrivate {
BrowserConnection *bcnc;
@@ -57,6 +58,10 @@ static void table_info_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec);
+/* BrowserPage interface */
+static void table_info_page_init (BrowserPageIface *iface);
+static GtkActionGroup *table_info_page_get_actions_group (BrowserPage *page);
+static const gchar *table_info_page_get_actions_ui (BrowserPage *page);
static void meta_changed_cb (BrowserConnection *bcnc, GdaMetaStruct *mstruct, TableInfo *tinfo);
@@ -92,6 +97,12 @@ table_info_class_init (TableInfoClass *klass)
object_class->dispose = table_info_dispose;
}
+static void
+table_info_page_init (BrowserPageIface *iface)
+{
+ iface->i_get_actions_group = table_info_page_get_actions_group;
+ iface->i_get_actions_ui = table_info_page_get_actions_ui;
+}
static void
table_info_init (TableInfo *tinfo, TableInfoClass *klass)
@@ -139,7 +150,15 @@ table_info_get_type (void)
0,
(GInstanceInitFunc) table_info_init
};
+
+ static GInterfaceInfo page_info = {
+ (GInterfaceInitFunc) table_info_page_init,
+ NULL,
+ NULL
+ };
+
type = g_type_register_static (GTK_TYPE_VBOX, "TableInfo", &info, 0);
+ g_type_add_interface_static (type, BROWSER_PAGE_TYPE, &page_info);
}
return type;
}
@@ -177,6 +196,24 @@ display_table_not_found_error (TableInfo *tinfo, gboolean is_error)
gtk_notebook_set_current_page (GTK_NOTEBOOK (tinfo->priv->contents), 1);
}
+static gchar *
+table_info_to_selection (TableInfo *tinfo)
+{
+ GString *string;
+ gchar *tmp;
+ string = g_string_new ("OBJ_TYPE=table");
+ tmp = gda_rfc1738_encode (tinfo->priv->schema);
+ g_string_append_printf (string, ";OBJ_SCHEMA=%s", tmp);
+ g_free (tmp);
+ tmp = gda_rfc1738_encode (tinfo->priv->table_name);
+ g_string_append_printf (string, ";OBJ_NAME=%s", tmp);
+ g_free (tmp);
+ tmp = gda_rfc1738_encode (tinfo->priv->table_short_name);
+ g_string_append_printf (string, ";OBJ_SHORT_NAME=%s", tmp);
+ g_free (tmp);
+ return g_string_free (string, FALSE);
+}
+
static void
source_drag_data_get_cb (GtkWidget *widget, GdkDragContext *context,
GtkSelectionData *selection_data,
@@ -184,21 +221,11 @@ source_drag_data_get_cb (GtkWidget *widget, GdkDragContext *context,
{
switch (info) {
case TARGET_KEY_VALUE: {
- GString *string;
- gchar *tmp;
- string = g_string_new ("OBJ_TYPE=table");
- tmp = gda_rfc1738_encode (tinfo->priv->schema);
- g_string_append_printf (string, ";OBJ_SCHEMA=%s", tmp);
- g_free (tmp);
- tmp = gda_rfc1738_encode (tinfo->priv->table_name);
- g_string_append_printf (string, ";OBJ_NAME=%s", tmp);
- g_free (tmp);
- tmp = gda_rfc1738_encode (tinfo->priv->table_short_name);
- g_string_append_printf (string, ";OBJ_SHORT_NAME=%s", tmp);
- g_free (tmp);
- gtk_selection_data_set (selection_data, selection_data->target, 8, (guchar*) string->str,
- strlen (string->str));
- g_string_free (string, TRUE);
+ gchar *str;
+ str = table_info_to_selection (tinfo);
+ gtk_selection_data_set (selection_data, selection_data->target, 8, (guchar*) str,
+ strlen (str));
+ g_free (str);
break;
}
default:
@@ -382,3 +409,61 @@ table_info_get_connection (TableInfo *tinfo)
g_return_val_if_fail (IS_TABLE_INFO (tinfo), NULL);
return tinfo->priv->bcnc;
}
+
+/*
+ * UI actions
+ */
+static void
+action_add_to_fav_cb (GtkAction *action, TableInfo *tinfo)
+{
+ BrowserFavorites *bfav;
+ BrowserFavoritesAttributes fav;
+ GError *error = NULL;
+
+ memset (&fav, 0, sizeof (BrowserFavoritesAttributes));
+ fav.id = -1;
+ fav.type = BROWSER_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)) {
+ browser_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) tinfo),
+ _("Could not add favorite: %s"),
+ error && error->message ? error->message : _("No detail"));
+ if (error)
+ g_error_free (error);
+ }
+ g_free (fav.contents);
+}
+
+static GtkActionEntry ui_actions[] = {
+ { "AddToFav", GTK_STOCK_ADD, N_("_Favorite"), NULL, N_("Add table to favorites"),
+ G_CALLBACK (action_add_to_fav_cb)},
+};
+static const gchar *ui_actions_info =
+ "<ui>"
+ " <menubar name='MenuBar'>"
+ " </menubar>"
+ " <toolbar name='ToolBar'>"
+ " <separator/>"
+ " <toolitem action='AddToFav'/>"
+ " </toolbar>"
+ "</ui>";
+
+static GtkActionGroup *
+table_info_page_get_actions_group (BrowserPage *page)
+{
+ GtkActionGroup *agroup;
+ agroup = gtk_action_group_new ("SchemaBrowserRelationsDiagramActions");
+ gtk_action_group_add_actions (agroup, ui_actions, G_N_ELEMENTS (ui_actions), page);
+
+ return agroup;
+}
+
+static const gchar *
+table_info_page_get_actions_ui (BrowserPage *page)
+{
+ return ui_actions_info;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]