Derive the GncPluginPage widget from a GObject instead of a

GInterface.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9429 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton
2003-09-29 03:06:33 +00:00
parent 7b31038eb4
commit 3c39fa12ef
8 changed files with 220 additions and 315 deletions

View File

@@ -1,3 +1,11 @@
2003-09-28 David Hampton <hampton@employees.org>
* src/gnome/gnc-main-window.c:
* src/gnome/gnc-plugin-page-account-tree.[ch]:
* src/gnome/gnc-plugin-page-register.[ch]:
* src/gnome/gnc-plugin-page.[ch]: Derive the GncPluginPage widget
from a GObject instead of a GInterface.
2003-09-27 David Hampton <hampton@employees.org> 2003-09-27 David Hampton <hampton@employees.org>
* lib/egg/egg-action-group.[ch]: * lib/egg/egg-action-group.[ch]:

View File

@@ -2,8 +2,8 @@
* gnc-main-window.c -- GtkWindow which represents the * gnc-main-window.c -- GtkWindow which represents the
* GnuCash main window. * GnuCash main window.
* *
* Copyright (C) 2003 Jan Arne Petersen * Copyright (C) 2003 Jan Arne Petersen <jpetersen@uni-bonn.de>
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de> * Copyright (C) 2003 David Hampton <hampton@employees.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -304,7 +304,6 @@ gnc_main_window_open_page (GncMainWindow *window,
GtkWidget *label_box; GtkWidget *label_box;
GtkWidget *label; GtkWidget *label;
const gchar *icon; const gchar *icon;
gchar *tab_name;
GtkWidget *image; GtkWidget *image;
GtkNotebook *notebook; GtkNotebook *notebook;
@@ -313,15 +312,13 @@ gnc_main_window_open_page (GncMainWindow *window,
g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
gnc_plugin_page_set_window (page, GTK_WIDGET(window)); page->window = GTK_WIDGET(window);
child = gnc_plugin_page_create_widget (page); child = gnc_plugin_page_create_widget (page);
g_object_set_data (G_OBJECT (child), "page-plugin", page); g_object_set_data (G_OBJECT (child), "page-plugin", page);
icon = gnc_plugin_page_get_tab_icon (page); icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
tab_name = gnc_plugin_page_get_tab_name (page); label = gtk_label_new (page->tab_name);
label = gtk_label_new (tab_name);
gtk_widget_show (label); gtk_widget_show (label);
g_free(tab_name);
if (icon != NULL) { if (icon != NULL) {
/* FIXME */ /* FIXME */
@@ -715,8 +712,8 @@ gnc_main_window_cmd_file_open_new_window (EggAction *action, GncMainWindow *wind
new_window = gnc_main_window_new (); new_window = gnc_main_window_new ();
if (window->priv->current_page != NULL) { if (window->priv->current_page != NULL) {
name = gnc_plugin_page_get_plugin_name (window->priv->current_page); name = GNC_PLUGIN_PAGE_GET_CLASS (window->priv->current_page)->plugin_name;
uri = gnc_plugin_page_get_uri (window->priv->current_page); uri = window->priv->current_page->uri;
plugin = gnc_plugin_manager_get_plugin (gnc_plugin_manager_get (), name); plugin = gnc_plugin_manager_get_plugin (gnc_plugin_manager_get (), name);
page = gnc_plugin_create_page (plugin, uri); page = gnc_plugin_create_page (plugin, uri);

View File

@@ -1,8 +1,8 @@
/* /*
* gnc-plugin-page-account-tree.c -- * gnc-plugin-page-account-tree.c --
* *
* Copyright (C) 2003 Jan Arne Petersen * Copyright (C) 2003 Jan Arne Petersen <jpetersen@uni-bonn.de>
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de> * Copyright (C) 2003 David Hampton <hampton@employees.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -69,17 +69,10 @@ static void gnc_plugin_page_account_tree_finalize (GObject *object);
static Account *gnc_plugin_page_account_tree_get_current_account (GncPluginPageAccountTree *page); static Account *gnc_plugin_page_account_tree_get_current_account (GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_plugin_page_init (GncPluginPageIface *iface);
static GtkWidget *gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page); 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_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_merge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
static void gnc_plugin_page_account_tree_unmerge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge); static void gnc_plugin_page_account_tree_unmerge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
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);
/* Callbacks */ /* Callbacks */
static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget,
@@ -212,19 +205,9 @@ gnc_plugin_page_account_tree_get_type (void)
(GInstanceInitFunc) gnc_plugin_page_account_tree_init (GInstanceInitFunc) gnc_plugin_page_account_tree_init
}; };
static const GInterfaceInfo plugin_page_info = { gnc_plugin_page_account_tree_type = g_type_register_static (GNC_TYPE_PLUGIN_PAGE,
(GInterfaceInitFunc) gnc_plugin_page_account_tree_plugin_page_init,
NULL,
NULL
};
gnc_plugin_page_account_tree_type = g_type_register_static (G_TYPE_OBJECT,
"GncPluginPageAccountTree", "GncPluginPageAccountTree",
&our_info, 0); &our_info, 0);
g_type_add_interface_static (gnc_plugin_page_account_tree_type,
GNC_TYPE_PLUGIN_PAGE,
&plugin_page_info);
} }
return gnc_plugin_page_account_tree_type; return gnc_plugin_page_account_tree_type;
@@ -247,10 +230,18 @@ static void
gnc_plugin_page_account_tree_class_init (GncPluginPageAccountTreeClass *klass) gnc_plugin_page_account_tree_class_init (GncPluginPageAccountTreeClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GncPluginPageClass *gnc_plugin_class = GNC_PLUGIN_PAGE_CLASS(klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gnc_plugin_page_account_tree_finalize; object_class->finalize = gnc_plugin_page_account_tree_finalize;
gnc_plugin_class->tab_icon = GNC_STOCK_ACCOUNT;
gnc_plugin_class->plugin_name = GNC_PLUGIN_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;
} }
/* DRH - Suggest this be added to libegg */ /* DRH - Suggest this be added to libegg */
@@ -302,6 +293,7 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page)
{ {
EggActionGroup *action_group; EggActionGroup *action_group;
GncPluginPageAccountTreePrivate *priv; GncPluginPageAccountTreePrivate *priv;
GncPluginPage *parent;
const gchar *url = NULL; const gchar *url = NULL;
int options_id; int options_id;
SCM find_options; SCM find_options;
@@ -311,6 +303,12 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page)
ENTER("page %p", plugin_page); ENTER("page %p", plugin_page);
priv = plugin_page->priv = g_new0 (GncPluginPageAccountTreePrivate, 1); priv = plugin_page->priv = g_new0 (GncPluginPageAccountTreePrivate, 1);
/* Init parent declared variables */
parent = GNC_PLUGIN_PAGE(plugin_page);
parent->title = g_strdup(_("Accounts"));
parent->tab_name = g_strdup(_("Accounts"));
parent->uri = g_strdup("default:");
/* Create menu and toolbar information */ /* Create menu and toolbar information */
action_group = egg_action_group_new ("GncPluginPageAccountTreeActions"); action_group = egg_action_group_new ("GncPluginPageAccountTreeActions");
priv->action_group = action_group; priv->action_group = action_group;
@@ -429,32 +427,15 @@ gnc_plugin_page_account_tree_get_current_account (GncPluginPageAccountTree *page
} }
/* Virtual table */ /* Virtual Functions */
static void
gnc_plugin_page_account_tree_plugin_page_init (GncPluginPageIface *iface)
{
ENTER(" ");
iface->create_widget = gnc_plugin_page_account_tree_create_widget;
iface->destroy_widget = gnc_plugin_page_account_tree_destroy_widget;
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_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(" ");
}
static void static void
gnc_plugin_page_account_tree_close_cb (gpointer user_data) gnc_plugin_page_account_tree_close_cb (gpointer user_data)
{ {
GncPluginPageAccountTree *page; GncPluginPage *page;
GtkWidget *window;
page = GNC_PLUGIN_PAGE_ACCOUNT_TREE(user_data); page = GNC_PLUGIN_PAGE(user_data);
window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE (page)); gnc_main_window_close_page (GNC_MAIN_WINDOW(page->window), page);
gnc_main_window_close_page (GNC_MAIN_WINDOW(window), GNC_PLUGIN_PAGE(page));
} }
static GtkWidget * static GtkWidget *
@@ -581,36 +562,6 @@ gnc_plugin_page_account_tree_unmerge_actions (GncPluginPage *plugin_page,
LEAVE(" "); LEAVE(" ");
} }
static gchar *
gnc_plugin_page_account_tree_get_title (GncPluginPage *plugin_page)
{
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_tab_icon (GncPluginPage *plugin_page)
{
return GNC_STOCK_ACCOUNT;
}
static G_CONST_RETURN gchar *
gnc_plugin_page_account_tree_get_plugin_name (GncPluginPage *plugin_page)
{
return GNC_PLUGIN_ACCOUNT_TREE_NAME;
}
static G_CONST_RETURN gchar *
gnc_plugin_page_account_tree_get_uri (GncPluginPage *plugin_page)
{
return "default:";
}
/* Callbacks */ /* Callbacks */
static gboolean static gboolean
gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget,
@@ -677,7 +628,8 @@ gnc_plugin_page_account_tree_cmd_new_account (EggAction *action, GncPluginPageAc
} }
static void static void
gnc_plugin_page_account_tree_cmd_open_account (EggAction *action, GncPluginPageAccountTree *page) gnc_plugin_page_account_tree_cmd_open_account (EggAction *action,
GncPluginPageAccountTree *page)
{ {
GtkWidget *window; GtkWidget *window;
GncPluginPage *new_page; GncPluginPage *new_page;
@@ -688,13 +640,14 @@ gnc_plugin_page_account_tree_cmd_open_account (EggAction *action, GncPluginPageA
if (account == NULL) if (account == NULL)
return; return;
window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE (page)); window = GNC_PLUGIN_PAGE (page)->window;
new_page = gnc_plugin_page_register_new (account, FALSE); new_page = gnc_plugin_page_register_new (account, FALSE);
gnc_main_window_open_page (GNC_MAIN_WINDOW(window), new_page); gnc_main_window_open_page (GNC_MAIN_WINDOW(window), new_page);
} }
static void static void
gnc_plugin_page_account_tree_cmd_open_subaccounts (EggAction *action, GncPluginPageAccountTree *page) gnc_plugin_page_account_tree_cmd_open_subaccounts (EggAction *action,
GncPluginPageAccountTree *page)
{ {
GtkWidget *window; GtkWidget *window;
GncPluginPage *new_page; GncPluginPage *new_page;
@@ -705,7 +658,7 @@ gnc_plugin_page_account_tree_cmd_open_subaccounts (EggAction *action, GncPluginP
if (account == NULL) if (account == NULL)
return; return;
window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE (page)); window = GNC_PLUGIN_PAGE (page)->window;
new_page = gnc_plugin_page_register_new (account, TRUE); new_page = gnc_plugin_page_register_new (account, TRUE);
gnc_main_window_open_page (GNC_MAIN_WINDOW(window), new_page); gnc_main_window_open_page (GNC_MAIN_WINDOW(window), new_page);
} }

