[Gnucash-changes] r11827 - gnucash/trunk - Push the summarybar
inside of the created page widget. This solves
David Hampton
hampton at cvs.gnucash.org
Fri Nov 4 00:49:16 EST 2005
Author: hampton
Date: 2005-11-04 00:49:15 -0500 (Fri, 04 Nov 2005)
New Revision: 11827
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/business/business-gnome/gnc-plugin-page-invoice.c
gnucash/trunk/src/gnome-utils/gnc-main-window.c
gnucash/trunk/src/gnome-utils/gnc-plugin-page.c
gnucash/trunk/src/gnome-utils/gnc-plugin-page.h
gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
gnucash/trunk/src/gnome/gnc-plugin-page-register.c
Log:
Push the summarybar inside of the created page widget. This solves
several problems with window resizing when switching between pages, or
when turning the summary bar off and on.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2005-11-04 05:48:06 UTC (rev 11826)
+++ gnucash/trunk/ChangeLog 2005-11-04 05:49:15 UTC (rev 11827)
@@ -1,3 +1,20 @@
+2005-11-03 David Hampton <hampton at employees.org>
+
+ * src/business/business-gnome/gnc-plugin-page-invoice.c:
+ * src/gnome-utils/gnc-main-window.c:
+ * src/gnome-utils/gnc-plugin-page.[ch]:
+ * src/gnome/gnc-plugin-page-register.c:
+ * src/gnome/gnc-plugin-page-account-tree.c: Push the summarybar
+ inside of the created page widget. This solves several problems
+ with window resizing when switching between pages, or when turning
+ the summary bar off and on.
+
+ * src/register/register-gnome/gnucash-sheet.c
+ (compute_optimal_height): This routine should always return the
+ minimal height the widget will accept, not the current height of
+ the widget. Returning the current height causes all sorts of
+ problems such as windows that are impossible to resize down.
+
2005-11-03 Neil Williams <linux at codehelp.co.uk>
* Various Makefile.am : Remove .cvsignore from
Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-page-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-page-invoice.c 2005-11-04 05:48:06 UTC (rev 11826)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-page-invoice.c 2005-11-04 05:49:15 UTC (rev 11827)
@@ -365,7 +365,7 @@
{
GncPluginPageInvoice *page;
GncPluginPageInvoicePrivate *priv;
- GtkWidget *regWidget;
+ GtkWidget *regWidget, *widget;
ENTER("page %p", plugin_page);
page = GNC_PLUGIN_PAGE_INVOICE (plugin_page);
@@ -373,11 +373,15 @@
if (priv->widget != NULL)
return priv->widget;
- priv->widget = gnc_invoice_create_page(priv->iw, page);
+ priv->widget = gtk_vbox_new (FALSE, 0);
gtk_widget_show (priv->widget);
+
+ widget = gnc_invoice_create_page(priv->iw, page);
+ gtk_widget_show (widget);
+ gtk_box_pack_start(GTK_BOX (priv->widget), widget, TRUE, TRUE, 0);
plugin_page->summarybar = gnc_invoice_window_create_summary_bar(priv->iw);
- gtk_widget_show(plugin_page->summarybar);
+ gtk_box_pack_end(GTK_BOX (priv->widget), plugin_page->summarybar, FALSE, FALSE, 0);
regWidget = gnc_invoice_get_register(priv->iw);
if (regWidget) {
Modified: gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c 2005-11-04 05:48:06 UTC (rev 11826)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c 2005-11-04 05:49:15 UTC (rev 11827)
@@ -500,6 +500,8 @@
gnc_get_current_session());
plugin_page->summarybar = gnc_main_window_summary_new();
+ gtk_box_pack_end (GTK_BOX (page->priv->widget), plugin_page->summarybar,
+ FALSE, FALSE, 0);
gtk_widget_show(plugin_page->summarybar);
LEAVE("widget = %p", page->priv->widget);
@@ -524,11 +526,6 @@
page->priv->component_id = 0;
}
- if (plugin_page->summarybar) {
- g_object_unref(G_OBJECT(plugin_page->summarybar));
- plugin_page->summarybar = NULL;
- }
-
LEAVE("widget destroyed");
}
Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register.c 2005-11-04 05:48:06 UTC (rev 11826)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register.c 2005-11-04 05:49:15 UTC (rev 11827)
@@ -615,8 +615,11 @@
gnc_plugin_page_register_update_menus (page);
plugin_page->summarybar = gsr_create_summary_bar(priv->gsr);
- if (plugin_page->summarybar)
+ if (plugin_page->summarybar) {
gtk_widget_show_all(plugin_page->summarybar);
+ gtk_box_pack_end(GTK_BOX (priv->widget), plugin_page->summarybar,
+ FALSE, FALSE, 0);
+ }
priv->component_manager_id =
gnc_register_gui_component(GNC_PLUGIN_PAGE_REGISTER_NAME,
Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c 2005-11-04 05:48:06 UTC (rev 11826)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c 2005-11-04 05:49:15 UTC (rev 11827)
@@ -123,9 +123,6 @@
GtkWidget *statusbar;
GtkWidget *progressbar;
- GtkWidget *summarybar_dock;
- gboolean show_summarybar;
-
GtkActionGroup *action_group;
GncPluginPage *current_page;
@@ -1169,11 +1166,6 @@
gnc_plugin_page_unmerge_actions (page, window->ui_merge);
gnc_plugin_page_unselected (page);
window->priv->current_page = NULL;
-
- if (page->summarybar) {
- gtk_container_remove(GTK_CONTAINER(window->priv->summarybar_dock),
- page->summarybar);
- }
}
/* Remove it from the list of pages in the window */
@@ -1608,12 +1600,6 @@
gtk_box_pack_start (GTK_BOX (main_vbox), priv->notebook,
TRUE, TRUE, 0);
- priv->show_summarybar = TRUE;
- priv->summarybar_dock = gtk_vbox_new (FALSE, 0);
- gtk_widget_show (priv->summarybar_dock);
- gtk_box_pack_start (GTK_BOX (main_vbox), priv->summarybar_dock,
- FALSE, TRUE, 0);
-
priv->statusbar = gtk_statusbar_new ();
gtk_widget_show (priv->statusbar);
gtk_box_pack_start (GTK_BOX (main_vbox), priv->statusbar,
@@ -1710,6 +1696,29 @@
gtk_widget_show (widget);
}
+/** Should a summary bar be visible in this window? In order to
+ * prevent synchronization issues, the "ViewSummaryBar"
+ * GtkToggleAction is the sole source of information for whether or
+ * not any summary bar should be visibile in a window.
+ *
+ * @param window A pointer to the window in question.
+ *
+ * @param action If known, a pointer to the "ViewSummaryBar"
+ * GtkToggleAction. If NULL, the function will look up this action.
+ *
+ * @return TRUE if the summarybar should be visible.
+ */
+static gboolean
+gnc_main_window_show_summarybar (GncMainWindow *window, GtkAction *action)
+{
+ if (action == NULL)
+ action = gtk_action_group_get_action(window->priv->action_group,
+ "ViewSummaryAction");
+ if (action == NULL)
+ return TRUE;
+ return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+}
+
/** This function is invoked when the GtkNotebook switches pages. It
* is responsible for updating the rest of the window contents
* outside of the notebook. I.E. Updating the user interface, the
@@ -1725,26 +1734,18 @@
gint pos,
GncMainWindow *window)
{
- GtkWidget *child, *summarybar, *summarybar_dock;
+ GtkWidget *child;
GncPluginPage *page;
- gboolean immutable;
+ gboolean immutable, visible;
ENTER("Notebook %p, page, %p, index %d, window %p",
notebook, notebook_page, pos, window);
g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
- summarybar_dock = window->priv->summarybar_dock;
-
if (window->priv->current_page != NULL) {
page = window->priv->current_page;
gnc_plugin_page_unmerge_actions (page, window->ui_merge);
gnc_plugin_page_unselected (page);
-
- /* Remove old page's summarybar too */
- if (page->summarybar) {
- gtk_container_remove(GTK_CONTAINER(summarybar_dock),
- page->summarybar);
- }
}
child = gtk_notebook_get_nth_page (notebook, pos);
@@ -1759,25 +1760,9 @@
if (page != NULL) {
/* Update the user interface (e.g. menus and toolbars */
gnc_plugin_page_merge_actions (page, window->ui_merge);
+ visible = gnc_main_window_show_summarybar(window, NULL);
+ gnc_plugin_page_show_summarybar (page, visible);
- /* install new summarybar (if any) */
- summarybar = page->summarybar;
- if (summarybar) {
- if (GTK_OBJECT_FLOATING(summarybar)) {
- /* Own this object. This will prevent it from being deleted by
- * gtk when it is removed from the summarybar. */
- g_object_ref (summarybar);
- gtk_object_sink (GTK_OBJECT (summarybar));
- }
-
- if (window->priv->show_summarybar)
- gtk_widget_show(summarybar);
- else
- gtk_widget_hide(summarybar);
- gtk_box_pack_start(GTK_BOX(summarybar_dock), summarybar,
- FALSE, TRUE, 0 );
- }
-
/* Allow page specific actions */
gnc_plugin_page_selected (page);
gnc_window_update_status (GNC_WINDOW(window), page);
@@ -1891,10 +1876,12 @@
static void
gnc_main_window_cmd_view_summary (GtkAction *action, GncMainWindow *window)
{
- if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) {
- gtk_widget_show (window->priv->summarybar_dock);
- } else {
- gtk_widget_hide (window->priv->summarybar_dock);
+ GList *item;
+ gboolean visible;
+
+ visible = gnc_main_window_show_summarybar(window, action);
+ for (item = window->priv->installed_pages; item; item = g_list_next(item)) {
+ gnc_plugin_page_show_summarybar(item->data, visible);
}
}
@@ -1959,8 +1946,8 @@
g_object_unref(page);
/* just a little debugging. :-) */
- DEBUG("Moved page %p (sb %p) from window %p to new window %p",
- page, page->summarybar, window, new_window);
+ DEBUG("Moved page %p from window %p to new window %p",
+ page, window, new_window);
DEBUG("Old window current is %p, new window current is %p",
window->priv->current_page, new_window->priv->current_page);
}
Modified: gnucash/trunk/src/gnome-utils/gnc-plugin-page.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin-page.c 2005-11-04 05:48:06 UTC (rev 11826)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin-page.c 2005-11-04 05:49:15 UTC (rev 11827)
@@ -165,6 +165,22 @@
}
void
+gnc_plugin_page_show_summarybar (GncPluginPage *page,
+ gboolean visible)
+{
+ g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
+
+ if (!page->summarybar)
+ return;
+
+ if (visible) {
+ gtk_widget_show(page->summarybar);
+ } else {
+ gtk_widget_hide(page->summarybar);
+ }
+}
+
+void
gnc_plugin_page_merge_actions (GncPluginPage *page,
GtkUIManager *ui_merge)
{
@@ -410,10 +426,6 @@
priv->books = NULL;
}
- if (page->summarybar) {
- g_object_unref(G_OBJECT(page->summarybar));
- page->summarybar = NULL;
- }
page->window = NULL; // Don't need to free it.
gnc_gobject_tracking_forget(object);
Modified: gnucash/trunk/src/gnome-utils/gnc-plugin-page.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin-page.h 2005-11-04 05:48:06 UTC (rev 11826)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin-page.h 2005-11-04 05:49:15 UTC (rev 11827)
@@ -93,6 +93,14 @@
GtkWidget *gnc_plugin_page_create_widget (GncPluginPage *plugin_page);
void gnc_plugin_page_destroy_widget (GncPluginPage *plugin_page);
+/** Show the summarybar associated with this page.
+ *
+ * @param page The page whose summarybar visibility should be changed.
+ *
+ * @param visible Whether or not the summarybar should be shown..
+ */
+void gnc_plugin_page_show_summarybar (GncPluginPage *page, gboolean visible);
+
void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page,
GtkUIManager *merge);
void gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page,
More information about the gnucash-changes
mailing list