[libgda] One can now directly view a table's contents in GdaBrowser
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] One can now directly view a table's contents in GdaBrowser
- Date: Wed, 31 Mar 2010 15:43:01 +0000 (UTC)
commit 5e5f805440e80ee92ba7b06b12b9024c090e004d
Author: Vivien Malerba <malerba gnome-db org>
Date: Wed Mar 31 17:04:31 2010 +0200
One can now directly view a table's contents in GdaBrowser
tools/browser/browser-core.c | 22 ++++++++
tools/browser/browser-core.h | 3 +-
tools/browser/browser-window.c | 55 ++++++++++++++++++-
tools/browser/browser-window.h | 2 +
tools/browser/data-manager/data-console.c | 24 ++++++--
tools/browser/data-manager/data-console.h | 1 +
.../data-manager/data-manager-perspective.c | 39 +++++++++++++
.../data-manager/data-manager-perspective.h | 5 +-
tools/browser/doc/Makefile.am | 7 ++-
tools/browser/doc/gda-browser-docs.sgml | 10 ++++
tools/browser/doc/gda-browser-sections.txt | 15 +++++-
tools/browser/doc/gda-browser.types | 1 +
tools/browser/doc/tmpl/browser-core.sgml | 18 ++++++
tools/browser/doc/tmpl/browser-perspective.sgml | 6 +--
tools/browser/doc/tmpl/browser-window.sgml | 10 ++++
.../browser/doc/tmpl/data-manager-perspective.sgml | 58 ++++++++++++++++++++
tools/browser/schema-browser/table-info.c | 33 +++++++++++
17 files changed, 291 insertions(+), 18 deletions(-)
---
diff --git a/tools/browser/browser-core.c b/tools/browser/browser-core.c
index 417f5b8..109ed28 100644
--- a/tools/browser/browser-core.c
+++ b/tools/browser/browser-core.c
@@ -295,6 +295,28 @@ browser_core_get_connections (void)
}
/**
+ * browser_core_get_factory
+ * @factory: the name of the requested factory
+ *
+ * Get a pointer to a #BrowserPerspectiveFactory, from its name
+ *
+ * Returns: a pointer to the #BrowserPerspectiveFactory, or %NULL if not found
+ */
+BrowserPerspectiveFactory *
+browser_core_get_factory (const gchar *factory)
+{
+ GSList *list;
+ g_return_val_if_fail (factory, NULL);
+ _bcore = browser_core_get ();
+ for (list = _bcore->priv->factories; list; list = list->next) {
+ BrowserPerspectiveFactory *bpf = BROWSER_PERSPECTIVE_FACTORY (list->data);
+ if (!g_ascii_strcasecmp (bpf->perspective_name, factory))
+ return bpf;
+ }
+ return NULL;
+}
+
+/**
* browser_core_get_default_factory
*
* Get the default #BrowserPerspectiveFactory used when making new #BrowserWindow if none
diff --git a/tools/browser/browser-core.h b/tools/browser/browser-core.h
index 78cd6ae..3822ff1 100644
--- a/tools/browser/browser-core.h
+++ b/tools/browser/browser-core.h
@@ -67,8 +67,9 @@ void browser_core_close_connection (BrowserConnection *bcnc);
void browser_core_quit (void);
BrowserPerspectiveFactory *browser_core_get_default_factory (void);
+BrowserPerspectiveFactory *browser_core_get_factory (const gchar *factory);
void browser_core_set_default_factory (const gchar *factory);
-const GSList *browser_core_get_factories (void);
+const GSList *browser_core_get_factories (void);
G_END_DECLS
diff --git a/tools/browser/browser-window.c b/tools/browser/browser-window.c
index df38f14..edb3c23 100644
--- a/tools/browser/browser-window.c
+++ b/tools/browser/browser-window.c
@@ -80,6 +80,7 @@ struct _BrowserWindowPrivate {
GtkWidget *spinner;
GtkUIManager *ui_manager;
GtkActionGroup *agroup;
+ GtkActionGroup *perspectives_actions;
gboolean updating_transaction_status;
GtkToolbarStyle toolbar_style;
@@ -453,6 +454,7 @@ browser_window_new (BrowserConnection *bcnc, BrowserPerspectiveFactory *factory)
mid = gtk_ui_manager_new_merge_id (bwin->priv->ui_manager);
agroup = gtk_action_group_new ("Perspectives");
gtk_ui_manager_insert_action_group (bwin->priv->ui_manager, agroup, 0);
+ bwin->priv->perspectives_actions = agroup;
g_object_unref (agroup);
GtkAction *active_action = NULL;
@@ -1000,7 +1002,7 @@ about_cb (GtkAction *action, BrowserWindow *bwin)
g_free (path);
dialog = gtk_about_dialog_new ();
- gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (dialog), _("Database browser"));
+ gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG (dialog), _("Database browser"));
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (dialog), PACKAGE_VERSION);
gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (dialog), "(C) 2009 GNOME Foundation");
gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (dialog), _("Database access services for the GNOME Desktop"));
@@ -1203,3 +1205,54 @@ browser_window_customize_perspective_ui (BrowserWindow *bwin, BrowserPerspective
-1, NULL);
}
}
+
+/**
+ * browser_window_change_perspective
+ * @bwin: a #BrowserWindow
+ * @perspective: the name of the perspective to change to
+ *
+ * Make @bwin switch to the perspective named @perspective
+ *
+ * Returns: a pointer to the #BrowserPerspective, or %NULL if not found
+ */
+BrowserPerspective *
+browser_window_change_perspective (BrowserWindow *bwin, const gchar *perspective)
+{
+ BrowserPerspectiveFactory *bpf;
+ BrowserPerspective *bpers = NULL;
+ PerspectiveData *current_pdata;
+
+ g_return_val_if_fail (BROWSER_IS_WINDOW (bwin), NULL);
+ g_return_val_if_fail (perspective, NULL);
+
+ current_pdata = bwin->priv->current_perspective;
+
+ bpf = browser_core_get_factory (perspective);
+ if (!bpf)
+ return NULL;
+ GList *actions, *list;
+ actions = gtk_action_group_list_actions (bwin->priv->perspectives_actions);
+ for (list = actions; list; list = list->next) {
+ GtkAction *action = (GtkAction *) list->data;
+ BrowserPerspectiveFactory *pf;
+ pf = BROWSER_PERSPECTIVE_FACTORY (g_object_get_data (G_OBJECT (action), "pers"));
+ if (pf == bpf) {
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ PerspectiveData *pdata = bwin->priv->current_perspective;
+ if (pdata && ! g_ascii_strcasecmp (pdata->factory->perspective_name, perspective))
+ bpers = pdata->perspective_widget;
+ break;
+ }
+ }
+ g_list_free (actions);
+
+ browser_show_notice (GTK_WINDOW (bwin), "Perspective change",
+ _("The current perspective has changed to the '%s' perspective, you "
+ "can switch back to previous perspective through the "
+ "'Perspective/%s' menu, or using the '%s' shortcut"),
+ bwin->priv->current_perspective->factory->perspective_name,
+ current_pdata->factory->perspective_name,
+ current_pdata->factory->menu_shortcut);
+
+ return bpers;
+}
diff --git a/tools/browser/browser-window.h b/tools/browser/browser-window.h
index d3e9a20..3f19488 100644
--- a/tools/browser/browser-window.h
+++ b/tools/browser/browser-window.h
@@ -60,6 +60,8 @@ void browser_window_customize_perspective_ui (BrowserWindow *bwin
GtkActionGroup *actions_group,
const gchar *ui_info);
+BrowserPerspective *browser_window_change_perspective (BrowserWindow *bwin, const gchar *perspective);
+
G_END_DECLS
#endif
diff --git a/tools/browser/data-manager/data-console.c b/tools/browser/data-manager/data-console.c
index b8c22a4..769198e 100644
--- a/tools/browser/data-manager/data-console.c
+++ b/tools/browser/data-manager/data-console.c
@@ -341,11 +341,7 @@ data_console_new (BrowserConnection *bcnc)
static void
execute_clicked_cb (GtkButton *button, DataConsole *dconsole)
{
- if (dconsole->priv->agroup) {
- GtkAction *action;
- action = gtk_action_group_get_action (dconsole->priv->agroup, "ComposeMode");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
- }
+ data_console_execute (dconsole);
}
static void
@@ -429,7 +425,6 @@ create_widget (DataConsole *dconsole, GArray *sources_array, GError **error)
return sw;
}
-
/*
* UI actions
*/
@@ -558,3 +553,20 @@ data_console_get_text (DataConsole *console)
return spec_editor_get_xml_text (console->priv->sped);
}
+
+/**
+ * data_console_execute
+ * @console: a #DataConsole widget
+ *
+ * Execute's @console's specs, if possible
+ */
+void
+data_console_execute (DataConsole *console)
+{
+ g_return_if_fail (IS_DATA_CONSOLE (console));
+ if (console->priv->agroup) {
+ GtkAction *action;
+ action = gtk_action_group_get_action (console->priv->agroup, "ComposeMode");
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
+ }
+}
diff --git a/tools/browser/data-manager/data-console.h b/tools/browser/data-manager/data-console.h
index 4b5eeb3..66467e7 100644
--- a/tools/browser/data-manager/data-console.h
+++ b/tools/browser/data-manager/data-console.h
@@ -52,6 +52,7 @@ GType data_console_get_type (void) G_GNUC_CONST;
GtkWidget *data_console_new (BrowserConnection *bcnc);
void data_console_set_text (DataConsole *console, const gchar *text);
gchar *data_console_get_text (DataConsole *console);
+void data_console_execute (DataConsole *console);
G_END_DECLS
diff --git a/tools/browser/data-manager/data-manager-perspective.c b/tools/browser/data-manager/data-manager-perspective.c
index cc331cb..169917b 100644
--- a/tools/browser/data-manager/data-manager-perspective.c
+++ b/tools/browser/data-manager/data-manager-perspective.c
@@ -326,3 +326,42 @@ data_manager_perspective_get_actions_ui (BrowserPerspective *bpers)
{
return ui_actions_info;
}
+
+/**
+ * data_manager_perspective_new_tab
+ * @dmp: a #DataManagerPerspective perspective
+ * @xml_spec: the XML specifications to use
+ *
+ * Make @dmp create a new page (unless the current one is empty)
+ */
+void
+data_manager_perspective_new_tab (DataManagerPerspective *dmp, const gchar *xml_spec)
+{
+ gint current;
+ GtkWidget *page = NULL;
+
+ g_return_if_fail (IS_DATA_MANAGER_PERSPECTIVE (dmp));
+ current = gtk_notebook_get_current_page (GTK_NOTEBOOK (dmp->priv->notebook));
+ if (current >= 0) {
+ page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (dmp->priv->notebook), current);
+ if (! IS_DATA_CONSOLE (page))
+ page = NULL;
+ else {
+ gchar *text;
+ text = data_console_get_text (DATA_CONSOLE (page));
+ if (text && *text)
+ page = NULL;
+ g_free (text);
+ }
+ }
+
+ if (!page) {
+ add_new_data_console (BROWSER_PERSPECTIVE (dmp));
+ current = gtk_notebook_get_current_page (GTK_NOTEBOOK (dmp->priv->notebook));
+ page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (dmp->priv->notebook), current);
+ g_assert (IS_DATA_CONSOLE (page));
+ }
+
+ data_console_set_text (DATA_CONSOLE (page), xml_spec);
+ data_console_execute (DATA_CONSOLE (page));
+}
diff --git a/tools/browser/data-manager/data-manager-perspective.h b/tools/browser/data-manager/data-manager-perspective.h
index f98879a..91cd8ab 100644
--- a/tools/browser/data-manager/data-manager-perspective.h
+++ b/tools/browser/data-manager/data-manager-perspective.h
@@ -48,8 +48,9 @@ struct _DataManagerPerspectiveClass
GtkVBoxClass parent_class;
};
-GType data_manager_perspective_get_type (void) G_GNUC_CONST;
-BrowserPerspective *data_manager_perspective_new (BrowserWindow *bwin);
+GType data_manager_perspective_get_type (void) G_GNUC_CONST;
+BrowserPerspective *data_manager_perspective_new (BrowserWindow *bwin);
+void data_manager_perspective_new_tab (DataManagerPerspective *dmp, const gchar *xml_spec);
G_END_DECLS
diff --git a/tools/browser/doc/Makefile.am b/tools/browser/doc/Makefile.am
index 3910a6c..a9d7ee7 100644
--- a/tools/browser/doc/Makefile.am
+++ b/tools/browser/doc/Makefile.am
@@ -35,14 +35,17 @@ GTKDOC_CFLAGS = -I$(top_srcdir) \
-I$(top_srcdir)/tools/browser \
$(LIBGDA_CFLAGS) \
$(GTK_CFLAGS) \
+ $(GTKSOURCEVIEW_CFLAGS) \
-DGETTEXT_PACKAGE=\""$(GETTEXT_PACKAGE)"\"
-GTKDOC_LIBS = $(top_builddir)/tools/browser/libbrowser.la \
+GTKDOC_LIBS = $(top_builddir)/tools/browser/data-manager/libperspective.la \
+ $(top_builddir)/tools/browser/libbrowser.la \
$(top_builddir)/tools/browser/common/libcommon.la \
$(top_builddir)/libgda/libgda-4.0.la \
$(top_builddir)/libgda-ui/libgda-ui-4.0.la \
$(LIBGDA_LIBS) \
- $(GTK_LIBS)
+ $(GTK_LIBS) \
+ $(GTKSOURCEVIEW_LIBS)
# Extra options to supply to gtkdoc-mkdb
MKDB_OPTIONS=--sgml-mode --output-format=xml --ignore-files="binreloc"
diff --git a/tools/browser/doc/gda-browser-docs.sgml b/tools/browser/doc/gda-browser-docs.sgml
index 28c1807..7a13e12 100644
--- a/tools/browser/doc/gda-browser-docs.sgml
+++ b/tools/browser/doc/gda-browser-docs.sgml
@@ -11,6 +11,7 @@
<!ENTITY BrowserFavorites SYSTEM "xml/browser-favorites.xml">
<!ENTITY BrowserPage SYSTEM "xml/browser-page.xml">
<!ENTITY BrowserPerspective SYSTEM "xml/browser-perspective.xml">
+<!ENTITY DataManagerPerspective SYSTEM "xml/data-manager-perspective.xml">
<!ENTITY CCGrayBar SYSTEM "xml/cc-gray-bar.xml">
<!ENTITY PopupContainer SYSTEM "xml/popup-container.xml">
]>
@@ -141,6 +142,15 @@
&CCGrayBar;
&PopupContainer;
</chapter>
+
+ <chapter id="perspectives">
+ <title>Perspectives' objects</title>
+ <para>
+ This section is a reference to some of the existing perspectives and the associated
+ widgets.
+ </para>
+ &DataManagerPerspective;
+ </chapter>
</part>
<part id="part_index">
diff --git a/tools/browser/doc/gda-browser-sections.txt b/tools/browser/doc/gda-browser-sections.txt
index 4cb6751..abd65dc 100644
--- a/tools/browser/doc/gda-browser-sections.txt
+++ b/tools/browser/doc/gda-browser-sections.txt
@@ -8,6 +8,7 @@ browser_window_get_connection
browser_window_push_status
browser_window_pop_status
browser_window_customize_perspective_ui
+browser_window_change_perspective
<SUBSECTION Standard>
BROWSER_WINDOW
BROWSER_IS_WINDOW
@@ -31,9 +32,11 @@ browser_core_take_connection
browser_core_get_connections
browser_core_close_connection
browser_core_quit
+BrowserPerspectiveFactory
browser_core_get_default_factory
browser_core_set_default_factory
browser_core_get_factories
+browser_core_get_factory
<SUBSECTION Standard>
BROWSER_CORE
BROWSER_IS_CORE
@@ -133,7 +136,7 @@ BROWSER_PERSPECTIVE_TYPE
BROWSER_PERSPECTIVE
IS_BROWSER_PERSPECTIVE
BROWSER_PERSPECTIVE_GET_CLASS
-BrowserPerspectiveIface
+BrowserPerspective
browser_perspective_get_type
browser_perspective_get_actions_group
browser_perspective_get_actions_ui
@@ -171,3 +174,13 @@ IS_POPUP_CONTAINER
IS_POPUP_CONTAINER_CLASS
</SECTION>
+<SECTION>
+<FILE>data-manager-perspective</FILE>
+DATA_MANAGER_PERSPECTIVE_TYPE
+DATA_MANAGER_PERSPECTIVE
+IS_DATA_MANAGER_PERSPECTIVE
+DATA_MANAGER_PERSPECTIVE_GET_CLASS
+DataManagerPerspective
+data_manager_perspective_get_type
+data_manager_perspective_new_tab
+</SECTION>
diff --git a/tools/browser/doc/gda-browser.types b/tools/browser/doc/gda-browser.types
index 121b9d1..16012c4 100644
--- a/tools/browser/doc/gda-browser.types
+++ b/tools/browser/doc/gda-browser.types
@@ -6,3 +6,4 @@ browser_perspective_get_type
browser_page_get_type
cc_gray_bar_get_type
popup_container_get_type
+data_manager_perspective_get_type
diff --git a/tools/browser/doc/tmpl/browser-core.sgml b/tools/browser/doc/tmpl/browser-core.sgml
index 4148dae..f908ff6 100644
--- a/tools/browser/doc/tmpl/browser-core.sgml
+++ b/tools/browser/doc/tmpl/browser-core.sgml
@@ -125,6 +125,15 @@ Singleton holding the global browser information
+<!-- ##### STRUCT BrowserPerspectiveFactory ##### -->
+<para>
+
+</para>
+
+ perspective_name:
+ menu_shortcut:
+ perspective_create:
+
<!-- ##### FUNCTION browser_core_get_default_factory ##### -->
<para>
@@ -149,3 +158,12 @@ Singleton holding the global browser information
@Returns:
+<!-- ##### FUNCTION browser_core_get_factory ##### -->
+<para>
+
+</para>
+
+ factory:
+ Returns:
+
+
diff --git a/tools/browser/doc/tmpl/browser-perspective.sgml b/tools/browser/doc/tmpl/browser-perspective.sgml
index cc0a1e4..67f488d 100644
--- a/tools/browser/doc/tmpl/browser-perspective.sgml
+++ b/tools/browser/doc/tmpl/browser-perspective.sgml
@@ -49,15 +49,11 @@ A "perspective" in a #BrowserWindow window
@obj:
-<!-- ##### STRUCT BrowserPerspectiveIface ##### -->
+<!-- ##### STRUCT BrowserPerspective ##### -->
<para>
</para>
- g_iface:
- i_get_actions_group:
- i_get_actions_ui:
- i_page_tab_label_change:
<!-- ##### FUNCTION browser_perspective_get_type ##### -->
<para>
diff --git a/tools/browser/doc/tmpl/browser-window.sgml b/tools/browser/doc/tmpl/browser-window.sgml
index cff4433..959e8f3 100644
--- a/tools/browser/doc/tmpl/browser-window.sgml
+++ b/tools/browser/doc/tmpl/browser-window.sgml
@@ -81,3 +81,13 @@ Top level browser window
@ui_info:
+<!-- ##### FUNCTION browser_window_change_perspective ##### -->
+<para>
+
+</para>
+
+ bwin:
+ perspective:
+ Returns:
+
+
diff --git a/tools/browser/doc/tmpl/data-manager-perspective.sgml b/tools/browser/doc/tmpl/data-manager-perspective.sgml
new file mode 100644
index 0000000..dc5a384
--- /dev/null
+++ b/tools/browser/doc/tmpl/data-manager-perspective.sgml
@@ -0,0 +1,58 @@
+<!-- ##### SECTION Title ##### -->
+data-manager-perspective
+
+<!-- ##### SECTION Short_Description ##### -->
+
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+
+
+<!-- ##### MACRO DATA_MANAGER_PERSPECTIVE ##### -->
+<para>
+
+</para>
+
+ obj:
+
+
+<!-- ##### MACRO IS_DATA_MANAGER_PERSPECTIVE ##### -->
+<para>
+
+</para>
+
+ obj:
+
+
+<!-- ##### STRUCT DataManagerPerspective ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### FUNCTION data_manager_perspective_get_type ##### -->
+<para>
+
+</para>
+
+ Returns:
+
+
+<!-- ##### FUNCTION data_manager_perspective_new_tab ##### -->
+<para>
+
+</para>
+
+ dmp:
+ xml_spec:
+
+
diff --git a/tools/browser/schema-browser/table-info.c b/tools/browser/schema-browser/table-info.c
index a53bfe4..64b7adf 100644
--- a/tools/browser/schema-browser/table-info.c
+++ b/tools/browser/schema-browser/table-info.c
@@ -34,6 +34,8 @@
#include "schema-browser-perspective.h"
#include "../browser-page.h"
#include "../browser-stock-icons.h"
+#include "../browser-window.h"
+#include "../data-manager/data-manager-perspective.h"
struct _TableInfoPrivate {
BrowserConnection *bcnc;
@@ -456,9 +458,39 @@ action_add_to_fav_cb (GtkAction *action, TableInfo *tinfo)
g_free (fav.contents);
}
+static void
+action_view_contents_cb (GtkAction *action, TableInfo *tinfo)
+{
+ if (! tinfo->priv->table_short_name)
+ return;
+
+ BrowserWindow *bwin;
+ BrowserPerspective *pers;
+ bwin = (BrowserWindow*) gtk_widget_get_toplevel ((GtkWidget*) tinfo);
+ pers = browser_window_change_perspective (bwin, "Data manager");
+ TO_IMPLEMENT;
+
+ xmlDocPtr doc;
+ xmlNodePtr node, topnode;
+ xmlChar *contents;
+ int size;
+ doc = xmlNewDoc (BAD_CAST "1.0");
+ topnode = xmlNewDocNode (doc, NULL, BAD_CAST "data", NULL);
+ xmlDocSetRootElement (doc, topnode);
+ node = xmlNewChild (topnode, NULL, BAD_CAST "table", NULL);
+ xmlSetProp (node, BAD_CAST "name", BAD_CAST tinfo->priv->table_short_name);
+ xmlDocDumpFormatMemory (doc, &contents, &size, 1);
+ xmlFreeDoc (doc);
+
+ data_manager_perspective_new_tab (DATA_MANAGER_PERSPECTIVE (pers), (gchar*) contents);
+ xmlFree (contents);
+}
+
static GtkActionEntry ui_actions[] = {
{ "AddToFav", STOCK_ADD_BOOKMARK, N_("_Favorite"), NULL, N_("Add table to favorites"),
G_CALLBACK (action_add_to_fav_cb)},
+ { "ViewContents", GTK_STOCK_EDIT, N_("_Contents"), NULL, N_("View contents"),
+ G_CALLBACK (action_view_contents_cb)},
};
static const gchar *ui_actions_info =
"<ui>"
@@ -467,6 +499,7 @@ static const gchar *ui_actions_info =
" <toolbar name='ToolBar'>"
" <separator/>"
" <toolitem action='AddToFav'/>"
+ " <toolitem action='ViewContents'/>"
" </toolbar>"
"</ui>";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]