View File

@@ -1,8 +1,8 @@
/* /*
* gnc-plugin_page-account-tree.h -- * gnc-plugin_page-account-tree.h --
* *
* Copyright (C) 2003 Jan Arne Petersen * Copyright (C) 2003 Jan Arne Petersen <jpetersen@uni-bonn.de>
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de> * Copyright (C) 2003 David Hampton <hampton@employees.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -45,13 +45,13 @@ G_BEGIN_DECLS
typedef struct GncPluginPageAccountTreePrivate GncPluginPageAccountTreePrivate; typedef struct GncPluginPageAccountTreePrivate GncPluginPageAccountTreePrivate;
typedef struct { typedef struct {
GObject parent; GncPluginPage parent;
GncPluginPageAccountTreePrivate *priv; GncPluginPageAccountTreePrivate *priv;
} GncPluginPageAccountTree; } GncPluginPageAccountTree;
typedef struct { typedef struct {
GObjectClass parent; GncPluginPageClass parent;
} GncPluginPageAccountTreeClass; } GncPluginPageAccountTreeClass;
/* function prototypes */ /* function prototypes */

View File

@@ -1,8 +1,8 @@
/* /*
* gnc-plugin-page-register.c -- * gnc-plugin-page-register.c --
* *
* Copyright (C) 2003 Jan Arne Petersen * Copyright (C) 2003 Jan Arne Petersen <jpetersen@uni-bonn.de>
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de> * Copyright (C) 2003 David Hampton <hampton@employees.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -43,17 +43,12 @@ static void gnc_plugin_page_register_finalize (GObject *object);
/* static Account *gnc_plugin_page_register_get_current_account (GncPluginPageRegister *page); */ /* static Account *gnc_plugin_page_register_get_current_account (GncPluginPageRegister *page); */
static void gnc_plugin_page_register_plugin_page_init (GncPluginPageIface *iface);
static GtkWidget *gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page); 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_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_merge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
static void gnc_plugin_page_register_unmerge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge); static void gnc_plugin_page_register_unmerge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
static gchar *gnc_plugin_page_register_get_title (GncPluginPage *plugin_page);
static gchar *gnc_plugin_page_register_get_tab_name (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);
/* Callbacks */ /* Callbacks */
#if 0 #if 0
@@ -133,76 +128,74 @@ gnc_plugin_page_register_get_type (void)
(GInstanceInitFunc) gnc_plugin_page_register_init (GInstanceInitFunc) gnc_plugin_page_register_init
}; };
static const GInterfaceInfo plugin_page_info = { gnc_plugin_page_register_type = g_type_register_static (GNC_TYPE_PLUGIN_PAGE,
(GInterfaceInitFunc) gnc_plugin_page_register_plugin_page_init, "GncPluginPageRegister",
NULL, &our_info, 0);
NULL
};
gnc_plugin_page_register_type = g_type_register_static (G_TYPE_OBJECT,
"GncPluginPageRegister",
&our_info, 0);
g_type_add_interface_static (gnc_plugin_page_register_type,
GNC_TYPE_PLUGIN_PAGE,
&plugin_page_info);
} }
return gnc_plugin_page_register_type; return gnc_plugin_page_register_type;
} }
static GncPluginPage *
gnc_plugin_page_register_new_common (GNCLedgerDisplay *ld)
{
GncPluginPageRegister *register_page;
GncPluginPage *plugin_page;
register_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_REGISTER, NULL);
register_page->priv->ld = ld;
plugin_page = GNC_PLUGIN_PAGE(register_page);
plugin_page->title = gnc_plugin_page_register_get_tab_name(plugin_page);
plugin_page->tab_name = gnc_plugin_page_register_get_tab_name(plugin_page);
return plugin_page;
}
GncPluginPage * GncPluginPage *
gnc_plugin_page_register_new (Account *account, gboolean subaccounts) gnc_plugin_page_register_new (Account *account, gboolean subaccounts)
{ {
GncPluginPageRegister *plugin_page;
GNCLedgerDisplay *ld; GNCLedgerDisplay *ld;
plugin_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_REGISTER,
NULL);
if (subaccounts) if (subaccounts)
ld = gnc_ledger_display_subaccounts (account); ld = gnc_ledger_display_subaccounts (account);
else else
ld = gnc_ledger_display_simple (account); ld = gnc_ledger_display_simple (account);
plugin_page->priv->ld = ld;
return gnc_plugin_page_register_new_common(ld);
return GNC_PLUGIN_PAGE (plugin_page);
} }
GncPluginPage * GncPluginPage *
gnc_plugin_page_register_new_gl (void) gnc_plugin_page_register_new_gl (void)
{ {
GncPluginPageRegister *plugin_page;
GNCLedgerDisplay *ld; GNCLedgerDisplay *ld;
plugin_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_REGISTER,
NULL);
ld = gnc_ledger_display_gl (); ld = gnc_ledger_display_gl ();
plugin_page->priv->ld = ld; return gnc_plugin_page_register_new_common(ld);
return GNC_PLUGIN_PAGE (plugin_page);
} }
GncPluginPage * GncPluginPage *
gnc_plugin_page_register_new_ledger (GNCLedgerDisplay *ledger) gnc_plugin_page_register_new_ledger (GNCLedgerDisplay *ledger)
{ {
GncPluginPageRegister *plugin_page; return gnc_plugin_page_register_new_common(ledger);
plugin_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_REGISTER, NULL);
plugin_page->priv->ld = ledger;
return GNC_PLUGIN_PAGE (plugin_page);
} }
static void static void
gnc_plugin_page_register_class_init (GncPluginPageRegisterClass *klass) gnc_plugin_page_register_class_init (GncPluginPageRegisterClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GncPluginPageClass *gnc_plugin_class = GNC_PLUGIN_PAGE_CLASS(klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gnc_plugin_page_register_finalize; object_class->finalize = gnc_plugin_page_register_finalize;
gnc_plugin_class->tab_icon = GNC_STOCK_ACCOUNT;
gnc_plugin_class->plugin_name = GNC_PLUGIN_REGISTER_NAME;
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->merge_actions = gnc_plugin_page_register_merge_actions;
gnc_plugin_class->unmerge_actions = gnc_plugin_page_register_unmerge_actions;
} }
/* DRH - Suggest this be added to libegg */ /* DRH - Suggest this be added to libegg */
@@ -236,11 +229,18 @@ static void
gnc_plugin_page_register_init (GncPluginPageRegister *plugin_page) gnc_plugin_page_register_init (GncPluginPageRegister *plugin_page)
{ {
GncPluginPageRegisterPrivate *priv; GncPluginPageRegisterPrivate *priv;
GncPluginPage *parent;
EggActionGroup *action_group; EggActionGroup *action_group;
priv = g_new0 (GncPluginPageRegisterPrivate, 1); priv = g_new0 (GncPluginPageRegisterPrivate, 1);
plugin_page->priv = priv; plugin_page->priv = priv;
/* Init parent declared variables */
parent = GNC_PLUGIN_PAGE(plugin_page);
parent->title = g_strdup(_("General Ledger"));
parent->tab_name = g_strdup(_("General Ledger"));
parent->uri = g_strdup("default:");
/* Create menu and toolbar information */ /* Create menu and toolbar information */
action_group = egg_action_group_new ("GncPluginPageRegisterActions"); action_group = egg_action_group_new ("GncPluginPageRegisterActions");
priv->action_group = action_group; priv->action_group = action_group;
@@ -281,20 +281,7 @@ gnc_plugin_page_register_get_current_account (GncPluginPageRegister *page)
} }
*/ */
/* Virtual table */ /* Virtual Functions */
static void
gnc_plugin_page_register_plugin_page_init (GncPluginPageIface *iface)
{
iface->create_widget = gnc_plugin_page_register_create_widget;
iface->destroy_widget = gnc_plugin_page_register_destroy_widget;
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_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;
}
static GtkWidget * static GtkWidget *
gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page) gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page)
@@ -386,14 +373,6 @@ gnc_plugin_page_register_unmerge_actions (GncPluginPage *plugin_page,
plugin_page_register->priv->ui_merge = NULL; plugin_page_register->priv->ui_merge = NULL;
} }
static gchar *
gnc_plugin_page_register_get_title (GncPluginPage *plugin_page)
{
return g_strdup(_("General Ledger"));
}
static gchar * static gchar *
gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page) gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page)
{ {
@@ -436,24 +415,6 @@ gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page)
return g_strdup(_("unknown")); return g_strdup(_("unknown"));
} }
static G_CONST_RETURN gchar *
gnc_plugin_page_register_get_tab_icon (GncPluginPage *plugin_page)
{
return GNC_STOCK_ACCOUNT;
}
static G_CONST_RETURN gchar *
gnc_plugin_page_register_get_plugin_name (GncPluginPage *plugin_page)
{
return GNC_PLUGIN_REGISTER_NAME;
}
static G_CONST_RETURN gchar *
gnc_plugin_page_register_get_uri (GncPluginPage *plugin_page)
{
return "default:";
}
/* Callbacks */ /* Callbacks */
#if 0 #if 0
static gboolean static gboolean

