[Gnucash-changes] Move some of the fields in a GncPluginPage from
the public to the
David Hampton
hampton at cvs.gnucash.org
Tue Jul 5 21:15:32 EDT 2005
Log Message:
-----------
Move some of the fields in a GncPluginPage from the public to the
private data structures.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash/src/gnome:
gnc-plugin-page-account-tree.c
gnc-plugin-page-register.c
gnucash/src/gnome-utils:
gnc-main-window.c
gnc-main-window.h
gnc-plugin-page.c
gnc-plugin-page.h
gnc-window.c
gnucash/src/report/report-gnome:
gnc-plugin-page-report.c
Revision Data
-------------
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.28
retrieving revision 1.1.2.29
diff -Lsrc/gnome/gnc-plugin-page-register.c -Lsrc/gnome/gnc-plugin-page-register.c -u -r1.1.2.28 -r1.1.2.29
--- src/gnome/gnc-plugin-page-register.c
+++ src/gnome/gnc-plugin-page-register.c
@@ -356,6 +356,7 @@
GNCSplitReg *gsr;
const GList *item;
GList *book_list;
+ gchar *label;
QofQuery *q;
/* Is there an existing page? */
@@ -373,8 +374,10 @@
register_page->priv->ledger = ledger;
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);
+ 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);
+ g_free(label);
q = gnc_ledger_display_get_query (ledger);
book_list = qof_query_get_books (q);
@@ -447,9 +450,9 @@
/* 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:");
+ gnc_plugin_page_set_title(parent, _("General Ledger"));
+ gnc_plugin_page_set_tab_name(parent, _("General Ledger"));
+ gnc_plugin_page_set_uri(parent, "default:");
/* Create menu and toolbar information */
action_group = gtk_action_group_new ("GncPluginPageRegisterActions");
@@ -1646,7 +1649,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(page)->tab_name);
+ gnc_plugin_page_get_tab_name(GNC_PLUGIN_PAGE(page)));
gtk_window_set_title(GTK_WINDOW(dialog), title);
g_free(title);
@@ -1695,7 +1698,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(page)->tab_name);
+ gnc_plugin_page_get_tab_name(GNC_PLUGIN_PAGE(page)));
gtk_window_set_title(GTK_WINDOW(dialog), title);
g_free(title);
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.44
retrieving revision 1.1.2.45
diff -Lsrc/gnome/gnc-plugin-page-account-tree.c -Lsrc/gnome/gnc-plugin-page-account-tree.c -u -r1.1.2.44 -r1.1.2.45
--- src/gnome/gnc-plugin-page-account-tree.c
+++ src/gnome/gnc-plugin-page-account-tree.c
@@ -314,9 +314,9 @@
/* 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:");
+ gnc_plugin_page_set_title(parent, _("Accounts"));
+ gnc_plugin_page_set_tab_name(parent, _("Accounts"));
+ gnc_plugin_page_set_uri(parent, "default:");
/* change me when the system supports multiple books */
gnc_plugin_page_add_book(parent, gnc_get_current_book());
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.3
retrieving revision 1.1.2.4
diff -Lsrc/gnome-utils/gnc-plugin-page.c -Lsrc/gnome-utils/gnc-plugin-page.c -u -r1.1.2.3 -r1.1.2.4
--- src/gnome-utils/gnc-plugin-page.c
+++ src/gnome-utils/gnc-plugin-page.c
@@ -49,6 +49,11 @@
struct GncPluginPagePrivate
{
GList *books;
+
+ gchar *title;
+ gchar *tab_name;
+ gchar *uri;
+ gchar *statusbar_text;
};
GType
@@ -247,9 +252,9 @@
priv = plugin_page->priv = g_new0 (GncPluginPagePrivate, 1);
- plugin_page->title = NULL;
- plugin_page->tab_name = NULL;
- plugin_page->uri = NULL;
+ priv->title = NULL;
+ priv->tab_name = NULL;
+ priv->uri = NULL;
plugin_page->window = NULL;
plugin_page->summarybar = NULL;
@@ -266,16 +271,17 @@
GList *item;
page = GNC_PLUGIN_PAGE (object);
- if (page->statusbar_text)
- g_free (page->statusbar_text);
- if (page->title)
- g_free(page->title);
- if (page->tab_name)
- g_free(page->tab_name);
- if (page->uri)
- g_free(page->uri);
priv = page->priv;
+ if (priv->title)
+ g_free(priv->title);
+ if (priv->tab_name)
+ g_free(priv->tab_name);
+ if (priv->uri)
+ g_free(priv->uri);
+ if (priv->statusbar_text)
+ g_free(priv->statusbar_text);
+
if (priv->books) {
for (item = priv->books; item; item = g_list_next(item)) {
guid_free (item->data);
@@ -338,10 +344,82 @@
return (page->priv->books != NULL);
}
+GtkWidget *
+gnc_plugin_page_get_window (GncPluginPage *page)
+{
+ g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
+
+ return page->window;
+}
+
+const gchar *
+gnc_plugin_page_get_tab_name (GncPluginPage *page)
+{
+ g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
+
+ return page->priv->tab_name;
+}
+
+void
+gnc_plugin_page_set_tab_name (GncPluginPage *page, const gchar *name)
+{
+ 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);
+}
+
const gchar *
gnc_plugin_page_get_title (GncPluginPage *page)
{
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
- return page->title;
+ return page->priv->title;
+}
+
+void
+gnc_plugin_page_set_title (GncPluginPage *page, const gchar *name)
+{
+ g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
+
+ if (page->priv->title)
+ g_free(page->priv->title);
+ page->priv->title = g_strdup(name);
+}
+
+const gchar *
+gnc_plugin_page_get_uri (GncPluginPage *page)
+{
+ g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
+
+ return page->priv->uri;
+}
+
+void
+gnc_plugin_page_set_uri (GncPluginPage *page, const gchar *name)
+{
+ g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
+
+ if (page->priv->uri)
+ g_free(page->priv->uri);
+ page->priv->uri = g_strdup(name);
+}
+
+const gchar *
+gnc_plugin_page_get_statusbar_text (GncPluginPage *page)
+{
+ g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
+
+ return page->priv->statusbar_text;
+}
+
+void
+gnc_plugin_page_set_statusbar_text (GncPluginPage *page, const gchar *message)
+{
+ 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);
}
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.2
retrieving revision 1.1.2.3
diff -Lsrc/gnome-utils/gnc-main-window.h -Lsrc/gnome-utils/gnc-main-window.h -u -r1.1.2.2 -r1.1.2.3
--- src/gnome-utils/gnc-main-window.h
+++ src/gnome-utils/gnc-main-window.h
@@ -95,6 +95,14 @@
GncMainWindow *gnc_main_window_new (void);
+/** Bring the window containing the specified page to the top of the
+ * window stack, then switch the notebook to show the specified page.
+ *
+ * @param page The existing page to be displayed.
+ */
+void gnc_main_window_display_page (GncPluginPage *page);
+
+
/** Display a data plugin page in a window. If the page already
* exists in any window, then that window will be brought to the
* front and the notebook switch to display the specified page. If
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.5
retrieving revision 1.1.2.6
diff -Lsrc/gnome-utils/gnc-main-window.c -Lsrc/gnome-utils/gnc-main-window.c -u -r1.1.2.5 -r1.1.2.6
--- src/gnome-utils/gnc-main-window.c
+++ src/gnome-utils/gnc-main-window.c
@@ -853,6 +853,8 @@
gtk_notebook_append_page (notebook, page->notebook_page, tab_widget);
gnc_plugin_page_inserted (page);
gtk_notebook_set_current_page (notebook, -1);
+ 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);
}
@@ -920,6 +922,21 @@
************************************************************/
+void
+gnc_main_window_display_page (GncPluginPage *page)
+{
+ GncMainWindow *window;
+ GtkNotebook *notebook;
+ gint page_num;
+
+ window = GNC_MAIN_WINDOW (page->window);
+ notebook = GTK_NOTEBOOK (window->priv->notebook);
+ page_num = gtk_notebook_page_num(notebook, page->notebook_page);
+ gtk_notebook_set_current_page (notebook, page_num);
+ gtk_window_present(GTK_WINDOW(window));
+}
+
+
/* Display a data plugin page in a window. If the page already
* exists in any window, then that window will be brought to the
* front and the notebook switch to display the specified page. If
@@ -935,8 +952,6 @@
GtkWidget *label;
const gchar *icon;
GtkWidget *image;
- GtkNotebook *notebook;
- gint page_num;
if (window)
g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
@@ -944,11 +959,7 @@
g_return_if_fail (gnc_plugin_page_has_books(page));
if (gnc_main_window_page_exists(page)) {
- window = GNC_MAIN_WINDOW (page->window);
- notebook = GTK_NOTEBOOK (window->priv->notebook);
- page_num = gtk_notebook_page_num(notebook, page->notebook_page);
- gtk_notebook_set_current_page (notebook, page_num);
- gtk_window_present(GTK_WINDOW(window));
+ gnc_main_window_display_page(page);
return;
}
@@ -967,7 +978,7 @@
PLUGIN_PAGE_LABEL, page);
icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
- label = gtk_label_new (page->tab_name);
+ label = gtk_label_new (gnc_plugin_page_get_tab_name(page));
gtk_widget_show (label);
if (icon != NULL) {
@@ -1613,7 +1624,6 @@
g_return_if_fail(GTK_IS_RADIO_ACTION(current));
g_return_if_fail(GNC_IS_MAIN_WINDOW(unused));
- /* DRH - Start here */
ENTER("action %p, current %p, window %p", action, current, unused);
value = gtk_radio_action_get_current_value(current);
window = g_list_nth_data(active_windows, value);
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.2
retrieving revision 1.1.2.3
diff -Lsrc/gnome-utils/gnc-plugin-page.h -Lsrc/gnome-utils/gnc-plugin-page.h -u -r1.1.2.2 -r1.1.2.3
--- src/gnome-utils/gnc-plugin-page.h
+++ src/gnome-utils/gnc-plugin-page.h
@@ -46,15 +46,11 @@
GObject parent;
GncPluginPagePrivate *priv;
+ /** These fields are semi-private. They should only be access by
+ * the gnucash window management code. */
GtkWidget *window;
GtkWidget *notebook_page;
GtkWidget *summarybar;
-
- gchar *title;
- gchar *tab_name;
- gchar *uri;
-
- gchar *statusbar_text;
} GncPluginPage;
typedef struct {
@@ -72,7 +68,7 @@
/* Virtual Table */
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;
@@ -119,12 +115,83 @@
*/
gboolean gnc_plugin_page_has_books (GncPluginPage *page);
+/** Retrieve a pointer to the GncMainWindow (GtkWindow) containing
+ * this page.
+ *
+ * @param page The page whose window should be retrieved.
+ *
+ * @return A pointer to the window.
+ */
+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.
*
* @param page The page whose title component should be retrieved.
+ *
+ * @return The page title. This string is owned by the page and
+ * should not be freed by the caller.
*/
const gchar *gnc_plugin_page_get_title (GncPluginPage *page);
+/** Set the page part of the window title.
+ *
+ * @param page The page whose title component should be set.
+ *
+ * @param name The new title for the page.
+ */
+void gnc_plugin_page_set_title (GncPluginPage *page, const char *name);
+
+/** Retrieve the Uniform Resource Identifier for this page.
+ *
+ * @param page The page whose URI should be retrieved.
+ *
+ * @return The URI for this page. This string is owned by the page and
+ * should not be freed by the caller.
+ */
+const gchar *gnc_plugin_page_get_uri (GncPluginPage *page);
+
+/** Set the Uniform Resource Identifier for this page.
+ *
+ * @param page The page whose URI should be set.
+ *
+ * @param name The new URI for the page.
+ */
+void gnc_plugin_page_set_uri (GncPluginPage *page, const char *name);
+
+/** Retrieve the statusbar text associated with this page.
+ *
+ * @param page The page whose statusbar should text be retrieved.
+ *
+ * @return A pointer to the statusbar text for this page. This
+ * string is owned by the page and should not be freed by the caller.
+ */
+const gchar *gnc_plugin_page_get_statusbar_text (GncPluginPage *page);
+
+/** Set the statusbar text associated with this page.
+ *
+ * @param page The page whose statusbar text should be set.
+ *
+ * @param name The new statusbar text for the page.
+ */
+void gnc_plugin_page_set_statusbar_text (GncPluginPage *page, const char *name);
+
/* Signals */
void gnc_plugin_page_inserted (GncPluginPage *plugin_page);
void gnc_plugin_page_removed (GncPluginPage *plugin_page);
Index: gnc-window.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-window.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lsrc/gnome-utils/gnc-window.c -Lsrc/gnome-utils/gnc-window.c -u -r1.1.2.1 -r1.1.2.2
--- src/gnome-utils/gnc-window.c
+++ src/gnome-utils/gnc-window.c
@@ -97,13 +97,14 @@
gnc_window_update_status (GncWindow *window, GncPluginPage *page)
{
GtkWidget *statusbar;
+ const gchar *message;
g_return_if_fail(GNC_WINDOW (window));
statusbar = gnc_window_get_statusbar (window);
+ message = gnc_plugin_page_get_statusbar_text(page);
gtk_statusbar_pop(GTK_STATUSBAR(statusbar), 0);
- gtk_statusbar_push(GTK_STATUSBAR(statusbar), 0,
- page->statusbar_text ? page->statusbar_text : "");
+ gtk_statusbar_push(GTK_STATUSBAR(statusbar), 0, message ? message : "");
}
void
@@ -112,10 +113,7 @@
g_return_if_fail(GNC_WINDOW (window));
g_return_if_fail(GNC_PLUGIN_PAGE (page));
- if (page->statusbar_text)
- g_free(page->statusbar_text);
- page->statusbar_text = g_strdup(message ? message : "");
-
+ gnc_plugin_page_set_statusbar_text(page, message);
gnc_window_update_status (window, page);
}
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.12
retrieving revision 1.1.2.13
diff -Lsrc/report/report-gnome/gnc-plugin-page-report.c -Lsrc/report/report-gnome/gnc-plugin-page-report.c -u -r1.1.2.12 -r1.1.2.13
--- src/report/report-gnome/gnc-plugin-page-report.c
+++ src/report/report-gnome/gnc-plugin-page-report.c
@@ -687,9 +687,9 @@
tmpStr = g_string_sized_new( 32 );
g_string_sprintf( tmpStr, "%s: %s", _("Report"),
gnc_report_name( priv->initial_report ) );
- parent->title = g_strdup(tmpStr->str);
- parent->tab_name = g_strdup( tmpStr->str );
- parent->uri = g_strdup("default:");
+ gnc_plugin_page_set_title(parent, tmpStr->str);
+ gnc_plugin_page_set_tab_name(parent, tmpStr->str);
+ gnc_plugin_page_set_uri(parent, "default:");
/* change me when the system supports multiple books */
gnc_plugin_page_add_book(parent, gnc_get_current_book());
More information about the gnucash-changes
mailing list