[libgda] GdaBrowser: some work to move away from deprecated GtkAction and related
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaBrowser: some work to move away from deprecated GtkAction and related
- Date: Fri, 8 May 2015 18:47:50 +0000 (UTC)
commit 6ef3c42e57873f3f7cbea39ac28e2e4fd373c460
Author: Vivien Malerba <malerba gnome-db org>
Date: Fri May 8 19:38:06 2015 +0200
GdaBrowser: some work to move away from deprecated GtkAction and related
tools/Makefile.am | 1 +
tools/browser/.gitignore | 1 +
tools/browser/browser-connections-list.c | 5 +-
tools/browser/browser-perspective.c | 121 +--
tools/browser/browser-perspective.h | 17 +-
tools/browser/browser-window.c | 1162 ++++++--------------
tools/browser/connection-binding-properties.c | 2 +-
tools/browser/data-manager/Makefile.am | 15 +-
.../data-manager/data-manager-perspective.c | 176 ++--
tools/browser/data-manager/data-source.c | 27 +-
tools/browser/data-manager/perspective-main.c | 3 +-
tools/browser/dummy-perspective/Makefile.am | 29 +
.../browser/dummy-perspective/dummy-perspective.c | 194 +++-
.../dummy-perspective.gresource.xml | 6 +
.../browser/dummy-perspective/dummy-perspective.h | 6 +-
tools/browser/dummy-perspective/perspective-main.c | 5 +-
.../browser/dummy-perspective/perspective-menus.ui | 15 +
tools/browser/ldap-browser/Makefile.am | 12 +-
.../ldap-browser/ldap-browser-perspective.c | 235 ++--
tools/browser/ldap-browser/perspective-main.c | 3 +-
tools/browser/query-exec/Makefile.am | 12 +-
tools/browser/query-exec/perspective-main.c | 3 +-
tools/browser/query-exec/query-exec-perspective.c | 198 ++--
tools/browser/query-exec/query-result.c | 25 +-
tools/browser/schema-browser/Makefile.am | 10 +-
tools/browser/schema-browser/perspective-main.c | 3 +-
.../schema-browser/schema-browser-perspective.c | 199 ++--
tools/browser/ui-formgrid.c | 148 ++--
tools/browser/ui-formgrid.h | 5 +-
tools/browser/ui-support.c | 18 +-
tools/browser/ui-support.h | 2 +-
tools/common/t-app.c | 12 +-
tools/common/t-app.h | 5 +
tools/common/t-connection.c | 89 +-
tools/common/t-connection.h | 3 +-
tools/common/t-decl.h | 3 +-
tools/resources/menus.ui | 91 ++
tools/resources/transaction-commit-symbolic.png | Bin 0 -> 868 bytes
tools/resources/transaction-rollback-symbolic.png | Bin 0 -> 842 bytes
tools/resources/transaction-start-symbolic.png | Bin 0 -> 573 bytes
tools/tools-main.c | 330 +++++-
tools/tools.gresource.xml | 12 +
42 files changed, 1559 insertions(+), 1644 deletions(-)
---
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 62df4f4..a156418 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -103,6 +103,7 @@ endif
# resources
RESOURCES=\
tools.gresource.xml \
+ resources/menus.ui \
resources/gda-browser-action.png \
resources/gda-browser-auth-big.png \
resources/gda-browser-auth.png \
diff --git a/tools/browser/.gitignore b/tools/browser/.gitignore
index 20d65fc..c577b09 100644
--- a/tools/browser/.gitignore
+++ b/tools/browser/.gitignore
@@ -1,2 +1,3 @@
marshal.[ch]
+*.gresources.[ch]
diff --git a/tools/browser/browser-connections-list.c b/tools/browser/browser-connections-list.c
index dea81d2..4967561 100644
--- a/tools/browser/browser-connections-list.c
+++ b/tools/browser/browser-connections-list.c
@@ -149,7 +149,7 @@ static void cell_name_data_func (G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
const GdaDsnInfo *cncinfo;
gtk_tree_model_get (tree_model, iter, COLUMN_TCNC, &tcnc, -1);
- cncinfo = t_connection_get_information (tcnc);
+ cncinfo = t_connection_get_dsn_information (tcnc);
if (cncinfo) {
if (cncinfo->name)
cncstr = g_strdup_printf (_("DSN: %s"), cncinfo->name);
@@ -181,7 +181,7 @@ selection_changed_cb (GtkTreeSelection *select, BrowserConnectionsList *clist)
if (gtk_tree_selection_get_selected (select, &model, &iter)) {
gtk_tree_model_get (model, &iter, COLUMN_TCNC, &tcnc, -1);
- cncinfo = t_connection_get_information (tcnc);
+ cncinfo = t_connection_get_dsn_information (tcnc);
g_object_unref (tcnc);
gtk_widget_set_sensitive (_clist->priv->close_cnc_button, TRUE);
@@ -398,7 +398,6 @@ browser_connections_list_show (TConnection *current)
treeview = ui_make_tree_view (GTK_TREE_MODEL (store));
_clist->priv->treeview = GTK_TREE_VIEW (treeview);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);
g_object_unref (G_OBJECT (store));
gtk_container_add (GTK_CONTAINER (sw), treeview);
diff --git a/tools/browser/browser-perspective.c b/tools/browser/browser-perspective.c
index 2f5194f..50b3243 100644
--- a/tools/browser/browser-perspective.c
+++ b/tools/browser/browser-perspective.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2009 - 2015 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2010 David King <davidk openismus com>
* Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
*
@@ -79,103 +79,79 @@ browser_perspective_class_init (G_GNUC_UNUSED gpointer g_class)
}
/**
- * browser_perspective_get_actions_group
- * @pers: an object implementing the #BrowserPerspective interface
- *
- * Get the #GtkActionGroup from a @pers to represent its specific actions.
+ * browser_perspective_customize:
+ * @perspective: an object implementing the #BrowserPerspective interface
+ * @toolbar: (allow-none):
+ * @header: (allow-none):
+ * @menu: (allow-none):
*
- * Returns: a new #GtkActionGroup
+ * Add optional custom UI elements to @toolbar, @header and @menu. any call to the
+ * browser_perspective_uncustomize() function will undo all the customizations to
+ * these elements
*/
-GtkActionGroup *
-browser_perspective_get_actions_group (BrowserPerspective *pers)
+void
+browser_perspective_customize (BrowserPerspective *perspective, GtkToolbar *toolbar,
+ GtkHeaderBar *header, GMenu *menu)
{
- g_return_val_if_fail (IS_BROWSER_PERSPECTIVE (pers), NULL);
-
- if (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_get_actions_group)
- return (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_get_actions_group) (pers);
- else
- return NULL;
+ g_return_if_fail (IS_BROWSER_PERSPECTIVE (perspective));
+ g_print ("%s (%p)\n", __FUNCTION__, perspective);
+ if (BROWSER_PERSPECTIVE_GET_CLASS (perspective)->i_customize)
+ (BROWSER_PERSPECTIVE_GET_CLASS (perspective)->i_customize) (perspective, toolbar, header,
menu);
}
/**
- * browser_perspective_get_actions_ui
- * @pers: an object implementing the #BrowserPerspective interface
- *
- * Get the UI definition from a perspective to represent how its specific actions (obtained
- * using browser_perspective_get_actions_group()) are to be integrated in a #BrowserWindow's menu
- * and toolbar.
+ * browser_perspective_uncustomize:
+ * @perspective: an object implementing the #BrowserPerspective interface
+ * @toolbar: (allow-none):
+ * @header: (allow-none):
+ * @menu: (allow-none):
*
- * Returns: a read-only string
- */
-const gchar *
-browser_perspective_get_actions_ui (BrowserPerspective *pers)
-{
- g_return_val_if_fail (IS_BROWSER_PERSPECTIVE (pers), NULL);
-
- if (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_get_actions_ui)
- return (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_get_actions_ui) (pers);
- else
- return NULL;
-}
-
-/**
- * browser_perspective_get_current_customization
- * @pers: an object implementing the #BrowserPerspective interface
- * @out_agroup: (transfer full): a place to store the returned GtkActionGroup, not %NULL
- * @out_ui: (transfer none): a place to store the returned UI string, not %NULL
- *
- * Rem: * out_agroup is a new object and should be unref'ed when not needed anymore
+ * Remove any optional custom UI elements to @toolbar, @header and @menu which have been added
+ * when browser_perspective_customize() was called.
*/
void
-browser_perspective_get_current_customization (BrowserPerspective *pers,
- GtkActionGroup **out_agroup,
- const gchar **out_ui)
+browser_perspective_uncustomize (BrowserPerspective *perspective, GtkToolbar *toolbar,
+ GtkHeaderBar *header, GMenu *menu)
{
- g_return_if_fail (IS_BROWSER_PERSPECTIVE (pers));
- g_return_if_fail (out_agroup);
- g_return_if_fail (out_ui);
-
- *out_agroup = NULL;
- *out_ui = NULL;
- if (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_get_current_customization)
- (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_get_current_customization) (pers,
- out_agroup,
- out_ui);
+ g_return_if_fail (IS_BROWSER_PERSPECTIVE (perspective));
+ g_print ("%s (%p)\n", __FUNCTION__, perspective);
+ if (BROWSER_PERSPECTIVE_GET_CLASS (perspective)->i_uncustomize)
+ (BROWSER_PERSPECTIVE_GET_CLASS (perspective)->i_uncustomize) (perspective, toolbar, header,
menu);
}
/**
- * browser_perspective_page_tab_label_change
- * @pers: an object implementing the #BrowserPerspective interface
+ * browser_perspective_page_tab_label_change:
+ * @perspective: an object implementing the #BrowserPerspective interface
* @page: an object implementing the #BrowserPage interface
*
- * When @pers organizes its contents as pages in a notebook, each page may
+ * When @perspective organizes its contents as pages in a notebook, each page may
* request that the tab's label may be changed, and the purpose of this method
- * is to request that @pers update the tab's label associated to @page.
+ * is to request that @perspective update the tab's label associated to @page.
*/
void
-browser_perspective_page_tab_label_change (BrowserPerspective *pers, BrowserPage *page)
+browser_perspective_page_tab_label_change (BrowserPerspective *perspective, BrowserPage *page)
{
- g_return_if_fail (IS_BROWSER_PERSPECTIVE (pers));
+ g_return_if_fail (IS_BROWSER_PERSPECTIVE (perspective));
g_return_if_fail (IS_BROWSER_PAGE (page));
- if (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_page_tab_label_change)
- (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_page_tab_label_change) (pers, page);
+ if (BROWSER_PERSPECTIVE_GET_CLASS (perspective)->i_page_tab_label_change)
+ (BROWSER_PERSPECTIVE_GET_CLASS (perspective)->i_page_tab_label_change) (perspective, page);
}
/**
* browser_perspective_get_window:
- * @pers: an object implementing the #BrowserPerspective interface
+ * @perspective: an object implementing the #BrowserPerspective interface
*
* Returns: (transfer none): the #BrowserWindow @perspective is in
*/
BrowserWindow *
-browser_perspective_get_window (BrowserPerspective *pers)
+browser_perspective_get_window (BrowserPerspective *perspective)
{
- g_return_val_if_fail (IS_BROWSER_PERSPECTIVE (pers), NULL);
- if (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_get_window)
- return (BROWSER_PERSPECTIVE_GET_CLASS (pers)->i_get_window) (pers);
+ g_return_val_if_fail (IS_BROWSER_PERSPECTIVE (perspective), NULL);
+ if (BROWSER_PERSPECTIVE_GET_CLASS (perspective)->i_get_window)
+ return (BROWSER_PERSPECTIVE_GET_CLASS (perspective)->i_get_window) (perspective);
else
- return (BrowserWindow*) ui_find_parent_widget (GTK_WIDGET (pers), BROWSER_PERSPECTIVE_TYPE);
+ return (BrowserWindow*) ui_find_parent_widget (GTK_WIDGET (perspective), BROWSER_TYPE_WINDOW);
}
static void nb_page_added_or_removed_cb (GtkNotebook *nb, GtkWidget *child, guint page_num,
@@ -204,6 +180,7 @@ browser_perspective_declare_notebook (BrowserPerspective *perspective, GtkNotebo
if (!bwin)
return;
+ g_print ("REMOVE THIS FUNCTION: %s()\n", __FUNCTION__);
GtkNotebook *onb;
onb = g_object_get_data (G_OBJECT (perspective), "fullscreen_nb");
if (onb) {
@@ -338,22 +315,22 @@ _factories_init (void)
/**
* browser_get_factory
- * @factory: the name of the requested factory
+ * @factory_id: the ID 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_get_factory (const gchar *factory)
+browser_get_factory (const gchar *factory_id)
{
- GSList *list;
- g_return_val_if_fail (factory, NULL);
+ g_return_val_if_fail (factory_id, NULL);
_factories_init ();
+ GSList *list;
for (list = factories; list; list = list->next) {
BrowserPerspectiveFactory *bpf = BROWSER_PERSPECTIVE_FACTORY (list->data);
- if (!g_ascii_strcasecmp (bpf->perspective_name, factory))
+ if (!g_ascii_strcasecmp (bpf->id, factory_id))
return bpf;
}
return NULL;
diff --git a/tools/browser/browser-perspective.h b/tools/browser/browser-perspective.h
index 319107d..71021cd 100644
--- a/tools/browser/browser-perspective.h
+++ b/tools/browser/browser-perspective.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2009 - 2015 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
@@ -38,6 +38,10 @@ struct _BrowserPerspectiveIface {
/* virtual table */
BrowserWindow *(* i_get_window) (BrowserPerspective *perspective);
+ void (* i_customize) (BrowserPerspective *perspective, GtkToolbar *toolbar,
+ GtkHeaderBar *header, GMenu *menu);
+ void (* i_uncustomize) (BrowserPerspective *perspective, GtkToolbar *toolbar,
+ GtkHeaderBar *header, GMenu *menu);
GtkActionGroup *(* i_get_actions_group) (BrowserPerspective *perspective);
const gchar *(* i_get_actions_ui) (BrowserPerspective *perspective);
void (* i_get_current_customization) (BrowserPerspective *perspective,
@@ -59,11 +63,11 @@ struct _BrowserPerspectiveIface {
GType browser_perspective_get_type (void) G_GNUC_CONST;
-GtkActionGroup *browser_perspective_get_actions_group (BrowserPerspective *perspective);
-const gchar *browser_perspective_get_actions_ui (BrowserPerspective *perspective);
-void browser_perspective_get_current_customization (BrowserPerspective *perspective,
- GtkActionGroup **out_agroup,
- const gchar **out_ui);
+void browser_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu
*menu);
+void browser_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu
*menu);
+
void browser_perspective_page_tab_label_change (BrowserPerspective *perspective,
BrowserPage *page);
@@ -74,6 +78,7 @@ void browser_perspective_declare_notebook (BrowserPerspective *perspe
* All perspectives information
*/
typedef struct {
+ const gchar *id;
const gchar *perspective_name;
const gchar *menu_shortcut;
BrowserPerspective *(*perspective_create) (BrowserWindow *);
diff --git a/tools/browser/browser-window.c b/tools/browser/browser-window.c
index bb5cccb..5e38988 100644
--- a/tools/browser/browser-window.c
+++ b/tools/browser/browser-window.c
@@ -21,14 +21,13 @@
#include <string.h>
#include <glib/gi18n-lib.h>
#include "browser-window.h"
-#include "login-dialog.h"
#include <common/t-app.h>
#include <common/t-connection.h>
#include "ui-support.h"
-#include "browser-connections-list.h"
#include "connection-binding-properties.h"
#include <gdk/gdkkeysyms.h>
#include <thread-wrapper/gda-connect.h>
+#include "browser-connections-list.h"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -41,12 +40,7 @@
typedef struct {
BrowserWindow *bwin; /* pointer to window the tab is in, no ref held here */
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))
static PerspectiveData *perspective_data_new (BrowserWindow *bwin, BrowserPerspectiveFactory *factory);
@@ -59,12 +53,8 @@ static void browser_window_class_init (BrowserWindowClass *klass);
static void browser_window_init (BrowserWindow *bwin);
static void browser_window_dispose (GObject *object);
-static gboolean window_state_event (GtkWidget *widget, GdkEventWindowState *event);
static gboolean key_press_event (GtkWidget *widget, GdkEventKey *event);
-static void connection_added_cb (TApp *tapp, TConnection *tcnc, BrowserWindow *bwin);
-static void connection_removed_cb (TApp *tapp, TConnection *tcnc, BrowserWindow *bwin);
-
static void transaction_status_changed_cb (TConnection *tcnc, BrowserWindow *bwin);
static void cnc_status_changed_cb (TConnection *tcnc, GdaConnectionStatus status, BrowserWindow *bwin);
@@ -82,25 +72,15 @@ static GObjectClass *parent_class = NULL;
struct _BrowserWindowPrivate {
TConnection *tcnc;
- GtkNotebook *perspectives_nb; /* notebook used to switch between tabs, for the selector part */
- GSList *perspectives; /* list of PerspectiveData pointers, owned here */
+ GtkStack *pers_stack; /* notebook used to switch between tabs */
+ GSList *pers_list; /* list of PerspectiveData pointers, owned here */
PerspectiveData *current_perspective;
guint ui_manager_merge_id; /* for current perspective */
- GtkWidget *menubar;
- GtkWidget *toolbar;
- gboolean toolbar_shown;
- gboolean cursor_in_toolbar;
GtkWidget *spinner;
- GtkUIManager *ui_manager;
- GtkActionGroup *agroup;
- GtkActionGroup *perspectives_actions;
gboolean updating_transaction_status;
GtkToolbarStyle toolbar_style;
- GtkActionGroup *cnc_agroup; /* one GtkAction for each TConnection */
- gulong cnc_added_sigid;
- gulong cnc_removed_sigid;
GtkWidget *notif_box;
GSList *notif_widgets;
@@ -109,11 +89,12 @@ struct _BrowserWindowPrivate {
guint cnc_statusbar_context;
gboolean fullscreen;
- gulong fullscreen_motion_sig_id;
- guint fullscreen_timer_id;
gulong cnc_status_sigid;
gulong trans_status_sigid;
+
+ GtkToolbar *toolbar;
+ GtkHeaderBar *header;
};
GType
@@ -151,12 +132,11 @@ browser_window_class_init (BrowserWindowClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->window_state_event = window_state_event;
widget_class->key_press_event = key_press_event;
parent_class = g_type_class_peek_parent (klass);
browser_window_signals[FULLSCREEN_CHANGED] =
- g_signal_new ("fullscreen_changed",
+ g_signal_new ("fullscreen-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (BrowserWindowClass, fullscreen_changed),
@@ -165,7 +145,6 @@ browser_window_class_init (BrowserWindowClass *klass)
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
object_class->dispose = browser_window_dispose;
- klass->fullscreen_changed = NULL;
}
static void
@@ -173,15 +152,10 @@ browser_window_init (BrowserWindow *bwin)
{
bwin->priv = g_new0 (BrowserWindowPrivate, 1);
bwin->priv->tcnc = NULL;
- bwin->priv->perspectives_nb = NULL;
- bwin->priv->perspectives = NULL;
- bwin->priv->cnc_agroup = NULL;
- bwin->priv->cnc_added_sigid = 0;
- bwin->priv->cnc_removed_sigid = 0;
+ bwin->priv->pers_stack = NULL;
+ bwin->priv->pers_list = NULL;
bwin->priv->updating_transaction_status = FALSE;
bwin->priv->fullscreen = FALSE;
- bwin->priv->fullscreen_motion_sig_id = 0;
- bwin->priv->fullscreen_timer_id = 0;
}
static void
@@ -195,35 +169,17 @@ browser_window_dispose (GObject *object)
if (bwin->priv) {
GSList *connections;
- for (connections = t_app_get_all_connections (); connections; connections = connections->next)
- connection_removed_cb (t_app_get(), T_CONNECTION (connections->data), bwin);
-
- if (bwin->priv->fullscreen_timer_id)
- g_source_remove (bwin->priv->fullscreen_timer_id);
-
- if (bwin->priv->fullscreen_motion_sig_id)
- g_signal_handler_disconnect (bwin, bwin->priv->fullscreen_motion_sig_id);
-
- if (bwin->priv->cnc_added_sigid > 0)
- gda_signal_handler_disconnect (t_app_get (), bwin->priv->cnc_added_sigid);
- if (bwin->priv->cnc_removed_sigid > 0)
- gda_signal_handler_disconnect (t_app_get (), bwin->priv->cnc_removed_sigid);
- if (bwin->priv->ui_manager)
- g_object_unref (bwin->priv->ui_manager);
- if (bwin->priv->cnc_agroup)
- g_object_unref (bwin->priv->cnc_agroup);
-
if (bwin->priv->tcnc) {
gda_signal_handler_disconnect (bwin->priv->tcnc, bwin->priv->cnc_status_sigid);
gda_signal_handler_disconnect (bwin->priv->tcnc, bwin->priv->trans_status_sigid);
g_object_unref (bwin->priv->tcnc);
}
- if (bwin->priv->perspectives) {
- g_slist_foreach (bwin->priv->perspectives, (GFunc) perspective_data_free, NULL);
- g_slist_free (bwin->priv->perspectives);
+ if (bwin->priv->pers_list) {
+ g_slist_foreach (bwin->priv->pers_list, (GFunc) perspective_data_free, NULL);
+ g_slist_free (bwin->priv->pers_list);
}
- if (bwin->priv->perspectives_nb)
- g_object_unref (bwin->priv->perspectives_nb);
+ if (bwin->priv->pers_stack)
+ g_object_unref (bwin->priv->pers_stack);
if (bwin->priv->notif_widgets)
g_slist_free (bwin->priv->notif_widgets);
@@ -235,114 +191,28 @@ browser_window_dispose (GObject *object)
parent_class->dispose (object);
}
-static void transaction_begin_cb (GtkAction *action, BrowserWindow *bwin);
-static void transaction_commit_cb (GtkAction *action, BrowserWindow *bwin);
-static void transaction_rollback_cb (GtkAction *action, BrowserWindow *bwin);
-static void quit_cb (GtkAction *action, BrowserWindow *bwin);
-static void about_cb (GtkAction *action, BrowserWindow *bwin);
-#ifdef HAVE_GDU
-static void manual_cb (GtkAction *action, BrowserWindow *bwin);
-#endif
-static void window_close_cb (GtkAction *action, BrowserWindow *bwin);
-static void window_fullscreen_cb (GtkToggleAction *action, BrowserWindow *bwin);
-static void window_new_cb (GtkAction *action, BrowserWindow *bwin);
-static void window_new_with_cnc_cb (GtkAction *action, BrowserWindow *bwin);
-static void connection_properties_cb (GtkAction *action, BrowserWindow *bwin);
-static void connection_close_cb (GtkAction *action, BrowserWindow *bwin);
-static void connection_open_cb (GtkAction *action, BrowserWindow *bwin);
-static void connection_bind_cb (GtkAction *action, BrowserWindow *bwin);
-static void connection_list_cb (GtkAction *action, BrowserWindow *bwin);
-static void connection_meta_update_cb (GtkAction *action, BrowserWindow *bwin);
-static void perspective_toggle_cb (GtkRadioAction *action, GtkRadioAction *current, BrowserWindow *bwin);
-
-static const GtkToggleActionEntry ui_toggle_actions [] =
-{
- { "WindowFullScreen", GTK_STOCK_FULLSCREEN, N_("_Fullscreen"), "F11", N_("Use the whole screen"),
G_CALLBACK (window_fullscreen_cb), FALSE}
-};
+static void connection_meta_update_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer
data);
+static void transaction_begin_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+static void transaction_commit_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+static void transaction_rollback_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer
data);
+static void connection_properties_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer
data);
+static void connection_close_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+static void fullscreen_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *state, gpointer data);
+static void change_perspective_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *state, gpointer data);
+static GActionEntry win_entries[] = {
+ { "change-perspective", NULL, "s", NULL, change_perspective_cb },
-static const GtkActionEntry ui_actions[] = {
- { "Connection", NULL, N_("_Connection"), NULL, N_("Connection"), NULL },
- { "ConnectionOpen", GTK_STOCK_CONNECT, N_("_Connect"), NULL, N_("Open a connection"), G_CALLBACK
(connection_open_cb)},
- { "ConnectionBind", NULL, N_("_Bind Connection"), "<control>I", N_("Use connection to create\n"
- "a new binding connection to access data\n"
- "from multiple databases at once"), G_CALLBACK
(connection_bind_cb)},
- { "ConnectionProps", GTK_STOCK_PROPERTIES, N_("_Properties"), NULL, N_("Connection properties"),
G_CALLBACK (connection_properties_cb)},
- { "ConnectionList", NULL, N_("_Connections List"), NULL, N_("Connections list"), G_CALLBACK
(connection_list_cb)},
- { "ConnectionMetaSync", GTK_STOCK_REFRESH, N_("_Fetch Meta Data"), NULL, N_("Fetch meta data"),
G_CALLBACK (connection_meta_update_cb)},
- { "ConnectionClose", GTK_STOCK_CLOSE, N_("_Close Connection"), NULL, N_("Close this connection"),
G_CALLBACK (connection_close_cb)},
- { "Quit", GTK_STOCK_QUIT, N_("_Quit"), NULL, N_("Quit"), G_CALLBACK (quit_cb)},
- { "Edit", NULL, N_("_Edit"), NULL, N_("Edit"), NULL },
- { "Display", NULL, N_("_Display"), NULL, N_("Display"), NULL },
- { "Perspective", NULL, N_("_Perspective"), NULL, N_("Perspective"), NULL },
- { "Window", NULL, N_("_Window"), NULL, N_("Window"), NULL },
- { "WindowNew", GTK_STOCK_MISSING_IMAGE /*STOCK_NEW_WINDOW*/, N_("_New Window"), "<control>N",
N_("Open a new window for current connection"), G_CALLBACK (window_new_cb)},
- { "WindowNewOthers", NULL, N_("New Window for _Connection"), NULL, N_("Open a new window for a
connection"), NULL},
- { "WindowClose", GTK_STOCK_CLOSE, N_("_Close"), NULL, N_("Close this window"), G_CALLBACK
(window_close_cb)},
- { "Help", NULL, N_("_Help"), NULL, N_("Help"), NULL },
- { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL, N_("About"), G_CALLBACK (about_cb) },
-#ifdef HAVE_GDU
- { "HelpManual", GTK_STOCK_HELP, N_("_Manual"), "F1", N_("Manual"), G_CALLBACK (manual_cb) },
-#endif
- { "TransactionBegin", GTK_STOCK_MISSING_IMAGE /*BROWSER_STOCK_BEGIN*/, N_("Begin transaction"), NULL,
N_("Begin a new transaction"),
- G_CALLBACK (transaction_begin_cb)},
- { "TransactionCommit", GTK_STOCK_MISSING_IMAGE /*BROWSER_STOCK_COMMIT*/, N_("Commit transaction"),
NULL, N_("Commit current transaction"),
- G_CALLBACK (transaction_commit_cb)},
- { "TransactionRollback", GTK_STOCK_MISSING_IMAGE /*BROWSER_STOCK_ROLLBACK*/, N_("Rollback
transaction"), NULL, N_("Rollback current transaction"),
- G_CALLBACK (transaction_rollback_cb)},
-};
+ { "meta-sync", connection_meta_update_cb, NULL, NULL, NULL },
-static const gchar *ui_actions_info =
- "<ui>"
- " <menubar name='MenuBar'>"
- " <menu name='Connection' action='Connection'>"
- " <menuitem name='ConnectionOpen' action= 'ConnectionOpen'/>"
- " <menuitem name='ConnectionList' action= 'ConnectionList'/>"
- " <menuitem name='ConnectionMetaSync' action= 'ConnectionMetaSync'/>"
- " <separator/>"
- " <menuitem name='ConnectionProps' action= 'ConnectionProps'/>"
- " <menuitem name='ConnectionBind' action= 'ConnectionBind'/>"
- " <menuitem name='ConnectionClose' action= 'ConnectionClose'/>"
- " <separator/>"
- " <menuitem name='TransactionBegin' action= 'TransactionBegin'/>"
- " <menuitem name='TransactionCommit' action= 'TransactionCommit'/>"
- " <menuitem name='TransactionRollback' action= 'TransactionRollback'/>"
- " <separator/>"
- " <menuitem name='Quit' action= 'Quit'/>"
- " <separator/>"
- " </menu>"
- " <menu name='Edit' action='Edit'>"
- " </menu>"
- " <menu name='Display' action='Display'>"
- " </menu>"
- " <menu name='Perspective' action='Perspective'>"
- " <placeholder name='PersList'/>"
- " </menu>"
- " <menu name='Window' action='Window'>"
- " <menuitem name='WindowFullScreen' action= 'WindowFullScreen'/>"
- " <separator/>"
- " <menuitem name='WindowNew' action= 'WindowNew'/>"
- " <menu name='WindowNewOthers' action='WindowNewOthers'>"
- " <placeholder name='CncList'/>"
- " </menu>"
- " <separator/>"
- " <menuitem name='WindowClose' action= 'WindowClose'/>"
- " </menu>"
- " <placeholder name='MenuExtension'/>"
- " <menu name='Help' action='Help'>"
-#ifdef HAVE_GDU
- " <menuitem name='HelpManual' action= 'HelpManual'/>"
-#endif
- " <menuitem name='HelpAbout' action= 'HelpAbout'/>"
- " </menu>"
- " </menubar>"
- " <toolbar name='ToolBar'>"
- " <toolitem action='WindowClose'/>"
- " <toolitem action='WindowFullScreen'/>"
- " <toolitem action='TransactionBegin'/>"
- " <toolitem action='TransactionCommit'/>"
- " <toolitem action='TransactionRollback'/>"
- " </toolbar>"
- "</ui>";
+ { "begin", transaction_begin_cb, NULL, NULL, NULL },
+ { "commit", transaction_commit_cb, NULL, NULL, NULL },
+ { "rollback", transaction_rollback_cb, NULL, NULL, NULL },
+
+ { "properties", connection_properties_cb, NULL, NULL, NULL },
+ { "cncclose", connection_close_cb, NULL, NULL, NULL },
+
+ { "fullscreen", NULL, NULL, "false", fullscreen_cb },
+};
/**
* browser_window_new
@@ -363,8 +233,11 @@ browser_window_new (TConnection *tcnc, BrowserPerspectiveFactory *factory)
g_return_val_if_fail (T_IS_CONNECTION (tcnc), NULL);
- bwin = BROWSER_WINDOW (g_object_new (BROWSER_TYPE_WINDOW, "application", t_app_get(), NULL));
+ bwin = BROWSER_WINDOW (g_object_new (BROWSER_TYPE_WINDOW, "application", t_app_get(),
+ "show-menubar", TRUE, NULL));
gtk_application_add_window (GTK_APPLICATION (t_app_get ()), GTK_WINDOW (bwin));
+ gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (bwin), FALSE);
+
bwin->priv->tcnc = g_object_ref (tcnc);
bwin->priv->trans_status_sigid = gda_signal_connect (tcnc, "transaction-status-changed",
G_CALLBACK (transaction_status_changed_cb), bwin,
@@ -374,9 +247,6 @@ browser_window_new (TConnection *tcnc, BrowserPerspectiveFactory *factory)
NULL, 0, NULL);
gchar *tmp;
- tmp = t_connection_get_long_name (tcnc);
- gtk_window_set_title (GTK_WINDOW (bwin), tmp);
- g_free (tmp);
gtk_window_set_default_size ((GtkWindow*) bwin, 900, 650);
@@ -388,279 +258,239 @@ browser_window_new (TConnection *tcnc, BrowserPerspectiveFactory *factory)
g_object_unref (icon);
}
+ /* Obtain a valid Perspective factory */
+ if (! factory && t_connection_is_ldap (tcnc))
+ factory = browser_get_factory (_("LDAP browser"));
+ if (!factory)
+ factory = browser_get_default_factory ();
+ tmp = g_strdup_printf ("'%s'", factory->id);
+ win_entries [0].state = tmp;
+
+ /* menu */
+ g_action_map_add_action_entries (G_ACTION_MAP (bwin),
+ win_entries, G_N_ELEMENTS (win_entries),
+ bwin);
+ win_entries [0].state = NULL;
+ g_free (tmp);
+
/* main VBox */
GtkWidget *vbox;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (bwin), vbox);
gtk_widget_show (vbox);
- /* menu */
- GtkWidget *menubar;
- GtkWidget *toolbar;
- GtkUIManager *ui;
- GtkActionGroup *group;
-
- group = gtk_action_group_new ("Actions");
- gtk_action_group_set_translation_domain (group, GETTEXT_PACKAGE);
-
- bwin->priv->agroup = group;
- gtk_action_group_add_actions (group, ui_actions, G_N_ELEMENTS (ui_actions), bwin);
- gtk_action_group_add_toggle_actions (group, ui_toggle_actions, G_N_ELEMENTS (ui_toggle_actions),
bwin);
- if (t_connection_is_virtual (bwin->priv->tcnc)) {
- GtkAction *action;
- action = gtk_action_group_get_action (bwin->priv->agroup, "TransactionBegin");
- gtk_action_set_visible (action, FALSE);
- action = gtk_action_group_get_action (bwin->priv->agroup, "TransactionCommit");
- gtk_action_set_visible (action, FALSE);
- action = gtk_action_group_get_action (bwin->priv->agroup, "TransactionRollback");
- gtk_action_set_visible (action, FALSE);
- }
- transaction_status_changed_cb (bwin->priv->tcnc, bwin);
-
- ui = gtk_ui_manager_new ();
- gtk_ui_manager_insert_action_group (ui, group, 0);
- gtk_ui_manager_add_ui_from_string (ui, ui_actions_info, -1, NULL);
- bwin->priv->ui_manager = ui;
-
- GtkAccelGroup *accel_group;
- accel_group = gtk_ui_manager_get_accel_group (ui);
- gtk_window_add_accel_group (GTK_WINDOW (bwin), accel_group);
-
- menubar = gtk_ui_manager_get_widget (ui, "/MenuBar");
- bwin->priv->menubar = menubar;
-#ifdef HAVE_MAC_INTEGRATION
- gtk_osxapplication_set_menu_bar (theApp, GTK_MENU_SHELL (menubar));
-#else
- gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
- gtk_widget_show (menubar);
-#endif
-
- toolbar = gtk_ui_manager_get_widget (ui, "/ToolBar");
- bwin->priv->toolbar = toolbar;
- bwin->priv->toolbar_shown = TRUE;
- gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, TRUE, 0);
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
- gtk_widget_show (toolbar);
- bwin->priv->toolbar_style = gtk_toolbar_get_style (GTK_TOOLBAR (toolbar));
+ /* header */
+ GtkWidget *header;
+ header = gtk_header_bar_new ();
+ bwin->priv->header = GTK_HEADER_BAR (header);
+ gtk_window_set_titlebar (GTK_WINDOW (bwin), header);
+ tmp = t_connection_get_long_name (tcnc);
+ gtk_header_bar_set_title (GTK_HEADER_BAR (header), t_connection_get_name (tcnc));
+ gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header), t_connection_get_information (tcnc));
+ g_free (tmp);
+ gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header), TRUE);
+ gtk_header_bar_set_has_subtitle (GTK_HEADER_BAR (header), FALSE);
+ gtk_widget_show (header);
+
+ /* Main menu button */
+ GtkWidget *img, *button;
+ button = gtk_menu_button_new ();
+ img = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_MENU);
+ gtk_button_set_image (GTK_BUTTON (button), img);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
+ gtk_widget_show_all (button);
+ GMenu *menu;
+ menu = g_menu_new ();
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (menu));
+
+ GMenu *smenu;
+ smenu = g_menu_new ();
+ GMenuItem *msection;
+ msection = g_menu_item_new_section (NULL, G_MENU_MODEL (smenu));
+ g_menu_insert_item (menu, -1, msection);
+
+ GMenuItem *menu_item;
+ menu_item = g_menu_item_new (_("Fetch Meta Data"), "win.meta-sync");
+ g_menu_insert_item (smenu, -1, menu_item);
+ g_object_unref (menu_item);
+ menu_item = g_menu_item_new (_("Connection properties"), "win.properties");
+ g_menu_insert_item (smenu, -1, menu_item);
+ g_object_unref (menu_item);
+
+ smenu = g_menu_new ();
+ msection = g_menu_item_new_section (NULL, G_MENU_MODEL (smenu));
+ g_menu_insert_item (menu, -1, msection);
+ menu_item = g_menu_item_new (_("Close connection"), "win.cncclose");
+ g_menu_insert_item (smenu, -1, menu_item);
+ g_object_unref (menu_item);
+
+ /* Display options button */
+ GtkWidget *menu_button;
+ button = gtk_menu_button_new ();
+ gtk_widget_set_tooltip_text (button, _("Display options"));
+ img = gtk_image_new_from_icon_name ("document-properties-symbolic", GTK_ICON_SIZE_MENU);
+ gtk_button_set_image (GTK_BUTTON (button), img);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
+ gtk_widget_show_all (button);
+ menu_button = button;
+
+ /* toolbar */
+ GtkWidget *toolbar;
+ toolbar = gtk_toolbar_new ();
+ bwin->priv->toolbar = GTK_TOOLBAR (toolbar);
+ gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
+ GtkToolItem *titem;
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Rollback transaction"));
+ img = gtk_image_new_from_resource ("/images/transaction-rollback-symbolic.png");
+ gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (titem), img);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, 0);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.rollback");
+
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Commit transaction"));
+ img = gtk_image_new_from_resource ("/images/transaction-commit-symbolic.png");
+ gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (titem), img);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, 0);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.commit");
+
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Begin transaction"));
+ img = gtk_image_new_from_resource ("/images/transaction-start-symbolic.png");
+ gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (titem), img);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, 0);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.begin");
+
+ titem = gtk_separator_tool_item_new ();
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+
+ gtk_widget_show_all (toolbar);
+
+ /* notification area */
bwin->priv->notif_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start (GTK_BOX (vbox), bwin->priv->notif_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), bwin->priv->notif_box, FALSE, FALSE, 0);
gtk_widget_show (bwin->priv->notif_box);
- bwin->priv->notif_widgets = NULL;
-
- GtkToolItem *ti;
- GtkWidget *spinner, *svbox, *align;
-
- ti = gtk_separator_tool_item_new ();
- gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (ti), FALSE);
- gtk_tool_item_set_expand (ti, TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), ti, -1);
- gtk_widget_show (GTK_WIDGET (ti));
-
- spinner = gtk_spinner_new ();
-
- svbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
- gtk_container_add (GTK_CONTAINER (align), spinner);
- gtk_box_pack_start (GTK_BOX (svbox), align, TRUE, TRUE, 0);
-
- ti = gtk_tool_item_new ();
- gtk_container_add (GTK_CONTAINER (ti), svbox);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), ti, -1);
- gtk_widget_show_all (GTK_WIDGET (ti));
- gtk_widget_hide (GTK_WIDGET (spinner));
- bwin->priv->spinner = spinner;
-
- /* statusbar */
- bwin->priv->statusbar = gtk_statusbar_new ();
-
- GSList *list;
- bwin->priv->cnc_agroup = gtk_action_group_new ("CncActions");
- gtk_action_group_set_translation_domain (bwin->priv->cnc_agroup, GETTEXT_PACKAGE);
-
- for (list = t_app_get_all_connections (); list; list = list->next)
- connection_added_cb (t_app_get(), T_CONNECTION (list->data), bwin);
-
- gtk_ui_manager_insert_action_group (bwin->priv->ui_manager, bwin->priv->cnc_agroup, 0);
- bwin->priv->cnc_added_sigid = gda_signal_connect (t_app_get (), "connection-added",
- G_CALLBACK (connection_added_cb), bwin,
- NULL, 0, NULL);
- bwin->priv->cnc_removed_sigid = gda_signal_connect (t_app_get (), "connection-removed",
- G_CALLBACK (connection_removed_cb), bwin,
- NULL, 0, NULL);
+ bwin->priv->notif_widgets = NULL;
/* create a PerspectiveData */
PerspectiveData *pers;
- if (! factory && t_connection_is_ldap (tcnc))
- factory = browser_get_factory (_("LDAP browser"));
pers = perspective_data_new (bwin, factory);
- bwin->priv->perspectives = g_slist_prepend (bwin->priv->perspectives, pers);
- GtkActionGroup *actions;
- actions = browser_perspective_get_actions_group (BROWSER_PERSPECTIVE (pers->perspective_widget));
- if (actions) {
- gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
- gtk_ui_manager_insert_action_group (bwin->priv->ui_manager, actions, 0);
- g_object_unref (actions);
- }
- const gchar *ui_info;
- ui_info = browser_perspective_get_actions_ui (BROWSER_PERSPECTIVE (pers->perspective_widget));
- 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->pers_list = g_slist_prepend (bwin->priv->pers_list, pers);
bwin->priv->current_perspective = pers;
- browser_perspective_get_current_customization (BROWSER_PERSPECTIVE (pers->perspective_widget),
- &actions, &ui_info);
- browser_window_customize_perspective_ui (bwin, BROWSER_PERSPECTIVE (pers->perspective_widget),
- actions, ui_info);
- if (actions)
- g_object_unref (actions);
/* insert perspective into window */
- bwin->priv->perspectives_nb = (GtkNotebook*) gtk_notebook_new ();
- g_object_ref (bwin->priv->perspectives_nb);
- gtk_notebook_set_show_tabs (bwin->priv->perspectives_nb, FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), (GtkWidget*) bwin->priv->perspectives_nb,
+ bwin->priv->pers_stack = (GtkStack*) gtk_stack_new ();
+ g_object_ref (bwin->priv->pers_stack);
+ gtk_box_pack_start (GTK_BOX (vbox), (GtkWidget*) bwin->priv->pers_stack,
TRUE, TRUE, 0);
- pers->page_number = gtk_notebook_append_page (bwin->priv->perspectives_nb,
- GTK_WIDGET (pers->perspective_widget), NULL);
- gtk_widget_show_all ((GtkWidget*) bwin->priv->perspectives_nb);
+ gtk_stack_add_named (bwin->priv->pers_stack, GTK_WIDGET (pers->perspective_widget),
+ pers->factory->id);
+ gtk_widget_show_all ((GtkWidget*) bwin->priv->pers_stack);
gtk_widget_grab_focus (GTK_WIDGET (pers->perspective_widget));
/* build the perspectives menu */
- GtkActionGroup *agroup;
- const GSList *plist;
- GSList *radio_group = NULL;
- guint mid;
+ GMenuModel *menumodel;
+ menumodel = (GMenuModel*) g_object_get_data (G_OBJECT (t_app_get ()), "perspectives");
+ g_assert (menumodel);
+ menu = G_MENU (menumodel);
+ g_menu_remove_all (menu);
+
+ GMenu *bmenu;
+ bmenu = g_menu_new ();
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), G_MENU_MODEL (bmenu));
- mid = gtk_ui_manager_new_merge_id (bwin->priv->ui_manager);
- agroup = gtk_action_group_new ("Perspectives");
- gtk_action_group_set_translation_domain (agroup, GETTEXT_PACKAGE);
+ GMenuItem *mitem;
+ mitem = g_menu_item_new (_("Fullscreen"), "win.fullscreen");
+ g_menu_insert_item (bmenu, -1, mitem);
- gtk_ui_manager_insert_action_group (bwin->priv->ui_manager, agroup, 0);
- bwin->priv->perspectives_actions = agroup;
- g_object_unref (agroup);
+ smenu = g_menu_new ();
+ msection = g_menu_item_new_section (_("Perspectives"), G_MENU_MODEL (smenu));
+ g_menu_insert_item (bmenu, -1, msection);
- GtkAction *active_action = NULL;
+ const GSList *plist;
for (plist = browser_get_factories (); plist; plist = plist->next) {
- GtkAction *action;
- const gchar *name;
+ const gchar *name, *id;
name = BROWSER_PERSPECTIVE_FACTORY (plist->data)->perspective_name;
+ id = BROWSER_PERSPECTIVE_FACTORY (plist->data)->id;
if (!strcmp (name, _("LDAP browser")) && !t_connection_is_ldap (tcnc))
continue;
- action = GTK_ACTION (gtk_radio_action_new (name, name, NULL, NULL, FALSE));
-
- if (!active_action &&
- ((factory && (BROWSER_PERSPECTIVE_FACTORY (plist->data) == factory)) ||
- (!factory && (BROWSER_PERSPECTIVE_FACTORY (plist->data) == browser_get_default_factory
()))))
- active_action = action;
- if (BROWSER_PERSPECTIVE_FACTORY (plist->data)->menu_shortcut)
- gtk_action_group_add_action_with_accel (agroup, action,
- BROWSER_PERSPECTIVE_FACTORY
(plist->data)->menu_shortcut);
- else
- gtk_action_group_add_action (agroup, action);
-
- gtk_radio_action_set_group (GTK_RADIO_ACTION (action), radio_group);
- radio_group = gtk_radio_action_get_group (GTK_RADIO_ACTION (action));
-
- g_object_set_data (G_OBJECT (action), "pers", plist->data);
- g_signal_connect (action, "changed",
- G_CALLBACK (perspective_toggle_cb), bwin);
+ gchar *tmp;
+ tmp = g_strdup_printf ("win.change-perspective::%s", id);
- g_object_unref (action);
+ menu_item = g_menu_item_new (name, tmp);
+ g_menu_insert_item (menu, -1, menu_item);
+ g_object_unref (menu_item);
- gtk_ui_manager_add_ui (bwin->priv->ui_manager, mid, "/MenuBar/Perspective/PersList",
- name, name,
- GTK_UI_MANAGER_AUTO, FALSE);
+ menu_item = g_menu_item_new (name, tmp);
+ g_menu_insert_item (smenu, -1, menu_item);
+ g_object_unref (menu_item);
+
+ /* accelerators */
+ const gchar *accels[2];
+ accels [0] = BROWSER_PERSPECTIVE_FACTORY (plist->data)->menu_shortcut;
+ accels [1] = NULL;
+ gtk_application_set_accels_for_action (GTK_APPLICATION (t_app_get ()), tmp, accels);
+
+ g_print ("ADDED perspective %s (%s) to menu with action [%s], accel [%s]\n", name, id, tmp,
+ BROWSER_PERSPECTIVE_FACTORY (plist->data)->menu_shortcut);
+ g_free (tmp);
}
-
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (active_action), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), bwin->priv->statusbar, FALSE, FALSE, 0);
- gtk_widget_show (bwin->priv->statusbar);
+ /* statusbar and spinner */
+ bwin->priv->statusbar = gtk_statusbar_new ();
bwin->priv->cnc_statusbar_context = gtk_statusbar_get_context_id (GTK_STATUSBAR
(bwin->priv->statusbar),
"cncbusy");
-
+ GtkWidget *lbox;
+ lbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), lbox, FALSE, FALSE, 0);
+ bwin->priv->spinner = gtk_spinner_new (); /* don't show spinner now */
+ gtk_box_pack_start (GTK_BOX (lbox), bwin->priv->statusbar, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (lbox), bwin->priv->spinner, FALSE, FALSE, 0);
+ gtk_widget_show_all (lbox);
+
+ /* accels */
+ const gchar *accels[2];
+ accels [0] = "F11";
+ accels [1] = NULL;
+ gtk_application_set_accels_for_action (GTK_APPLICATION (t_app_get ()), "win.fullscreen", accels);
+
+ cnc_status_changed_cb (tcnc, gda_connection_get_status (t_connection_get_cnc (tcnc)), bwin);
gtk_widget_show (GTK_WIDGET (bwin));
gtk_widget_set_can_focus ((GtkWidget* )pers->perspective_widget, TRUE);
gtk_widget_grab_focus ((GtkWidget* )pers->perspective_widget);
+ /* customize currect perspective */
+ browser_perspective_customize (bwin->priv->current_perspective->perspective_widget,
+ bwin->priv->toolbar, bwin->priv->header,
+ G_MENU (gtk_application_get_menubar (GTK_APPLICATION (t_app_get ()))));
+
return bwin;
}
static void
-perspective_toggle_cb (GtkRadioAction *action, GtkRadioAction *current, BrowserWindow *bwin)
+fullscreen_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *state, gpointer data)
{
- BrowserPerspectiveFactory *pf;
- GSList *list;
- PerspectiveData *pers;
- if (action != current)
- return;
-
- 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) {
- pers = PERSPECTIVE_DATA (list->data);
- break;
- }
- }
-
- if (!pers) {
- pers = perspective_data_new (bwin, pf);
- bwin->priv->perspectives = g_slist_prepend (bwin->priv->perspectives, pers);
- pers->page_number = gtk_notebook_append_page (bwin->priv->perspectives_nb,
- GTK_WIDGET (pers->perspective_widget), NULL);
- gtk_widget_show (GTK_WIDGET (pers->perspective_widget));
-
- GtkActionGroup *actions;
- actions = browser_perspective_get_actions_group (BROWSER_PERSPECTIVE
(pers->perspective_widget));
- if (actions) {
- gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
- gtk_ui_manager_insert_action_group (bwin->priv->ui_manager, actions, 0);
- g_object_unref (actions);
- }
+ BrowserWindow *bwin = BROWSER_WINDOW (data);
+ if (g_variant_get_boolean (state)) {
+ gtk_window_fullscreen (GTK_WINDOW (bwin));
+ bwin->priv->fullscreen = TRUE;
+ gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (bwin), TRUE);
+ browser_window_show_notice_printf (bwin, GTK_MESSAGE_INFO,
+ "fullscreen-esc",
+ "%s", _("Hit the F11 key to leave the fullscreen mode"));
}
-
- 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);
- bwin->priv->ui_manager_merge_id = 0;
+ else {
+ gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (bwin), FALSE);
+ gtk_window_unfullscreen (GTK_WINDOW (bwin));
+ bwin->priv->fullscreen = FALSE;
}
-
- const gchar *ui_info;
- ui_info = browser_perspective_get_actions_ui (BROWSER_PERSPECTIVE (pers->perspective_widget));
- 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;
-
- GtkActionGroup *actions;
- browser_perspective_get_current_customization (BROWSER_PERSPECTIVE (pers->perspective_widget),
- &actions, &ui_info);
- browser_window_customize_perspective_ui (bwin, BROWSER_PERSPECTIVE (pers->perspective_widget),
- actions, ui_info);
- if (actions)
- g_object_unref (actions);
+ g_simple_action_set_state (action, state);
}
static void
@@ -672,104 +502,39 @@ cnc_status_changed_cb (TConnection *tcnc, GdaConnectionStatus status, BrowserWin
is_busy = (status == GDA_CONNECTION_STATUS_IDLE) ? FALSE : TRUE;
if (tcnc == bwin->priv->tcnc) {
- /* @bcbc is @bwin's own connection */
- if (! is_busy) {
- gtk_spinner_stop (GTK_SPINNER (bwin->priv->spinner));
- gtk_widget_hide (GTK_WIDGET (bwin->priv->spinner));
- gtk_widget_set_tooltip_text (bwin->priv->spinner, NULL);
- gtk_statusbar_pop (GTK_STATUSBAR (bwin->priv->statusbar),
- bwin->priv->cnc_statusbar_context);
- }
- else {
+ if (is_busy) {
gtk_widget_show (GTK_WIDGET (bwin->priv->spinner));
gtk_spinner_start (GTK_SPINNER (bwin->priv->spinner));
gtk_widget_set_tooltip_text (bwin->priv->spinner, reason);
gtk_statusbar_push (GTK_STATUSBAR (bwin->priv->statusbar),
bwin->priv->cnc_statusbar_context,
reason);
- }
- gboolean bsens = FALSE, csens = FALSE;
- if (! is_busy) {
- if (t_connection_get_transaction_status (tcnc))
- csens = TRUE;
- else
- bsens = TRUE;
+ GAction *action;
+ action = g_action_map_lookup_action (G_ACTION_MAP (bwin), "begin");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+ action = g_action_map_lookup_action (G_ACTION_MAP (bwin), "commit");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+ action = g_action_map_lookup_action (G_ACTION_MAP (bwin), "rollback");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+ action = g_action_map_lookup_action (G_ACTION_MAP (bwin), "meta-sync");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+ }
+ else {
+ gtk_spinner_stop (GTK_SPINNER (bwin->priv->spinner));
+ gtk_widget_hide (GTK_WIDGET (bwin->priv->spinner));
+ gtk_widget_set_tooltip_text (bwin->priv->spinner, NULL);
+ gtk_statusbar_pop (GTK_STATUSBAR (bwin->priv->statusbar),
+ bwin->priv->cnc_statusbar_context);
+ transaction_status_changed_cb (tcnc, bwin);
}
- action = gtk_action_group_get_action (bwin->priv->agroup, "TransactionBegin");
- gtk_action_set_sensitive (action, bsens);
- action = gtk_action_group_get_action (bwin->priv->agroup, "TransactionCommit");
- gtk_action_set_sensitive (action, csens);
- action = gtk_action_group_get_action (bwin->priv->agroup, "TransactionRollback");
- gtk_action_set_sensitive (action, csens);
-
- action = gtk_action_group_get_action (bwin->priv->agroup, "WindowNew");
- gtk_action_set_sensitive (action, !is_busy);
- action = gtk_action_group_get_action (bwin->priv->agroup, "ConnectionMetaSync");
- gtk_action_set_sensitive (action, !is_busy);
}
-
- gchar *cncname;
- cncname = t_connection_get_long_name (tcnc);
- action = gtk_action_group_get_action (bwin->priv->cnc_agroup, cncname);
- g_free (cncname);
- if (action)
- gtk_action_set_sensitive (action, !is_busy);
-}
-
-/* update @bwin->priv->cnc_agroup and @bwin->priv->ui_manager */
-static void
-connection_added_cb (G_GNUC_UNUSED TApp *tapp, TConnection *tcnc, BrowserWindow *bwin)
-{
- GtkAction *action;
- gchar *cncname;
- guint mid;
-
- mid = gtk_ui_manager_new_merge_id (bwin->priv->ui_manager);
- cncname = t_connection_get_long_name (tcnc);
- action = gtk_action_new (cncname, cncname, NULL, NULL);
- gtk_action_group_add_action (bwin->priv->cnc_agroup, action);
- guint *amid = g_new (guint, 1);
- *amid = mid;
- g_object_set_data_full (G_OBJECT (action), "mid", amid, g_free);
-
- gtk_ui_manager_add_ui (bwin->priv->ui_manager, mid, "/MenuBar/Window/WindowNewOthers/CncList",
- cncname, cncname,
- GTK_UI_MANAGER_AUTO, FALSE);
- g_free (cncname);
- g_signal_connect (action, "activate",
- G_CALLBACK (window_new_with_cnc_cb), bwin);
- g_object_set_data (G_OBJECT (action), "tcnc", tcnc);
- gtk_action_set_sensitive (action, ! t_connection_is_busy (tcnc, NULL));
- g_object_unref (action);
-}
-
-/* update @bwin->priv->cnc_agroup and @bwin->priv->ui_manager */
-static void
-connection_removed_cb (G_GNUC_UNUSED TApp *tapp, TConnection *tcnc, BrowserWindow *bwin)
-{
- GtkAction *action;
- gchar *path;
- gchar *cncname;
- guint *mid;
-
- cncname = t_connection_get_long_name (tcnc);
- path = g_strdup_printf ("/MenuBar/Window/WindowNewOthers/CncList/%s", cncname);
- g_free (cncname);
- action = gtk_ui_manager_get_action (bwin->priv->ui_manager, path);
- g_free (path);
- g_assert (action);
-
- mid = g_object_get_data (G_OBJECT (action), "mid");
- g_assert (mid);
-
- gtk_ui_manager_remove_ui (bwin->priv->ui_manager, *mid);
- gtk_action_group_remove_action (bwin->priv->cnc_agroup, action);
}
static void
-connection_close_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
+connection_close_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
{
+ BrowserWindow *bwin = BROWSER_WINDOW (data);
/* confirmation dialog */
GtkWidget *dialog;
char *str;
@@ -794,63 +559,31 @@ connection_close_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
}
static void
-quit_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
-{
- /* confirmation dialog */
- GtkWidget *dialog;
- GSList *connections;
-
- connections = t_app_get_all_connections ();
- if (connections && connections->next)
- dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (bwin), GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- "<b>%s</b>\n<small>%s</small>",
- _("Do you want to quit the application?"),
- _("all the connections will be closed."));
- else
- dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (bwin), GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- "<b>%s</b>\n<small>%s</small>",
- _("Do you want to quit the application?"),
- _("the connection will be closed."));
-
-
- gboolean doquit;
- doquit = (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) ? TRUE : FALSE;
- gtk_widget_destroy (dialog);
- if (doquit)
- t_app_request_quit ();
-}
-
-static void
transaction_status_changed_cb (TConnection *tcnc, BrowserWindow *bwin)
{
- if (!bwin->priv->agroup)
- return;
-
- GtkAction *action;
gboolean trans_started;
trans_started = t_connection_get_transaction_status (tcnc) ? TRUE : FALSE;
bwin->priv->updating_transaction_status = TRUE;
- action = gtk_action_group_get_action (bwin->priv->agroup, "TransactionBegin");
- gtk_action_set_sensitive (action, !trans_started);
+ GAction *action;
+ action = g_action_map_lookup_action (G_ACTION_MAP (bwin), "begin");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !trans_started);
+ action = g_action_map_lookup_action (G_ACTION_MAP (bwin), "commit");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), trans_started);
+ action = g_action_map_lookup_action (G_ACTION_MAP (bwin), "rollback");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), trans_started);
- action = gtk_action_group_get_action (bwin->priv->agroup, "TransactionCommit");
- gtk_action_set_sensitive (action, trans_started);
-
- action = gtk_action_group_get_action (bwin->priv->agroup, "TransactionRollback");
- gtk_action_set_sensitive (action, trans_started);
+ action = g_action_map_lookup_action (G_ACTION_MAP (bwin), "meta-sync");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !trans_started);
bwin->priv->updating_transaction_status = FALSE;
}
static void
-transaction_begin_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
+transaction_begin_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
{
+ BrowserWindow *bwin = BROWSER_WINDOW (data);
if (!bwin->priv->updating_transaction_status) {
GError *error = NULL;
if (! t_connection_begin (bwin->priv->tcnc, &error)) {
@@ -863,8 +596,9 @@ transaction_begin_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
}
static void
-transaction_commit_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
+transaction_commit_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
{
+ BrowserWindow *bwin = BROWSER_WINDOW (data);
if (!bwin->priv->updating_transaction_status) {
GError *error = NULL;
if (! t_connection_commit (bwin->priv->tcnc, &error)) {
@@ -877,8 +611,9 @@ transaction_commit_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
}
static void
-transaction_rollback_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
+transaction_rollback_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
{
+ BrowserWindow *bwin = BROWSER_WINDOW (data);
if (!bwin->priv->updating_transaction_status) {
GError *error = NULL;
if (! t_connection_rollback (bwin->priv->tcnc, &error)) {
@@ -890,117 +625,15 @@ transaction_rollback_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
}
}
-
static void
-window_close_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
+change_perspective_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *state, gpointer data)
{
- gtk_window_close (GTK_WINDOW (bwin));
-}
-
-static gboolean
-toolbar_hide_timeout_cb (BrowserWindow *bwin)
-{
- if (!bwin->priv->cursor_in_toolbar) {
- gtk_widget_hide (bwin->priv->toolbar);
- gtk_widget_hide (bwin->priv->menubar);
- bwin->priv->toolbar_shown = FALSE;
-
- /* remove timer */
- bwin->priv->fullscreen_timer_id = 0;
- return FALSE;
- }
- else
- /* keep timer */
- return TRUE;
-}
-
-#define BWIN_WINDOW_FULLSCREEN_POPUP_THRESHOLD 15
-#define BWIN_WINDOW_FULLSCREEN_POPUP_TIMER 5
-
-static gboolean
-fullscreen_motion_notify_cb (GtkWidget *widget, GdkEventMotion *event, G_GNUC_UNUSED gpointer user_data)
-{
- BrowserWindow *bwin = BROWSER_WINDOW (widget);
- if (gtk_widget_get_window (widget) != event->window)
- return FALSE;
-
- if (event->y < BWIN_WINDOW_FULLSCREEN_POPUP_THRESHOLD) {
- gtk_widget_show (bwin->priv->toolbar);
- gtk_widget_show (bwin->priv->menubar);
- bwin->priv->toolbar_shown = TRUE;
- }
-
- if (bwin->priv->toolbar_shown) {
- /* reset toolbar hiding timer */
- if (bwin->priv->fullscreen_timer_id)
- g_source_remove (bwin->priv->fullscreen_timer_id);
- bwin->priv->fullscreen_timer_id = g_timeout_add_seconds (BWIN_WINDOW_FULLSCREEN_POPUP_TIMER,
- (GSourceFunc)
toolbar_hide_timeout_cb,
- bwin);
- }
- return FALSE;
-}
-
-gboolean
-toolbar_enter_notify_cb (G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEventCrossing *event,
- BrowserWindow *bwin)
-{
- bwin->priv->cursor_in_toolbar = TRUE;
- return FALSE;
-}
-
-gboolean
-toolbar_leave_notify_cb (G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEventCrossing *event,
BrowserWindow *bwin)
-{
- bwin->priv->cursor_in_toolbar = FALSE;
- return FALSE;
-}
-
-static void
-window_fullscreen_cb (GtkToggleAction *action, BrowserWindow *bwin)
-{
- if (gtk_toggle_action_get_active (action)) {
- gtk_window_fullscreen (GTK_WINDOW (bwin));
- browser_window_show_notice_printf (bwin, GTK_MESSAGE_INFO,
- "fullscreen-esc",
- "%s", _("Hit the Escape key to leave the fullscreen
mode"));
- gtk_widget_hide (bwin->priv->toolbar);
- gtk_widget_hide (bwin->priv->menubar);
- bwin->priv->toolbar_shown = FALSE;
- bwin->priv->fullscreen_motion_sig_id = g_signal_connect (bwin, "motion-notify-event",
- G_CALLBACK
(fullscreen_motion_notify_cb),
- NULL);
- g_signal_connect (bwin->priv->toolbar, "enter-notify-event",
- G_CALLBACK (toolbar_enter_notify_cb), bwin);
- g_signal_connect (bwin->priv->toolbar, "leave-notify-event",
- G_CALLBACK (toolbar_leave_notify_cb), bwin);
- g_signal_connect (bwin->priv->menubar, "enter-notify-event",
- G_CALLBACK (toolbar_enter_notify_cb), bwin);
- g_signal_connect (bwin->priv->menubar, "leave-notify-event",
- G_CALLBACK (toolbar_leave_notify_cb), bwin);
- }
- else {
- gtk_window_unfullscreen (GTK_WINDOW (bwin));
- g_signal_handler_disconnect (bwin, bwin->priv->fullscreen_motion_sig_id);
- bwin->priv->fullscreen_motion_sig_id = 0;
- g_signal_handlers_disconnect_by_func (bwin->priv->toolbar,
- G_CALLBACK (toolbar_enter_notify_cb), bwin);
- g_signal_handlers_disconnect_by_func (bwin->priv->toolbar,
- G_CALLBACK (toolbar_leave_notify_cb), bwin);
- g_signal_handlers_disconnect_by_func (bwin->priv->menubar,
- G_CALLBACK (toolbar_enter_notify_cb), bwin);
- g_signal_handlers_disconnect_by_func (bwin->priv->menubar,
- G_CALLBACK (toolbar_leave_notify_cb), bwin);
-
- gtk_widget_show (bwin->priv->toolbar);
- gtk_widget_show (bwin->priv->menubar);
- bwin->priv->toolbar_shown = TRUE;
-
- if (bwin->priv->fullscreen_timer_id) {
- g_source_remove (bwin->priv->fullscreen_timer_id);
- bwin->priv->fullscreen_timer_id = 0;
- }
- }
+ BrowserWindow *bwin = BROWSER_WINDOW (data);
+ const gchar *pname;
+ pname = g_variant_get_string (state, NULL);
+ g_print ("Switching to perspective [%s]\n", pname);
+ browser_window_change_perspective (bwin, pname);
+ g_simple_action_set_state (action, state);
}
static gboolean
@@ -1016,76 +649,10 @@ key_press_event (GtkWidget *widget, GdkEventKey *event)
return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);
}
-static gboolean
-window_state_event (GtkWidget *widget, GdkEventWindowState *event)
-{
- BrowserWindow *bwin = BROWSER_WINDOW (widget);
- gboolean (* window_state_event) (GtkWidget *, GdkEventWindowState *);
- window_state_event = GTK_WIDGET_CLASS (parent_class)->window_state_event;
-
- /* calling parent's method */
- if (window_state_event)
- window_state_event (widget, event);
-
- if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
- gboolean fullscreen;
- GtkWidget *wid;
-
- wid = gtk_ui_manager_get_widget (bwin->priv->ui_manager, "/ToolBar");
-
- fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
- bwin->priv->fullscreen = fullscreen;
- if (fullscreen)
- gtk_toolbar_set_style (GTK_TOOLBAR (wid), GTK_TOOLBAR_ICONS);
- else
- gtk_toolbar_set_style (GTK_TOOLBAR (wid), bwin->priv->toolbar_style);
-
- wid = gtk_ui_manager_get_widget (bwin->priv->ui_manager, "/MenuBar");
- if (fullscreen)
- gtk_widget_hide (wid);
- else
- gtk_widget_show (wid);
-
- g_signal_emit (G_OBJECT (bwin), browser_window_signals[FULLSCREEN_CHANGED], 0, fullscreen);
- }
- return FALSE;
-}
-
-static void
-window_new_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
-{
- BrowserWindow *nbwin;
- TConnection *tcnc;
- tcnc = browser_window_get_connection (bwin);
- nbwin = browser_window_new (tcnc, NULL);
- gtk_widget_show (GTK_WIDGET (nbwin));
-}
-
-static void
-window_new_with_cnc_cb (GtkAction *action, G_GNUC_UNUSED BrowserWindow *bwin)
-{
- BrowserWindow *nbwin;
- TConnection *tcnc;
-
- tcnc = g_object_get_data (G_OBJECT (action), "tcnc");
- g_return_if_fail (T_IS_CONNECTION (tcnc));
- nbwin = browser_window_new (tcnc, NULL);
- gtk_widget_show (GTK_WIDGET (nbwin));
-}
-
-static void
-connection_open_cb (G_GNUC_UNUSED GtkAction *action, G_GNUC_UNUSED BrowserWindow *bwin)
-{
- LoginDialog *dialog;
- dialog = login_dialog_new (NULL);
-
- login_dialog_run_open_connection (dialog, TRUE, NULL);
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
static void
-connection_properties_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
+connection_properties_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
{
+ BrowserWindow *bwin = BROWSER_WINDOW (data);
if (T_IS_VIRTUAL_CONNECTION (bwin->priv->tcnc)) {
GtkWidget *win;
TVirtualConnectionSpecs *specs;
@@ -1119,92 +686,13 @@ connection_properties_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
}
static void
-connection_bind_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
-{
- GtkWidget *win;
- gint res;
-
- win = connection_binding_properties_new_create (bwin->priv->tcnc);
- gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (bwin));
- gtk_widget_show (win);
-
- res = gtk_dialog_run (GTK_DIALOG (win));
- gtk_widget_hide (win);
- if (res == GTK_RESPONSE_OK) {
- TConnection *tcnc;
- GError *error = NULL;
- tcnc = t_virtual_connection_new (connection_binding_properties_get_specs
- (CONNECTION_BINDING_PROPERTIES (win)), &error);
- if (tcnc) {
- BrowserWindow *bwin;
- bwin = browser_window_new (tcnc, NULL);
- gtk_widget_show (GTK_WIDGET (bwin));
- }
- else {
- ui_show_error ((GtkWindow*) bwin,
- _("Could not open binding connection: %s"),
- error && error->message ? error->message : _("No detail"));
- g_clear_error (&error);
- }
- }
- gtk_widget_destroy (win);
-}
-
-static void
-connection_list_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
-{
- browser_connections_list_show (bwin->priv->tcnc);
-}
-
-static void
-connection_meta_update_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
+connection_meta_update_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
{
+ BrowserWindow *bwin = BROWSER_WINDOW (data);
t_connection_update_meta_data (bwin->priv->tcnc);
+ //gtk_widget_insert_action_group (GTK_WIDGET (bwin), "win", NULL);
}
-static void
-about_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
-{
- GdkPixbuf *icon;
- GtkWidget *dialog;
- const gchar *authors[] = {
- "Vivien Malerba <malerba gnome-db org> (current maintainer)",
- NULL
- };
- const gchar *documenters[] = {
- NULL
- };
- const gchar *translator_credits = "";
-
- icon = gdk_pixbuf_new_from_resource ("/images/gda-browser.png", NULL);
-
- dialog = gtk_about_dialog_new ();
- 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 - 2014 GNOME Foundation");
- gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (dialog), _("Database access services for the GNOME
Desktop"));
- gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (dialog), "GNU General Public License");
- gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (dialog), "http://www.gnome-db.org");
- gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (dialog), authors);
- gtk_about_dialog_set_documenters (GTK_ABOUT_DIALOG (dialog), documenters);
- gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (dialog), translator_credits);
- gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (dialog), icon);
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (bwin));
- gtk_widget_show (dialog);
- g_object_unref (icon);
-}
-
-#ifdef HAVE_GDU
-void
-manual_cb (G_GNUC_UNUSED GtkAction *action, BrowserWindow *bwin)
-{
- ui_show_help (GTK_WINDOW (bwin), NULL);
-}
-#endif
-
/**
* browser_window_get_connection
@@ -1239,7 +727,6 @@ perspective_data_new (BrowserWindow *bwin, BrowserPerspectiveFactory *factory)
pers->factory = factory;
if (!pers->factory)
pers->factory = browser_get_default_factory ();
- pers->page_number = -1;
g_assert (pers->factory);
pers->perspective_widget = g_object_ref (pers->factory->perspective_create (bwin));
@@ -1254,9 +741,6 @@ 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);
}
@@ -1585,83 +1069,80 @@ browser_window_customize_perspective_ui (BrowserWindow *bwin, BrowserPerspective
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) {
+ for (list = bwin->priv->pers_list; 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;
- }
- 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;
- gtk_ui_manager_ensure_update (bwin->priv->ui_manager);
-
- if (actions_group) {
- g_return_if_fail (GTK_IS_ACTION_GROUP (actions_group));
- gtk_action_group_set_translation_domain (actions_group, GETTEXT_PACKAGE);
- 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);
- }
}
/**
* browser_window_change_perspective
* @bwin: a #BrowserWindow
- * @perspective: the name of the perspective to change to
+ * @perspective_id: the ID 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)
+browser_window_change_perspective (BrowserWindow *bwin, const gchar *perspective_id)
{
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);
+ g_return_val_if_fail (perspective_id, NULL);
current_pdata = bwin->priv->current_perspective;
+ if (current_pdata) {
+ if (!strcmp (current_pdata->factory->id, perspective_id))
+ /* nothing to do, keep same perspective shown */
+ return current_pdata->perspective_widget;
+
+ /* clean ups for current perspective */
+ browser_perspective_uncustomize (bwin->priv->current_perspective->perspective_widget,
+ bwin->priv->toolbar, bwin->priv->header,
+ G_MENU (gtk_application_get_menubar (GTK_APPLICATION
(t_app_get ()))));
+ }
- bpf = browser_get_factory (perspective);
- if (!bpf)
+ /* find factory */
+ bpf = browser_get_factory (perspective_id);
+ if (!bpf) {
+ g_warning ("Could not identify perspective %s", perspective_id);
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);
+ /* check if perspective already exists */
+ PerspectiveData *pdata = NULL;
+ bpers = (BrowserPerspective*) gtk_stack_get_child_by_name (bwin->priv->pers_stack, perspective_id);
+ if (! bpers) {
+ pdata = perspective_data_new (bwin, bpf);
+ bwin->priv->pers_list = g_slist_prepend (bwin->priv->pers_list, pdata);
+ gtk_stack_add_named (bwin->priv->pers_stack, GTK_WIDGET (pdata->perspective_widget),
+ bpf->id);
+ bpers = pdata->perspective_widget;
+ gtk_widget_show_all (GTK_WIDGET (pdata->perspective_widget));
+ }
+ else {
+ GSList *list;
+ for (list = bwin->priv->pers_list; list; list = list->next) {
+ if (PERSPECTIVE_DATA (list->data)->factory == bpf) {
+ pdata = PERSPECTIVE_DATA (list->data);
+ break;
+ }
+ }
+ }
+ gtk_stack_set_visible_child (bwin->priv->pers_stack, GTK_WIDGET (bpers));
+ browser_perspective_customize (bpers,
+ bwin->priv->toolbar, bwin->priv->header,
+ G_MENU (gtk_application_get_menubar (GTK_APPLICATION (t_app_get ()))));
+ bwin->priv->current_perspective = pdata;
+
+ /* setup for the new perspective */
+ /* TODO */
gchar *tmp;
tmp = g_markup_printf_escaped (_("The current perspective has changed to the '%s' perspective, you "
"can switch back to previous perspective through the "
@@ -1700,9 +1181,12 @@ browser_window_is_fullscreen (BrowserWindow *bwin)
void
browser_window_set_fullscreen (BrowserWindow *bwin, gboolean fullscreen)
{
- GtkAction *action;
g_return_if_fail (BROWSER_IS_WINDOW (bwin));
-
- action = gtk_action_group_get_action (bwin->priv->agroup, "WindowFullScreen");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), fullscreen);
+
+ GAction *action;
+ action = g_action_map_lookup_action (G_ACTION_MAP (bwin), "fullscreen");
+
+ GVariant *value;
+ value = g_variant_new_boolean (fullscreen);
+ g_action_change_state (action, value);
}
diff --git a/tools/browser/connection-binding-properties.c b/tools/browser/connection-binding-properties.c
index acccec5..4cf8c6d 100644
--- a/tools/browser/connection-binding-properties.c
+++ b/tools/browser/connection-binding-properties.c
@@ -289,7 +289,7 @@ update_display (ConnectionBindingProperties *cprop)
button = gtk_button_new ();
label = ui_make_tab_label_with_icon (_("Add binding"), "list-add", FALSE, NULL);
gtk_container_add (GTK_CONTAINER (button), label);
- arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
+ arrow = gtk_image_new_from_icon_name ("go-next-symbolic", GTK_ICON_SIZE_MENU);
gtk_box_pack_start (GTK_BOX (label), arrow, FALSE, FALSE, 0);
g_object_set (G_OBJECT (button), "relief", GTK_RELIEF_NONE, NULL);
gtk_grid_attach (cprop->priv->layout_grid, button, 0, top, 2, 1);
diff --git a/tools/browser/data-manager/Makefile.am b/tools/browser/data-manager/Makefile.am
index 33a21af..0ad0a47 100644
--- a/tools/browser/data-manager/Makefile.am
+++ b/tools/browser/data-manager/Makefile.am
@@ -18,9 +18,14 @@ marshal.h: marshal.list $(GLIB_GENMARSHAL)
marshal.c: marshal.list $(GLIB_GENMARSHAL) marshal.h
$(GLIB_GENMARSHAL) $< --body --prefix=_dm_marshal > $@
+GENFILES = \
+ marshal.c \
+ marshal.h
+
+$(libperspective_la_OBJECTS): $(GENFILES)
+
libperspective_la_SOURCES = \
- marshal.c \
- marshal.h \
+ $(GENFILES) \
analyser.c \
analyser.h \
data-console.c \
@@ -44,13 +49,9 @@ libperspective_la_SOURCES = \
xml-spec-editor.c \
xml-spec-editor.h
-
-$(OBJECTS): marshal.c marshal.h
-
EXTRA_DIST= \
$(langspec_DATA) \
marshal.list
CLEANFILES = \
- marshal.h \
- marshal.c
+ $(GENFILES)
diff --git a/tools/browser/data-manager/data-manager-perspective.c
b/tools/browser/data-manager/data-manager-perspective.c
index bc4938d..e165a81 100644
--- a/tools/browser/data-manager/data-manager-perspective.c
+++ b/tools/browser/data-manager/data-manager-perspective.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 David King <davidk openismus com>
- * Copyright (C) 2010 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2010 - 2015 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
*
* This program is free software; you can redistribute it and/or
@@ -26,8 +26,6 @@
#include "../browser-page.h"
#include "data-favorite-selector.h"
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
/*
* Main static functions
*/
@@ -38,12 +36,10 @@ static void data_manager_perspective_grab_focus (GtkWidget *widget);
/* BrowserPerspective interface */
static void data_manager_perspective_perspective_init (BrowserPerspectiveIface *iface);
-static BrowserWindow *data_manager_perspective_get_window (BrowserPerspective *perspective);
-static GtkActionGroup *data_manager_perspective_get_actions_group (BrowserPerspective *perspective);
-static const gchar *data_manager_perspective_get_actions_ui (BrowserPerspective *perspective);
-static void data_manager_perspective_get_current_customization (BrowserPerspective
*perspective,
- GtkActionGroup **out_agroup,
- const gchar **out_ui);
+static void data_manager_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header,
GMenu *menu);
+static void data_manager_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header,
GMenu *menu);
/* get a pointer to the parents to be able to call their destructor */
static GObjectClass *parent_class = NULL;
@@ -54,6 +50,8 @@ struct _DataManagerPerspectivePriv {
gboolean favorites_shown;
BrowserWindow *bwin;
TConnection *tcnc;
+
+ GArray *custom_parts;
};
GType
@@ -115,10 +113,8 @@ data_manager_perspective_grab_focus (GtkWidget *widget)
static void
data_manager_perspective_perspective_init (BrowserPerspectiveIface *iface)
{
- iface->i_get_window = data_manager_perspective_get_window;
- iface->i_get_actions_group = data_manager_perspective_get_actions_group;
- iface->i_get_actions_ui = data_manager_perspective_get_actions_ui;
- iface->i_get_current_customization = data_manager_perspective_get_current_customization;
+ iface->i_customize = data_manager_perspective_customize;
+ iface->i_uncustomize = data_manager_perspective_uncustomize;
}
@@ -127,6 +123,7 @@ data_manager_perspective_init (DataManagerPerspective *perspective)
{
perspective->priv = g_new0 (DataManagerPerspectivePriv, 1);
perspective->priv->favorites_shown = TRUE;
+ perspective->priv->custom_parts = NULL;
gtk_orientable_set_orientation (GTK_ORIENTABLE (perspective), GTK_ORIENTATION_VERTICAL);
}
@@ -309,82 +306,105 @@ data_manager_perspective_dispose (GObject *object)
}
static void
-manager_new_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspective *bpers)
+manager_new_cb (G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *state, gpointer data)
{
+ /* @data is a DataManagerPerspective */
+ BrowserPerspective *bpers;
+ bpers = BROWSER_PERSPECTIVE (data);
add_new_data_console (bpers, -1);
}
static void
-favorites_toggle_cb (GtkToggleAction *action, BrowserPerspective *bpers)
+favorites_toggle_cb (GSimpleAction *action, GVariant *state, gpointer data)
{
+ /* @data is a DataManagerPerspective */
DataManagerPerspective *perspective;
- perspective = DATA_MANAGER_PERSPECTIVE (bpers);
+ perspective = DATA_MANAGER_PERSPECTIVE (data);
if (! perspective->priv->favorites)
return;
- perspective->priv->favorites_shown = gtk_toggle_action_get_active (action);
+ perspective->priv->favorites_shown = g_variant_get_boolean (state);
if (perspective->priv->favorites_shown)
gtk_widget_show (perspective->priv->favorites);
else
gtk_widget_hide (perspective->priv->favorites);
+ g_simple_action_set_state (action, state);
}
-static const GtkToggleActionEntry ui_toggle_actions [] =
-{
- { "DataManagerFavoritesShow", NULL, N_("_Show Favorites"), "F9", N_("Show or hide favorites"),
G_CALLBACK (favorites_toggle_cb), FALSE}
-};
-
-static GtkActionEntry ui_actions[] = {
- { "DataManagerMenu", NULL, N_("_Manager"), NULL, N_("Manager"), NULL },
- { "NewDataManager", GTK_STOCK_NEW, N_("_New Data Manager"), "<control>T", N_("New data manager"),
- G_CALLBACK (manager_new_cb)},
+static GActionEntry win_entries[] = {
+ { "show-favorites", NULL, NULL, "true", favorites_toggle_cb },
+ { "data-manager-new", manager_new_cb, NULL, NULL, NULL },
};
-static const gchar *ui_actions_info =
- "<ui>"
- " <menubar name='MenuBar'>"
- " <menu name='Display' action='Display'>"
- " <menuitem name='DataManagerFavoritesShow' action='DataManagerFavoritesShow'/>"
- " </menu>"
- " <placeholder name='MenuExtension'>"
- " <menu name='Data manager' action='DataManagerMenu'>"
- " <menuitem name='NewDataManager' action= 'NewDataManager'/>"
- " </menu>"
- " </placeholder>"
- " </menubar>"
- " <toolbar name='ToolBar'>"
- " <separator/>"
- " <toolitem action='NewDataManager'/>"
- " </toolbar>"
- "</ui>";
-
-static GtkActionGroup *
-data_manager_perspective_get_actions_group (BrowserPerspective *perspective)
+static void
+data_manager_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- GtkActionGroup *agroup;
- DataManagerPerspective *bpers;
- bpers = DATA_MANAGER_PERSPECTIVE (perspective);
- agroup = gtk_action_group_new ("DataManagerActions");
- gtk_action_group_set_translation_domain (agroup, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (agroup, ui_actions, G_N_ELEMENTS (ui_actions), 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, "DataManagerFavoritesShow");
- if (bpers->priv->favorites)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- bpers->priv->favorites_shown);
- else
- gtk_action_set_sensitive (GTK_ACTION (action), FALSE);
+ g_print ("%s ()\n", __FUNCTION__);
+ DataManagerPerspective *persp;
+ persp = DATA_MANAGER_PERSPECTIVE (perspective);
- return agroup;
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* add perspective's actions */
+ g_action_map_add_action_entries (G_ACTION_MAP (bwin),
+ win_entries, G_N_ELEMENTS (win_entries),
+ perspective);
+
+ g_assert (! persp->priv->custom_parts);
+ persp->priv->custom_parts = g_array_new (FALSE, FALSE, sizeof (gpointer));
+
+ /* add to toolbar */
+ GtkToolItem *titem;
+ titem = gtk_toggle_tool_button_new ();
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "user-bookmarks-symbolic");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Show favorites"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.show-favorites");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
+
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "tab-new-symbolic");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("New data manager tab"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.data-manager-new");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
}
-static const gchar *
-data_manager_perspective_get_actions_ui (G_GNUC_UNUSED BrowserPerspective *bpers)
+static void
+data_manager_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- return ui_actions_info;
+ g_print ("%s ()\n", __FUNCTION__);
+ DataManagerPerspective *persp;
+ persp = DATA_MANAGER_PERSPECTIVE (perspective);
+
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* remove perspective's actions */
+ guint i;
+ for (i = 0; i < G_N_ELEMENTS (win_entries); i++) {
+ GActionEntry *entry;
+ entry = &win_entries [i];
+ g_action_map_remove_action (G_ACTION_MAP (bwin), entry->name);
+ }
+
+ /* cleanups, headerbar and toolbar */
+ g_assert (persp->priv->custom_parts);
+ for (i = 0; i < persp->priv->custom_parts->len; i++) {
+ GObject *obj;
+ obj = g_array_index (persp->priv->custom_parts, GObject*, i);
+ if (GTK_IS_WIDGET (obj))
+ gtk_widget_destroy (GTK_WIDGET (obj));
+ else
+ g_warning ("Unknown type to uncustomize: %s\n", G_OBJECT_CLASS_NAME
(G_OBJECT_GET_CLASS (obj)));
+ }
+ g_array_free (persp->priv->custom_parts, TRUE);
+ persp->priv->custom_parts = NULL;
}
/**
@@ -420,27 +440,3 @@ data_manager_perspective_new_tab (DataManagerPerspective *dmp, const gchar *xml_
gtk_widget_grab_focus (page);
}
-static void
-data_manager_perspective_get_current_customization (BrowserPerspective *perspective,
- GtkActionGroup **out_agroup,
- const gchar **out_ui)
-{
- DataManagerPerspective *bpers;
- GtkWidget *page_contents;
-
- bpers = DATA_MANAGER_PERSPECTIVE (perspective);
- page_contents = gtk_notebook_get_nth_page (GTK_NOTEBOOK (bpers->priv->notebook),
- gtk_notebook_get_current_page (GTK_NOTEBOOK
(bpers->priv->notebook)));
- if (IS_BROWSER_PAGE (page_contents)) {
- *out_agroup = browser_page_get_actions_group (BROWSER_PAGE (page_contents));
- *out_ui = browser_page_get_actions_ui (BROWSER_PAGE (page_contents));
- }
-}
-
-static BrowserWindow *
-data_manager_perspective_get_window (BrowserPerspective *perspective)
-{
- DataManagerPerspective *bpers;
- bpers = DATA_MANAGER_PERSPECTIVE (perspective);
- return bpers->priv->bwin;
-}
diff --git a/tools/browser/data-manager/data-source.c b/tools/browser/data-manager/data-source.c
index 4ebe882..f6acf3f 100644
--- a/tools/browser/data-manager/data-source.c
+++ b/tools/browser/data-manager/data-source.c
@@ -2,7 +2,7 @@
* Copyright (C) 2010 Claude Paroz <claude 2xlibre net>
* Copyright (C) 2010 David King <davidk openismus com>
* Copyright (C) 2010 Murray Cumming <murrayc murrayc com>
- * Copyright (C) 2010 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2010 - 2015 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
@@ -30,8 +30,6 @@
#include "../ui-formgrid.h"
#include "common/t-errors.h"
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
#include "data-source.h"
#define DEFAULT_DATA_SOURCE_NAME "DataSource"
#define DEPENDENCY_SEPARATOR "<|>"
@@ -966,28 +964,7 @@ data_source_create_grid (DataSource *source)
GtkWidget *fg;
fg = ui_formgrid_new (source->priv->model, FALSE, GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS);
- /* add a refresh action */
- GtkUIManager *uimanager;
- GtkActionGroup *agroup;
- GtkAction *action;
- guint mid;
-
- agroup = gtk_action_group_new ("DSGroup");
- gtk_action_group_set_translation_domain (agroup, GETTEXT_PACKAGE);
- action = gtk_action_new ("Refresh", "Refresh",
- _("Refresh data"), GTK_STOCK_EXECUTE);
- gtk_action_group_add_action (agroup, action);
- g_signal_connect (G_OBJECT (action), "activate",
- G_CALLBACK (action_refresh_cb), source);
- g_object_unref (action);
- uimanager = ui_formgrid_get_ui_manager (UI_FORMGRID (fg));
- gtk_ui_manager_insert_action_group (uimanager, agroup, 0);
- g_object_unref (agroup);
-
- mid = gtk_ui_manager_new_merge_id (uimanager);
- gtk_ui_manager_add_ui (uimanager, mid, "/ToolBar/RowModifExtension", "Refresh", "Refresh",
- GTK_UI_MANAGER_AUTO, TRUE);
- gtk_ui_manager_ensure_update (uimanager);
+ ui_formgrid_set_refresh_func (UI_FORMGRID (fg), G_CALLBACK (action_refresh_cb), source);
return fg;
}
diff --git a/tools/browser/data-manager/perspective-main.c b/tools/browser/data-manager/perspective-main.c
index d6d56d2..2fa945c 100644
--- a/tools/browser/data-manager/perspective-main.c
+++ b/tools/browser/data-manager/perspective-main.c
@@ -3,7 +3,7 @@
* Copyright (C) 2001 - 2002 Rodrigo Moya <rodrigo gnome-db org>
* Copyright (C) 2003 Danilo Schoeneberg <dj starfire-programming net>
* Copyright (C) 2003 Laurent Sansonetti <lrz gnome org>
- * Copyright (C) 2005 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2005 - 2015 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
@@ -30,6 +30,7 @@ static BrowserPerspectiveFactory bfact;
BrowserPerspectiveFactory *
data_manager_perspective_get_factory (void)
{
+ bfact.id = "DataManP";
bfact.perspective_name = _("Data manager");
bfact.menu_shortcut ="<control>D";
bfact.perspective_create = data_manager_perspective_new;
diff --git a/tools/browser/dummy-perspective/Makefile.am b/tools/browser/dummy-perspective/Makefile.am
index 76e707c..46aa6f7 100644
--- a/tools/browser/dummy-perspective/Makefile.am
+++ b/tools/browser/dummy-perspective/Makefile.am
@@ -1,17 +1,46 @@
noinst_LTLIBRARIES = libperspective.la
AM_CPPFLAGS = \
+ -I$(top_srcdir)/tools \
+ -I$(top_srcdir)/tools/base \
+ -I$(top_srcdir)/tools/common \
-I$(top_srcdir)/tools/browser \
-I$(top_builddir) \
+ -I$(top_builddir)/libgda \
-I$(top_srcdir) \
-I$(top_srcdir)/libgda \
+ -I$(top_srcdir)/libgda/sqlite \
$(COREDEPS_CFLAGS) \
$(COREDEPS_WFLAGS) \
$(GTK_CFLAGS) \
$(MAC_INTEGRATION_CFLAGS)
+GENFILES = \
+ dummy-perspective.gresources.c \
+ dummy-perspective.gresources.h
+
+$(libperspective_la_OBJECTS): $(GENFILES)
+
libperspective_la_SOURCES = \
+ $(GENFILES) \
perspective-main.c \
perspective-main.h \
dummy-perspective.h \
dummy-perspective.c
+
+# resources
+RESOURCES=\
+ dummy-perspective.gresource.xml \
+ perspective-menus.ui
+
+dummy-perspective.gresources.c: $(RESOURCES)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=. --generate-source
$(srcdir)/dummy-perspective.gresource.xml
+
+dummy-perspective.gresources.h: $(RESOURCES)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=. --generate-header
$(srcdir)/dummy-perspective.gresource.xml
+
+EXTRA_DIST= \
+ $(RESOURCES)
+
+CLEANFILES = \
+ $(GENFILES)
diff --git a/tools/browser/dummy-perspective/dummy-perspective.c
b/tools/browser/dummy-perspective/dummy-perspective.c
index d55de9e..20deb8f 100644
--- a/tools/browser/dummy-perspective/dummy-perspective.c
+++ b/tools/browser/dummy-perspective/dummy-perspective.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2009 - 2015 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2010 David King <davidk openismus com>
* Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
*
@@ -21,9 +21,12 @@
#include <string.h>
#include <glib/gi18n-lib.h>
#include "dummy-perspective.h"
+#include "dummy-perspective.gresources.h"
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
+struct _DummyPerspectivePriv {
+ GArray *custom_parts;
+ gint custom_menu_pos;
+};
/*
* Main static functions
*/
@@ -33,9 +36,10 @@ static void dummy_perspective_dispose (GObject *object);
/* BrowserPerspective interface */
static void dummy_perspective_perspective_init (BrowserPerspectiveIface *iface);
-static BrowserWindow *dummy_perspective_get_window (BrowserPerspective *perspective);
-static GtkActionGroup *dummy_perspective_get_actions_group (BrowserPerspective *perspective);
-static const gchar *dummy_perspective_get_actions_ui (BrowserPerspective *perspective);
+static void dummy_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu
*menu);
+static void dummy_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu
*menu);
/* get a pointer to the parents to be able to call their destructor */
static GObjectClass *parent_class = NULL;
@@ -83,14 +87,16 @@ dummy_perspective_class_init (DummyPerspectiveClass * klass)
parent_class = g_type_class_peek_parent (klass);
object_class->dispose = dummy_perspective_dispose;
+
+ /* force loading of rerources */
+ dummy_perspective_get_resource ();
}
static void
dummy_perspective_perspective_init (BrowserPerspectiveIface *iface)
{
- iface->i_get_window = dummy_perspective_get_window;
- iface->i_get_actions_group = dummy_perspective_get_actions_group;
- iface->i_get_actions_ui = dummy_perspective_get_actions_ui;
+ iface->i_customize = dummy_perspective_customize;
+ iface->i_uncustomize = dummy_perspective_uncustomize;
}
@@ -99,6 +105,10 @@ dummy_perspective_init (DummyPerspective *perspective)
{
GtkWidget *wid;
+ perspective->priv = g_new0 (DummyPerspectivePriv, 1);
+ perspective->priv->custom_parts = NULL;
+ perspective->priv->custom_menu_pos = -1;
+
gtk_orientable_set_orientation (GTK_ORIENTABLE (perspective), GTK_ORIENTATION_VERTICAL);
wid = gtk_label_new ("");
@@ -115,10 +125,12 @@ dummy_perspective_init (DummyPerspective *perspective)
* Creates new #BrowserPerspective widget which
*/
BrowserPerspective *
-dummy_perspective_new (G_GNUC_UNUSED BrowserWindow *bwin)
+dummy_perspective_new (BrowserWindow *bwin)
{
BrowserPerspective *bpers;
bpers = (BrowserPerspective*) g_object_new (TYPE_DUMMY_PERSPECTIVE, NULL);
+ DummyPerspective *dpers;
+ dpers = (DummyPerspective *) bpers;
/* if there is a notebook to store pages, use:
browser_perspective_declare_notebook (bpers, GTK_NOTEBOOK (perspective->priv->notebook));
@@ -138,69 +150,141 @@ dummy_perspective_dispose (GObject *object)
perspective = DUMMY_PERSPECTIVE (object);
browser_perspective_declare_notebook ((BrowserPerspective*) perspective, NULL);
+ if (perspective->priv) {
+ g_free (perspective->priv);
+ perspective->priv = NULL;
+ }
/* parent class */
parent_class->dispose (object);
}
static void
-dummy_add_cb (G_GNUC_UNUSED GtkAction *action, G_GNUC_UNUSED BrowserPerspective *bpers)
+dummy1_cb (GSimpleAction *action, GVariant *state, gpointer data)
{
- g_print ("Add something...\n");
+ /* @data is a DummyPerspective */
+ if (g_variant_get_boolean (state))
+ g_print ("%s () called, checked\n", __FUNCTION__);
+ else
+ g_print ("%s () called, not checked\n", __FUNCTION__);
+ g_simple_action_set_state (action, state);
}
static void
-dummy_list_cb (G_GNUC_UNUSED GtkAction *action, G_GNUC_UNUSED BrowserPerspective *bpers)
+dummy2_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *state, gpointer data)
{
- g_print ("List something...\n");
+ /* @data is a DummyPerspective */
+ g_print ("%s () called\n", __FUNCTION__);
}
-static GtkActionEntry ui_actions[] = {
- { "DummyMenu", NULL, "_Dummy", NULL, "DummyMenu", NULL },
- { "DummyItem1", GTK_STOCK_ADD, "_Dummy Add", NULL, "Add something",
- G_CALLBACK (dummy_add_cb)},
- { "DummyItem2", GTK_STOCK_REMOVE, "_Dummy List", NULL, "List something",
- G_CALLBACK (dummy_list_cb)},
+static GActionEntry win_entries[] = {
+ { "dummy1", NULL, NULL, "false", dummy1_cb },
+ { "dummy2", dummy2_cb, NULL, NULL, NULL },
};
-static const gchar *ui_actions_info =
- "<ui>"
- " <menubar name='MenuBar'>"
- " <placeholder name='MenuExtension'>"
- " <menu name='Dummy' action='DummyMenu'>"
- " <menuitem name='DummyItem1' action= 'DummyItem1'/>"
- " <menuitem name='DummyItem2' action= 'DummyItem2'/>"
- " </menu>"
- " </placeholder>"
- " </menubar>"
- " <toolbar name='ToolBar'>"
- " <separator/>"
- " <toolitem action='DummyItem1'/>"
- " <toolitem action='DummyItem2'/>"
- " </toolbar>"
- "</ui>";
-
-static GtkActionGroup *
-dummy_perspective_get_actions_group (BrowserPerspective *bpers)
+static void
+dummy_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- GtkActionGroup *agroup;
- agroup = gtk_action_group_new ("DummyActions");
- gtk_action_group_set_translation_domain (agroup, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (agroup, ui_actions, G_N_ELEMENTS (ui_actions), bpers);
-
- return agroup;
-}
+ g_print ("%s ()\n", __FUNCTION__);
+ DummyPerspective *dpers;
+ dpers = DUMMY_PERSPECTIVE (perspective);
-static const gchar *
-dummy_perspective_get_actions_ui (G_GNUC_UNUSED BrowserPerspective *bpers)
-{
- return ui_actions_info;
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* add perspective's actions */
+ g_action_map_add_action_entries (G_ACTION_MAP (bwin),
+ win_entries, G_N_ELEMENTS (win_entries),
+ dpers);
+
+ g_assert (! dpers->priv->custom_parts);
+ dpers->priv->custom_parts = g_array_new (FALSE, FALSE, sizeof (gpointer));
+ g_assert (dpers->priv->custom_menu_pos == -1);
+
+ /* add menu */
+ GtkBuilder *builder;
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder, "/dummy-perspective/perspective-menus.ui", NULL);
+ GMenuModel *menumodel;
+ menumodel = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"));
+ dpers->priv->custom_menu_pos = g_menu_model_get_n_items (G_MENU_MODEL (menu));
+ g_menu_append_submenu (menu, "Dummy", menumodel);
+ g_object_unref (builder);
+
+ /* add to toolbar */
+ GtkToolItem *titem;
+ titem = gtk_toggle_tool_button_new ();
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "send-to-symbolic");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), "Dummy 1 option");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.dummy1");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (dpers->priv->custom_parts, titem);
+
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "process-stop-symbolic");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), "Dummy 2 action");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.dummy2");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (dpers->priv->custom_parts, titem);
+
+ /* add to header bar */
+ GtkWidget *img, *button;
+ button = gtk_menu_button_new ();
+ g_array_append_val (dpers->priv->custom_parts, button);
+ img = gtk_image_new_from_icon_name ("start-here-symbolic", GTK_ICON_SIZE_MENU);
+ gtk_button_set_image (GTK_BUTTON (button), img);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
+ gtk_widget_show_all (button);
+
+ GMenu *smenu;
+ smenu = g_menu_new ();
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (smenu));
+
+ GMenuItem *mitem;
+ mitem = g_menu_item_new ("Dummy 1", "win.dummy1");
+ g_menu_insert_item (smenu, -1, mitem);
+ mitem = g_menu_item_new ("Dummy 2", "win.dummy2");
+ g_menu_insert_item (smenu, -1, mitem);
}
-static BrowserWindow *
-dummy_perspective_get_window (BrowserPerspective *perspective)
+static void
+dummy_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- DummyPerspective *bpers;
- bpers = DUMMY_PERSPECTIVE (perspective);
- return NULL;/*bpers->priv->bwin;*/
+ g_print ("%s ()\n", __FUNCTION__);
+ DummyPerspective *dpers;
+ dpers = DUMMY_PERSPECTIVE (perspective);
+
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* remove perspective's actions */
+ guint i;
+ for (i = 0; i < G_N_ELEMENTS (win_entries); i++) {
+ GActionEntry *entry;
+ entry = &win_entries [i];
+ g_action_map_remove_action (G_ACTION_MAP (bwin), entry->name);
+ }
+
+ /* cleanups, headerbar and toolbar */
+ g_assert (dpers->priv->custom_parts);
+ for (i = 0; i < dpers->priv->custom_parts->len; i++) {
+ GObject *obj;
+ obj = g_array_index (dpers->priv->custom_parts, GObject*, i);
+ if (GTK_IS_WIDGET (obj))
+ gtk_widget_destroy (GTK_WIDGET (obj));
+ else
+ g_warning ("Unknown type to uncustomize: %s\n", G_OBJECT_CLASS_NAME
(G_OBJECT_GET_CLASS (obj)));
+ }
+ g_array_free (dpers->priv->custom_parts, TRUE);
+ dpers->priv->custom_parts = NULL;
+
+ /* cleanups, menu */
+ if (dpers->priv->custom_menu_pos >= 0) {
+ g_menu_remove (menu, dpers->priv->custom_menu_pos);
+ dpers->priv->custom_menu_pos = -1;
+ }
}
diff --git a/tools/browser/dummy-perspective/dummy-perspective.gresource.xml
b/tools/browser/dummy-perspective/dummy-perspective.gresource.xml
new file mode 100644
index 0000000..bb0dbff
--- /dev/null
+++ b/tools/browser/dummy-perspective/dummy-perspective.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/dummy-perspective">
+ <file compressed="yes">perspective-menus.ui</file>
+ </gresource>
+</gresources>
diff --git a/tools/browser/dummy-perspective/dummy-perspective.h
b/tools/browser/dummy-perspective/dummy-perspective.h
index 29621c9..2dfe0a6 100644
--- a/tools/browser/dummy-perspective/dummy-perspective.h
+++ b/tools/browser/dummy-perspective/dummy-perspective.h
@@ -33,17 +33,19 @@ G_BEGIN_DECLS
typedef struct _DummyPerspective DummyPerspective;
typedef struct _DummyPerspectiveClass DummyPerspectiveClass;
+typedef struct _DummyPerspectivePriv DummyPerspectivePriv;
/* struct for the object's data */
struct _DummyPerspective
{
- GtkBox object;
+ GtkBox object;
+ DummyPerspectivePriv *priv;
};
/* struct for the object's class */
struct _DummyPerspectiveClass
{
- GtkBoxClass parent_class;
+ GtkBoxClass parent_class;
};
GType dummy_perspective_get_type (void) G_GNUC_CONST;
diff --git a/tools/browser/dummy-perspective/perspective-main.c
b/tools/browser/dummy-perspective/perspective-main.c
index 638d1cb..f3f0c41 100644
--- a/tools/browser/dummy-perspective/perspective-main.c
+++ b/tools/browser/dummy-perspective/perspective-main.c
@@ -3,7 +3,7 @@
* Copyright (C) 2001 - 2002 Rodrigo Moya <rodrigo gnome-db org>
* Copyright (C) 2003 Danilo Schoeneberg <dj starfire-programming net>
* Copyright (C) 2003 Laurent Sansonetti <lrz gnome org>
- * Copyright (C) 2005 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2005 - 2015 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
@@ -30,8 +30,9 @@ static BrowserPerspectiveFactory bfact;
BrowserPerspectiveFactory *
dummy_perspective_get_factory (void)
{
+ bfact.id = "DummyP";
bfact.perspective_name = "Dummy Perspective";
- bfact.menu_shortcut = NULL;
+ bfact.menu_shortcut = "<control>z";
bfact.perspective_create = dummy_perspective_new;
return &bfact;
diff --git a/tools/browser/dummy-perspective/perspective-menus.ui
b/tools/browser/dummy-perspective/perspective-menus.ui
new file mode 100644
index 0000000..d2d0f8d
--- /dev/null
+++ b/tools/browser/dummy-perspective/perspective-menus.ui
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<interface>
+ <menu id='menubar'>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>Dummy 1 option</attribute>
+ <attribute name='action'>win.dummy1</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>Dummy 2 action</attribute>
+ <attribute name='action'>win.dummy2</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/tools/browser/ldap-browser/Makefile.am b/tools/browser/ldap-browser/Makefile.am
index 9c5cb3d..eeeae6e 100644
--- a/tools/browser/ldap-browser/Makefile.am
+++ b/tools/browser/ldap-browser/Makefile.am
@@ -17,9 +17,14 @@ marshal.h: marshal.list $(GLIB_GENMARSHAL)
marshal.c: marshal.list $(GLIB_GENMARSHAL) marshal.h
$(GLIB_GENMARSHAL) $< --body --prefix=_ldap_marshal > $@
-libperspective_la_SOURCES = \
+GENFILES = \
marshal.c \
- marshal.h \
+ marshal.h
+
+$(libperspective_la_OBJECTS): $(GENFILES)
+
+libperspective_la_SOURCES = \
+ $(GENFILES) \
perspective-main.h \
perspective-main.c \
ldap-browser-perspective.h \
@@ -55,5 +60,4 @@ EXTRA_DIST = \
marshal.list
CLEANFILES = \
- marshal.h \
- marshal.c
+ $(GENFILES)
diff --git a/tools/browser/ldap-browser/ldap-browser-perspective.c
b/tools/browser/ldap-browser/ldap-browser-perspective.c
index 9486583..f84c1d4 100644
--- a/tools/browser/ldap-browser/ldap-browser-perspective.c
+++ b/tools/browser/ldap-browser/ldap-browser-perspective.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
- * Copyright (C) 2011 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2011 - 2015 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
@@ -28,8 +28,6 @@
#include "../browser-page.h"
#include "ldap-favorite-selector.h"
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
/*
* Main static functions
*/
@@ -39,13 +37,10 @@ static void ldap_browser_perspective_dispose (GObject *object);
/* BrowserPerspective interface */
static void ldap_browser_perspective_perspective_init (BrowserPerspectiveIface *iface);
-static BrowserWindow *ldap_browser_perspective_get_window (BrowserPerspective *perspective);
-static GtkActionGroup *ldap_browser_perspective_get_actions_group (BrowserPerspective *perspective);
-static const gchar *ldap_browser_perspective_get_actions_ui (BrowserPerspective *perspective);
-static void ldap_browser_perspective_page_tab_label_change (BrowserPerspective *perspective,
BrowserPage *page);
-static void ldap_browser_perspective_get_current_customization (BrowserPerspective
*perspective,
- GtkActionGroup **out_agroup,
- const gchar **out_ui);
+static void ldap_browser_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header,
GMenu *menu);
+static void ldap_browser_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header,
GMenu *menu);
/* get a pointer to the parents to be able to call their destructor */
static GObjectClass *parent_class = NULL;
@@ -55,6 +50,8 @@ struct _LdapBrowserPerspectivePrivate {
GtkWidget *favorites;
gboolean favorites_shown;
BrowserWindow *bwin;
+
+ GArray *custom_parts;
};
GType
@@ -105,11 +102,8 @@ ldap_browser_perspective_class_init (LdapBrowserPerspectiveClass * klass)
static void
ldap_browser_perspective_perspective_init (BrowserPerspectiveIface *iface)
{
- iface->i_get_window = ldap_browser_perspective_get_window;
- iface->i_get_actions_group = ldap_browser_perspective_get_actions_group;
- iface->i_get_actions_ui = ldap_browser_perspective_get_actions_ui;
- iface->i_page_tab_label_change = ldap_browser_perspective_page_tab_label_change;
- iface->i_get_current_customization = ldap_browser_perspective_get_current_customization;
+ iface->i_customize = ldap_browser_perspective_customize;
+ iface->i_uncustomize = ldap_browser_perspective_uncustomize;
}
@@ -118,6 +112,7 @@ ldap_browser_perspective_init (LdapBrowserPerspective *perspective)
{
perspective->priv = g_new0 (LdapBrowserPerspectivePrivate, 1);
perspective->priv->favorites_shown = TRUE;
+ perspective->priv->custom_parts = NULL;
gtk_orientable_set_orientation (GTK_ORIENTABLE (perspective), GTK_ORIENTATION_VERTICAL);
}
@@ -220,26 +215,29 @@ ldap_browser_perspective_dispose (GObject *object)
}
static void
-favorites_toggle_cb (GtkToggleAction *action, BrowserPerspective *bpers)
+favorites_toggle_cb (GSimpleAction *action, GVariant *state, gpointer data)
{
+ /* @data is a LdapBrowserPerspective */
LdapBrowserPerspective *perspective;
- perspective = LDAP_BROWSER_PERSPECTIVE (bpers);
- perspective->priv->favorites_shown = gtk_toggle_action_get_active (action);
+ perspective = LDAP_BROWSER_PERSPECTIVE (data);
+ perspective->priv->favorites_shown = g_variant_get_boolean (state);
if (perspective->priv->favorites_shown)
gtk_widget_show (perspective->priv->favorites);
else
gtk_widget_hide (perspective->priv->favorites);
+ g_simple_action_set_state (action, state);
}
static void
-ldab_ldap_entries_page_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspective *bpers)
+ldab_ldap_entries_page_add_cb (G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *state, gpointer
data)
{
+ /* @data is a LdapBrowserPerspective */
GtkWidget *page, *tlabel, *button;
LdapBrowserPerspective *perspective;
TConnection *tcnc;
gint i;
- perspective = LDAP_BROWSER_PERSPECTIVE (bpers);
+ perspective = LDAP_BROWSER_PERSPECTIVE (data);
tcnc = browser_window_get_connection (perspective->priv->bwin);
page = ldap_entries_page_new (tcnc, NULL);
@@ -262,14 +260,15 @@ ldab_ldap_entries_page_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspecti
}
static void
-ldab_ldap_classes_page_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspective *bpers)
+ldab_ldap_classes_page_add_cb (G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *state, gpointer
data)
{
+ /* @data is a LdapBrowserPerspective */
GtkWidget *page, *tlabel, *button;
LdapBrowserPerspective *perspective;
TConnection *tcnc;
gint i;
- perspective = LDAP_BROWSER_PERSPECTIVE (bpers);
+ perspective = LDAP_BROWSER_PERSPECTIVE (data);
tcnc = browser_window_get_connection (perspective->priv->bwin);
page = ldap_classes_page_new (tcnc, NULL);
@@ -292,14 +291,15 @@ ldab_ldap_classes_page_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspecti
}
static void
-ldab_search_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspective *bpers)
+ldab_search_add_cb (G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *state, gpointer data)
{
+ /* @data is a LdapBrowserPerspective */
GtkWidget *page, *tlabel, *button;
LdapBrowserPerspective *perspective;
TConnection *tcnc;
gint i;
- perspective = LDAP_BROWSER_PERSPECTIVE (bpers);
+ perspective = LDAP_BROWSER_PERSPECTIVE (data);
tcnc = browser_window_get_connection (perspective->priv->bwin);
i = gtk_notebook_get_current_page (GTK_NOTEBOOK (perspective->priv->notebook));
@@ -328,87 +328,109 @@ ldab_search_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspective *bpers)
gtk_widget_grab_focus (page);
}
-static const GtkToggleActionEntry ui_toggle_actions [] =
- {
- { "LdapTFavoritesShow", NULL, N_("_Show Favorites"), "F9", N_("Show or hide favorites"),
G_CALLBACK (favorites_toggle_cb), FALSE }
- };
-
-static GtkActionEntry ui_actions[] = {
- { "LDAP", NULL, N_("_LDAP"), NULL, N_("LDAP"), NULL },
- { "LdapLdapEntriesPageNew", /*BROWSER_STOCK_LDAP_ENTRIES*/ NULL, N_("_New LDAP Entries Browser"),
"<control>T", N_("Open a new LDAP entries browser"),
- G_CALLBACK (ldab_ldap_entries_page_add_cb)},
- { "LdapLdapClassesPageNew", NULL, N_("_New LDAP Classes Browser"), "<control>C", N_("Open a new LDAP
classes browser"),
- G_CALLBACK (ldab_ldap_classes_page_add_cb)},
- { "LdapSearchNew", GTK_STOCK_FIND, N_("_New LDAP Search"), "<control>G", N_("Open a new LDAP search
form"),
- G_CALLBACK (ldab_search_add_cb)},
+static GActionEntry win_entries[] = {
+ { "show-favorites", NULL, NULL, "true", favorites_toggle_cb },
+ { "entries-page-new", ldab_ldap_entries_page_add_cb, NULL, NULL, NULL },
+ { "classes-page-new", ldab_ldap_classes_page_add_cb, NULL, NULL, NULL },
+ { "search-page-new", ldab_search_add_cb, NULL, NULL, NULL },
};
-static const gchar *ui_actions_info =
- "<ui>"
- " <menubar name='MenuBar'>"
- " <menu name='Display' action='Display'>"
- " <menuitem name='LdapTFavoritesShow' action='LdapTFavoritesShow'/>"
- " </menu>"
- " <placeholder name='MenuExtension'>"
- " <menu name='LDAP' action='LDAP'>"
- " <menuitem name='LdapSearchNew' action= 'LdapSearchNew'/>"
- " <menuitem name='LdapLdapEntriesPageNew' action= 'LdapLdapEntriesPageNew'/>"
- " <menuitem name='LdapLdapClassesPageNew' action= 'LdapLdapClassesPageNew'/>"
- " </menu>"
- " </placeholder>"
- " </menubar>"
- " <toolbar name='ToolBar'>"
- " <separator/>"
- " <toolitem action='LdapSearchNew'/>"
- " <toolitem action='LdapLdapEntriesPageNew'/>"
- " </toolbar>"
- "</ui>";
-
-static GtkActionGroup *
-ldap_browser_perspective_get_actions_group (BrowserPerspective *bpers)
+static void
+ldap_browser_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- GtkActionGroup *agroup;
- agroup = gtk_action_group_new ("LdapBrowserActions");
- gtk_action_group_set_translation_domain (agroup, GETTEXT_PACKAGE);
-
- gtk_action_group_add_actions (agroup, ui_actions, G_N_ELEMENTS (ui_actions), 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, "LdapTFavoritesShow");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- LDAP_BROWSER_PERSPECTIVE (bpers)->priv->favorites_shown);
-
- return agroup;
-}
+ g_print ("%s ()\n", __FUNCTION__);
+ LdapBrowserPerspective *persp;
+ persp = LDAP_BROWSER_PERSPECTIVE (perspective);
-static const gchar *
-ldap_browser_perspective_get_actions_ui (G_GNUC_UNUSED BrowserPerspective *bpers)
-{
- return ui_actions_info;
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* add perspective's actions */
+ g_action_map_add_action_entries (G_ACTION_MAP (bwin),
+ win_entries, G_N_ELEMENTS (win_entries),
+ perspective);
+
+ g_assert (! persp->priv->custom_parts);
+ persp->priv->custom_parts = g_array_new (FALSE, FALSE, sizeof (gpointer));
+
+ /* add to toolbar */
+ GtkToolItem *titem;
+ titem = gtk_toggle_tool_button_new ();
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "user-bookmarks-symbolic");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Show favorites"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.show-favorites");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
+
+ GdkPixbuf *pix;
+ GtkWidget *img;
+ pix = ui_get_pixbuf_icon (UI_ICON_LDAP_ORGANIZATION);
+ img = gtk_image_new_from_pixbuf (pix);
+ gtk_widget_show (img);
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (titem), img);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("New LDAP entries tab"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.entries-page-new");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
+
+ pix = ui_get_pixbuf_icon (UI_ICON_LDAP_CLASS_STRUCTURAL);
+ img = gtk_image_new_from_pixbuf (pix);
+ gtk_widget_show (img);
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (titem), img);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("New LDAP classes tab"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.classes-page-new");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
+
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "edit-find");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("New LDAP search tab"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.search-page-new");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
}
static void
-ldap_browser_perspective_page_tab_label_change (BrowserPerspective *perspective, BrowserPage *page)
+ldap_browser_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- LdapBrowserPerspective *bpers;
- GtkWidget *tab_label;
- GtkWidget *close_btn;
-
- bpers = LDAP_BROWSER_PERSPECTIVE (perspective);
- tab_label = browser_page_get_tab_label (page, &close_btn);
- if (tab_label) {
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (bpers->priv->notebook),
- GTK_WIDGET (page), tab_label);
- g_signal_connect (close_btn, "clicked",
- G_CALLBACK (close_button_clicked_cb), page);
-
- tab_label = browser_page_get_tab_label (page, NULL);
- gtk_notebook_set_menu_label (GTK_NOTEBOOK (bpers->priv->notebook),
- GTK_WIDGET (page), tab_label);
+ g_print ("%s ()\n", __FUNCTION__);
+ LdapBrowserPerspective *persp;
+ persp = LDAP_BROWSER_PERSPECTIVE (perspective);
+
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* remove perspective's actions */
+ guint i;
+ for (i = 0; i < G_N_ELEMENTS (win_entries); i++) {
+ GActionEntry *entry;
+ entry = &win_entries [i];
+ g_action_map_remove_action (G_ACTION_MAP (bwin), entry->name);
}
+
+ /* cleanups, headerbar and toolbar */
+ g_assert (persp->priv->custom_parts);
+ for (i = 0; i < persp->priv->custom_parts->len; i++) {
+ GObject *obj;
+ obj = g_array_index (persp->priv->custom_parts, GObject*, i);
+ if (GTK_IS_WIDGET (obj))
+ gtk_widget_destroy (GTK_WIDGET (obj));
+ else
+ g_warning ("Unknown type to uncustomize: %s\n", G_OBJECT_CLASS_NAME
(G_OBJECT_GET_CLASS (obj)));
+ }
+ g_array_free (persp->priv->custom_parts, TRUE);
+ persp->priv->custom_parts = NULL;
}
+
/**
* ldap_browser_perspective_display_ldap_entry
*
@@ -506,28 +528,3 @@ ldap_browser_perspective_display_ldap_class (LdapBrowserPerspective *bpers, cons
TRUE);
}
}
-
-static void
-ldap_browser_perspective_get_current_customization (BrowserPerspective *perspective,
- GtkActionGroup **out_agroup,
- const gchar **out_ui)
-{
- LdapBrowserPerspective *bpers;
- GtkWidget *page_contents;
-
- bpers = LDAP_BROWSER_PERSPECTIVE (perspective);
- page_contents = gtk_notebook_get_nth_page (GTK_NOTEBOOK (bpers->priv->notebook),
- gtk_notebook_get_current_page (GTK_NOTEBOOK
(bpers->priv->notebook)));
- if (IS_BROWSER_PAGE (page_contents)) {
- *out_agroup = browser_page_get_actions_group (BROWSER_PAGE (page_contents));
- *out_ui = browser_page_get_actions_ui (BROWSER_PAGE (page_contents));
- }
-}
-
-static BrowserWindow *
-ldap_browser_perspective_get_window (BrowserPerspective *perspective)
-{
- LdapBrowserPerspective *bpers;
- bpers = LDAP_BROWSER_PERSPECTIVE (perspective);
- return bpers->priv->bwin;
-}
diff --git a/tools/browser/ldap-browser/perspective-main.c b/tools/browser/ldap-browser/perspective-main.c
index c637e1d..e3320ea 100644
--- a/tools/browser/ldap-browser/perspective-main.c
+++ b/tools/browser/ldap-browser/perspective-main.c
@@ -3,7 +3,7 @@
* Copyright (C) 2001 - 2002 Rodrigo Moya <rodrigo gnome-db org>
* Copyright (C) 2003 Danilo Schoeneberg <dj starfire-programming net>
* Copyright (C) 2003 Laurent Sansonetti <lrz gnome org>
- * Copyright (C) 2005 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2005 - 2015 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
@@ -30,6 +30,7 @@ static BrowserPerspectiveFactory bfact;
BrowserPerspectiveFactory *
ldap_browser_perspective_get_factory (void)
{
+ bfact.id = "LDAPBrP";
bfact.perspective_name = _("LDAP browser");
bfact.menu_shortcut = "<control>P";
bfact.perspective_create = ldap_browser_perspective_new;
diff --git a/tools/browser/query-exec/Makefile.am b/tools/browser/query-exec/Makefile.am
index f49221d..38b3a44 100644
--- a/tools/browser/query-exec/Makefile.am
+++ b/tools/browser/query-exec/Makefile.am
@@ -21,9 +21,14 @@ marshal.h: marshal.list $(GLIB_GENMARSHAL)
marshal.c: marshal.list $(GLIB_GENMARSHAL) marshal.h
$(GLIB_GENMARSHAL) $< --body --prefix=_qe_marshal > $@
+GENFILES = \
+ marshal.c \
+ marshal.h
+
+$(libperspective_la_OBJECTS): $(GENFILES)
+
libperspective_la_SOURCES = \
- marshal.c \
- marshal.h \
+ $(GENFILES) \
query-console-page.c \
query-console-page.h \
query-editor.c \
@@ -44,5 +49,4 @@ EXTRA_DIST= \
marshal.list
CLEANFILES = \
- marshal.h \
- marshal.c
+ $(GENFILES)
diff --git a/tools/browser/query-exec/perspective-main.c b/tools/browser/query-exec/perspective-main.c
index e2aec5e..6c62e24 100644
--- a/tools/browser/query-exec/perspective-main.c
+++ b/tools/browser/query-exec/perspective-main.c
@@ -3,7 +3,7 @@
* Copyright (C) 2001 - 2002 Rodrigo Moya <rodrigo gnome-db org>
* Copyright (C) 2003 Danilo Schoeneberg <dj starfire-programming net>
* Copyright (C) 2003 Laurent Sansonetti <lrz gnome org>
- * Copyright (C) 2005 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2005 - 2015 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
@@ -30,6 +30,7 @@ static BrowserPerspectiveFactory bfact;
BrowserPerspectiveFactory *
query_exec_perspective_get_factory (void)
{
+ bfact.id = "QueryExecP";
bfact.perspective_name = _("Query execution (SQL)");
bfact.menu_shortcut = "<control>S";
bfact.perspective_create = query_exec_perspective_new;
diff --git a/tools/browser/query-exec/query-exec-perspective.c
b/tools/browser/query-exec/query-exec-perspective.c
index d9c74dc..a816f11 100644
--- a/tools/browser/query-exec/query-exec-perspective.c
+++ b/tools/browser/query-exec/query-exec-perspective.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2009 - 2015 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2010 David King <davidk openismus com>
* Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
*
@@ -29,8 +29,6 @@
#include "query-editor.h"
#include <libgda/gda-debug-macros.h>
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
/*
* Main static functions
*/
@@ -39,19 +37,14 @@ static void query_exec_perspective_init (QueryExecPerspective *stmt);
static void query_exec_perspective_dispose (GObject *object);
static void query_exec_perspective_grab_focus (GtkWidget *widget);
-static void query_exec_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspective *bpers);
-
+static void query_exec_new_cb (G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *state, gpointer
data);
/* BrowserPerspective interface */
static void query_exec_perspective_perspective_init (BrowserPerspectiveIface *iface);
-static BrowserWindow *query_exec_perspective_get_window (BrowserPerspective *perspective);
-static GtkActionGroup *query_exec_perspective_get_actions_group (BrowserPerspective *perspective);
-static const gchar *query_exec_perspective_get_actions_ui (BrowserPerspective *perspective);
-static void query_exec_perspective_get_current_customization (BrowserPerspective
*perspective,
- GtkActionGroup **out_agroup,
- const gchar **out_ui);
-static void query_exec_perspective_page_tab_label_change (BrowserPerspective *perspective,
BrowserPage *page);
-
+static void query_exec_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header,
GMenu *menu);
+static void query_exec_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header,
GMenu *menu);
/* get a pointer to the parents to be able to call their destructor */
static GObjectClass *parent_class = NULL;
@@ -62,6 +55,8 @@ struct _QueryExecPerspectivePrivate {
gboolean favorites_shown;
BrowserWindow *bwin;
TConnection *tcnc;
+
+ GArray *custom_parts;
};
GType
@@ -122,11 +117,8 @@ query_exec_perspective_grab_focus (GtkWidget *widget)
static void
query_exec_perspective_perspective_init (BrowserPerspectiveIface *iface)
{
- iface->i_get_window = query_exec_perspective_get_window;
- iface->i_get_actions_group = query_exec_perspective_get_actions_group;
- iface->i_get_actions_ui = query_exec_perspective_get_actions_ui;
- iface->i_get_current_customization = query_exec_perspective_get_current_customization;
- iface->i_page_tab_label_change = query_exec_perspective_page_tab_label_change;
+ iface->i_customize = query_exec_perspective_customize;
+ iface->i_uncustomize = query_exec_perspective_uncustomize;
}
static void
@@ -221,7 +213,7 @@ fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gint fav_id,
nb = GTK_NOTEBOOK (perspective->priv->notebook);
page = gtk_notebook_get_nth_page (nb, gtk_notebook_get_current_page (nb));
if (!page) {
- query_exec_add_cb (NULL, BROWSER_PERSPECTIVE (perspective));
+ query_exec_new_cb (NULL, NULL, BROWSER_PERSPECTIVE (perspective));
page = gtk_notebook_get_nth_page (nb, gtk_notebook_get_current_page (nb));
if (!page)
return;
@@ -265,14 +257,15 @@ query_exec_perspective_dispose (GObject *object)
}
static void
-query_exec_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspective *bpers)
+query_exec_new_cb (G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *state, gpointer data)
{
+ /* @data is a QueryExecPerspective */
GtkWidget *page, *tlabel, *button;
QueryExecPerspective *perspective;
TConnection *tcnc;
gint i;
- perspective = QUERY_EXEC_PERSPECTIVE (bpers);
+ perspective = QUERY_EXEC_PERSPECTIVE (data);
tcnc = perspective->priv->tcnc;
page = query_console_page_new (tcnc);
@@ -296,121 +289,94 @@ query_exec_add_cb (G_GNUC_UNUSED GtkAction *action, BrowserPerspective *bpers)
}
static void
-favorites_toggle_cb (GtkToggleAction *action, BrowserPerspective *bpers)
+favorites_toggle_cb (GSimpleAction *action, GVariant *state, gpointer data)
{
+ /* @data is a QueryExecPerspective */
QueryExecPerspective *perspective;
- perspective = QUERY_EXEC_PERSPECTIVE (bpers);
+ perspective = QUERY_EXEC_PERSPECTIVE (data);
if (!perspective->priv->favorites)
return;
- perspective->priv->favorites_shown = gtk_toggle_action_get_active (action);
+ perspective->priv->favorites_shown = g_variant_get_boolean (state);
if (perspective->priv->favorites_shown)
gtk_widget_show (perspective->priv->favorites);
else
gtk_widget_hide (perspective->priv->favorites);
+ g_simple_action_set_state (action, state);
}
-static const GtkToggleActionEntry ui_toggle_actions [] =
-{
- { "QueryExecFavoritesShow", NULL, N_("_Show Favorites"), "F9", N_("Show or hide favorites"),
G_CALLBACK (favorites_toggle_cb), FALSE }
+static GActionEntry win_entries[] = {
+ { "show-favorites", NULL, NULL, "true", favorites_toggle_cb },
+ { "query-exec-new", query_exec_new_cb, NULL, NULL, NULL },
};
-static GtkActionEntry ui_actions[] = {
- { "QueryExecMenu", NULL, N_("_Query"), NULL, N_("Query"), NULL },
- { "QueryExecItem1", GTK_STOCK_MISSING_IMAGE, N_("_New Editor"), "<control>T", N_("Open a new query
editor"),
- G_CALLBACK (query_exec_add_cb)},
-};
-
-static const gchar *ui_actions_info =
- "<ui>"
- " <menubar name='MenuBar'>"
- " <menu name='Display' action='Display'>"
- " <menuitem name='QueryExecFavoritesShow' action='QueryExecFavoritesShow'/>"
- " </menu>"
- " <placeholder name='MenuExtension'>"
- " <menu name='QueryExec' action='QueryExecMenu'>"
- " <menuitem name='QueryExecItem1' action= 'QueryExecItem1'/>"
- " </menu>"
- " </placeholder>"
- " </menubar>"
- " <toolbar name='ToolBar'>"
- " <separator/>"
- " <toolitem action='QueryExecItem1'/>"
- " </toolbar>"
- "</ui>";
-
-static GtkActionGroup *
-query_exec_perspective_get_actions_group (BrowserPerspective *perspective)
+static void
+query_exec_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- QueryExecPerspective *bpers;
- GtkActionGroup *agroup;
- bpers = QUERY_EXEC_PERSPECTIVE (perspective);
- agroup = gtk_action_group_new ("QueryExecActions");
- gtk_action_group_set_translation_domain (agroup, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (agroup, ui_actions, G_N_ELEMENTS (ui_actions), 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, "QueryExecFavoritesShow");
- if (bpers->priv->favorites)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- bpers->priv->favorites_shown);
- else
- gtk_action_set_sensitive (GTK_ACTION (action), FALSE);
-
- return agroup;
-}
+ g_print ("%s ()\n", __FUNCTION__);
+ QueryExecPerspective *persp;
+ persp = QUERY_EXEC_PERSPECTIVE (perspective);
-static const gchar *
-query_exec_perspective_get_actions_ui (G_GNUC_UNUSED BrowserPerspective *perspective)
-{
- return ui_actions_info;
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* add perspective's actions */
+ g_action_map_add_action_entries (G_ACTION_MAP (bwin),
+ win_entries, G_N_ELEMENTS (win_entries),
+ perspective);
+
+ g_assert (! persp->priv->custom_parts);
+ persp->priv->custom_parts = g_array_new (FALSE, FALSE, sizeof (gpointer));
+
+ /* add to toolbar */
+ GtkToolItem *titem;
+ titem = gtk_toggle_tool_button_new ();
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "user-bookmarks-symbolic");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Show favorites"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.show-favorites");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
+
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "tab-new-symbolic");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("New query execution tab"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.query-exec-new");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
}
static void
-query_exec_perspective_page_tab_label_change (BrowserPerspective *perspective, BrowserPage *page)
+query_exec_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- QueryExecPerspective *bpers;
- GtkWidget *tab_label;
- GtkWidget *close_btn;
-
- bpers = QUERY_EXEC_PERSPECTIVE (perspective);
- tab_label = browser_page_get_tab_label (page, &close_btn);
- if (tab_label) {
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (bpers->priv->notebook),
- GTK_WIDGET (page), tab_label);
- g_signal_connect (close_btn, "clicked",
- G_CALLBACK (close_button_clicked_cb), page);
-
- tab_label = browser_page_get_tab_label (page, NULL);
- gtk_notebook_set_menu_label (GTK_NOTEBOOK (bpers->priv->notebook),
- GTK_WIDGET (page), tab_label);
- }
-}
+ g_print ("%s ()\n", __FUNCTION__);
+ QueryExecPerspective *persp;
+ persp = QUERY_EXEC_PERSPECTIVE (perspective);
-static void
-query_exec_perspective_get_current_customization (BrowserPerspective *perspective,
- GtkActionGroup **out_agroup,
- const gchar **out_ui)
-{
- QueryExecPerspective *bpers;
- GtkWidget *page_contents;
-
- bpers = QUERY_EXEC_PERSPECTIVE (perspective);
- page_contents = gtk_notebook_get_nth_page (GTK_NOTEBOOK (bpers->priv->notebook),
- gtk_notebook_get_current_page (GTK_NOTEBOOK
(bpers->priv->notebook)));
- if (IS_BROWSER_PAGE (page_contents)) {
- *out_agroup = browser_page_get_actions_group (BROWSER_PAGE (page_contents));
- *out_ui = browser_page_get_actions_ui (BROWSER_PAGE (page_contents));
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* remove perspective's actions */
+ guint i;
+ for (i = 0; i < G_N_ELEMENTS (win_entries); i++) {
+ GActionEntry *entry;
+ entry = &win_entries [i];
+ g_action_map_remove_action (G_ACTION_MAP (bwin), entry->name);
}
-}
-static BrowserWindow *
-query_exec_perspective_get_window (BrowserPerspective *perspective)
-{
- QueryExecPerspective *bpers;
- bpers = QUERY_EXEC_PERSPECTIVE (perspective);
- return bpers->priv->bwin;
+ /* cleanups, headerbar and toolbar */
+ g_assert (persp->priv->custom_parts);
+ for (i = 0; i < persp->priv->custom_parts->len; i++) {
+ GObject *obj;
+ obj = g_array_index (persp->priv->custom_parts, GObject*, i);
+ if (GTK_IS_WIDGET (obj))
+ gtk_widget_destroy (GTK_WIDGET (obj));
+ else
+ g_warning ("Unknown type to uncustomize: %s\n", G_OBJECT_CLASS_NAME
(G_OBJECT_GET_CLASS (obj)));
+ }
+ g_array_free (persp->priv->custom_parts, TRUE);
+ persp->priv->custom_parts = NULL;
}
diff --git a/tools/browser/query-exec/query-result.c b/tools/browser/query-exec/query-result.c
index 2d96070..c0e6770 100644
--- a/tools/browser/query-exec/query-result.c
+++ b/tools/browser/query-exec/query-result.c
@@ -27,8 +27,6 @@
#include "../ui-formgrid.h"
#include "marshal.h"
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
struct _QueryResultPrivate {
QueryEditor *history;
@@ -389,28 +387,7 @@ make_widget_for_data_model (GdaDataModel *model, QueryResult *qres, const gchar
ui_formgrid_handle_user_prefs (UI_FORMGRID (grid), tcnc, stmt);
g_object_unref (stmt);
- GtkUIManager *uimanager;
- GtkActionGroup *agroup;
- GtkAction *action;
- guint mid;
-
- agroup = gtk_action_group_new ("QueryResultGroup");
- gtk_action_group_set_translation_domain (agroup, GETTEXT_PACKAGE);
- action = gtk_action_new ("Refresh", "Refresh",
- _("Re-execute query"),
- GTK_STOCK_EXECUTE);
- gtk_action_group_add_action (agroup, action);
- g_signal_connect (G_OBJECT (action), "activate",
- G_CALLBACK (action_refresh_cb), qres);
- g_object_unref (action);
- uimanager = ui_formgrid_get_ui_manager (UI_FORMGRID (grid));
- gtk_ui_manager_insert_action_group (uimanager, agroup, 0);
- g_object_unref (agroup);
-
- mid = gtk_ui_manager_new_merge_id (uimanager);
- gtk_ui_manager_add_ui (uimanager, mid, "/ToolBar/RowModifExtension", "Refresh", "Refresh",
- GTK_UI_MANAGER_AUTO, TRUE);
- gtk_ui_manager_ensure_update (uimanager);
+ ui_formgrid_set_refresh_func (UI_FORMGRID (grid), G_CALLBACK (action_refresh_cb), qres);
}
out:
return grid;
diff --git a/tools/browser/schema-browser/Makefile.am b/tools/browser/schema-browser/Makefile.am
index ebad86e..ddc50a3 100644
--- a/tools/browser/schema-browser/Makefile.am
+++ b/tools/browser/schema-browser/Makefile.am
@@ -25,7 +25,14 @@ marshal.h: marshal.list $(GLIB_GENMARSHAL)
marshal.c: marshal.list $(GLIB_GENMARSHAL) marshal.h
$(GLIB_GENMARSHAL) $< --body --prefix=_sb_marshal > $@
+GENFILES = \
+ marshal.c \
+ marshal.h
+
+$(libperspective_la_OBJECTS): $(GENFILES)
+
libperspective_la_SOURCES = \
+ $(GENFILES) \
marshal.c \
marshal.h \
perspective-main.h \
@@ -59,5 +66,4 @@ EXTRA_DIST = \
marshal.list
CLEANFILES = \
- marshal.h \
- marshal.c
+ $(GENFILES)
diff --git a/tools/browser/schema-browser/perspective-main.c b/tools/browser/schema-browser/perspective-main.c
index fbb69b5..d470d91 100644
--- a/tools/browser/schema-browser/perspective-main.c
+++ b/tools/browser/schema-browser/perspective-main.c
@@ -3,7 +3,7 @@
* Copyright (C) 2001 - 2002 Rodrigo Moya <rodrigo gnome-db org>
* Copyright (C) 2003 Danilo Schoeneberg <dj starfire-programming net>
* Copyright (C) 2003 Laurent Sansonetti <lrz gnome org>
- * Copyright (C) 2005 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2005 - 2015 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
@@ -30,6 +30,7 @@ static BrowserPerspectiveFactory bfact;
BrowserPerspectiveFactory *
schema_browser_perspective_get_factory (void)
{
+ bfact.id = "SchBrowP";
bfact.perspective_name = _("Schema browser");
bfact.menu_shortcut = "<control>B";
bfact.perspective_create = schema_browser_perspective_new;
diff --git a/tools/browser/schema-browser/schema-browser-perspective.c
b/tools/browser/schema-browser/schema-browser-perspective.c
index 8363faa..4bfc152 100644
--- a/tools/browser/schema-browser/schema-browser-perspective.c
+++ b/tools/browser/schema-browser/schema-browser-perspective.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2009 - 2015 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2010 David King <davidk openismus com>
* Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
*
@@ -32,8 +32,6 @@
#endif
#include <libgda/gda-debug-macros.h>
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
/*
* Main static functions
*/
@@ -43,13 +41,10 @@ static void schema_browser_perspective_dispose (GObject *object);
/* BrowserPerspective interface */
static void schema_browser_perspective_perspective_init (BrowserPerspectiveIface *iface);
-static BrowserWindow *schema_browser_perspective_get_window (BrowserPerspective *perspective);
-static GtkActionGroup *schema_browser_perspective_get_actions_group (BrowserPerspective *perspective);
-static const gchar *schema_browser_perspective_get_actions_ui (BrowserPerspective *perspective);
-static void schema_browser_perspective_page_tab_label_change (BrowserPerspective
*perspective, BrowserPage *page);
-static void schema_browser_perspective_get_current_customization (BrowserPerspective
*perspective,
- GtkActionGroup **out_agroup,
- const gchar **out_ui);
+static void schema_browser_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header,
GMenu *menu);
+static void schema_browser_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar
*header, GMenu *menu);
/* get a pointer to the parents to be able to call their destructor */
static GObjectClass *parent_class = NULL;
@@ -59,6 +54,8 @@ struct _SchemaBrowserPerspectivePrivate {
GtkWidget *favorites;
gboolean favorites_shown;
BrowserWindow *bwin;
+
+ GArray *custom_parts;
};
GType
@@ -109,11 +106,8 @@ schema_browser_perspective_class_init (SchemaBrowserPerspectiveClass * klass)
static void
schema_browser_perspective_perspective_init (BrowserPerspectiveIface *iface)
{
- iface->i_get_window = schema_browser_perspective_get_window;
- iface->i_get_actions_group = schema_browser_perspective_get_actions_group;
- iface->i_get_actions_ui = schema_browser_perspective_get_actions_ui;
- iface->i_page_tab_label_change = schema_browser_perspective_page_tab_label_change;
- iface->i_get_current_customization = schema_browser_perspective_get_current_customization;
+ iface->i_customize = schema_browser_perspective_customize;
+ iface->i_uncustomize = schema_browser_perspective_uncustomize;
}
@@ -122,6 +116,7 @@ schema_browser_perspective_init (SchemaBrowserPerspective *perspective)
{
perspective->priv = g_new0 (SchemaBrowserPerspectivePrivate, 1);
perspective->priv->favorites_shown = TRUE;
+ perspective->priv->custom_parts = NULL;
gtk_orientable_set_orientation (GTK_ORIENTABLE (perspective), GTK_ORIENTATION_VERTICAL);
}
@@ -283,108 +278,113 @@ schema_browser_perspective_dispose (GObject *object)
#ifdef HAVE_GOOCANVAS
static void
-action_create_diagram_cb (G_GNUC_UNUSED GtkAction *action, SchemaBrowserPerspective *bpers)
+action_diagram_new_cb (G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *state, gpointer data)
{
- schema_browser_perspective_display_diagram (bpers, -1);
+ /* @data is a SchemaBrowserPerspective */
+ SchemaBrowserPerspective *perspective;
+ perspective = SCHEMA_BROWSER_PERSPECTIVE (data);
+ schema_browser_perspective_display_diagram (perspective, -1);
}
#endif
static void
-favorites_toggle_cb (GtkToggleAction *action, BrowserPerspective *bpers)
+favorites_toggle_cb (GSimpleAction *action, GVariant *state, gpointer data)
{
+ /* @data is a SchemaBrowserPerspective */
SchemaBrowserPerspective *perspective;
- perspective = SCHEMA_BROWSER_PERSPECTIVE (bpers);
+ perspective = SCHEMA_BROWSER_PERSPECTIVE (data);
if (! perspective->priv->favorites)
return;
- perspective->priv->favorites_shown = gtk_toggle_action_get_active (action);
+ perspective->priv->favorites_shown = g_variant_get_boolean (state);
if (perspective->priv->favorites_shown)
gtk_widget_show (perspective->priv->favorites);
else
gtk_widget_hide (perspective->priv->favorites);
+ g_simple_action_set_state (action, state);
}
-static const GtkToggleActionEntry ui_toggle_actions [] =
-{
- { "SchemaTFavoritesShow", NULL, N_("_Show Favorites"), "F9", N_("Show or hide favorites"),
G_CALLBACK (favorites_toggle_cb), FALSE }
-};
-
-static GtkActionEntry ui_actions[] = {
+static GActionEntry win_entries[] = {
+ { "show-favorites", NULL, NULL, "true", favorites_toggle_cb },
#ifdef HAVE_GOOCANVAS
- { "Schema", NULL, N_("_Schema"), NULL, N_("Schema"), NULL },
- { "NewDiagram", GTK_STOCK_ADD, N_("_New Diagram"), NULL, N_("Create a new diagram"),
- G_CALLBACK (action_create_diagram_cb)},
+ { "action-diagram-new", action_diagram_new_cb, NULL, NULL, NULL },
#endif
};
-static const gchar *ui_actions_info =
- "<ui>"
- " <menubar name='MenuBar'>"
- " <menu name='Display' action='Display'>"
- " <menuitem name='SchemaTFavoritesShow' action='SchemaTFavoritesShow'/>"
- " </menu>"
-#ifdef HAVE_GOOCANVAS
- " <placeholder name='MenuExtension'>"
- " <menu name='Schema' action='Schema'>"
- " <menuitem name='NewDiagram' action= 'NewDiagram'/>"
- " </menu>"
- " </placeholder>"
-#endif
- " </menubar>"
- "</ui>";
-
-static GtkActionGroup *
-schema_browser_perspective_get_actions_group (BrowserPerspective *perspective)
+static void
+schema_browser_perspective_customize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- SchemaBrowserPerspective *bpers;
- GtkActionGroup *agroup;
- bpers = SCHEMA_BROWSER_PERSPECTIVE (perspective);
- agroup = gtk_action_group_new ("SchemaBrowserActions");
- gtk_action_group_set_translation_domain (agroup, GETTEXT_PACKAGE);
-
- gtk_action_group_add_actions (agroup, ui_actions, G_N_ELEMENTS (ui_actions), 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, "SchemaTFavoritesShow");
- if (bpers->priv->favorites)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- bpers->priv->favorites_shown);
- else
- gtk_action_set_sensitive (GTK_ACTION (action), FALSE);
+ g_print ("%s ()\n", __FUNCTION__);
+ SchemaBrowserPerspective *persp;
+ persp = SCHEMA_BROWSER_PERSPECTIVE (perspective);
- return agroup;
-}
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* add perspective's actions */
+ g_action_map_add_action_entries (G_ACTION_MAP (bwin),
+ win_entries, G_N_ELEMENTS (win_entries),
+ perspective);
+
+ g_assert (! persp->priv->custom_parts);
+ persp->priv->custom_parts = g_array_new (FALSE, FALSE, sizeof (gpointer));
+
+ /* add to toolbar */
+ GtkToolItem *titem;
+ titem = gtk_toggle_tool_button_new ();
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "user-bookmarks-symbolic");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Show favorites"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.show-favorites");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
-static const gchar *
-schema_browser_perspective_get_actions_ui (G_GNUC_UNUSED BrowserPerspective *bpers)
-{
- return ui_actions_info;
+#ifdef HAVE_GOOCANVAS
+ titem = gtk_tool_button_new (NULL, NULL);
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "tab-new-symbolic");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Create a new diagram"));
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.action-diagram-new");
+ gtk_widget_show (GTK_WIDGET (titem));
+ g_array_append_val (persp->priv->custom_parts, titem);
+#endif
}
static void
-schema_browser_perspective_page_tab_label_change (BrowserPerspective *perspective, BrowserPage *page)
+schema_browser_perspective_uncustomize (BrowserPerspective *perspective,
+ GtkToolbar *toolbar, GtkHeaderBar *header, GMenu *menu)
{
- SchemaBrowserPerspective *bpers;
- GtkWidget *tab_label;
- GtkWidget *close_btn;
-
- bpers = SCHEMA_BROWSER_PERSPECTIVE (perspective);
- tab_label = browser_page_get_tab_label (page, &close_btn);
- if (tab_label) {
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (bpers->priv->notebook),
- GTK_WIDGET (page), tab_label);
- g_signal_connect (close_btn, "clicked",
- G_CALLBACK (close_button_clicked_cb), page);
-
- tab_label = browser_page_get_tab_label (page, NULL);
- gtk_notebook_set_menu_label (GTK_NOTEBOOK (bpers->priv->notebook),
- GTK_WIDGET (page), tab_label);
+ g_print ("%s ()\n", __FUNCTION__);
+ SchemaBrowserPerspective *persp;
+ persp = SCHEMA_BROWSER_PERSPECTIVE (perspective);
+
+ BrowserWindow *bwin;
+ bwin = browser_perspective_get_window (perspective);
+
+ /* remove perspective's actions */
+ guint i;
+ for (i = 0; i < G_N_ELEMENTS (win_entries); i++) {
+ GActionEntry *entry;
+ entry = &win_entries [i];
+ g_action_map_remove_action (G_ACTION_MAP (bwin), entry->name);
+ }
+
+ /* cleanups, headerbar and toolbar */
+ g_assert (persp->priv->custom_parts);
+ for (i = 0; i < persp->priv->custom_parts->len; i++) {
+ GObject *obj;
+ obj = g_array_index (persp->priv->custom_parts, GObject*, i);
+ if (GTK_IS_WIDGET (obj))
+ gtk_widget_destroy (GTK_WIDGET (obj));
+ else
+ g_warning ("Unknown type to uncustomize: %s\n", G_OBJECT_CLASS_NAME
(G_OBJECT_GET_CLASS (obj)));
}
+ g_array_free (persp->priv->custom_parts, TRUE);
+ persp->priv->custom_parts = NULL;
}
+
#ifdef HAVE_GOOCANVAS
/**
* schema_browser_perspective_display_diagram
@@ -499,28 +499,3 @@ schema_browser_perspective_display_table_info (SchemaBrowserPerspective *bpers,
TRUE);
}
}
-
-static void
-schema_browser_perspective_get_current_customization (BrowserPerspective *perspective,
- GtkActionGroup **out_agroup,
- const gchar **out_ui)
-{
- SchemaBrowserPerspective *bpers;
- GtkWidget *page_contents;
-
- bpers = SCHEMA_BROWSER_PERSPECTIVE (perspective);
- page_contents = gtk_notebook_get_nth_page (GTK_NOTEBOOK (bpers->priv->notebook),
- gtk_notebook_get_current_page (GTK_NOTEBOOK
(bpers->priv->notebook)));
- if (IS_BROWSER_PAGE (page_contents)) {
- *out_agroup = browser_page_get_actions_group (BROWSER_PAGE (page_contents));
- *out_ui = browser_page_get_actions_ui (BROWSER_PAGE (page_contents));
- }
-}
-
-static BrowserWindow *
-schema_browser_perspective_get_window (BrowserPerspective *perspective)
-{
- SchemaBrowserPerspective *bpers;
- bpers = SCHEMA_BROWSER_PERSPECTIVE (perspective);
- return bpers->priv->bwin;
-}
diff --git a/tools/browser/ui-formgrid.c b/tools/browser/ui-formgrid.c
index d4041f6..41d9df1 100644
--- a/tools/browser/ui-formgrid.c
+++ b/tools/browser/ui-formgrid.c
@@ -30,13 +30,10 @@
#include "widget-overlay.h"
#include <libgda/gda-data-model-extra.h>
#include "../common/t-favorites-actions.h"
-#undef HAVE_LDAP /* FIXME */
#ifdef HAVE_LDAP
- #include "../ldap-browser/ldap-browser-perspective.h" FIXME
+ #include "ldap-browser/ldap-browser-perspective.h"
#endif
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
static void ui_formgrid_class_init (UiFormGridClass * class);
static void ui_formgrid_init (UiFormGrid *wid);
static void ui_formgrid_dispose (GObject *object);
@@ -65,26 +62,31 @@ typedef enum {
struct _UiFormGridPriv
{
- GtkWidget *nb;
- GtkWidget *raw_form;
- GtkWidget *raw_grid;
- GtkWidget *info;
- GtkWidget *overlay_form;
- GtkWidget *overlay_grid;
- GtkWidget *autoupdate_toggle;
- gboolean autoupdate;
- gboolean autoupdate_possible;
+ GtkWidget *nb;
+ GtkWidget *raw_form;
+ GtkWidget *raw_grid;
+ GtkWidget *info;
+ GtkWidget *overlay_form;
+ GtkWidget *overlay_grid;
+ GtkWidget *autoupdate_toggle;
+ gboolean autoupdate;
+ gboolean autoupdate_possible;
GdauiDataProxyInfoFlag flags;
- TConnection *tcnc;
- gboolean scroll_form;
+ TConnection *tcnc;
+ gboolean scroll_form;
+
+ /* refresh handling */
+ GCallback refresh_callback;
+ gpointer refresh_user_data;
+ GtkWidget *refresh_button;
/* modifications to the data */
- gboolean compute_mod_stmt; /* if %TRUE, then the INSERT, UPDATE and DELETE
- * statements are automatically computed, see the PROP_AUTOMOD
property */
- gboolean mod_stmt_auto_computed; /* %TRUE if mod_stmt[*] have automatically
- * been computed */
- GdaStatement *mod_stmt[MOD_LAST];
+ gboolean compute_mod_stmt; /* if %TRUE, then the INSERT, UPDATE and DELETE
+ * statements are automatically computed, see the PROP_AUTOMOD
property */
+ gboolean mod_stmt_auto_computed; /* %TRUE if mod_stmt[*] have automatically
+ * been computed */
+ GdaStatement *mod_stmt[MOD_LAST];
};
/* get a pointer to the parents to be able to call their destructor */
@@ -288,7 +290,7 @@ ui_formgrid_show (GtkWidget *widget)
}
static void form_grid_autoupdate_cb (GtkToggleButton *button, UiFormGrid *formgrid);
-static void form_grid_toggled_cb (GtkToggleAction *action, UiFormGrid *formgrid);
+static void form_grid_toggled_cb (GtkToggleToolButton *button, UiFormGrid *formgrid);
static void form_grid_populate_popup_cb (GtkWidget *wid, GtkMenu *menu, UiFormGrid *formgrid);
static void selection_changed_cb (GdauiDataSelector *sel, UiFormGrid *formgrid);
@@ -308,6 +310,9 @@ ui_formgrid_init (UiFormGrid *formgrid)
formgrid->priv->scroll_form = FALSE;
formgrid->priv->compute_mod_stmt = FALSE;
+ formgrid->priv->refresh_callback = NULL;
+ formgrid->priv->refresh_user_data = NULL;
+
gtk_orientable_set_orientation (GTK_ORIENTABLE (formgrid), GTK_ORIENTATION_VERTICAL);
/* notebook */
@@ -352,40 +357,20 @@ ui_formgrid_init (UiFormGrid *formgrid)
GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
GDAUI_DATA_PROXY_INFO_CHUNCK_CHANGE_BUTTONS);
- GtkUIManager *uimanager;
- GtkActionGroup *agroup;
- GtkAction *action;
- guint mid;
-
- g_object_get (G_OBJECT (formgrid->priv->info), "ui-manager", &uimanager, NULL);
- agroup = gtk_action_group_new ("FormGrid");
- gtk_action_group_set_translation_domain (agroup, GETTEXT_PACKAGE);
-
- action = GTK_ACTION (gtk_toggle_action_new ("FGToggle", "FGToggle",
- _("Toggle between grid and form presentations"),
- GTK_STOCK_MISSING_IMAGE));
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
- gtk_action_group_add_action (agroup, action);
- g_signal_connect (G_OBJECT (action), "toggled",
+ button = GTK_WIDGET (gtk_toggle_tool_button_new ());
+ gtk_widget_set_tooltip_text (button, _("Toggle between grid and form presentations"));
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (button), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (formgrid->priv->info), GTK_TOOL_ITEM (button), 0);
+ gtk_widget_show (button);
+ g_signal_connect (button, "toggled",
G_CALLBACK (form_grid_toggled_cb), formgrid);
- g_object_unref (action);
- gtk_ui_manager_insert_action_group (uimanager, agroup, 0);
- g_object_unref (agroup);
-
- mid = gtk_ui_manager_new_merge_id (uimanager);
- gtk_ui_manager_add_ui (uimanager, mid, "/ToolBar", "FGToggle", "FGToggle",
- GTK_UI_MANAGER_AUTO, TRUE);
- gtk_ui_manager_ensure_update (uimanager);
- gtk_box_pack_start (GTK_BOX (hbox), formgrid->priv->info, TRUE, TRUE, 0);
- gtk_widget_show (formgrid->priv->info);
- g_object_unref (G_OBJECT (uimanager));
-
-
- /*gchar *tmp;
- g_object_get (uimanager, "ui", &tmp, NULL);
- g_print ("==>[%s]\n", tmp);
- g_free (tmp);
- */
+
+ /* refresh button, don't show it yet */
+ button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL));
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "view-refresh-symbolic");
+ gtk_widget_set_tooltip_text (button, _("Refresh data"));
+ gtk_toolbar_insert (GTK_TOOLBAR (formgrid->priv->info), GTK_TOOL_ITEM (button), 0);
+ formgrid->priv->refresh_button = button;
/* keep data in sync */
g_signal_connect (formgrid->priv->raw_grid, "selection-changed",
@@ -394,21 +379,6 @@ ui_formgrid_init (UiFormGrid *formgrid)
G_CALLBACK (selection_changed_cb), formgrid);
}
-/**
- * ui_formgrid_get_ui_manager:
- *
- * Returns: (transfer none): the #GtkUIManager
- */
-GtkUIManager *
-ui_formgrid_get_ui_manager (UiFormGrid *formgrid)
-{
- GtkUIManager *uimanager;
- g_return_val_if_fail (UI_IS_FORMGRID (formgrid), NULL);
- g_object_get (G_OBJECT (formgrid->priv->info), "ui-manager", &uimanager, NULL);
- g_object_unref (uimanager);
- return uimanager;
-}
-
static void
selection_changed_cb (GdauiDataSelector *sel, UiFormGrid *formgrid)
{
@@ -439,16 +409,14 @@ form_grid_autoupdate_cb (GtkToggleButton *button, UiFormGrid *formgrid)
}
static void
-form_grid_toggled_cb (GtkToggleAction *action, UiFormGrid *formgrid)
+form_grid_toggled_cb (GtkToggleToolButton *button, UiFormGrid *formgrid)
{
- if (!gtk_toggle_action_get_active (action)) {
+ if (!gtk_toggle_tool_button_get_active (button)) {
/* switch to form view */
gtk_notebook_set_current_page (GTK_NOTEBOOK (formgrid->priv->nb), 1);
g_object_set (G_OBJECT (formgrid->priv->info),
"data-proxy", formgrid->priv->raw_form,
"flags", formgrid->priv->flags | FORM_FLAGS, NULL);
-
- g_object_set (G_OBJECT (action), "stock-id", GTK_STOCK_MISSING_IMAGE, NULL);
}
else {
/* switch to grid view */
@@ -456,8 +424,6 @@ form_grid_toggled_cb (GtkToggleAction *action, UiFormGrid *formgrid)
g_object_set (G_OBJECT (formgrid->priv->info),
"data-proxy", formgrid->priv->raw_grid,
"flags", formgrid->priv->flags | GRID_FLAGS, NULL);
-
- g_object_set (G_OBJECT (action), "stock-id", GTK_STOCK_MISSING_IMAGE, NULL);
}
}
@@ -1142,3 +1108,35 @@ compute_modification_statements (UiFormGrid *formgrid, GdaDataModel *model)
}
*/
}
+
+/**
+ * ui_formgrid_set_refresh_func:
+ * @formgrid: a #UiFormGrid widget
+ * @callback: (allow-none): a callback, or %NULL
+ * @user_data: (allow-none): a pointer passed to the @callback function, or %NULL
+ *
+ * If @callback is not %NULL, then a "Refresh" button is added to @formgrid which, when clicked,
+ * calls @callback.
+ *
+ * If @callback is %NULL, then the "Refresh" button (if there was any) is removed.
+ */
+void
+ui_formgrid_set_refresh_func (UiFormGrid *formgrid, GCallback callback, gpointer user_data)
+{
+ g_return_if_fail (UI_IS_FORMGRID (formgrid));
+
+ if (formgrid->priv->refresh_callback)
+ g_signal_handlers_disconnect_by_func (formgrid->priv->refresh_button,
+ formgrid->priv->refresh_callback,
+ formgrid->priv->refresh_user_data);
+
+ formgrid->priv->refresh_user_data = user_data;
+ formgrid->priv->refresh_callback = callback;
+ if (formgrid->priv->refresh_callback) {
+ g_signal_connect (formgrid->priv->refresh_button, "clicked",
+ formgrid->priv->refresh_callback, formgrid->priv->refresh_user_data);
+ gtk_widget_show (formgrid->priv->refresh_button);
+ }
+ else
+ gtk_widget_hide (formgrid->priv->refresh_button);
+}
diff --git a/tools/browser/ui-formgrid.h b/tools/browser/ui-formgrid.h
index 3ed87eb..23e1ef4 100644
--- a/tools/browser/ui-formgrid.h
+++ b/tools/browser/ui-formgrid.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2010 - 2015 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
*
* This program is free software; you can redistribute it and/or
@@ -50,6 +50,7 @@ struct _UiFormGrid
struct _UiFormGridClass
{
GtkBoxClass parent_class;
+
/* signals */
void (*data_set_changed) (UiFormGrid *fg);
};
@@ -76,7 +77,7 @@ void ui_formgrid_set_sample_size (UiFormGrid *formgrid, gint sa
GdauiRawGrid *ui_formgrid_get_grid_widget (UiFormGrid *formgrid);
void ui_formgrid_set_connection (UiFormGrid *formgrid, TConnection *bcnc);
-GtkUIManager *ui_formgrid_get_ui_manager (UiFormGrid *formgrid);
+void ui_formgrid_set_refresh_func (UiFormGrid *formgrid, GCallback callback, gpointer
user_data);
G_END_DECLS
diff --git a/tools/browser/ui-support.c b/tools/browser/ui-support.c
index e145d18..2d0bdfc 100644
--- a/tools/browser/ui-support.c
+++ b/tools/browser/ui-support.c
@@ -270,7 +270,7 @@ ui_show_help (GtkWindow *parent, const gchar *topic)
if (strchr (lang, '.'))
continue;
- uri = gda_gbr_get_file_path (GDA_DATA_DIR, "gnome", "help", "gda-browser", lang, NULL);
+ uri = gda_gbr_get_file_path (GDA_DATA_DIR, "help", lang, "gda-browser", NULL);
/*g_print ("TST URI [%s]\n", uri);*/
if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
@@ -291,9 +291,10 @@ ui_show_help (GtkWindow *parent, const gchar *topic)
uri = NULL;
}
/*g_print ("URI [%s]\n", uri);*/
- if (uri == NULL) {
- ui_show_error (NULL, _("Unable to display help. Please make sure the "
- "documentation package is installed."));
+
+ if (!uri) {
+ ui_show_error (parent, _("Unable to display help. Please make sure the "
+ "documentation package is installed."));
return;
}
@@ -317,11 +318,6 @@ ui_show_help (GtkWindow *parent, const gchar *topic)
g_error_free (error);
}
- else if (BROWSER_IS_WINDOW (parent))
- browser_window_show_notice (BROWSER_WINDOW (parent), GTK_MESSAGE_INFO,
- "show-help", _("Help is being loaded, please wait..."));
- else
- ui_show_message (parent, "%s", _("Help is being loaded, please wait..."));
g_free (uri);
}
@@ -412,7 +408,7 @@ ui_make_small_button (gboolean is_toggle, gboolean with_arrow,
}
if (with_arrow) {
GtkWidget *arrow;
- arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
+ arrow = gtk_image_new_from_icon_name ("go-next-symbolic", GTK_ICON_SIZE_MENU);
gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0);
gtk_widget_set_halign (arrow, GTK_ALIGN_END);
gtk_widget_set_valign (arrow, GTK_ALIGN_CENTER);
@@ -542,7 +538,7 @@ static const gchar *fnames[] = {
"-non-connected-big.png",
"-non-connected.png",
- ".png",
+ "-table.png",
"-view.png"
*/
};
diff --git a/tools/browser/ui-support.h b/tools/browser/ui-support.h
index 4c75b57..9c6ff03 100644
--- a/tools/browser/ui-support.h
+++ b/tools/browser/ui-support.h
@@ -60,7 +60,7 @@ GtkWidget *ui_make_tab_label_with_pixbuf (const gchar *label,
GtkWidget **out_close_button);
/*
- * icons, see browser_get_pixbuf_icon() for the associated icons
+ * icons, use with ui_get_pixbuf_icon() for the associated icons
*/
typedef enum {
UI_ICON_BOOKMARK,
diff --git a/tools/common/t-app.c b/tools/common/t-app.c
index 5b544c7..fdbef6b 100644
--- a/tools/common/t-app.c
+++ b/tools/common/t-app.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2014 - 2015 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
@@ -312,10 +312,7 @@ idle_create_window (GApplication *app)
GtkWidget *bwin;
bwin = (GtkWidget*) browser_window_new (tcnc, NULL);
- gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (bwin), FALSE);
gtk_window_set_default_size ((GtkWindow*) bwin, 640, 480);
-#define PRGNAME "Gda Browser"
- gtk_window_set_title (GTK_WINDOW (bwin), PRGNAME);
gtk_widget_show (bwin);
g_application_release (app); /* release now that the 1st window has been created, cf.
t_app_add_feature() where
@@ -537,6 +534,7 @@ t_app_add_tcnc (TConnection *tcnc)
gboolean
t_app_open_connections (gint argc, const gchar *argv[], GError **error)
{
+ g_assert (argc >= 0);
#ifdef HAVE_GTK_CLASSES
if (argc == 0) {
LoginDialog *dlg;
@@ -569,8 +567,8 @@ t_app_open_connections (gint argc, const gchar *argv[], GError **error)
if (term_console)
ostream = t_context_get_output_stream (term_console, NULL);
- gint i;
- for (i = 0; i < argc; i++) {
+ guint i;
+ for (i = 0; i < (guint) argc; i++) {
/* open connection */
TConnection *tcnc;
GdaDsnInfo *info = NULL;
@@ -581,7 +579,7 @@ t_app_open_connections (gint argc, const gchar *argv[], GError **error)
if (info)
str = g_strdup (info->name);
else
- str = g_strdup_printf ("c%d", i);
+ str = g_strdup_printf (T_CNC_NAME_PREFIX "%u", i);
if (!ostream) {
gchar *params, *prov, *user;
gda_connection_string_split (argv[i], ¶ms, &prov, &user, NULL);
diff --git a/tools/common/t-app.h b/tools/common/t-app.h
index 2917438..549ba92 100644
--- a/tools/common/t-app.h
+++ b/tools/common/t-app.h
@@ -82,6 +82,11 @@ void t_app_setup (TAppFeatures features);
void t_app_add_feature (TAppFeatures feature);
void t_app_remove_feature (TAppFeatures feature);
+#ifdef HAVE_GTK_CLASSES
+GMenu *t_app_get_app_menu (void);
+GMenu *t_app_get_win_menu (void);
+#endif
+
void t_app_cleanup (void);
TApp *t_app_get (void);
void t_app_request_quit (void);
diff --git a/tools/common/t-connection.c b/tools/common/t-connection.c
index f74d7c9..2d2f7fd 100644
--- a/tools/common/t-connection.c
+++ b/tools/common/t-connection.c
@@ -104,7 +104,8 @@ static GObjectClass *parent_class = NULL;
/* properties */
enum {
PROP_0,
- PROP_GDA_CNC
+ PROP_GDA_CNC,
+ PROP_NAME
};
GType
@@ -213,6 +214,10 @@ t_connection_class_init (TConnectionClass *klass)
GDA_TYPE_CONNECTION,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_NAME,
+ g_param_spec_string ("name", NULL, "Connection's name",
+ NULL,
+ G_PARAM_WRITABLE | G_PARAM_READABLE));
object_class->dispose = t_connection_dispose;
}
@@ -224,7 +229,7 @@ t_connection_init (TConnection *tcnc)
tcnc->priv = g_new0 (TConnectionPrivate, 1);
tcnc->priv->executed_statements = NULL;
- tcnc->priv->name = g_strdup_printf (_("c%u"), index++);
+ tcnc->priv->name = g_strdup_printf (T_CNC_NAME_PREFIX "%u", index++);
tcnc->priv->cnc = NULL;
tcnc->priv->parser = NULL;
tcnc->priv->variables = NULL;
@@ -411,8 +416,6 @@ t_connection_set_property (GObject *object,
if (!tcnc->priv->cnc)
return;
- /*g_print ("TConnection %p [%s], wrapper %p, GdaConnection %p\n",
- tcnc, tcnc->priv->name, tcnc->priv->wrapper, tcnc->priv->cnc);*/
g_object_ref (tcnc->priv->cnc);
g_object_set (G_OBJECT (tcnc->priv->cnc), "execution-timer", TRUE, NULL);
g_signal_connect (tcnc->priv->cnc, "status-changed",
@@ -439,6 +442,15 @@ t_connection_set_property (GObject *object,
g_free (tmp);
}
break;
+ case PROP_NAME: {
+ const gchar *name;
+ name = g_value_get_string (value);
+ if (name && *name) {
+ g_free (tcnc->priv->name);
+ tcnc->priv->name = g_strdup (name);
+ }
+ break;
+ }
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -462,6 +474,9 @@ t_connection_get_property (GObject *object,
case PROP_GDA_CNC:
g_value_set_object (value, tcnc->priv->cnc);
break;
+ case PROP_NAME:
+ g_value_set_string (value, tcnc->priv->name);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -874,7 +889,6 @@ t_connection_open (const gchar *cnc_name, const gchar *cnc_string, const gchar *
g_free (real_auth_string);
if (newcnc) {
- const gchar *rootname;
gint i;
g_object_set (G_OBJECT (newcnc), "execution-timer", TRUE, NULL);
g_object_set (newcnc, "execution-slowdown", 2000000, NULL);
@@ -882,25 +896,23 @@ t_connection_open (const gchar *cnc_name, const gchar *cnc_string, const gchar *
tcnc = t_connection_new (newcnc);
g_object_unref (newcnc);
- if (cnc_name && *cnc_name)
+ if (cnc_name && *cnc_name) {
+ const gchar *rootname;
rootname = cnc_name;
- else
- rootname = "c";
- if (t_connection_get_by_name (rootname)) {
- for (i = 1; ; i++) {
- gchar *tmp;
- tmp = g_strdup_printf ("%s%d", rootname, i);
- if (t_connection_get_by_name (tmp))
- g_free (tmp);
- else {
- t_connection_set_name (tcnc, tmp);
- g_free (tmp);
- break;
+ if (t_connection_get_by_name (rootname)) {
+ for (i = 1; ; i++) {
+ gchar *tmp;
+ tmp = g_strdup_printf ("%s%d", rootname, i);
+ if (t_connection_get_by_name (tmp))
+ g_free (tmp);
+ else {
+ t_connection_set_name (tcnc, tmp);
+ g_free (tmp);
+ break;
+ }
}
}
}
- else
- t_connection_set_name (tcnc, rootname);
/* show date format */
GDateDMY order[3];
@@ -1026,9 +1038,7 @@ void
t_connection_set_name (TConnection *tcnc, const gchar *name)
{
g_return_if_fail (T_IS_CONNECTION (tcnc));
- g_return_if_fail (name && *name);
- g_free (tcnc->priv->name);
- tcnc->priv->name = g_strdup (name);
+ g_object_set (tcnc, "name", name, NULL);
}
/**
@@ -1045,10 +1055,35 @@ t_connection_get_name (TConnection *tcnc)
}
/**
+ * t_connection_get_information:
+ * @tcnc: a #TConnection
+ *
+ * Get the information about @tcnc as a string.
+ *
+ * Returns: a new string
+ */
+const gchar *
+t_connection_get_information (TConnection *tcnc)
+{
+ g_return_val_if_fail (T_IS_CONNECTION (tcnc), NULL);
+ GString *title;
+ title = g_string_new ("");
+ const GdaDsnInfo *dsn;
+ dsn = t_connection_get_dsn_information (tcnc);
+ if (dsn) {
+ if (dsn->name)
+ g_string_append_printf (title, "%s '%s'", _("Data source"), dsn->name);
+ if (dsn->provider)
+ g_string_append_printf (title, " (%s)", dsn->provider);
+ }
+ return g_string_free (title, FALSE);
+}
+
+/**
* t_connection_get_long_name:
* @tcnc: a #TConnection
*
- * Get the "long" name of @tcnc
+ * Get the "long" name of @tcnc, in the form "Connection <name>, <data source or provider>"
*
* Returns: a new string
*/
@@ -1060,7 +1095,7 @@ t_connection_get_long_name (TConnection *tcnc)
const GdaDsnInfo *dsn;
GString *title;
- dsn = t_connection_get_information (tcnc);
+ dsn = t_connection_get_dsn_information (tcnc);
cncname = t_connection_get_name (tcnc);
title = g_string_new (_("Connection"));
g_string_append (title, " ");
@@ -1075,7 +1110,7 @@ t_connection_get_long_name (TConnection *tcnc)
}
/**
- * t_connection_get_information
+ * t_connection_get_dsn_information
* @tcnc: a #TConnection
*
* Get some information about the connection
@@ -1083,7 +1118,7 @@ t_connection_get_long_name (TConnection *tcnc)
* Returns: a pointer to the associated #GdaDsnInfo
*/
const GdaDsnInfo *
-t_connection_get_information (TConnection *tcnc)
+t_connection_get_dsn_information (TConnection *tcnc)
{
g_return_val_if_fail (T_IS_CONNECTION (tcnc), NULL);
diff --git a/tools/common/t-connection.h b/tools/common/t-connection.h
index 703e9cf..a8a4f9e 100644
--- a/tools/common/t-connection.h
+++ b/tools/common/t-connection.h
@@ -85,8 +85,9 @@ TConnection *t_connection_get_by_name (const gchar *name);
GdaConnection *t_connection_get_cnc (TConnection *tcnc);
void t_connection_set_name (TConnection *tcnc, const gchar *name);
const gchar *t_connection_get_name (TConnection *tcnc);
+const gchar *t_connection_get_information (TConnection *tcnc);
gchar *t_connection_get_long_name (TConnection *tcnc);
-const GdaDsnInfo *t_connection_get_information (TConnection *tcnc);
+const GdaDsnInfo *t_connection_get_dsn_information (TConnection *tcnc);
gboolean t_connection_is_busy (TConnection *tcnc, gchar **out_reason);
gboolean t_connection_is_virtual (TConnection *tcnc);
diff --git a/tools/common/t-decl.h b/tools/common/t-decl.h
index c10368d..cdb7c5a 100644
--- a/tools/common/t-decl.h
+++ b/tools/common/t-decl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2014 - 2015 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
@@ -22,6 +22,7 @@
typedef struct _TApp TApp;
typedef struct _TContext TContext;
+#define T_CNC_NAME_PREFIX "cnc"
#define T_DEFAULT_LDAP_ATTRIBUTES "cn"
#define T_LAST_DATA_MODEL_NAME "_"
diff --git a/tools/resources/menus.ui b/tools/resources/menus.ui
new file mode 100644
index 0000000..de15879
--- /dev/null
+++ b/tools/resources/menus.ui
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<interface>
+ <menu id='app-menu'>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>_Open Connection</attribute>
+ <attribute name='action'>app.opencnc</attribute>
+ <attribute name='accel'><Primary>n</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>Bind connections</attribute>
+ <attribute name='action'>app.bind</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>_Connections list</attribute>
+ <attribute name='action'>app.listcnc</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>_New Window</attribute>
+ <attribute name='action'>app.newwin</attribute>
+ </item>
+ <submenu id='win-menu'>
+ <attribute name="label" translatable="yes">New Window for...</attribute>
+ </submenu>
+ </section>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>_Help</attribute>
+ <attribute name='action'>app.help</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>_About</attribute>
+ <attribute name='action'>app.about</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>_Quit</attribute>
+ <attribute name='action'>app.quit</attribute>
+ <attribute name='accel'><Primary>q</attribute>
+ </item>
+ </section>
+ </menu>
+ <menu id='menubar'>
+ <submenu>
+ <attribute name='label' translatable='yes'>_Connection</attribute>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>_Begin transaction</attribute>
+ <attribute name='action'>win.begin</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>_Commit transaction</attribute>
+ <attribute name='action'>win.commit</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>_Rollback transaction</attribute>
+ <attribute name='action'>win.rollback</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>_Fetch Meta Data</attribute>
+ <attribute name='action'>win.meta-sync</attribute>
+ <attribute name='accel'><Primary>f</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>_Connection properties</attribute>
+ <attribute name='action'>win.properties</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>_Close connection</attribute>
+ <attribute name='action'>win.cncclose</attribute>
+ </item>
+ </section>
+ </submenu>
+ <submenu>
+ <attribute name="label" translatable="yes">Display</attribute>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>Fullscreen</attribute>
+ <attribute name='action'>win.fullscreen</attribute>
+ </item>
+ </section>
+ <section id='perspectives'>
+ </section>
+ </submenu>
+ </menu>
+</interface>
diff --git a/tools/resources/transaction-commit-symbolic.png b/tools/resources/transaction-commit-symbolic.png
new file mode 100644
index 0000000..b08be6b
Binary files /dev/null and b/tools/resources/transaction-commit-symbolic.png differ
diff --git a/tools/resources/transaction-rollback-symbolic.png
b/tools/resources/transaction-rollback-symbolic.png
new file mode 100644
index 0000000..b91e4e7
Binary files /dev/null and b/tools/resources/transaction-rollback-symbolic.png differ
diff --git a/tools/resources/transaction-start-symbolic.png b/tools/resources/transaction-start-symbolic.png
new file mode 100644
index 0000000..341b22b
Binary files /dev/null and b/tools/resources/transaction-start-symbolic.png differ
diff --git a/tools/tools-main.c b/tools/tools-main.c
index b5d6341..82a8381 100644
--- a/tools/tools-main.c
+++ b/tools/tools-main.c
@@ -69,6 +69,10 @@
#ifdef IS_BROWSER
#include <libgda-ui/libgda-ui.h>
#include <browser/browser-window.h>
+ #include <browser/login-dialog.h>
+ #include <browser/browser-connections-list.h>
+ #include <browser/ui-support.h>
+ #include <browser/connection-binding-properties.h>
#endif
/* options */
@@ -172,13 +176,80 @@ free_strings_array (GArray *array)
g_array_free (array, TRUE);
}
+#ifdef IS_BROWSER
+static gchar *
+double_first_underscore (const gchar *label)
+{
+ gchar *str, *dptr;
+ const gchar *sptr;
+ gboolean first = TRUE;
+ str = g_new (gchar, strlen (label) + 2);
+ for (sptr = label, dptr = str;
+ *sptr;
+ sptr++, dptr++) {
+ *dptr = *sptr;
+ if ((*sptr == '_') && first) {
+ dptr ++;
+ *dptr = '_';
+ first = FALSE;
+ }
+ }
+ *dptr = 0;
+ return str;
+}
+
+static void
+update_newwin_for_opened_cnc (void)
+{
+ GMenuModel *menumodel;
+ menumodel = (GMenuModel*) g_object_get_data (G_OBJECT (t_app_get ()), "win-menu");
+ if (menumodel) {
+ GMenu *menu;
+ menu = G_MENU (menumodel);
+ g_menu_remove_all (menu);
+
+ GSList *cnclist;
+ for (cnclist = t_app_get_all_connections (); cnclist; cnclist = cnclist->next) {
+ TConnection *tcnc = T_CONNECTION (cnclist->data);
+ gchar *dble, *tmp, *tmpname;
+ dble = double_first_underscore (t_connection_get_name (tcnc));
+ tmpname = g_strdup_printf (_("Connection '%s'"), dble);
+ g_free (dble);
+ tmp = g_strdup_printf ("app.newwin_cnc::%s", t_connection_get_name (tcnc));
+ g_menu_append (menu, tmpname, tmp);
+ g_free (tmpname);
+ g_free (tmp);
+ }
+ }
+}
+
+static void
+cnc_name_changed_cb (G_GNUC_UNUSED TConnection *tcnc, G_GNUC_UNUSED GParamSpec *pspec, G_GNUC_UNUSED
gpointer data)
+{
+ update_newwin_for_opened_cnc ();
+}
+#endif /* IS_BROWSER */
+
static void
cnc_added_cb (TApp *app, TConnection *tcnc)
{
gda_signal_connect (tcnc, "status-changed",
G_CALLBACK (cnc_status_changed_cb), NULL,
NULL, 0, NULL);
+#ifdef IS_BROWSER
+ gda_signal_connect (tcnc, "notify::name",
+ G_CALLBACK (cnc_name_changed_cb), NULL,
+ NULL, 0, NULL);
+ update_newwin_for_opened_cnc ();
+#endif
+}
+static void
+cnc_removed_cb (TApp *app, TConnection *tcnc)
+{
+#ifdef IS_BROWSER
+ update_newwin_for_opened_cnc ();
+#endif
}
GThread *term_console_thread = NULL;
@@ -421,6 +492,9 @@ command_line (GApplication *application, GApplicationCommandLine *cmdline)
gda_signal_connect (application, "connection-added",
G_CALLBACK (cnc_added_cb), NULL,
NULL, 0, NULL);
+ gda_signal_connect (application, "connection-removed",
+ G_CALLBACK (cnc_removed_cb), NULL,
+ NULL, 0, NULL);
/* open connections if specified */
if (! nocnc) {
@@ -482,46 +556,29 @@ command_line (GApplication *application, GApplicationCommandLine *cmdline)
if (ui) {
GtkBuilder *builder;
builder = gtk_builder_new ();
- gtk_builder_add_from_string (builder,
- "<interface>"
- " <menu id='app-menu'>"
- " <section>"
- " <item>"
- " <attribute name='label' translatable='yes'>_New
Window</attribute>"
- " <attribute name='action'>app.new</attribute>"
- " <attribute name='accel'><Primary>n</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label' translatable='yes'>_About
Bloatpad</attribute>"
- " <attribute name='action'>app.about</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'
translatable='yes'>_Quit</attribute>"
- " <attribute name='action'>app.quit</attribute>"
- " <attribute name='accel'><Primary>q</attribute>"
- " </item>"
- " </section>"
- " </menu>"
- " <menu id='menubar'>"
- " <submenu label='_Edit'>"
- " <item label='_Copy' action='win.copy'/>"
- " <item label='_Paste' action='win.paste'/>"
- " </submenu>"
- " </menu>"
- "</interface>", -1, NULL);
+ gtk_builder_add_from_resource (builder, "/ui/menus.ui", NULL);
gtk_application_set_app_menu (GTK_APPLICATION (t_app_get ()),
G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
gtk_application_set_menubar (GTK_APPLICATION (t_app_get ()),
G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
+ g_object_set_data_full (G_OBJECT (t_app_get ()), "win-menu",
+ gtk_builder_get_object (builder, "win-menu"), g_object_unref);
+ g_object_set_data_full (G_OBJECT (t_app_get ()), "perspectives",
+ gtk_builder_get_object (builder, "perspectives"), g_object_unref);
g_object_unref (builder);
+ update_newwin_for_opened_cnc ();
+
t_app_add_feature (T_APP_BROWSER);
if (!is_interactive)
t_app_remove_feature (T_APP_TERM_CONSOLE);
+
+ /* hack */
+ TConnection *tcnc = T_CONNECTION (t_app_get_all_connections ()->data);
+ gchar *tmp;
+ tmp = g_strdup_printf ("%s_AAA_B", t_connection_get_name (tcnc));
+ t_connection_set_name (tcnc, tmp);
+ g_free (tmp);
}
#endif
@@ -530,6 +587,33 @@ command_line (GApplication *application, GApplicationCommandLine *cmdline)
return exit_status;
}
+#ifdef IS_BROWSER
+
+static void about_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+#ifdef HAVE_GDU
+static void manual_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+#endif
+static void quit_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+static void connection_open_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+static void connection_bind_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+static void connection_list_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+static void window_new_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+static void window_new_cnc_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data);
+
+static GActionEntry app_entries[] = {
+ { "opencnc", connection_open_cb, NULL, NULL, NULL },
+ { "bind", connection_bind_cb, NULL, NULL, NULL },
+ { "newwin", window_new_cb, NULL, NULL, NULL },
+ { "newwin_cnc", window_new_cnc_cb, "s", NULL, NULL },
+ { "listcnc", connection_list_cb, NULL, NULL, NULL },
+ { "about", about_cb, NULL, NULL, NULL },
+ #ifdef HAVE_GDU
+ { "help", manual_cb, NULL, NULL, NULL },
+ #endif
+ { "quit", quit_cb, NULL, NULL, NULL },
+};
+#endif
+
int
main (int argc, char *argv[])
{
@@ -552,7 +636,7 @@ main (int argc, char *argv[])
#endif
#endif
- g_set_application_name ("Bloatpad");
+ g_set_application_name ("GdaBrowser");
/* TApp initialization */
GApplication *app;
@@ -561,6 +645,11 @@ main (int argc, char *argv[])
g_application_set_inactivity_timeout (app, 0);
g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
+#ifdef IS_BROWSER
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ app);
+#endif
g_application_run (app, argc, argv);
@@ -593,3 +682,180 @@ output_data_model (GdaDataModel *model)
g_free (str);
t_app_store_data_model (model, T_LAST_DATA_MODEL_NAME);
}
+
+#ifdef IS_BROWSER
+static GtkWindow *
+get_window (GtkApplication *app)
+{
+ GList *appwinlist;
+ appwinlist = gtk_application_get_windows (app);
+ if (appwinlist)
+ return GTK_WINDOW (appwinlist->data);
+ else
+ return NULL;
+}
+
+static void
+about_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ static GtkWidget *dialog = NULL;
+ if (dialog)
+ gtk_window_present (GTK_WINDOW (dialog));
+ else {
+ GdkPixbuf *icon;
+ const gchar *authors[] = {
+ "Vivien Malerba <malerba gnome-db org> (current maintainer)",
+ NULL
+ };
+ const gchar *documenters[] = {
+ NULL
+ };
+ const gchar *translator_credits = "";
+
+ icon = gdk_pixbuf_new_from_resource ("/images/gda-browser.png", NULL);
+
+ dialog = gtk_about_dialog_new ();
+ 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 - 2015 GNOME
Foundation");
+ gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (dialog), _("Database access services for the
GNOME Desktop"));
+ gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (dialog), "GNU General Public License");
+ gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (dialog), "http://www.gnome-db.org");
+ gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (dialog), authors);
+ gtk_about_dialog_set_documenters (GTK_ABOUT_DIALOG (dialog), documenters);
+ gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (dialog), translator_credits);
+ gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (dialog), icon);
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
+ g_object_add_weak_pointer ((GObject*) dialog, (gpointer) &dialog);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), get_window (GTK_APPLICATION (data)));
+ gtk_widget_show (dialog);
+ g_object_unref (icon);
+ }
+}
+
+#ifdef HAVE_GDU
+static void
+manual_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ ui_show_help (get_window (GTK_APPLICATION (data)), NULL);
+}
+#endif
+
+static void
+quit_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ /* confirmation dialog */
+ GtkWidget *dialog;
+ GSList *connections;
+ GtkWindow *win;
+ win = get_window (GTK_APPLICATION (data));
+
+ connections = t_app_get_all_connections ();
+ if (connections && connections->next)
+ dialog = gtk_message_dialog_new_with_markup (win, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ "<b>%s</b>\n<small>%s</small>",
+ _("Do you want to quit the application?"),
+ _("all the connections will be closed."));
+ else
+ dialog = gtk_message_dialog_new_with_markup (win, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ "<b>%s</b>\n<small>%s</small>",
+ _("Do you want to quit the application?"),
+ _("the connection will be closed."));
+
+
+ gboolean doquit;
+ doquit = (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) ? TRUE : FALSE;
+ gtk_widget_destroy (dialog);
+ if (doquit)
+ t_app_request_quit ();
+}
+
+static void
+connection_open_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ LoginDialog *dialog;
+ dialog = login_dialog_new (NULL);
+
+ login_dialog_run_open_connection (dialog, TRUE, NULL);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+connection_bind_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ BrowserWindow *bwin;
+ bwin = BROWSER_WINDOW (gtk_application_get_active_window (GTK_APPLICATION (data)));
+ TConnection *tcnc;
+ tcnc = browser_window_get_connection (bwin);
+
+ GtkWidget *win;
+ win = connection_binding_properties_new_create (tcnc);
+ gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (bwin));
+ gtk_widget_show (win);
+
+ gint res;
+ res = gtk_dialog_run (GTK_DIALOG (win));
+ gtk_widget_hide (win);
+ if (res == GTK_RESPONSE_OK) {
+ TConnection *tcnc;
+ GError *error = NULL;
+ tcnc = t_virtual_connection_new (connection_binding_properties_get_specs
+ (CONNECTION_BINDING_PROPERTIES (win)), &error);
+ if (tcnc) {
+ BrowserWindow *bwin;
+ bwin = browser_window_new (tcnc, NULL);
+ gtk_widget_show (GTK_WIDGET (bwin));
+ }
+ else {
+ ui_show_error ((GtkWindow*) bwin,
+ _("Could not open binding connection: %s"),
+ error && error->message ? error->message : _("No detail"));
+ g_clear_error (&error);
+ }
+ }
+ gtk_widget_destroy (win);
+}
+
+static void
+connection_list_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ BrowserWindow *bwin;
+ bwin = BROWSER_WINDOW (gtk_application_get_active_window (GTK_APPLICATION (data)));
+ browser_connections_list_show (browser_window_get_connection (bwin));
+}
+
+static void
+window_new_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ BrowserWindow *nbwin;
+ TConnection *tcnc;
+ BrowserWindow *bwin;
+ bwin = BROWSER_WINDOW (gtk_application_get_active_window (GTK_APPLICATION (data)));
+ tcnc = browser_window_get_connection (bwin);
+ nbwin = browser_window_new (tcnc, NULL);
+ gtk_widget_show (GTK_WIDGET (nbwin));
+}
+
+static void
+window_new_cnc_cb (G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+ const gchar *cncname;
+ cncname = g_variant_get_string (parameter, NULL);
+
+ TConnection *tcnc = t_connection_get_by_name (cncname);
+ if (tcnc) {
+ BrowserWindow *nbwin;
+ nbwin = browser_window_new (tcnc, NULL);
+ gtk_widget_show (GTK_WIDGET (nbwin));
+ }
+ else
+ g_print ("ERROR for cnc named %s\n", cncname);
+}
+
+#endif /* IS_BROWSER */
diff --git a/tools/tools.gresource.xml b/tools/tools.gresource.xml
index f856e1a..0c5a3da 100644
--- a/tools/tools.gresource.xml
+++ b/tools/tools.gresource.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
+ <gresource prefix="/ui">
+ <file compressed="yes">menus.ui</file>
+ </gresource>
<gresource prefix="/images">
<file compressed="no">gda-browser-action.png</file>
</gresource>
@@ -87,4 +90,13 @@
<gresource prefix="/images">
<file compressed="no">gda-browser-view.png</file>
</gresource>
+ <gresource prefix="/images">
+ <file compressed="no">transaction-start-symbolic.png</file>
+ </gresource>
+ <gresource prefix="/images">
+ <file compressed="no">transaction-commit-symbolic.png</file>
+ </gresource>
+ <gresource prefix="/images">
+ <file compressed="no">transaction-rollback-symbolic.png</file>
+ </gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]