mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Tweak the plugin page functions for more flexibility.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9300 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -291,7 +291,7 @@ gnc_main_window_open_page (GncMainWindow *window,
|
||||
GtkWidget *label_box;
|
||||
GtkWidget *label;
|
||||
const gchar *icon;
|
||||
const gchar *title;
|
||||
gchar *tab_name;
|
||||
GtkWidget *image;
|
||||
/* gint pos;*/
|
||||
|
||||
@@ -300,12 +300,13 @@ gnc_main_window_open_page (GncMainWindow *window,
|
||||
|
||||
child = gnc_plugin_page_create_widget (page);
|
||||
g_object_set_data (G_OBJECT (child), "page-plugin", page);
|
||||
g_object_set_data (G_OBJECT (child), "window", window);
|
||||
|
||||
icon = gnc_plugin_page_get_icon (page);
|
||||
title = gnc_plugin_page_get_title (page);
|
||||
|
||||
label = gtk_label_new (title);
|
||||
icon = gnc_plugin_page_get_tab_icon (page);
|
||||
tab_name = gnc_plugin_page_get_tab_name (page);
|
||||
label = gtk_label_new (tab_name);
|
||||
gtk_widget_show (label);
|
||||
g_free(tab_name);
|
||||
|
||||
if (icon != NULL) {
|
||||
/* FIXME */
|
||||
|
||||
@@ -71,8 +71,9 @@ static GtkWidget *gnc_plugin_page_account_tree_create_widget (GncPluginPage *plu
|
||||
static void gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page);
|
||||
static void gnc_plugin_page_account_tree_merge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
|
||||
static void gnc_plugin_page_account_tree_unmerge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_account_tree_get_title (GncPluginPage *plugin_page);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_account_tree_get_icon (GncPluginPage *plugin_page);
|
||||
static gchar *gnc_plugin_page_account_tree_get_title (GncPluginPage *plugin_page);
|
||||
static gchar *gnc_plugin_page_account_tree_get_tab_name (GncPluginPage *plugin_page);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_account_tree_get_tab_icon (GncPluginPage *plugin_page);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_account_tree_get_plugin_name (GncPluginPage *plugin_page);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_account_tree_get_uri (GncPluginPage *plugin_page);
|
||||
|
||||
@@ -432,7 +433,8 @@ gnc_plugin_page_account_tree_plugin_page_init (GncPluginPageIface *iface)
|
||||
iface->merge_actions = gnc_plugin_page_account_tree_merge_actions;
|
||||
iface->unmerge_actions = gnc_plugin_page_account_tree_unmerge_actions;
|
||||
iface->get_title = gnc_plugin_page_account_tree_get_title;
|
||||
iface->get_icon = gnc_plugin_page_account_tree_get_icon;
|
||||
iface->get_tab_name = gnc_plugin_page_account_tree_get_tab_name;
|
||||
iface->get_tab_icon = gnc_plugin_page_account_tree_get_tab_icon;
|
||||
iface->get_plugin_name = gnc_plugin_page_account_tree_get_plugin_name;
|
||||
iface->get_uri = gnc_plugin_page_account_tree_get_uri;
|
||||
LEAVE(" ");
|
||||
@@ -542,14 +544,20 @@ gnc_plugin_page_account_tree_unmerge_actions (GncPluginPage *plugin_page,
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
static G_CONST_RETURN gchar *
|
||||
static gchar *
|
||||
gnc_plugin_page_account_tree_get_title (GncPluginPage *plugin_page)
|
||||
{
|
||||
return _("Accounts");
|
||||
return g_strdup(_("Accounts"));
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gnc_plugin_page_account_tree_get_tab_name (GncPluginPage *plugin_page)
|
||||
{
|
||||
return g_strdup(_("Accounts"));
|
||||
}
|
||||
|
||||
static G_CONST_RETURN gchar *
|
||||
gnc_plugin_page_account_tree_get_icon (GncPluginPage *plugin_page)
|
||||
gnc_plugin_page_account_tree_get_tab_icon (GncPluginPage *plugin_page)
|
||||
{
|
||||
return GNC_STOCK_ACCOUNT;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <gtk/gtkvbox.h>
|
||||
#include "egg-action-group.h"
|
||||
#include "global-options.h"
|
||||
#include "gnc-icons.h"
|
||||
#include "gnc-plugin-page-register.h"
|
||||
#include "gnc-plugin-register.h"
|
||||
#include "gnc-split-reg.h"
|
||||
@@ -47,8 +48,9 @@ static GtkWidget *gnc_plugin_page_register_create_widget (GncPluginPage *plugin_
|
||||
static void gnc_plugin_page_register_destroy_widget (GncPluginPage *plugin_page);
|
||||
static void gnc_plugin_page_register_merge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
|
||||
static void gnc_plugin_page_register_unmerge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_register_get_title (GncPluginPage *plugin_page);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_register_get_icon (GncPluginPage *plugin_page);
|
||||
static gchar *gnc_plugin_page_register_get_title (GncPluginPage *plugin_page);
|
||||
static gchar *gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_register_get_tab_icon (GncPluginPage *plugin_page);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_register_get_plugin_name (GncPluginPage *plugin_page);
|
||||
static G_CONST_RETURN gchar *gnc_plugin_page_register_get_uri (GncPluginPage *plugin_page);
|
||||
|
||||
@@ -243,7 +245,8 @@ gnc_plugin_page_register_plugin_page_init (GncPluginPageIface *iface)
|
||||
iface->merge_actions = gnc_plugin_page_register_merge_actions;
|
||||
iface->unmerge_actions = gnc_plugin_page_register_unmerge_actions;
|
||||
iface->get_title = gnc_plugin_page_register_get_title;
|
||||
iface->get_icon = gnc_plugin_page_register_get_icon;
|
||||
iface->get_tab_name = gnc_plugin_page_register_get_tab_name;
|
||||
iface->get_tab_icon = gnc_plugin_page_register_get_tab_icon;
|
||||
iface->get_plugin_name = gnc_plugin_page_register_get_plugin_name;
|
||||
iface->get_uri = gnc_plugin_page_register_get_uri;
|
||||
}
|
||||
@@ -326,16 +329,60 @@ gnc_plugin_page_register_unmerge_actions (GncPluginPage *plugin_page,
|
||||
plugin_page_register->priv->ui_merge = NULL;
|
||||
}
|
||||
|
||||
static G_CONST_RETURN gchar *
|
||||
|
||||
static gchar *
|
||||
gnc_plugin_page_register_get_title (GncPluginPage *plugin_page)
|
||||
{
|
||||
return _("General Ledger");
|
||||
return g_strdup(_("General Ledger"));
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page)
|
||||
{
|
||||
GNCLedgerDisplayType ledger_type;
|
||||
GNCLedgerDisplay *ld;
|
||||
SplitRegister *reg;
|
||||
Account *leader;
|
||||
|
||||
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), _("unknown"));
|
||||
|
||||
ld = GNC_PLUGIN_PAGE_REGISTER (plugin_page)->priv->ld;
|
||||
reg = gnc_ledger_display_get_split_register (ld);
|
||||
ledger_type = gnc_ledger_display_type (ld);
|
||||
leader = gnc_ledger_display_leader (ld);
|
||||
|
||||
switch (ledger_type) {
|
||||
case LD_SINGLE:
|
||||
return g_strdup(xaccAccountGetName (leader));
|
||||
|
||||
case LD_SUBACCOUNT:
|
||||
return g_strdup_printf("%s+", xaccAccountGetName (leader));
|
||||
|
||||
case LD_GL:
|
||||
switch (reg->type) {
|
||||
case GENERAL_LEDGER:
|
||||
case INCOME_LEDGER:
|
||||
return g_strdup(_("General Ledger"));
|
||||
case PORTFOLIO_LEDGER:
|
||||
return g_strdup(_("Portfolio"));
|
||||
case SEARCH_LEDGER:
|
||||
return g_strdup(_("Search Results"));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return g_strdup(_("unknown"));
|
||||
}
|
||||
|
||||
static G_CONST_RETURN gchar *
|
||||
gnc_plugin_page_register_get_icon (GncPluginPage *plugin_page)
|
||||
gnc_plugin_page_register_get_tab_icon (GncPluginPage *plugin_page)
|
||||
{
|
||||
return NULL;
|
||||
return GNC_STOCK_ACCOUNT;
|
||||
}
|
||||
|
||||
static G_CONST_RETURN gchar *
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
#include "Account.h"
|
||||
#include "gnc-plugin-page.h"
|
||||
|
||||
#include "gnc-ledger-display.h"
|
||||
|
||||
@@ -116,7 +116,7 @@ gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page,
|
||||
GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->unmerge_actions (plugin_page, ui_merge);
|
||||
}
|
||||
|
||||
G_CONST_RETURN gchar *
|
||||
gchar *
|
||||
gnc_plugin_page_get_title (GncPluginPage *plugin_page)
|
||||
{
|
||||
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL);
|
||||
@@ -125,13 +125,22 @@ gnc_plugin_page_get_title (GncPluginPage *plugin_page)
|
||||
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_title (plugin_page);
|
||||
}
|
||||
|
||||
G_CONST_RETURN gchar *
|
||||
gnc_plugin_page_get_icon (GncPluginPage *plugin_page)
|
||||
gchar *
|
||||
gnc_plugin_page_get_tab_name (GncPluginPage *plugin_page)
|
||||
{
|
||||
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL);
|
||||
g_return_val_if_fail (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_icon != NULL, NULL);
|
||||
g_return_val_if_fail (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_tab_name != NULL, NULL);
|
||||
|
||||
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_icon (plugin_page);
|
||||
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_tab_name (plugin_page);
|
||||
}
|
||||
|
||||
G_CONST_RETURN gchar *
|
||||
gnc_plugin_page_get_tab_icon (GncPluginPage *plugin_page)
|
||||
{
|
||||
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL);
|
||||
g_return_val_if_fail (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_tab_icon != NULL, NULL);
|
||||
|
||||
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_tab_icon (plugin_page);
|
||||
}
|
||||
|
||||
G_CONST_RETURN gchar *
|
||||
|
||||
@@ -56,8 +56,9 @@ typedef struct {
|
||||
void (* merge_actions) (GncPluginPage *plugin_page, EggMenuMerge *merge);
|
||||
void (* unmerge_actions) (GncPluginPage *plugin_page, EggMenuMerge *merge);
|
||||
|
||||
G_CONST_RETURN gchar *(* get_title) (GncPluginPage *plugin_page);
|
||||
G_CONST_RETURN gchar *(* get_icon) (GncPluginPage *plugin_page);
|
||||
gchar *(* get_title) (GncPluginPage *plugin_page);
|
||||
gchar *(* get_tab_name) (GncPluginPage *plugin_page);
|
||||
G_CONST_RETURN gchar *(* get_tab_icon) (GncPluginPage *plugin_page);
|
||||
|
||||
G_CONST_RETURN gchar *(* get_plugin_name) (GncPluginPage *plugin_page);
|
||||
G_CONST_RETURN gchar *(* get_uri) (GncPluginPage *plugin_page);
|
||||
@@ -74,8 +75,9 @@ void gnc_plugin_page_merge_actions (GncPluginPage *plugin_pag
|
||||
void gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page,
|
||||
EggMenuMerge *merge);
|
||||
|
||||
G_CONST_RETURN gchar *gnc_plugin_page_get_title (GncPluginPage *plugin_page);
|
||||
G_CONST_RETURN gchar *gnc_plugin_page_get_icon (GncPluginPage *plugin_page);
|
||||
gchar *gnc_plugin_page_get_title (GncPluginPage *plugin_page);
|
||||
gchar *gnc_plugin_page_get_tab_name (GncPluginPage *plugin_page);
|
||||
G_CONST_RETURN gchar *gnc_plugin_page_get_tab_icon (GncPluginPage *plugin_page);
|
||||
|
||||
G_CONST_RETURN gchar *gnc_plugin_page_get_plugin_name (GncPluginPage *plugin_page);
|
||||
G_CONST_RETURN gchar *gnc_plugin_page_get_uri (GncPluginPage *plugin_page);
|
||||
|
||||
Reference in New Issue
Block a user