[Gnucash-changes] Factor out common code for handling menus,
popup menus, and the toolbar
David Hampton
hampton at cvs.gnucash.org
Mon Oct 24 22:27:54 EDT 2005
Log Message:
-----------
Factor out common code for handling menus, popup menus, and the
toolbar and move the code to the shared base class. Rework the
private data structure in gnc-plugin-page.c.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash:
ChangeLog
gnucash/src/business/business-gnome:
gnc-plugin-page-invoice.c
gnucash/src/business/business-gnome/ui:
gnc-plugin-page-invoice-ui.xml
gnucash/src/gnome:
dialog-scheduledxaction.c
dialog-sxsincelast.c
gnc-plugin-page-account-tree.c
gnc-plugin-page-register.c
gnc-plugin-page-register.h
gnucash/src/gnome/ui:
gnc-plugin-page-account-tree-ui.xml
gnc-plugin-page-register-ui.xml
gnucash/src/gnome-utils:
gnc-main-window.c
gnc-main-window.h
gnc-plugin-page.c
gnc-plugin-page.h
gnucash/src/gnome-utils/ui:
gnc-main-window-ui.xml
gnucash/src/report/report-gnome:
gnc-plugin-page-report-ui.xml
gnc-plugin-page-report.c
Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.351
retrieving revision 1.1487.2.352
diff -LChangeLog -LChangeLog -u -r1.1487.2.351 -r1.1487.2.352
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,22 @@
+2005-10-24 David Hampton <hampton at employees.org>
+
+ * src/business/business-gnome/gnc-plugin-page-invoice.c:
+ * src/business/business-gnome/ui/gnc-plugin-page-invoice-ui.xml:
+ * src/gnome/dialog-scheduledxaction.c:
+ * src/gnome/dialog-sxsincelast.c:
+ * src/gnome/gnc-plugin-page-account-tree.c:
+ * src/gnome/gnc-plugin-page-register.[ch]:
+ * src/gnome/ui/gnc-plugin-page-account-tree-ui.xml:
+ * src/gnome/ui/gnc-plugin-page-register-ui.xml:
+ * src/gnome-utils/gnc-main-window.[ch]:
+ * src/gnome-utils/gnc-plugin-page.[ch]:
+ * src/gnome-utils/ui/gnc-main-window-ui.xml:
+ * src/report/report-gnome/gnc-plugin-page-report-ui.xml:
+ * src/report/report-gnome/gnc-plugin-page-report.c: Factor out
+ common code for handling menus, popup menus, and the toolbar and
+ move the code to the shared base class. Rework the private data
+ structure in gnc-plugin-page.c.
+
2005-10-23 David Hampton <hampton at employees.org>
* Makefile.TAGS:
Index: gnc-plugin-page-invoice-ui.xml
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-gnome/ui/Attic/gnc-plugin-page-invoice-ui.xml,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lsrc/business/business-gnome/ui/gnc-plugin-page-invoice-ui.xml -Lsrc/business/business-gnome/ui/gnc-plugin-page-invoice-ui.xml -u -r1.1.2.1 -r1.1.2.2
--- src/business/business-gnome/ui/gnc-plugin-page-invoice-ui.xml
+++ src/business/business-gnome/ui/gnc-plugin-page-invoice-ui.xml
@@ -72,12 +72,14 @@
</placeholder>
</toolbar>
- <popup name="InvoicePopup" action="FakeToplevel">
- <menuitem name="RecordEntry" action="RecordEntryAction"/>
- <menuitem name="CancelEntry" action="CancelEntryAction"/>
- <menuitem name="DeleteEntry" action="DeleteEntryAction"/>
- <separator name="PopupSep1"/>
- <menuitem name="DuplicateEntry" action="DuplicateEntryAction"/>
- <menuitem name="BlankEntry" action="BlankEntryAction"/>
+ <popup name="MainPopup" action="FakeToplevel">
+ <placeholder name="PopupPlaceholder2">
+ <menuitem name="RecordEntry" action="RecordEntryAction"/>
+ <menuitem name="CancelEntry" action="CancelEntryAction"/>
+ <menuitem name="DeleteEntry" action="DeleteEntryAction"/>
+ <separator name="PopupSep1"/>
+ <menuitem name="DuplicateEntry" action="DuplicateEntryAction"/>
+ <menuitem name="BlankEntry" action="BlankEntryAction"/>
+ </placeholder>
</popup>
</ui>
Index: gnc-plugin-page-register.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/Attic/gnc-plugin-page-register.c,v
retrieving revision 1.1.2.40
retrieving revision 1.1.2.41
diff -Lsrc/gnome/gnc-plugin-page-register.c -Lsrc/gnome/gnc-plugin-page-register.c -u -r1.1.2.40 -r1.1.2.41
--- src/gnome/gnc-plugin-page-register.c
+++ src/gnome/gnc-plugin-page-register.c
@@ -75,16 +75,9 @@
static GtkWidget *gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page);
static void gnc_plugin_page_register_destroy_widget (GncPluginPage *plugin_page);
static void gnc_plugin_page_register_window_changed (GncPluginPage *plugin_page, GtkWidget *window);
-static void gnc_plugin_page_register_merge_actions (GncPluginPage *plugin_page, GtkUIManager *ui_merge);
-static void gnc_plugin_page_register_unmerge_actions (GncPluginPage *plugin_page, GtkUIManager *ui_merge);
static gchar *gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page);
-/* Callbacks */
-static gboolean gnc_plugin_page_register_button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- GncPluginPageRegister *page);
-
/* Callbacks for the "Sort By" dialog */
void gnc_plugin_page_register_sort_button_cb(GtkToggleButton *button, GncPluginPageRegister *page);
void gnc_plugin_page_register_sort_response_cb(GtkDialog *dialog, gint response, GncPluginPageRegister *plugin_page);
@@ -298,17 +291,11 @@
struct GncPluginPageRegisterPrivate
{
- GtkActionGroup *action_group;
- guint merge_id;
- GtkUIManager *ui_merge;
-
GNCLedgerDisplay *ledger;
GNCSplitReg *gsr;
GtkWidget *widget;
- char *ui_description;
-
gint component_manager_id;
const char *lines_opt_section;
@@ -374,7 +361,6 @@
GList *book_list;
gchar *label;
QofQuery *q;
- gboolean use_new;
/* Is there an existing page? */
gsr = gnc_ledger_display_get_user_data (ledger);
@@ -392,13 +378,9 @@
plugin_page = GNC_PLUGIN_PAGE(register_page);
label = gnc_plugin_page_register_get_tab_name(plugin_page);
- gnc_plugin_page_set_title(plugin_page, label);
- gnc_plugin_page_set_tab_name(plugin_page, label);
+ gnc_plugin_page_set_page_name(plugin_page, label);
g_free(label);
- use_new = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER, KEY_USE_NEW, NULL);
- gnc_plugin_page_set_use_new_window(plugin_page, use_new);
-
q = gnc_ledger_display_get_query (ledger);
book_list = qof_query_get_books (q);
for (item = book_list; item; item = g_list_next(item))
@@ -456,8 +438,6 @@
gnc_plugin_class->create_widget = gnc_plugin_page_register_create_widget;
gnc_plugin_class->destroy_widget = gnc_plugin_page_register_destroy_widget;
gnc_plugin_class->window_changed = gnc_plugin_page_register_window_changed;
- gnc_plugin_class->merge_actions = gnc_plugin_page_register_merge_actions;
- gnc_plugin_class->unmerge_actions = gnc_plugin_page_register_unmerge_actions;
}
static void
@@ -466,19 +446,25 @@
GncPluginPageRegisterPrivate *priv;
GncPluginPage *parent;
GtkActionGroup *action_group;
+ gboolean use_new;
priv = g_new0 (GncPluginPageRegisterPrivate, 1);
plugin_page->priv = priv;
/* Init parent declared variables */
parent = GNC_PLUGIN_PAGE(plugin_page);
- gnc_plugin_page_set_title(parent, _("General Ledger"));
- gnc_plugin_page_set_tab_name(parent, _("General Ledger"));
- gnc_plugin_page_set_uri(parent, "default:");
+ use_new = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER, KEY_USE_NEW, NULL);
+ g_object_set(G_OBJECT(plugin_page),
+ "page-name", _("General Ledger"),
+ "page-uri", "default:",
+ "ui-description", "gnc-plugin-page-register-ui.xml",
+ "use-new-window", use_new,
+ NULL);
/* Create menu and toolbar information */
- action_group = gtk_action_group_new ("GncPluginPageRegisterActions");
- priv->action_group = action_group;
+ action_group =
+ gnc_plugin_page_create_action_group(parent,
+ "GncPluginPageRegisterActions");
gtk_action_group_add_actions (action_group, gnc_plugin_page_register_actions,
gnc_plugin_page_register_n_actions, plugin_page);
gtk_action_group_add_toggle_actions (action_group,
@@ -492,8 +478,6 @@
gnc_plugin_init_short_names (action_group, short_labels);
- priv->ui_description = g_strdup("gnc-plugin-page-register-ui.xml");
-
priv->lines_opt_section = DEFAULT_LINES_OPTION_SECTION;
priv->lines_opt_name = DEFAULT_LINES_OPTION_NAME;
priv->lines_default = DEFAULT_LINES_AMOUNT;
@@ -512,7 +496,6 @@
g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
g_return_if_fail (page->priv != NULL);
- g_free (page->priv->ui_description);
g_free (page->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -539,6 +522,7 @@
gnc_plugin_page_register_update_menus (GncPluginPageRegister *page)
{
GncPluginPageRegisterPrivate *priv ;
+ GtkActionGroup *action_group;
Account *account;
SplitRegister *sr;
GtkAction *action;
@@ -546,7 +530,8 @@
priv = page->priv;
account = gnc_plugin_page_register_get_account (page);
- gnc_plugin_update_actions(priv->action_group, actions_requiring_account,
+ action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(page));
+ gnc_plugin_update_actions(action_group, actions_requiring_account,
"sensitive", account != NULL);
/* Set "style" radio button */
@@ -560,13 +545,13 @@
}
/* Either a match was found, or fell out with i = 0 */
- action = gtk_action_group_get_action(priv->action_group, radio_entries_2[i].name);
+ action = gtk_action_group_get_action(action_group, radio_entries_2[i].name);
g_signal_handlers_block_by_func(action, gnc_plugin_page_register_cmd_style_changed, page);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action), TRUE);
g_signal_handlers_unblock_by_func(action, gnc_plugin_page_register_cmd_style_changed, page);
/* Set "double line" toggle button */
- action = gtk_action_group_get_action (priv->action_group,
+ action = gtk_action_group_get_action (action_group,
"ViewStyleDoubleLineAction");
g_signal_handlers_block_by_func(action, gnc_plugin_page_register_cmd_style_double_line, page);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action), sr->use_double_line);
@@ -616,8 +601,6 @@
g_signal_connect (G_OBJECT (gsr), "help-changed",
G_CALLBACK ( gnc_plugin_page_help_changed_cb ),
page );
- g_signal_connect (G_OBJECT (gsr), "button-press-event",
- G_CALLBACK (gnc_plugin_page_register_button_press_cb), page);
sr = gnc_ledger_display_get_split_register(priv->ledger);
gnc_split_register_config(sr, sr->type, sr->style, sr->use_double_line);
@@ -686,40 +669,6 @@
GTK_WIDGET(gnc_window_get_gtk_window(GNC_WINDOW(window)));
}
-static void
-gnc_plugin_page_register_merge_actions (GncPluginPage *plugin_page,
- GtkUIManager *ui_merge)
-{
- GncPluginPageRegister *register_page;
- GncPluginPageRegisterPrivate *priv;
-
- g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
-
- register_page = GNC_PLUGIN_PAGE_REGISTER(plugin_page);
- priv = register_page->priv;
-
- priv->ui_merge = ui_merge;
- priv->merge_id = gnc_plugin_add_actions (priv->ui_merge,
- priv->action_group,
- priv->ui_description);
-}
-
-static void
-gnc_plugin_page_register_unmerge_actions (GncPluginPage *plugin_page,
- GtkUIManager *ui_merge)
-{
- GncPluginPageRegister *plugin_page_register = GNC_PLUGIN_PAGE_REGISTER(plugin_page);
-
- g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page_register));
- g_return_if_fail (plugin_page_register->priv->merge_id != 0);
- g_return_if_fail (plugin_page_register->priv->action_group != NULL);
-
- gtk_ui_manager_remove_ui (ui_merge, plugin_page_register->priv->merge_id);
- gtk_ui_manager_remove_action_group (ui_merge, plugin_page_register->priv->action_group);
-
- plugin_page_register->priv->ui_merge = NULL;
-}
-
static gchar *
gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page)
{
@@ -762,26 +711,6 @@
return g_strdup(_("unknown"));
}
-/* Callbacks */
-static gboolean
-gnc_plugin_page_register_button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- GncPluginPageRegister *page)
-{
- GtkWidget *menu;
-
- if (event->button == 3 && page->priv->ui_merge != NULL) {
- /* Maybe show a different popup menu if no account is selected. */
- menu = gtk_ui_manager_get_widget (page->priv->ui_merge, "/RegisterPopup");
- if (menu)
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
- event->button, event->time);
- return TRUE;
- }
-
- return FALSE;
-}
-
/************************************************************/
/* "Sort By" Dialog */
/************************************************************/
@@ -1701,7 +1630,7 @@
gtk_window_set_transient_for(GTK_WINDOW(dialog),
GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window));
title = g_strdup_printf(N_("Sort %s by..."),
- gnc_plugin_page_get_tab_name(GNC_PLUGIN_PAGE(page)));
+ gnc_plugin_page_get_page_name(GNC_PLUGIN_PAGE(page)));
gtk_window_set_title(GTK_WINDOW(dialog), title);
g_free(title);
@@ -1750,7 +1679,7 @@
gtk_window_set_transient_for(GTK_WINDOW(dialog),
GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window));
title = g_strdup_printf(N_("Filter %s by..."),
- gnc_plugin_page_get_tab_name(GNC_PLUGIN_PAGE(page)));
+ gnc_plugin_page_get_page_name(GNC_PLUGIN_PAGE(page)));
gtk_window_set_title(GTK_WINDOW(dialog), title);
g_free(title);
@@ -2328,22 +2257,6 @@
priv->disallowCaps = disallowCaps;
}
-void
-gnc_plugin_page_register_set_ui_description (GncPluginPage *plugin_page,
- const char *ui_filename)
-{
- GncPluginPageRegister *page;
- GncPluginPageRegisterPrivate *priv;
-
- g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page));
-
- page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
- priv = page->priv;
-
- g_free(priv->ui_description);
- priv->ui_description = g_strdup(ui_filename);
-}
-
GNCSplitReg *
gnc_plugin_page_register_get_gsr (GncPluginPage *plugin_page)
{
Index: gnc-plugin-page-register.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/Attic/gnc-plugin-page-register.h,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -Lsrc/gnome/gnc-plugin-page-register.h -Lsrc/gnome/gnc-plugin-page-register.h -u -r1.1.2.13 -r1.1.2.14
--- src/gnome/gnc-plugin-page-register.h
+++ src/gnome/gnc-plugin-page-register.h
@@ -133,22 +133,6 @@
gint disallowCaps);
-/** Set an alternate UI for the specified register. This alternate ui
- * may only use actions specified in the standard (default) register
- * ui.
- *
- * @note This function must be called before the register page is
- * installed into a window.
- *
- * @param plugin_page The "register" page to modify.
- *
- * @param ui_filename The filename (no path) of the alternate UI.
- */
-void
-gnc_plugin_page_register_set_ui_description (GncPluginPage *plugin_page,
- const char *ui_filename);
-
-
/** Get the GNCSplitReg data structure associated with this register page.
*
* @param plugin_page A "register" page.
Index: gnc-plugin-page-account-tree.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/Attic/gnc-plugin-page-account-tree.c,v
retrieving revision 1.1.2.52
retrieving revision 1.1.2.53
diff -Lsrc/gnome/gnc-plugin-page-account-tree.c -Lsrc/gnome/gnc-plugin-page-account-tree.c -u -r1.1.2.52 -r1.1.2.53
--- src/gnome/gnc-plugin-page-account-tree.c
+++ src/gnome/gnc-plugin-page-account-tree.c
@@ -75,15 +75,11 @@
static GtkWidget *gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page);
static void gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page);
-static void gnc_plugin_page_account_tree_merge_actions (GncPluginPage *plugin_page, GtkUIManager *ui_merge);
-static void gnc_plugin_page_account_tree_unmerge_actions (GncPluginPage *plugin_page, GtkUIManager *ui_merge);
/* Callbacks */
-static gboolean gnc_plugin_page_account_tree_popup_menu_cb (GtkTreeView *treeview,
- GncPluginPageAccountTree *page);
-static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkTreeView *treeview,
+static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget,
GdkEventButton *event,
- GncPluginPageAccountTree *page);
+ GncPluginPage *page);
static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview,
GtkTreePath *path,
GtkTreeViewColumn *col,
@@ -167,6 +163,12 @@
{ "ScrubAllAction", NULL, N_("Check & Repair A_ll"), NULL,
N_("Check for and repair unbalanced transactions and orphan splits " "in all accounts"),
G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub_all) },
+
+ /* Popup menu */
+
+ { "PopupOptionsAction", GTK_STOCK_PROPERTIES, N_("_Options"), NULL,
+ N_("Edit the account view options"),
+ G_CALLBACK (gnc_plugin_page_account_tree_cmd_view_options) },
};
static guint gnc_plugin_page_account_tree_n_actions = G_N_ELEMENTS (gnc_plugin_page_account_tree_actions);
@@ -192,10 +194,6 @@
struct GncPluginPageAccountTreePrivate
{
- GtkActionGroup *action_group;
- guint merge_id;
- GtkUIManager *ui_merge;
-
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -266,8 +264,6 @@
gnc_plugin_class->plugin_name = GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME;
gnc_plugin_class->create_widget = gnc_plugin_page_account_tree_create_widget;
gnc_plugin_class->destroy_widget = gnc_plugin_page_account_tree_destroy_widget;
- gnc_plugin_class->merge_actions = gnc_plugin_page_account_tree_merge_actions;
- gnc_plugin_class->unmerge_actions = gnc_plugin_page_account_tree_unmerge_actions;
plugin_page_signals[ACCOUNT_SELECTED] =
g_signal_new ("account_selected",
@@ -302,20 +298,23 @@
/* Init parent declared variables */
parent = GNC_PLUGIN_PAGE(plugin_page);
- gnc_plugin_page_set_title(parent, _("Accounts"));
- gnc_plugin_page_set_tab_name(parent, _("Accounts"));
- gnc_plugin_page_set_uri(parent, "default:");
+ g_object_set(G_OBJECT(plugin_page),
+ "page-name", _("Accounts"),
+ "page-uri", "default:",
+ "ui-description", "gnc-plugin-page-account-tree-ui.xml",
+ NULL);
/* change me when the system supports multiple books */
gnc_plugin_page_add_book(parent, gnc_get_current_book());
/* Create menu and toolbar information */
- action_group = gtk_action_group_new ("GncPluginPageAccountTreeActions");
- priv->action_group = action_group;
- gtk_action_group_add_actions (action_group,
- gnc_plugin_page_account_tree_actions,
- gnc_plugin_page_account_tree_n_actions,
- plugin_page);
+ action_group =
+ gnc_plugin_page_create_action_group(parent,
+ "GncPluginPageAccountTreeActions");
+ gtk_action_group_add_actions(action_group,
+ gnc_plugin_page_account_tree_actions,
+ gnc_plugin_page_account_tree_n_actions,
+ plugin_page);
gnc_plugin_init_short_names (action_group, short_labels);
@@ -368,7 +367,7 @@
scm_gc_protect_object(priv->name_change_callback_id);
LEAVE("page %p, priv %p, action group %p",
- plugin_page, plugin_page->priv, plugin_page->priv->action_group);
+ plugin_page, plugin_page->priv, action_group);
}
static void
@@ -482,8 +481,6 @@
selection = gtk_tree_view_get_selection(tree_view);
g_signal_connect (G_OBJECT (selection), "changed",
G_CALLBACK (gnc_plugin_page_account_tree_selection_changed_cb), page);
- g_signal_connect (G_OBJECT (tree_view), "popup-menu",
- G_CALLBACK (gnc_plugin_page_account_tree_popup_menu_cb), page);
g_signal_connect (G_OBJECT (tree_view), "button-press-event",
G_CALLBACK (gnc_plugin_page_account_tree_button_press_cb), page);
g_signal_connect (G_OBJECT (tree_view), "row-activated",
@@ -535,98 +532,29 @@
LEAVE("widget destroyed");
}
-static void
-gnc_plugin_page_account_tree_merge_actions (GncPluginPage *plugin_page,
- GtkUIManager *ui_merge)
-{
- GncPluginPageAccountTree *account_page;
- GncPluginPageAccountTreePrivate *priv;
-
- ENTER("page %p, ui_merge %p", plugin_page, ui_merge);
-
- g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (plugin_page));
-
- account_page = GNC_PLUGIN_PAGE_ACCOUNT_TREE(plugin_page);
- priv = account_page->priv;
-
- priv->ui_merge = ui_merge;
- priv->merge_id =
- gnc_plugin_add_actions (priv->ui_merge,
- priv->action_group,
- "gnc-plugin-page-account-tree-ui.xml");
- LEAVE(" ");
-}
-
-static void
-gnc_plugin_page_account_tree_unmerge_actions (GncPluginPage *plugin_page,
- GtkUIManager *ui_merge)
-{
- GncPluginPageAccountTree *plugin_page_account_tree = GNC_PLUGIN_PAGE_ACCOUNT_TREE(plugin_page);
-
- ENTER("page %p (merge_id %d, action_group %p), ui_merge %p",
- plugin_page,
- plugin_page_account_tree->priv->merge_id,
- plugin_page_account_tree->priv->action_group,
- ui_merge);
- g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (plugin_page_account_tree));
- g_return_if_fail (plugin_page_account_tree->priv->merge_id != 0);
- g_return_if_fail (plugin_page_account_tree->priv->action_group != NULL);
-
- gtk_ui_manager_remove_ui (ui_merge, plugin_page_account_tree->priv->merge_id);
- gtk_ui_manager_remove_action_group (ui_merge, plugin_page_account_tree->priv->action_group);
-
- plugin_page_account_tree->priv->ui_merge = NULL;
- LEAVE(" ");
-}
-
/* Callbacks */
+
+/** This button press handler calls the common button press handler
+ * for all pages. The GtkTreeView eats all button presses and
+ * doesn't pass them up the widget tree, even when doesn't do
+ * anything with them. The only way to get access to the button
+ * presses in an account tree page is here on the tree view widget.
+ * Button presses on all other pages are caught by the signal
+ * registered in gnc-main-window.c. */
static gboolean
-gnc_plugin_page_account_tree_button_press_cb (GtkTreeView *treeview,
+gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget,
GdkEventButton *event,
- GncPluginPageAccountTree *page)
+ GncPluginPage *page)
{
- GtkWidget *menu;
- gint button;
- guint32 time;
-
- ENTER("tree %p, event %p, page %p", treeview, event, page);
-
- if (event && event->button != 3) {
- LEAVE("not button 3");
- return FALSE;
- }
-
- if (page->priv->ui_merge == NULL) {
- LEAVE("no ui merge");
- return FALSE;
- }
+ gboolean result;
- button = event ? event->button : 0;
- time = event ? event->time : 0;
+ g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
- /* Maybe show a different popup menu if no account is selected. */
- menu = gtk_ui_manager_get_widget (page->priv->ui_merge, "/AccountPopup");
- if (!menu) {
- LEAVE("no menu");
- return FALSE;
- }
-
- gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time);
- LEAVE(" ");
- return TRUE;
-}
-
-static gboolean
-gnc_plugin_page_account_tree_popup_menu_cb (GtkTreeView *treeview,
- GncPluginPageAccountTree *page)
-{
- gboolean result;
-
- ENTER("tree %p, page %p", treeview, page);
- result = gnc_plugin_page_account_tree_button_press_cb (treeview, NULL, page);
- LEAVE("result %d", result);
- return result;
+ ENTER("widget %p, event %p, page %p", widget, event, page);
+ result = gnc_main_window_button_press_cb(widget, event, page);
+ LEAVE(" ");
+ return result;
}
static void
@@ -671,7 +599,7 @@
/* Check here for placeholder accounts, etc. */
}
- action_group = page->priv->action_group;
+ action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(page));
gnc_plugin_update_actions (action_group, actions_requiring_account,
"sensitive", sensitive);
g_signal_emit (page, plugin_page_signals[ACCOUNT_SELECTED], 0, account);
@@ -734,8 +662,7 @@
{
Account *account;
- ENTER("action %p, page %p (merge_id %d, action_group %p)",
- action, page, page->priv->merge_id, page->priv->action_group);
+ ENTER("action %p, page %p", action, page);
account = gnc_plugin_page_account_tree_get_current_account (page);
g_return_if_fail (account != NULL);
Index: dialog-sxsincelast.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/dialog-sxsincelast.c,v
retrieving revision 1.65.4.14
retrieving revision 1.65.4.15
diff -Lsrc/gnome/dialog-sxsincelast.c -Lsrc/gnome/dialog-sxsincelast.c -u -r1.65.4.14 -r1.65.4.15
--- src/gnome/dialog-sxsincelast.c
+++ src/gnome/dialog-sxsincelast.c
@@ -3586,8 +3586,8 @@
/* Then the register in it */
sxsld->ac_register = gnc_plugin_page_register_new_ledger(sxsld->ac_ledger);
- gnc_plugin_page_register_set_ui_description (sxsld->ac_register,
- "gnc-plugin-page-sxregister-ui.xml");
+ gnc_plugin_page_set_ui_description (sxsld->ac_register,
+ "gnc-plugin-page-sxregister-ui.xml");
gnc_plugin_page_register_set_options (sxsld->ac_register,
NULL, NULL, 4,
CAP_SCHEDULE);
@@ -3629,8 +3629,8 @@
/* Then the register in it */
sxsld->created_register = gnc_plugin_page_register_new_ledger(sxsld->created_ledger);
- gnc_plugin_page_register_set_ui_description (sxsld->created_register,
- "gnc-plugin-page-sxregister-ui.xml");
+ gnc_plugin_page_set_ui_description (sxsld->created_register,
+ "gnc-plugin-page-sxregister-ui.xml");
gnc_plugin_page_register_set_options (sxsld->created_register,
NULL, NULL, 4,
CAP_SCHEDULE);
@@ -3737,8 +3737,8 @@
/* Then the register in it */
sxsld->to_create_register = gnc_plugin_page_register_new_ledger(sxsld->to_create_ledger);
- gnc_plugin_page_register_set_ui_description (sxsld->to_create_register,
- "gnc-plugin-page-sxregister-ui.xml");
+ gnc_plugin_page_set_ui_description (sxsld->to_create_register,
+ "gnc-plugin-page-sxregister-ui.xml");
gnc_plugin_page_register_set_options (sxsld->to_create_register,
NULL, NULL, 4,
CAP_READ_ONLY | CAP_SCHEDULE);
Index: dialog-scheduledxaction.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/dialog-scheduledxaction.c,v
retrieving revision 1.71.2.19
retrieving revision 1.71.2.20
diff -Lsrc/gnome/dialog-scheduledxaction.c -Lsrc/gnome/dialog-scheduledxaction.c -u -r1.71.2.19 -r1.71.2.20
--- src/gnome/dialog-scheduledxaction.c
+++ src/gnome/dialog-scheduledxaction.c
@@ -1588,8 +1588,8 @@
/* Now create the register plugin page. */
sxed->plugin_page = gnc_plugin_page_register_new_ledger (sxed->ledger);
- gnc_plugin_page_register_set_ui_description (sxed->plugin_page,
- "gnc-plugin-page-sxregister-ui.xml");
+ gnc_plugin_page_set_ui_description (sxed->plugin_page,
+ "gnc-plugin-page-sxregister-ui.xml");
gnc_plugin_page_register_set_options (sxed->plugin_page,
SXED_GCONF_SECTION,
KEY_NUMBER_OF_ROWS,
Index: gnc-plugin-page.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-plugin-page.c,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -Lsrc/gnome-utils/gnc-plugin-page.c -Lsrc/gnome-utils/gnc-plugin-page.c -u -r1.1.2.8 -r1.1.2.9
--- src/gnome-utils/gnc-plugin-page.c
+++ src/gnome-utils/gnc-plugin-page.c
@@ -35,6 +35,7 @@
#include "config.h"
#include <gtk/gtk.h>
+#include "gnc-plugin.h"
#include "gnc-plugin-page.h"
#include "gnc-gobject-utils.h"
@@ -44,29 +45,58 @@
static void gnc_plugin_page_init (GncPluginPage *plugin_page,
GncPluginPageClass *klass);
static void gnc_plugin_page_finalize (GObject *object);
+static void gnc_plugin_page_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gnc_plugin_page_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
enum {
- INSERTED,
- REMOVED,
- SELECTED,
- UNSELECTED,
- LAST_SIGNAL
+ INSERTED,
+ REMOVED,
+ SELECTED,
+ UNSELECTED,
+ LAST_SIGNAL
+};
+
+enum {
+ PROP_0,
+ PROP_PAGE_NAME,
+ PROP_PAGE_URI,
+ PROP_BOOK,
+ PROP_STATUSBAR_TEXT,
+ PROP_USE_NEW_WINDOW,
+ PROP_UI_DESCRIPTION,
+ PROP_UI_MERGE,
+ PROP_ACTION_GROUP,
};
static guint signals[LAST_SIGNAL] = { 0 };
-struct GncPluginPagePrivate
+typedef struct _GncPluginPagePrivate GncPluginPagePrivate;
+
+struct _GncPluginPagePrivate
{
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_merge;
+ guint merge_id;
+ char *ui_description;
+
GList *books;
gboolean use_new_window;
- gchar *title;
- gchar *tab_name;
+ gchar *page_name;
gchar *uri;
gchar *statusbar_text;
};
+#define GNC_PLUGIN_PAGE_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_PAGE, GncPluginPagePrivate))
+
GType
gnc_plugin_page_get_type (void)
{
@@ -135,33 +165,37 @@
}
void
-gnc_plugin_page_merge_actions (GncPluginPage *plugin_page,
+gnc_plugin_page_merge_actions (GncPluginPage *page,
GtkUIManager *ui_merge)
{
- GncPluginPageClass *klass;
-
- g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
-
- klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page);
- g_return_if_fail (klass != NULL);
- g_return_if_fail (klass->merge_actions != NULL);
+ GncPluginPagePrivate *priv;
+
+ g_return_if_fail (GNC_IS_PLUGIN_PAGE(page));
- klass->merge_actions (plugin_page, ui_merge);
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ priv->ui_merge = ui_merge;
+ priv->merge_id = gnc_plugin_add_actions(priv->ui_merge,
+ priv->action_group,
+ priv->ui_description);
}
void
-gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page,
+gnc_plugin_page_unmerge_actions (GncPluginPage *page,
GtkUIManager *ui_merge)
{
- GncPluginPageClass *klass;
+ GncPluginPagePrivate *priv;
- g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
- klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page);
- g_return_if_fail (klass != NULL);
- g_return_if_fail (klass->unmerge_actions != NULL);
+ g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
+ g_return_if_fail (priv->merge_id != 0);
+ g_return_if_fail (priv->action_group != NULL);
+
+ gtk_ui_manager_remove_ui(ui_merge, priv->merge_id);
+ gtk_ui_manager_remove_action_group(ui_merge, priv->action_group);
- klass->unmerge_actions (plugin_page, ui_merge);
+ priv->ui_merge = NULL;
+ priv->merge_id = 0;
}
const gchar *
@@ -218,10 +252,90 @@
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = gnc_plugin_page_finalize;
+ gobject_class->set_property = gnc_plugin_page_set_property;
+ gobject_class->get_property = gnc_plugin_page_get_property;
klass->tab_icon = NULL;
klass->plugin_name = NULL;
+ g_type_class_add_private(klass, sizeof(GncPluginPagePrivate));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_PAGE_NAME,
+ g_param_spec_string ("page-name",
+ "Page Name",
+ "The name of this page. This value is "
+ "used to generate the notebook tab and "
+ "menu items, and also the window title "
+ "when this page is visible.",
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_PAGE_URI,
+ g_param_spec_string ("page-uri",
+ "Page URI",
+ "The uri for this page.",
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_STATUSBAR_TEXT,
+ g_param_spec_string ("statusbar-text",
+ "Statusbar Text",
+ "The text to be displayed in the statusbar "
+ "at the bottom of the window when this page "
+ "is visible.",
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_USE_NEW_WINDOW,
+ g_param_spec_boolean ("use-new-window",
+ "Use New Window",
+ "When TRUE a new top level window will be "
+ "created to hold this page.",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_UI_DESCRIPTION,
+ g_param_spec_string ("ui-description",
+ "UI Description File",
+ "The filename containing the XML data that "
+ "describes this pages menus and toolbars.",
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_UI_MERGE,
+ g_param_spec_object ("ui-merge",
+ "UI Merge",
+ "A pointer to the GtkUIManager object that "
+ "represents this pages menu hierarchy.",
+ GTK_TYPE_UI_MANAGER,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_ACTION_GROUP,
+ g_param_spec_object ("action-group",
+ "Action Group",
+ "A pointer to the GtkActionGroup object that "
+ "represents this pages available menu/toolbar "
+ "actions.",
+ GTK_TYPE_ACTION_GROUP,
+ G_PARAM_READABLE));
+
+
+
+
signals[INSERTED] = g_signal_new ("inserted",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
@@ -257,21 +371,18 @@
}
static void
-gnc_plugin_page_init (GncPluginPage *plugin_page, GncPluginPageClass *klass)
+gnc_plugin_page_init (GncPluginPage *page, GncPluginPageClass *klass)
{
GncPluginPagePrivate *priv;
- priv = plugin_page->priv = g_new0 (GncPluginPagePrivate, 1);
-
- priv->title = NULL;
- priv->tab_name = NULL;
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ priv->page_name = NULL;
priv->uri = NULL;
- plugin_page->window = NULL;
- plugin_page->summarybar = NULL;
+ page->window = NULL;
+ page->summarybar = NULL;
- gnc_gobject_tracking_remember(G_OBJECT(plugin_page),
- G_OBJECT_CLASS(klass));
+ gnc_gobject_tracking_remember(G_OBJECT(page), G_OBJECT_CLASS(klass));
}
static void
@@ -283,11 +394,9 @@
page = GNC_PLUGIN_PAGE (object);
- priv = page->priv;
- if (priv->title)
- g_free(priv->title);
- if (priv->tab_name)
- g_free(priv->tab_name);
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ if (priv->page_name)
+ g_free(priv->page_name);
if (priv->uri)
g_free(priv->uri);
if (priv->statusbar_text)
@@ -300,8 +409,6 @@
g_list_free(priv->books);
priv->books = NULL;
}
- g_free (priv);
- page->priv = NULL;
if (page->summarybar) {
g_object_unref(G_OBJECT(page->summarybar));
@@ -313,6 +420,107 @@
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+/************************************************************/
+/* g_object other functions */
+/************************************************************/
+
+/** Retrieve a property specific to this GncPluginPage object. This is
+ * nothing more than a dispatch function for routines that can be
+ * called directly. It has the nice feature of allowing a single
+ * function call to retrieve multiple properties.
+ *
+ * @internal
+ */
+static void
+gnc_plugin_page_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncPluginPage *page;
+ GncPluginPagePrivate *priv;
+
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE(object));
+
+ page = GNC_PLUGIN_PAGE(object);
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ switch (prop_id)
+ {
+ case PROP_PAGE_NAME:
+ g_value_set_string (value, priv->page_name);
+ break;
+ case PROP_PAGE_URI:
+ g_value_set_string (value, priv->uri);
+ break;
+ case PROP_STATUSBAR_TEXT:
+ g_value_set_string (value, priv->statusbar_text);
+ break;
+ case PROP_USE_NEW_WINDOW:
+ g_value_set_boolean (value, priv->use_new_window);
+ break;
+ case PROP_UI_DESCRIPTION:
+ g_value_set_string (value, priv->ui_description);
+ break;
+ case PROP_UI_MERGE:
+ g_value_set_object (value, priv->ui_merge);
+ break;
+ case PROP_ACTION_GROUP:
+ g_value_set_object (value, priv->action_group);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+/** Set a property specific to this GncPluginPage object. This is
+ * nothing more than a dispatch function for routines that can be
+ * called directly. It has the nice feature of allowing a new view
+ * to be created with a varargs list specifying the properties,
+ * instead of having to explicitly call each property function.
+ *
+ * @internal
+ */
+static void
+gnc_plugin_page_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncPluginPage *page;
+
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE(object));
+
+ page = GNC_PLUGIN_PAGE(object);
+
+ switch (prop_id)
+ {
+ case PROP_PAGE_NAME:
+ gnc_plugin_page_set_page_name(page, g_value_get_string(value));
+ break;
+ case PROP_PAGE_URI:
+ gnc_plugin_page_set_uri(page, g_value_get_string(value));
+ break;
+ case PROP_STATUSBAR_TEXT:
+ gnc_plugin_page_set_statusbar_text(page, g_value_get_string(value));
+ break;
+ case PROP_USE_NEW_WINDOW:
+ gnc_plugin_page_set_use_new_window(page, g_value_get_boolean(value));
+ break;
+ case PROP_UI_DESCRIPTION:
+ gnc_plugin_page_set_ui_description(page, g_value_get_string(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/************************************************************/
+/* */
+/************************************************************/
+
void
gnc_plugin_page_add_book (GncPluginPage *page, QofBook *book)
{
@@ -322,7 +530,7 @@
g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
g_return_if_fail (book != NULL);
- priv = page->priv;
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
guid = guid_malloc();
*guid = *qof_book_get_guid(book);
@@ -338,7 +546,7 @@
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE);
g_return_val_if_fail (entity != NULL, FALSE);
- priv = page->priv;
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
for (item = priv->books; item; item = g_list_next(item)) {
if (guid_equal((GUID*)item->data, entity)) {
return TRUE;
@@ -350,9 +558,12 @@
gboolean
gnc_plugin_page_has_books (GncPluginPage *page)
{
+ GncPluginPagePrivate *priv;
+
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE);
- return (page->priv->books != NULL);
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ return (priv->books != NULL);
}
GtkWidget *
@@ -364,91 +575,153 @@
}
const gchar *
-gnc_plugin_page_get_tab_name (GncPluginPage *page)
+gnc_plugin_page_get_page_name (GncPluginPage *page)
{
+ GncPluginPagePrivate *priv;
+
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
- return page->priv->tab_name;
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ return priv->page_name;
}
void
-gnc_plugin_page_set_tab_name (GncPluginPage *page, const gchar *name)
+gnc_plugin_page_set_page_name (GncPluginPage *page, const gchar *name)
{
+ GncPluginPagePrivate *priv;
+
g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
- if (page->priv->tab_name)
- g_free(page->priv->tab_name);
- page->priv->tab_name = g_strdup(name);
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ if (priv->page_name)
+ g_free(priv->page_name);
+ priv->page_name = g_strdup(name);
}
const gchar *
-gnc_plugin_page_get_title (GncPluginPage *page)
+gnc_plugin_page_get_uri (GncPluginPage *page)
{
+ GncPluginPagePrivate *priv;
+
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
- return page->priv->title;
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ return priv->uri;
}
void
-gnc_plugin_page_set_title (GncPluginPage *page, const gchar *name)
+gnc_plugin_page_set_uri (GncPluginPage *page, const gchar *name)
{
+ GncPluginPagePrivate *priv;
+
g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
- if (page->priv->title)
- g_free(page->priv->title);
- page->priv->title = g_strdup(name);
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ if (priv->uri)
+ g_free(priv->uri);
+ priv->uri = g_strdup(name);
}
const gchar *
-gnc_plugin_page_get_uri (GncPluginPage *page)
+gnc_plugin_page_get_statusbar_text (GncPluginPage *page)
{
+ GncPluginPagePrivate *priv;
+
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
- return page->priv->uri;
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ return priv->statusbar_text;
}
void
-gnc_plugin_page_set_uri (GncPluginPage *page, const gchar *name)
+gnc_plugin_page_set_statusbar_text (GncPluginPage *page, const gchar *message)
{
+ GncPluginPagePrivate *priv;
+
g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
- if (page->priv->uri)
- g_free(page->priv->uri);
- page->priv->uri = g_strdup(name);
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ if (priv->statusbar_text)
+ g_free(priv->statusbar_text);
+ priv->statusbar_text = g_strdup(message);
}
-const gchar *
-gnc_plugin_page_get_statusbar_text (GncPluginPage *page)
+gboolean
+gnc_plugin_page_get_use_new_window (GncPluginPage *page)
{
- g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
+ GncPluginPagePrivate *priv;
- return page->priv->statusbar_text;
+ g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE);
+
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ return priv->use_new_window;
}
void
-gnc_plugin_page_set_statusbar_text (GncPluginPage *page, const gchar *message)
+gnc_plugin_page_set_use_new_window (GncPluginPage *page, gboolean use_new)
{
+ GncPluginPagePrivate *priv;
+
g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
- if (page->priv->statusbar_text)
- g_free(page->priv->statusbar_text);
- page->priv->statusbar_text = g_strdup(message);
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ priv->use_new_window = use_new;
}
-gboolean
-gnc_plugin_page_get_use_new_window (GncPluginPage *page)
+const gchar *
+gnc_plugin_page_get_ui_description (GncPluginPage *page)
{
+ GncPluginPagePrivate *priv;
+
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE);
- return page->priv->use_new_window;
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ return priv->ui_description;
}
void
-gnc_plugin_page_set_use_new_window (GncPluginPage *page, gboolean use_new)
+gnc_plugin_page_set_ui_description (GncPluginPage *page,
+ const char *ui_filename)
{
- g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
+ GncPluginPagePrivate *priv;
+
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE(page));
+
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ if (priv->ui_description)
+ g_free(priv->ui_description);
+ priv->ui_description = g_strdup(ui_filename);
+}
+
+GtkUIManager *
+gnc_plugin_page_get_ui_merge (GncPluginPage *page)
+{
+ GncPluginPagePrivate *priv;
+
+ g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), NULL);
+
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ return priv->ui_merge;
+}
+
+GtkActionGroup *
+gnc_plugin_page_get_action_group(GncPluginPage *page)
+{
+ GncPluginPagePrivate *priv;
+
+ g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ return priv->action_group;
+}
+
+GtkActionGroup *
+gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name)
+{
+ GncPluginPagePrivate *priv;
- page->priv->use_new_window = use_new;
+ priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
+ priv->action_group = gtk_action_group_new(group_name);
+ return priv->action_group;
}
/** @} */
Index: gnc-main-window.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-main-window.h,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -Lsrc/gnome-utils/gnc-main-window.h -Lsrc/gnome-utils/gnc-main-window.h -u -r1.1.2.7 -r1.1.2.8
--- src/gnome-utils/gnc-main-window.h
+++ src/gnome-utils/gnc-main-window.h
@@ -256,6 +256,27 @@
*/
void gnc_main_window_set_progressbar_window( GncMainWindow *window );
+
+/** Callback function invoked when the user clicks in the content of
+ * any Gnucash window. If this was a "right-click" then Gnucash will
+ * popup the contextual menu.
+ *
+ * @param widget Whatever widget had focus when the user issued the
+ * keyboard context-menu request.
+ *
+ * @param event The event parameter describing where on the screen
+ * the mouse was pointing when clicked, type of click, modifiers,
+ * etc.
+ *
+ * @param page This is the GncPluginPage corresponding to the visible
+ * page.
+ *
+ * @return Returns TRUE if this was a right-click, meaning Gnucash
+ * handled the click.
+ */
+gboolean gnc_main_window_button_press_cb (GtkWidget *whatever,
+ GdkEventButton *event,
+ GncPluginPage *page);
G_END_DECLS
#endif /* __GNC_MAIN_WINDOW_H */
Index: gnc-main-window.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-main-window.c,v
retrieving revision 1.1.2.26
retrieving revision 1.1.2.27
diff -Lsrc/gnome-utils/gnc-main-window.c -Lsrc/gnome-utils/gnc-main-window.c -u -r1.1.2.26 -r1.1.2.27
--- src/gnome-utils/gnc-main-window.c
+++ src/gnome-utils/gnc-main-window.c
@@ -111,6 +111,10 @@
static void gnc_main_window_cmd_test( GtkAction *action, GncMainWindow *window );
+static void do_popup_menu(GncPluginPage *page, GdkEventButton *event);
+static gboolean gnc_main_window_popup_menu_cb (GtkWidget *widget, GncPluginPage *page);
+
+
struct GncMainWindowPrivate
{
GtkWidget *menu_dock;
@@ -555,7 +559,7 @@
if (page) {
/* The Gnome HIG 2.0 recommends the application name not be used. (p16) */
title = g_strdup_printf("%s - %s", filename,
- gnc_plugin_page_get_title(page));
+ gnc_plugin_page_get_page_name(page));
} else {
title = g_strdup_printf("%s", filename);
}
@@ -1121,6 +1125,11 @@
if (GNC_PLUGIN_PAGE_GET_CLASS(page)->window_changed)
(GNC_PLUGIN_PAGE_GET_CLASS(page)->window_changed)(page, GTK_WIDGET(window));
g_signal_emit (window, main_window_signals[PAGE_ADDED], 0, page);
+
+ g_signal_connect(G_OBJECT(page->notebook_page), "popup-menu",
+ G_CALLBACK(gnc_main_window_popup_menu_cb), page);
+ g_signal_connect_after(G_OBJECT(page->notebook_page), "button-press-event",
+ G_CALLBACK(gnc_main_window_button_press_cb), page);
}
@@ -1144,6 +1153,12 @@
GtkNotebook *notebook;
gint page_num;
+ /* Disconnect the callbacks */
+ g_signal_handlers_disconnect_by_func(G_OBJECT(page->notebook_page),
+ G_CALLBACK(gnc_main_window_popup_menu_cb), page);
+ g_signal_handlers_disconnect_by_func(G_OBJECT(page->notebook_page),
+ G_CALLBACK(gnc_main_window_button_press_cb), page);
+
/* Disconnect the page and summarybar from the window */
if (window->priv->current_page == page) {
gnc_plugin_page_unmerge_actions (page, window->ui_merge);
@@ -1253,7 +1268,7 @@
* The page tab.
*/
icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
- label = gtk_label_new (gnc_plugin_page_get_tab_name(page));
+ label = gtk_label_new (gnc_plugin_page_get_page_name(page));
gtk_widget_show (label);
tab_hbox = gtk_hbox_new (FALSE, 6);
@@ -1292,7 +1307,7 @@
/*
* The popup menu
*/
- label = gtk_label_new (gnc_plugin_page_get_tab_name(page));
+ label = gtk_label_new (gnc_plugin_page_get_page_name(page));
/*
* Now install it all in the window.
@@ -2091,5 +2106,101 @@
gnc_window_set_progressbar_window(gncwin);
}
+
+/** Popup a contextual menu. This function ends up being called when
+ * the user right-clicks in the context of a window, or uses the
+ * keyboard context-menu request key combination (Shift-F10 by
+ * default).
+ *
+ * @param page This is the GncPluginPage corresponding to the visible
+ * page.
+ *
+ * @param event The event parameter passed to the "button-press"
+ * callback. May be null if there was no event (aka keyboard
+ * request).
+ */
+static void
+do_popup_menu(GncPluginPage *page, GdkEventButton *event)
+{
+ GtkUIManager *ui_merge;
+ GtkWidget *menu;
+ int button, event_time;
+
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE(page));
+
+ ENTER("page %p, event %p", page, event);
+ ui_merge = gnc_plugin_page_get_ui_merge(page);
+ if (ui_merge == NULL) {
+ LEAVE("no ui merge");
+ return;
+ }
+
+ menu = gtk_ui_manager_get_widget(ui_merge, "/MainPopup");
+ if (!menu) {
+ LEAVE("no menu");
+ return;
+ }
+
+ if (event) {
+ button = event->button;
+ event_time = event->time;
+ } else {
+ button = 0;
+ event_time = gtk_get_current_event_time ();
+ }
+
+ gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, event_time);
+ LEAVE(" ");
+}
+
+
+/** Callback function invoked when the user requests that Gnucash
+ * popup the contextual menu via the keyboard context-menu request
+ * key combination (Shift-F10 by default).
+ *
+ * @param page This is the GncPluginPage corresponding to the visible
+ * page.
+ *
+ * @param widget Whatever widget had focus when the user issued the
+ * keyboard context-menu request.
+ *
+ * @return Always returns TRUE to indicate that the menu request was
+ * handled.
+ */
+static gboolean
+gnc_main_window_popup_menu_cb (GtkWidget *widget,
+ GncPluginPage *page)
+{
+ ENTER("widget %p, page %p", widget, page);
+ do_popup_menu(page, NULL);
+ LEAVE(" ");
+ return TRUE;
+}
+
+
+/* Callback function invoked when the user clicks in the content of
+ * any Gnucash window. If this was a "right-click" then Gnucash will
+ * popup the contextual menu.
+ */
+gboolean
+gnc_main_window_button_press_cb (GtkWidget *whatever,
+ GdkEventButton *event,
+ GncPluginPage *page)
+{
+ g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
+
+ ENTER("widget %p, event %p, page %p", whatever, event, page);
+ /* Ignore double-clicks and triple-clicks */
+ if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
+ do_popup_menu(page, event);
+ LEAVE("menu shown");
+ return TRUE;
+ }
+
+ LEAVE("other click");
+ return FALSE;
+}
+
+
/** @} */
/** @} */
Index: gnc-plugin-page.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-plugin-page.h,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -Lsrc/gnome-utils/gnc-plugin-page.h -Lsrc/gnome-utils/gnc-plugin-page.h -u -r1.1.2.6 -r1.1.2.7
--- src/gnome-utils/gnc-plugin-page.h
+++ src/gnome-utils/gnc-plugin-page.h
@@ -50,11 +50,8 @@
#define GNC_PLUGIN_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_PLUGIN_PAGE, GncPluginPageClass))
/* typedefs & structures */
-typedef struct GncPluginPagePrivate GncPluginPagePrivate;
-
typedef struct GncPluginPage {
GObject parent; /**< The parent object data. */
- GncPluginPagePrivate *priv; /**< Object private data. */
GtkWidget *window; /**< The window that contains the
* display widget for this plugin.
@@ -88,8 +85,6 @@
GtkWidget *(* create_widget) (GncPluginPage *plugin_page);
void (* destroy_widget) (GncPluginPage *plugin_page);
void (* window_changed) (GncPluginPage *plugin_page, GtkWidget *window);
- void (* merge_actions) (GncPluginPage *plugin_page, GtkUIManager *merge);
- void (* unmerge_actions) (GncPluginPage *plugin_page, GtkUIManager *merge);
} GncPluginPageClass;
/* function prototypes */
@@ -143,39 +138,24 @@
*/
GtkWidget *gnc_plugin_page_get_window (GncPluginPage *page);
-/** Retrieve the name used in the notebook tab for this page.
- *
- * @param page The page whose tab name should be retrieved.
- *
- * @return The page's tab name. This string is owned by the page and
- * should not be freed by the caller.
- */
-const gchar *gnc_plugin_page_get_tab_name (GncPluginPage *page);
-
-/** Set the name used in the notebook tab for this page.
- *
- * @param page The page whose tab label should be set.
- *
- * @param name The new string for the tab label.
- */
-void gnc_plugin_page_set_tab_name (GncPluginPage *page, const char *name);
-
-/** Retrieve the page part of the window title.
+/** Retrieve the name of this page. This is the string used in the
+ * window title, and in the notebook tab and page selection menus.
*
- * @param page The page whose title component should be retrieved.
+ * @param page The page whose name should be retrieved.
*
- * @return The page title. This string is owned by the page and
+ * @return The page's name. This string is owned by the page and
* should not be freed by the caller.
*/
-const gchar *gnc_plugin_page_get_title (GncPluginPage *page);
+const gchar *gnc_plugin_page_get_page_name (GncPluginPage *page);
-/** Set the page part of the window title.
+/** Set the name of this page. This is the string used in the
+ * window title, and in the notebook tab and page selection menus.
*
- * @param page The page whose title component should be set.
+ * @param page The page whose name should be set.
*
- * @param name The new title for the page.
+ * @param name The new string for the name.
*/
-void gnc_plugin_page_set_title (GncPluginPage *page, const char *name);
+void gnc_plugin_page_set_page_name (GncPluginPage *page, const char *name);
/** Retrieve the Uniform Resource Identifier for this page.
*
@@ -232,12 +212,67 @@
void gnc_plugin_page_set_use_new_window (GncPluginPage *page, gboolean use_new);
+/** Retrieve the name of the XML UI file associated with this page.
+ *
+ * @param page The page whose setting should be retrieved.
+ *
+ * @return A pointer to the filename used for the UI. This
+ * string is owned by the page and should not be freed by the caller.
+ */
+const char *gnc_plugin_page_get_ui_description (GncPluginPage *page);
+
+
+/** Set an alternate UI for the specified page. This alternate ui
+ * may only use actions specified in the source for the page.
+ *
+ * @note This function must be called before the page is installed
+ * into a window.
+ *
+ * @param page The page to modify.
+ *
+ * @param ui_filename The filename (no path) of the alternate UI.
+ */
+void gnc_plugin_page_set_ui_description (GncPluginPage *page, const char *ui_filename);
+
+
+/** Retrieve the GtkUIManager object associated with this page.
+ *
+ * @param page The page whose UI information should be retrieved.
+ *
+ * @return A pointer to the GtkUIManager object for this page. */
+GtkUIManager *gnc_plugin_page_get_ui_merge (GncPluginPage *page);
+
+
+/** Retrieve the GtkActionGroup object associated with this page.
+ *
+ * @param page The page whose menu/toolbar action group should be
+ * retrieved.
+ *
+ * @return A pointer to the GtkActionGroup object for this page. */
+GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page);
+
+
+/** Create the GtkActionGroup object associated with this page.
+ *
+ * @param page The page whose menu/toolbar action group should be
+ * created.
+ *
+ * @param group_name The name associate with this action group. The
+ * name is used to associate keybindings with actions, so it should
+ * be consistent across all pages of the same type.
+ *
+ * @return A pointer to the newly created GtkActionGroup object for
+ * this page. */
+GtkActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name);
+
+
/* Signals */
void gnc_plugin_page_inserted (GncPluginPage *plugin_page);
void gnc_plugin_page_removed (GncPluginPage *plugin_page);
void gnc_plugin_page_selected (GncPluginPage *plugin_page);
void gnc_plugin_page_unselected (GncPluginPage *plugin_page);
+
G_END_DECLS
#endif /* __GNC_PLUGIN_PAGE_H */
Index: gnc-main-window-ui.xml
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/ui/Attic/gnc-main-window-ui.xml,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -Lsrc/gnome-utils/ui/gnc-main-window-ui.xml -Lsrc/gnome-utils/ui/gnc-main-window-ui.xml -u -r1.1.2.8 -r1.1.2.9
--- src/gnome-utils/ui/gnc-main-window-ui.xml
+++ src/gnome-utils/ui/gnc-main-window-ui.xml
@@ -125,9 +125,20 @@
<menu name="Misc" action="MiscAction">
<menuitem name="MiscTest" action="MiscTestAction"/>
</menu>
-
</menubar>
+ <popup name="MainPopup" action="FakeToplevel">
+ <separator name="PopupSep1"/>
+ <placeholder name="PopupPlaceholder1"/>
+ <separator name="PopupSep2"/>
+ <placeholder name="PopupPlaceholder2"/>
+ <separator name="PopupSep3"/>
+ <placeholder name="PopupPlaceholder3"/>
+ <separator name="PopupSep4"/>
+ <placeholder name="PopupPlaceholder4"/>
+ <separator name="PopupSep5"/>
+ </popup>
+
<toolbar name="DefaultToolbar">
<placeholder name="ToolbarSavePlaceholder"/>
<toolitem name="ToolbarClose" action="FileCloseAction"/>
Index: gnc-plugin-page-invoice.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-gnome/Attic/gnc-plugin-page-invoice.c,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -Lsrc/business/business-gnome/gnc-plugin-page-invoice.c -Lsrc/business/business-gnome/gnc-plugin-page-invoice.c -u -r1.1.2.5 -r1.1.2.6
--- src/business/business-gnome/gnc-plugin-page-invoice.c
+++ src/business/business-gnome/gnc-plugin-page-invoice.c
@@ -47,15 +47,8 @@
static GtkWidget *gnc_plugin_page_invoice_create_widget (GncPluginPage *plugin_page);
static void gnc_plugin_page_invoice_destroy_widget (GncPluginPage *plugin_page);
static void gnc_plugin_page_invoice_window_changed (GncPluginPage *plugin_page, GtkWidget *window);
-static void gnc_plugin_page_invoice_merge_actions (GncPluginPage *plugin_page, GtkUIManager *ui_merge);
-static void gnc_plugin_page_invoice_unmerge_actions (GncPluginPage *plugin_page, GtkUIManager *ui_merge);
-/* Callbacks */
-static gboolean gnc_plugin_page_invoice_button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- GncPluginPageInvoice *page);
-
void gnc_plugin_page_invoice_start_toggle_cb(GtkToggleButton *toggle, gpointer data);
void gnc_plugin_page_invoice_end_toggle_cb(GtkToggleButton *toggle, gpointer data);
void gnc_plugin_page_invoice_today_cb(GtkButton *buttontoggle, gpointer data);
@@ -209,10 +202,6 @@
struct GncPluginPageInvoicePrivate
{
- GtkActionGroup *action_group;
- guint merge_id;
- GtkUIManager *ui_merge;
-
InvoiceWindow *iw;
GtkWidget *widget;
@@ -293,8 +282,6 @@
gnc_plugin_class->create_widget = gnc_plugin_page_invoice_create_widget;
gnc_plugin_class->destroy_widget = gnc_plugin_page_invoice_destroy_widget;
gnc_plugin_class->window_changed = gnc_plugin_page_invoice_window_changed;
- gnc_plugin_class->merge_actions = gnc_plugin_page_invoice_merge_actions;
- gnc_plugin_class->unmerge_actions = gnc_plugin_page_invoice_unmerge_actions;
}
static void
@@ -310,19 +297,21 @@
/* Init parent declared variables */
parent = GNC_PLUGIN_PAGE(plugin_page);
- gnc_plugin_page_set_title(parent, _("Invoice"));
- gnc_plugin_page_set_tab_name(parent, _("Incoice"));
- gnc_plugin_page_set_uri(parent, "default:");
-
use_new = gnc_gconf_get_bool(GCONF_SECTION_INVOICE, KEY_USE_NEW, NULL);
- gnc_plugin_page_set_use_new_window(parent, use_new);
+ g_object_set(G_OBJECT(plugin_page),
+ "page-name", _("Invoice"),
+ "page-uri", "default:",
+ "ui-description", "gnc-plugin-page-invoice-ui.xml",
+ "use-new-window", use_new,
+ NULL);
/* change me when the system supports multiple books */
gnc_plugin_page_add_book(parent, gnc_get_current_book());
/* Create menu and toolbar information */
- action_group = gtk_action_group_new ("GncPluginPageInvoiceActions");
- priv->action_group = action_group;
+ action_group =
+ gnc_plugin_page_create_action_group(parent,
+ "GncPluginPageInvoiceActions");
gtk_action_group_add_actions (action_group, gnc_plugin_page_invoice_actions,
gnc_plugin_page_invoice_n_actions, plugin_page);
gtk_action_group_add_radio_actions (action_group,
@@ -355,13 +344,11 @@
void
gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, gboolean can_unpost)
{
- GncPluginPageInvoice *invoice_page;
GtkActionGroup *action_group;
g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(page));
- invoice_page = GNC_PLUGIN_PAGE_INVOICE(page);
- action_group = invoice_page->priv->action_group;
+ action_group = gnc_plugin_page_get_action_group(page);
gnc_plugin_update_actions (action_group, posted_actions,
"sensitive", is_posted);
gnc_plugin_update_actions (action_group, unposted_actions,
@@ -396,8 +383,6 @@
if (regWidget) {
g_signal_connect (G_OBJECT (regWidget), "redraw-help",
G_CALLBACK (gnc_plugin_page_redraw_help_cb), page);
- g_signal_connect (G_OBJECT (regWidget), "button-press-event",
- G_CALLBACK (gnc_plugin_page_invoice_button_press_cb), page);
}
priv->component_manager_id =
@@ -443,61 +428,6 @@
gnc_invoice_window_changed (page->priv->iw, window);
}
-static void
-gnc_plugin_page_invoice_merge_actions (GncPluginPage *plugin_page,
- GtkUIManager *ui_merge)
-{
- GncPluginPageInvoice *invoice_page;
- GncPluginPageInvoicePrivate *priv;
-
- g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE (plugin_page));
-
- invoice_page = GNC_PLUGIN_PAGE_INVOICE(plugin_page);
- priv = invoice_page->priv;
-
- priv->ui_merge = ui_merge;
- priv->merge_id =
- gnc_plugin_add_actions (priv->ui_merge,
- priv->action_group,
- "gnc-plugin-page-invoice-ui.xml");
-}
-
-static void
-gnc_plugin_page_invoice_unmerge_actions (GncPluginPage *plugin_page,
- GtkUIManager *ui_merge)
-{
- GncPluginPageInvoice *plugin_page_register = GNC_PLUGIN_PAGE_INVOICE(plugin_page);
-
- g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE (plugin_page_register));
- g_return_if_fail (plugin_page_register->priv->merge_id != 0);
- g_return_if_fail (plugin_page_register->priv->action_group != NULL);
-
- gtk_ui_manager_remove_ui (ui_merge, plugin_page_register->priv->merge_id);
- gtk_ui_manager_remove_action_group (ui_merge, plugin_page_register->priv->action_group);
-
- plugin_page_register->priv->ui_merge = NULL;
-}
-
-
-/* Callbacks */
-static gboolean
-gnc_plugin_page_invoice_button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- GncPluginPageInvoice *page)
-{
- GtkWidget *menu;
-
- if (event->button == 3 && page->priv->ui_merge != NULL) {
- /* Maybe show a different popup menu if no account is selected. */
- menu = gtk_ui_manager_get_widget (page->priv->ui_merge, "/RegisterPopup");
- if (menu)
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
- event->button, event->time);
- return TRUE;
- }
-
- return FALSE;
-}
/************************************************************/
/* Command callbacks */
@@ -761,9 +691,7 @@
page = GNC_PLUGIN_PAGE_INVOICE(plugin_page);
title = gnc_invoice_get_title(page->priv->iw);
- plugin_page = GNC_PLUGIN_PAGE(page);
- gnc_plugin_page_set_tab_name(plugin_page, title);
- gnc_plugin_page_set_title(plugin_page, title);
+ gnc_plugin_page_set_page_name(plugin_page, title);
g_free(title);
}
Index: gnc-plugin-page-account-tree-ui.xml
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/ui/Attic/gnc-plugin-page-account-tree-ui.xml,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -Lsrc/gnome/ui/gnc-plugin-page-account-tree-ui.xml -Lsrc/gnome/ui/gnc-plugin-page-account-tree-ui.xml -u -r1.1.2.9 -r1.1.2.10
--- src/gnome/ui/gnc-plugin-page-account-tree-ui.xml
+++ src/gnome/ui/gnc-plugin-page-account-tree-ui.xml
@@ -38,8 +38,11 @@
</menu>
</menubar>
- <popup name="AccountPopup" action="FakeToplevel">
- <placeholder name="ActionsMiddlePlaceholder">
+ <popup name="MainPopup" action="FakeToplevel">
+ <placeholder name="PopupPlaceholder1">
+ <menuitem name="PopupOptions" action="PopupOptionsAction"/>
+ </placeholder>
+ <placeholder name="PopupPlaceholder2">
<menuitem name="AccountOpenAccount" action="FileOpenAccountAction"/>
<menuitem name="AccountOpenSubaccounts" action="FileOpenSubaccountsAction"/>
<menuitem name="AccountEditAccount" action="EditEditAccountAction"/>
@@ -53,7 +56,7 @@
<menuitem name="AccountDeleteAccount" action="EditDeleteAccountAction"/>
<separator name="AccountSep3"/>
</placeholder>
- <placeholder name="ActionsBottomPlaceholder">
+ <placeholder name="PopupBottomPlaceholder">
<menu name="ScrubMenu" action="ScrubMenuAction">
<menuitem name="Scrub" action="ScrubAction"/>
<menuitem name="ScrubSub" action="ScrubSubAction"/>
Index: gnc-plugin-page-register-ui.xml
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/ui/Attic/gnc-plugin-page-register-ui.xml,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -Lsrc/gnome/ui/gnc-plugin-page-register-ui.xml -Lsrc/gnome/ui/gnc-plugin-page-register-ui.xml -u -r1.1.2.10 -r1.1.2.11
--- src/gnome/ui/gnc-plugin-page-register-ui.xml
+++ src/gnome/ui/gnc-plugin-page-register-ui.xml
@@ -80,21 +80,24 @@
</placeholder>
</toolbar>
- <popup name="RegisterPopup" action="FakeToplevel">
- <menuitem name="ViewSortBy" action="ViewSortByAction"/>
- <menuitem name="ViewFilterBy" action="ViewFilterByAction"/>
- <separator name="PopupSep1"/>
- <menuitem name="DuplicateTransaction" action="DuplicateTransactionAction"/>
- <menuitem name="DeleteTransaction" action="DeleteTransactionAction"/>
- <menuitem name="RemoveTransactionSplits" action="RemoveTransactionSplitsAction"/>
- <separator name="PopupSep2"/>
- <menuitem name="RecordTransaction" action="RecordTransactionAction"/>
- <menuitem name="CancelTransaction" action="CancelTransactionAction"/>
- <separator name="PopupSep3"/>
- <menuitem name="BlankTransaction" action="BlankTransactionAction"/>
- <menuitem name="SplitTransaction" action="SplitTransactionAction"/>
- <menuitem name="EditExchangeRate" action="EditExchangeRateAction"/>
- <menuitem name="ScheduleTransaction" action="ScheduleTransactionAction"/>
- <menuitem name="JumpTransaction" action="JumpTransactionAction"/>
+ <popup name="MainPopup" action="FakeToplevel">
+ <placeholder name="PopupPlaceholder1">
+ <menuitem name="ViewSortBy" action="ViewSortByAction"/>
+ <menuitem name="ViewFilterBy" action="ViewFilterByAction"/>
+ </placeholder>
+ <placeholder name="PopupPlaceholder2">
+ <menuitem name="DuplicateTransaction" action="DuplicateTransactionAction"/>
+ <menuitem name="DeleteTransaction" action="DeleteTransactionAction"/>
+ <menuitem name="RemoveTransactionSplits" action="RemoveTransactionSplitsAction"/>
+ <separator name="PopupSep2"/>
+ <menuitem name="RecordTransaction" action="RecordTransactionAction"/>
+ <menuitem name="CancelTransaction" action="CancelTransactionAction"/>
+ <separator name="PopupSep3"/>
+ <menuitem name="BlankTransaction" action="BlankTransactionAction"/>
+ <menuitem name="SplitTransaction" action="SplitTransactionAction"/>
+ <menuitem name="EditExchangeRate" action="EditExchangeRateAction"/>
+ <menuitem name="ScheduleTransaction" action="ScheduleTransactionAction"/>
+ <menuitem name="JumpTransaction" action="JumpTransactionAction"/>
+ </placeholder>
</popup>
</ui>
Index: gnc-plugin-page-report-ui.xml
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/report-gnome/Attic/gnc-plugin-page-report-ui.xml,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -Lsrc/report/report-gnome/gnc-plugin-page-report-ui.xml -Lsrc/report/report-gnome/gnc-plugin-page-report-ui.xml -u -r1.1.2.2 -r1.1.2.3
--- src/report/report-gnome/gnc-plugin-page-report-ui.xml
+++ src/report/report-gnome/gnc-plugin-page-report-ui.xml
@@ -15,6 +15,12 @@
</menu>
</menubar>
+ <popup name="MainPopup" action="FakeToplevel">
+ <placeholder name="PopupPlaceholder1">
+ <menuitem name="PopupOptions" action="ReportOptionsAction"/>
+ </placeholder>
+ </popup>
+
<toolbar name="DefaultToolbar">
<placeholder name="DefaultToolbarPlaceholder">
<separator name="ReportToolbarSep0" />
Index: gnc-plugin-page-report.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/report-gnome/Attic/gnc-plugin-page-report.c,v
retrieving revision 1.1.2.21
retrieving revision 1.1.2.22
diff -Lsrc/report/report-gnome/gnc-plugin-page-report.c -Lsrc/report/report-gnome/gnc-plugin-page-report.c -u -r1.1.2.21 -r1.1.2.22
--- src/report/report-gnome/gnc-plugin-page-report.c
+++ src/report/report-gnome/gnc-plugin-page-report.c
@@ -75,8 +75,6 @@
static void gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint reportId);
static GtkWidget* gnc_plugin_page_report_create_widget( GncPluginPage *plugin_page );
-static void gnc_plugin_page_report_merge_actions( GncPluginPage *plugin_page, GtkUIManager *merge );
-static void gnc_plugin_page_report_unmerge_actions( GncPluginPage *plugin_page, GtkUIManager *merge );
static void gnc_plugin_page_report_destroy_widget( GncPluginPage *plugin_page );
static int gnc_plugin_page_report_check_urltype(URLType t);
@@ -85,8 +83,8 @@
gpointer data);
static void gnc_plugin_page_report_expose_event_cb(GtkWidget *unused, GdkEventExpose *unused1, gpointer data);
static void gnc_plugin_page_report_refresh (gpointer data);
-static void gnc_plugin_page_report_set_fwd_button(GncPluginPageReportPrivate * win, int enabled);
-static void gnc_plugin_page_report_set_back_button(GncPluginPageReportPrivate * win, int enabled);
+static void gnc_plugin_page_report_set_fwd_button(GncPluginPageReport * page, int enabled);
+static void gnc_plugin_page_report_set_back_button(GncPluginPageReport * page, int enabled);
static void gnc_plugin_page_report_history_destroy_cb(gnc_html_history_node * node, gpointer user_data);
static void close_handler(gpointer user_data);
void gnc_plugin_page_report_destroy(GncPluginPageReportPrivate * win);
@@ -134,12 +132,6 @@
/// the container the above HTML widget is in.
GtkContainer *container;
-
- /// The GtkActionGroup to use for [un]merging our UI.
- GtkActionGroup *action_group;
-
- GtkUIManager *ui_merge;
- gint merge_id;
};
GType
@@ -238,8 +230,6 @@
gnc_plugin_page_class->create_widget = gnc_plugin_page_report_create_widget;
gnc_plugin_page_class->destroy_widget = gnc_plugin_page_report_destroy_widget;
- gnc_plugin_page_class->merge_actions = gnc_plugin_page_report_merge_actions;
- gnc_plugin_page_class->unmerge_actions = gnc_plugin_page_report_unmerge_actions;
// create the "reportId" property
g_object_class_install_property( object_class,
@@ -311,7 +301,7 @@
close_handler, report );
gnc_html_set_urltype_cb(report->html, gnc_plugin_page_report_check_urltype);
- gnc_html_set_load_cb(report->html, gnc_plugin_page_report_load_cb, report);
+ gnc_html_set_load_cb(report->html, gnc_plugin_page_report_load_cb, gppReport);
// FIXME. This is f^-1(f(x)), isn't it?
DEBUG( "id=%d", report->reportId );
@@ -401,8 +391,8 @@
const gchar * location, const gchar * label,
gpointer data)
{
- //GncPluginPageReport *report = GNC_PLUGIN_PAGE_REPORT();
- GncPluginPageReportPrivate *win = (GncPluginPageReportPrivate*)data;
+ GncPluginPageReport *report = GNC_PLUGIN_PAGE_REPORT(data);
+ GncPluginPageReportPrivate *win = report->priv;
int report_id;
SCM find_report = scm_c_eval_string("gnc:find-report");
SCM get_options = scm_c_eval_string("gnc:report-options");
@@ -480,15 +470,15 @@
win, NULL, NULL);
if (gnc_html_history_forward_p(gnc_html_get_history(win->html))) {
- gnc_plugin_page_report_set_fwd_button(win, TRUE);
+ gnc_plugin_page_report_set_fwd_button(report, TRUE);
} else {
- gnc_plugin_page_report_set_fwd_button(win, FALSE);
+ gnc_plugin_page_report_set_fwd_button(report, FALSE);
}
if(gnc_html_history_back_p(gnc_html_get_history(win->html))) {
- gnc_plugin_page_report_set_back_button(win, TRUE);
+ gnc_plugin_page_report_set_back_button(report, TRUE);
} else {
- gnc_plugin_page_report_set_back_button(win, FALSE);
+ gnc_plugin_page_report_set_back_button(report, FALSE);
}
LEAVE( "done" );
@@ -632,40 +622,6 @@
g_free(win);
}
-static void
-gnc_plugin_page_report_merge_actions( GncPluginPage *plugin_page,
- GtkUIManager *ui_merge )
-{
- GncPluginPageReport *page;
- GncPluginPageReportPrivate *priv;
-
- page = GNC_PLUGIN_PAGE_REPORT(plugin_page);
- priv = (GncPluginPageReportPrivate*)page->priv;
-
- DEBUG( "merge actions" );
- priv->ui_merge = ui_merge;
- priv->merge_id
- = gnc_plugin_add_actions( priv->ui_merge,
- priv->action_group,
- "gnc-plugin-page-report-ui.xml" );
- DEBUG( "done merging" );
-}
-
-static void
-gnc_plugin_page_report_unmerge_actions( GncPluginPage *plugin_page,
- GtkUIManager *ui_merge )
-{
- GncPluginPageReport *rep = GNC_PLUGIN_PAGE_REPORT( plugin_page );
- GncPluginPageReportPrivate *priv = (GncPluginPageReportPrivate*)rep->priv;
-
- DEBUG( "unmerge actions" );
- gtk_ui_manager_remove_ui( ui_merge, priv->merge_id );
- gtk_ui_manager_remove_action_group( ui_merge, priv->action_group );
-
- priv->ui_merge = NULL;
- DEBUG( "done unmerging" );
-}
-
static GtkActionEntry report_actions[] =
{
{ "FilePrintAction", GTK_STOCK_PRINT, N_("Print Report..."), NULL, NULL,
@@ -742,24 +698,25 @@
/* Init parent declared variables */
parent = GNC_PLUGIN_PAGE(plugin_page);
+ use_new = gnc_gconf_get_bool(GCONF_GENERAL_REPORT, KEY_USE_NEW, NULL);
tmpStr = g_string_sized_new( 32 );
g_string_sprintf( tmpStr, "%s: %s", _("Report"),
gnc_report_name( plugin_page->priv->initial_report ) );
- gnc_plugin_page_set_title(parent, tmpStr->str);
- gnc_plugin_page_set_tab_name(parent, tmpStr->str);
- gnc_plugin_page_set_uri(parent, "default:");
-
- use_new = gnc_gconf_get_bool(GCONF_GENERAL_REPORT, KEY_USE_NEW, NULL);
- gnc_plugin_page_set_use_new_window(parent, use_new);
+ g_object_set(G_OBJECT(plugin_page),
+ "page-name", tmpStr->str,
+ "page-uri", "default:",
+ "ui-description", "gnc-plugin-page-report-ui.xml",
+ "use-new-window", use_new,
+ NULL);
/* change me when the system supports multiple books */
gnc_plugin_page_add_book(parent, gnc_get_current_book());
- /* Create menu and toolbar information. */
- /* Note that we're not actually doing the merge, here ... just setup
- * the UI objects. See gnc_plugin_page_report_[un]merge_actions(...) */
- action_group = gtk_action_group_new ("GncPluginPageReportActions");
- plugin_page->priv->action_group = action_group;
+ /* Create menu and toolbar information */
+ action_group =
+ gnc_plugin_page_create_action_group(parent,
+ "GncPluginPageReportActions");
+ action_group = gnc_plugin_page_get_action_group(parent);
gtk_action_group_add_actions( action_group,
report_actions,
num_report_actions,
@@ -817,24 +774,28 @@
}
static void
-gnc_plugin_page_report_set_fwd_button(GncPluginPageReportPrivate *win, int enabled)
+gnc_plugin_page_report_set_fwd_button(GncPluginPageReport *report, int enabled)
{
+ GtkActionGroup *action_group;
GValue value = { 0 };
GtkAction *act;
- act = gtk_action_group_get_action( win->action_group, "ReportForwAction" );
+ action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(report));
+ act = gtk_action_group_get_action( action_group, "ReportForwAction" );
g_value_init (&value, G_TYPE_BOOLEAN);
g_value_set_boolean (&value, enabled);
g_object_set_property( G_OBJECT(act), "sensitive", &value );
}
static void
-gnc_plugin_page_report_set_back_button(GncPluginPageReportPrivate *win, int enabled)
+gnc_plugin_page_report_set_back_button(GncPluginPageReport *report, int enabled)
{
+ GtkActionGroup *action_group;
GValue value = { 0 };
GtkAction *act;
- act = gtk_action_group_get_action( win->action_group, "ReportBackAction" );
+ action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(report));
+ act = gtk_action_group_get_action( action_group, "ReportBackAction" );
g_value_init (&value, G_TYPE_BOOLEAN);
g_value_set_boolean (&value, enabled);
g_object_set_property( G_OBJECT(act), "sensitive", &value );
More information about the gnucash-changes
mailing list