Get the progress bar working.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9492 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton
2003-10-12 21:12:45 +00:00
parent be8e571266
commit 5ba749fe70
7 changed files with 127 additions and 31 deletions

View File

@@ -17,6 +17,17 @@
interface to update the status bar when moving through the
register.
* src/gnome/gnc-main-window.c:
* src/gnome/gnc-plugin-page-register.c:
* src/gnome/gnc-plugin-page.[ch]: Update status bar code to handle
multiple windows, and to track page switches within a window.
* src/app-file/gncmod-app-file.c:
* src/gnome/gnc-main-window.c:
* src/gnome/gnc-plugin-file-history.c:
* src/gnome/gnc-window.[ch]:
* src/gnome-utils/gnc-mdi-utils.c: Get the progress bar working.
2003-10-11 David Hampton <hampton@employees.org>
* src/business/business-gnome/gnc-plugin-business.[ch]:

View File

@@ -73,8 +73,6 @@ libgncmod_app_file_LTX_gnc_module_init(int refcount)
gnc_history_get_last,
gnc_file_dialog);
gnc_file_set_pct_handler (gnc_mdi_show_progress);
gnc_file_init ();
}

View File

@@ -135,29 +135,7 @@ gnc_mdi_set_summarybar_visibility (gboolean visible)
void
gnc_mdi_show_progress (const char *message, double percentage)
{
GtkWidget *app;
GnomeAppBar *appbar;
app = gnc_ui_get_toplevel();
if (app == NULL)
return;
if (GNOME_APP(app)->statusbar == NULL)
return;
appbar = GNOME_APPBAR(GNOME_APP(app)->statusbar);
if (percentage < 0) {
gnome_appbar_refresh(appbar);
gnome_appbar_set_progress_percentage(appbar, 0.0);
} else {
if (message)
gnome_appbar_set_status(appbar, message);
gnome_appbar_set_progress_percentage(appbar, percentage/100);
}
/* make sure new text is up */
while (gtk_events_pending ())
gtk_main_iteration ();
g_assert_not_reached();
}
typedef struct {

View File

@@ -460,6 +460,7 @@ gnc_main_window_close_page (GncMainWindow *window,
gnc_plugin_page_removed (page);
egg_menu_merge_ensure_update (window->ui_merge);
gnc_window_set_status (GNC_WINDOW(window), page, NULL);
gnc_plugin_page_destroy_widget (page);
g_object_unref(page);
@@ -684,8 +685,6 @@ gnc_main_window_setup_window (GncMainWindow *window)
priv->progressbar = gtk_progress_bar_new ();
gtk_widget_show (priv->progressbar);
gtk_progress_bar_set_text (GTK_PROGRESS_BAR(priv->progressbar),
"<- Progress Bar ->");
gtk_box_pack_start (GTK_BOX (priv->statusbar), priv->progressbar,
FALSE, TRUE, 0);
@@ -769,6 +768,7 @@ gnc_main_window_switch_page_internal (GtkNotebook *notebook,
if (page != NULL) {
gnc_plugin_page_merge_actions (page, window->ui_merge);
gnc_plugin_page_selected (page);
gnc_window_update_status (GNC_WINDOW(window), page);
}
}
@@ -823,7 +823,9 @@ gnc_main_window_cmd_file_new (EggAction *action, GncMainWindow *window)
static void
gnc_main_window_cmd_file_open (EggAction *action, GncMainWindow *window)
{
gnc_window_set_progressbar_window (GNC_WINDOW(window));
gnc_file_open ();
gnc_window_set_progressbar_window (NULL);
gnc_main_window_update_title (window);
/* FIXME GNOME 2 Port (update the title etc.) */
}
@@ -858,21 +860,27 @@ gnc_main_window_cmd_file_open_new_window (EggAction *action, GncMainWindow *wind
static void
gnc_main_window_cmd_file_save (EggAction *action, GncMainWindow *window)
{
gnc_window_set_progressbar_window (GNC_WINDOW(window));
gnc_file_save ();
gnc_window_set_progressbar_window (NULL);
/* FIXME GNOME 2 Port (update the title etc.) */
}
static void
gnc_main_window_cmd_file_save_as (EggAction *action, GncMainWindow *window)
{
gnc_window_set_progressbar_window (GNC_WINDOW(window));
gnc_file_save_as ();
gnc_window_set_progressbar_window (NULL);
/* FIXME GNOME 2 Port (update the title etc.) */
}
static void
gnc_main_window_cmd_file_export_accounts (EggAction *action, GncMainWindow *window)
{
gnc_window_set_progressbar_window (GNC_WINDOW(window));
gnc_file_export_file (NULL);
gnc_window_set_progressbar_window (NULL);
/* FIXME GNOME 2 Port (update the title etc.) */
/* gnc_refresh_main_window_info (); */
}

View File

@@ -30,6 +30,7 @@
#include "gnc-file-history.h"
#include "gnc-main-window.h"
#include "gnc-plugin-file-history.h"
#include "gnc-window.h"
#include "messages.h"
static GList *active_pages = NULL;
@@ -272,7 +273,9 @@ gnc_plugin_file_history_cmd_open_file (EggAction *action,
g_return_if_fail(GNC_IS_PLUGIN(plugin));
filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING);
gnc_window_set_progressbar_window (GNC_WINDOW(plugin->window));
gnc_file_open_file (filename); /* also opens new account page */
gnc_window_set_progressbar_window (NULL);
gnc_main_window_update_title (plugin->window);
/* FIXME GNOME 2 Port (update the title etc.) */
}

View File

@@ -24,6 +24,10 @@
#include "config.h"
#include <gtk/gtk.h>
#include "gnc-file.h"
#include "gnc-plugin-page.h"
#include "gnc-window.h"
@@ -49,12 +53,18 @@ gnc_window_get_type (void)
"GncWindow",
&our_info, 0);
g_type_interface_add_prerequisite (gnc_window_type, G_TYPE_OBJECT);
gnc_file_set_pct_handler (gnc_window_show_progress);
}
return gnc_window_type;
}
GtkWidget *
/************************************************************
* Interface access functions *
************************************************************/
static GtkWidget *
gnc_window_get_statusbar (GncWindow *window)
{
g_return_val_if_fail(GNC_WINDOW (window), NULL);
@@ -65,7 +75,7 @@ gnc_window_get_statusbar (GncWindow *window)
return GNC_WINDOW_GET_IFACE (window)->get_statusbar (window);
}
GtkWidget *
static GtkWidget *
gnc_window_get_progressbar (GncWindow *window)
{
g_return_val_if_fail(GNC_WINDOW (window), NULL);
@@ -76,3 +86,86 @@ gnc_window_get_progressbar (GncWindow *window)
return GNC_WINDOW_GET_IFACE (window)->get_progressbar (window);
}
/************************************************************
* Auxiliary status bar functions *
************************************************************/
void
gnc_window_update_status (GncWindow *window, GncPluginPage *page)
{
GtkWidget *statusbar;
g_return_if_fail(GNC_WINDOW (window));
statusbar = gnc_window_get_statusbar (window);
gtk_statusbar_pop(GTK_STATUSBAR(statusbar), 0);
gtk_statusbar_push(GTK_STATUSBAR(statusbar), 0,
page->statusbar_text ? page->statusbar_text : "");
}
void
gnc_window_set_status (GncWindow *window, GncPluginPage *page, const gchar *message)
{
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_window_update_status (window, page);
}
/************************************************************
* Auxiliary progress bar functions *
************************************************************/
/*
* Single threaded hack. Otherwise the window value has to be passed
* all the way down to the backend and then back out again. Not too
* bad from C, but also has to be done in Scheme.
*/
static GncWindow *progress_bar_hack_window = NULL;
/*
* Must be set to a valid window or to NULL (no window).
*/
void
gnc_window_set_progressbar_window (GncWindow *window)
{
if (window != NULL) {
g_return_if_fail(GNC_WINDOW (window));
}
progress_bar_hack_window = window;
}
void
gnc_window_show_progress (const char *message, double percentage)
{
GncWindow *window;
GtkWidget *progressbar;
window = progress_bar_hack_window;
if (window == NULL)
return;
progressbar = gnc_window_get_progressbar (window);
if (progressbar == NULL)
return;
if (percentage < 0) {
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbar), NULL);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), 0.0);
} else {
if (message)
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbar), message);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), percentage/100);
}
/* make sure new text is up */
while (gtk_events_pending ())
gtk_main_iteration ();
}

View File

@@ -26,6 +26,7 @@
#define __GNC_WINDOW_H
#include <gtk/gtkwindow.h>
#include "gnc-plugin-page.h"
G_BEGIN_DECLS
@@ -50,8 +51,12 @@ typedef struct {
/* function prototypes */
GType gnc_window_get_type (void);
GtkWidget *gnc_window_get_statusbar (GncWindow *window);
GtkWidget *gnc_window_get_progressbar (GncWindow *window);
void gnc_window_update_status (GncWindow *window, GncPluginPage *page);
void gnc_window_set_status (GncWindow *window, GncPluginPage *page, const gchar *message);
void gnc_window_set_progressbar_window (GncWindow *window);
void gnc_window_show_progress (const char *message, double percentage);
G_END_DECLS