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.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@11827 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2005-11-04 05:49:15 +00:00
parent b8641ed7ea
commit f7a382607b
7 changed files with 89 additions and 61 deletions

View File

@ -1,3 +1,20 @@
2005-11-03 David Hampton <hampton@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@codehelp.co.uk>
* Various Makefile.am : Remove .cvsignore from

View File

@ -365,7 +365,7 @@ gnc_plugin_page_invoice_create_widget (GncPluginPage *plugin_page)
{
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 @@ gnc_plugin_page_invoice_create_widget (GncPluginPage *plugin_page)
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) {

View File

@ -123,9 +123,6 @@ struct GncMainWindowPrivate
GtkWidget *statusbar;
GtkWidget *progressbar;
GtkWidget *summarybar_dock;
gboolean show_summarybar;
GtkActionGroup *action_group;
GncPluginPage *current_page;
@ -1169,11 +1166,6 @@ gnc_main_window_disconnect (GncMainWindow *window,
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 @@ gnc_main_window_setup_window (GncMainWindow *window)
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 @@ gnc_main_window_add_widget (GtkUIManager *merge,
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 @@ gnc_main_window_switch_page (GtkNotebook *notebook,
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,24 +1760,8 @@ gnc_main_window_switch_page (GtkNotebook *notebook,
if (page != NULL) {
/* Update the user interface (e.g. menus and toolbars */
gnc_plugin_page_merge_actions (page, window->ui_merge);
/* 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 );
}
visible = gnc_main_window_show_summarybar(window, NULL);
gnc_plugin_page_show_summarybar (page, visible);
/* Allow page specific actions */
gnc_plugin_page_selected (page);
@ -1891,10 +1876,12 @@ gnc_main_window_cmd_view_toolbar (GtkAction *action, GncMainWindow *window)
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 @@ gnc_main_window_cmd_window_move_page (GtkAction *action, GncMainWindow *window)
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);
}

View File

@ -164,6 +164,22 @@ gnc_plugin_page_destroy_widget (GncPluginPage *plugin_page)
return klass->destroy_widget (plugin_page);
}
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 @@ gnc_plugin_page_finalize (GObject *object)
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);

View File

@ -93,6 +93,14 @@ GType gnc_plugin_page_get_type (void);
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,

View File

@ -500,6 +500,8 @@ gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page)
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 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page)
page->priv->component_id = 0;
}
if (plugin_page->summarybar) {
g_object_unref(G_OBJECT(plugin_page->summarybar));
plugin_page->summarybar = NULL;
}
LEAVE("widget destroyed");
}

View File

@ -615,8 +615,11 @@ gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page)
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,