View File

@@ -1,8 +1,8 @@
/* /*
* gnc-plugin-page-register.h -- * gnc-plugin-page-register.h --
* *
* Copyright (C) 2003 Jan Arne Petersen * Copyright (C) 2003 Jan Arne Petersen <jpetersen@uni-bonn.de>
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de> * Copyright (C) 2003 David Hampton <hampton@employees.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -47,13 +47,13 @@ G_BEGIN_DECLS
typedef struct GncPluginPageRegisterPrivate GncPluginPageRegisterPrivate; typedef struct GncPluginPageRegisterPrivate GncPluginPageRegisterPrivate;
typedef struct { typedef struct {
GObject parent; GncPluginPage parent;
GncPluginPageRegisterPrivate *priv; GncPluginPageRegisterPrivate *priv;
} GncPluginPageRegister; } GncPluginPageRegister;
typedef struct { typedef struct {
GObjectClass parent; GncPluginPageClass parent;
} GncPluginPageRegisterClass; } GncPluginPageRegisterClass;
/* function prototypes */ /* function prototypes */

View File

@@ -26,7 +26,11 @@
#include "gnc-plugin-page.h" #include "gnc-plugin-page.h"
static void gnc_plugin_page_base_init (gpointer klass); static gpointer parent_class = NULL;
static void gnc_plugin_page_class_init (GncPluginPageClass *klass);
static void gnc_plugin_page_init (GncPluginPage *plugin_page);
static void gnc_plugin_page_finalize (GObject *object);
enum { enum {
INSERTED, INSERTED,
@@ -45,21 +49,21 @@ gnc_plugin_page_get_type (void)
if (gnc_plugin_page_type == 0) { if (gnc_plugin_page_type == 0) {
static const GTypeInfo our_info = { static const GTypeInfo our_info = {
sizeof (GncPluginPageIface),
gnc_plugin_page_base_init, sizeof (GncPluginPageClass),
NULL, NULL, /* base_init */
NULL, NULL, /* base_finalize */
NULL, (GClassInitFunc) gnc_plugin_page_class_init,
NULL, NULL, /* class_finalize */
0, NULL, /* class_data */
0, sizeof (GncPluginPage),
NULL 0, /* n_preallocs */
(GInstanceInitFunc) gnc_plugin_page_init,
}; };
gnc_plugin_page_type = g_type_register_static (G_TYPE_INTERFACE, gnc_plugin_page_type = g_type_register_static (G_TYPE_OBJECT,
"GncPluginPage", "GncPluginPage",
&our_info, 0); &our_info, 0);
g_type_interface_add_prerequisite (gnc_plugin_page_type, G_TYPE_OBJECT);
} }
return gnc_plugin_page_type; return gnc_plugin_page_type;
@@ -68,12 +72,16 @@ gnc_plugin_page_get_type (void)
GtkWidget * GtkWidget *
gnc_plugin_page_create_widget (GncPluginPage *plugin_page) gnc_plugin_page_create_widget (GncPluginPage *plugin_page)
{ {
GncPluginPageClass *klass;
GtkWidget *widget; GtkWidget *widget;
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL); g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL);
g_return_val_if_fail (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->create_widget != NULL, NULL);
widget = GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->create_widget (plugin_page); klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page);
g_return_val_if_fail (klass != NULL, NULL);
g_return_val_if_fail (klass->create_widget != NULL, NULL);
widget = klass->create_widget (plugin_page);
/* /*
* If there is a destroy function, add a ref so that the * If there is a destroy function, add a ref so that the
@@ -81,7 +89,7 @@ gnc_plugin_page_create_widget (GncPluginPage *plugin_page)
* Otherwise it will be destroyed when it is removed from the * Otherwise it will be destroyed when it is removed from the
* main notebook for the window. * main notebook for the window.
*/ */
if (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->destroy_widget) if (klass->destroy_widget)
g_object_ref(widget); g_object_ref(widget);
return widget; return widget;
@@ -90,75 +98,45 @@ gnc_plugin_page_create_widget (GncPluginPage *plugin_page)
void void
gnc_plugin_page_destroy_widget (GncPluginPage *plugin_page) gnc_plugin_page_destroy_widget (GncPluginPage *plugin_page)
{ {
g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); GncPluginPageClass *klass;
g_return_if_fail (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->destroy_widget != NULL);
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->destroy_widget (plugin_page); 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->destroy_widget != NULL);
return klass->destroy_widget (plugin_page);
} }
void void
gnc_plugin_page_merge_actions (GncPluginPage *plugin_page, gnc_plugin_page_merge_actions (GncPluginPage *plugin_page,
EggMenuMerge *ui_merge) EggMenuMerge *ui_merge)
{ {
g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); GncPluginPageClass *klass;
g_return_if_fail (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->merge_actions != NULL);
GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->merge_actions (plugin_page, ui_merge); 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);
klass->merge_actions (plugin_page, ui_merge);
} }
void void
gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page, gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page,
EggMenuMerge *ui_merge) EggMenuMerge *ui_merge)
{ {
GncPluginPageClass *klass;
g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
g_return_if_fail (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->unmerge_actions != NULL);
GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->unmerge_actions (plugin_page, ui_merge); klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page);
} g_return_if_fail (klass != NULL);
g_return_if_fail (klass->unmerge_actions != NULL);
gchar * klass->unmerge_actions (plugin_page, ui_merge);
gnc_plugin_page_get_title (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_title != NULL, NULL);
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_title (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_tab_name != NULL, NULL);
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 *
gnc_plugin_page_get_plugin_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_plugin_name != NULL, NULL);
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_plugin_name (plugin_page);
}
G_CONST_RETURN gchar *
gnc_plugin_page_get_uri (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_uri != NULL, NULL);
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->get_uri (plugin_page);
} }
/* Signals */ /* Signals */
@@ -194,61 +172,74 @@ gnc_plugin_page_unselected (GncPluginPage *plugin_page)
g_signal_emit (G_OBJECT (plugin_page), signals[UNSELECTED], 0); g_signal_emit (G_OBJECT (plugin_page), signals[UNSELECTED], 0);
} }
GtkWidget * static void
gnc_plugin_page_get_window (GncPluginPage *plugin_page) gnc_plugin_page_class_init (GncPluginPageClass *klass)
{ {
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->window; parent_class = g_type_class_peek_parent (klass);
} gobject_class->finalize = gnc_plugin_page_finalize;
void klass->tab_icon = NULL;
gnc_plugin_page_set_window (GncPluginPage *plugin_page, GtkWidget *window) klass->plugin_name = NULL;
{
g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->window = window; signals[INSERTED] = g_signal_new ("inserted",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GncPluginPageClass, inserted),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
signals[REMOVED] = g_signal_new ("removed",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GncPluginPageClass, removed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
signals[SELECTED] = g_signal_new ("selected",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GncPluginPageClass, inserted),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
signals[UNSELECTED] = g_signal_new ("unselected",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GncPluginPageClass, removed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
} }
static void static void
gnc_plugin_page_base_init (gpointer klass) gnc_plugin_page_init (GncPluginPage *plugin_page)
{ {
static gboolean initialized = FALSE; plugin_page->title = NULL;
plugin_page->tab_name = NULL;
plugin_page->uri = NULL;
if (!initialized) { plugin_page->window = NULL;
initialized = TRUE; }
signals[INSERTED] = g_signal_new ("inserted", static void
G_OBJECT_CLASS_TYPE (klass), gnc_plugin_page_finalize (GObject *object)
G_SIGNAL_RUN_FIRST, {
G_STRUCT_OFFSET (GncPluginPageIface, inserted), GncPluginPage *page = GNC_PLUGIN_PAGE (object);
NULL, NULL,
g_cclosure_marshal_VOID__VOID, if (page->title)
G_TYPE_NONE, g_free(page->title);
0); if (page->tab_name)
signals[REMOVED] = g_signal_new ("removed", g_free(page->tab_name);
G_OBJECT_CLASS_TYPE (klass), if (page->uri)
G_SIGNAL_RUN_FIRST, g_free(page->uri);
G_STRUCT_OFFSET (GncPluginPageIface, removed),
NULL, NULL, page->window = NULL; // Don't need to free it.
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, G_OBJECT_CLASS (parent_class)->finalize (object);
0);
signals[SELECTED] = g_signal_new ("selected",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GncPluginPageIface, inserted),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
signals[UNSELECTED] = g_signal_new ("unselected",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GncPluginPageIface, removed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
}
} }

View File

@@ -2,8 +2,8 @@
* gnc-plugin-page.h -- A page, which can be added to the * gnc-plugin-page.h -- A page, which can be added to the
* GnuCash main window. * GnuCash main window.
* *
* Copyright (C) 2003 Jan Arne Petersen * Copyright (C) 2003 Jan Arne Petersen <jpetersen@uni-bonn.de>
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de> * Copyright (C) 2003 David Hampton <hampton@employees.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -32,16 +32,28 @@
G_BEGIN_DECLS G_BEGIN_DECLS
/* type macros */ /* type macros */
#define GNC_TYPE_PLUGIN_PAGE (gnc_plugin_page_get_type ()) #define GNC_TYPE_PLUGIN_PAGE (gnc_plugin_page_get_type ())
#define GNC_PLUGIN_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_PLUGIN_PAGE, GncPluginPage)) #define GNC_PLUGIN_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_PLUGIN_PAGE, GncPluginPage))
#define GNC_IS_PLUGIN_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_PLUGIN_PAGE)) #define GNC_PLUGIN_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_PAGE, GncPluginPageClass))
#define GNC_PLUGIN_PAGE_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GNC_TYPE_PLUGIN_PAGE, GncPluginPageIface)) #define GNC_IS_PLUGIN_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_PLUGIN_PAGE))
#define GNC_IS_PLUGIN_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_PAGE))
#define GNC_PLUGIN_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_PLUGIN_PAGE, GncPluginPageClass))
/* typedefs & structures */ /* typedefs & structures */
typedef struct GncPluginPage GncPluginPage; /* dummy typedef */ typedef struct GncPluginPage {
GObject parent;
gchar *title;
gchar *tab_name;
gchar *uri;
GtkWidget *window;
} GncPluginPage;
typedef struct { typedef struct {
GTypeInterface parent; GObjectClass parent;
const gchar *tab_icon;
const gchar *plugin_name;
/* Signals */ /* Signals */
void (* inserted) (GncPluginPage *plugin_page); void (* inserted) (GncPluginPage *plugin_page);
@@ -55,17 +67,7 @@ typedef struct {
void (* merge_actions) (GncPluginPage *plugin_page, EggMenuMerge *merge); void (* merge_actions) (GncPluginPage *plugin_page, EggMenuMerge *merge);
void (* unmerge_actions) (GncPluginPage *plugin_page, EggMenuMerge *merge); void (* unmerge_actions) (GncPluginPage *plugin_page, EggMenuMerge *merge);
} GncPluginPageClass;
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);
/* Variables */
GtkWidget *window;
} GncPluginPageIface;
/* function prototypes */ /* function prototypes */
GType gnc_plugin_page_get_type (void); GType gnc_plugin_page_get_type (void);
@@ -78,13 +80,6 @@ void gnc_plugin_page_merge_actions (GncPluginPage *plugin_pag
void gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page, void gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page,
EggMenuMerge *merge); EggMenuMerge *merge);
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);
/* Signals */ /* Signals */
void gnc_plugin_page_inserted (GncPluginPage *plugin_page); void gnc_plugin_page_inserted (GncPluginPage *plugin_page);
void gnc_plugin_page_removed (GncPluginPage *plugin_page); void gnc_plugin_page_removed (GncPluginPage *plugin_page);