Bug#506714: Add progress bar to splash; patch from Herbert Thoma <herbie hthoma de>.

BP


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16779 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Joshua Sled 2008-01-01 20:07:22 +00:00
parent 5d303b9c2d
commit ba69a12a2c
4 changed files with 44 additions and 10 deletions

View File

@ -140,7 +140,7 @@ try_load_config_array(const gchar *fns[])
static void static void
update_message(const gchar *msg) update_message(const gchar *msg)
{ {
gnc_update_splash_screen(msg); gnc_update_splash_screen(msg, GNC_SPLASH_PERCENTAGE_UNKNOWN);
g_message(msg); g_message(msg);
} }
@ -353,7 +353,7 @@ load_gnucash_modules()
/* module initializations go here */ /* module initializations go here */
len = sizeof(modules) / sizeof(*modules); len = sizeof(modules) / sizeof(*modules);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
gnc_update_splash_screen(modules[i].name); gnc_update_splash_screen(modules[i].name, GNC_SPLASH_PERCENTAGE_UNKNOWN);
if (modules[i].optional) if (modules[i].optional)
gnc_module_load_optional(modules[i].name, modules[i].version); gnc_module_load_optional(modules[i].name, modules[i].version);
else else
@ -464,14 +464,14 @@ inner_main (void *closure, int argc, char **argv)
scm_c_eval_string("(gnc:main)"); scm_c_eval_string("(gnc:main)");
/* Install Price Quote Sources */ /* Install Price Quote Sources */
gnc_update_splash_screen(_("Checking Finance::Quote...")); gnc_update_splash_screen(_("Checking Finance::Quote..."), GNC_SPLASH_PERCENTAGE_UNKNOWN);
scm_c_use_module("gnucash price-quotes"); scm_c_use_module("gnucash price-quotes");
scm_c_eval_string("(gnc:price-quotes-install-sources)"); scm_c_eval_string("(gnc:price-quotes-install-sources)");
gnc_hook_run(HOOK_STARTUP, NULL); gnc_hook_run(HOOK_STARTUP, NULL);
if (!nofile && (fn = get_file_to_load())) { if (!nofile && (fn = get_file_to_load())) {
gnc_update_splash_screen(_("Loading data...")); gnc_update_splash_screen(_("Loading data..."), GNC_SPLASH_PERCENTAGE_UNKNOWN);
gnc_file_open_file(fn); gnc_file_open_file(fn);
g_free(fn); g_free(fn);
} }

View File

@ -33,6 +33,7 @@
static GtkWidget * splash = NULL; static GtkWidget * splash = NULL;
static GtkWidget * progress = NULL; static GtkWidget * progress = NULL;
static GtkWidget * progress_bar = NULL;
static int splash_is_initialized = FALSE; static int splash_is_initialized = FALSE;
static void static void
@ -63,6 +64,7 @@ gnc_show_splash_screen (void)
GtkWidget *pixmap; GtkWidget *pixmap;
GtkWidget *frame; GtkWidget *frame;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *version; GtkWidget *version;
GtkWidget *separator; GtkWidget *separator;
gchar *ver_string, *markup; gchar *ver_string, *markup;
@ -90,6 +92,7 @@ gnc_show_splash_screen (void)
frame = gtk_frame_new (NULL); frame = gtk_frame_new (NULL);
vbox = gtk_vbox_new (FALSE, 3); vbox = gtk_vbox_new (FALSE, 3);
hbox = gtk_hbox_new (FALSE, 3);
#ifdef GNUCASH_SVN #ifdef GNUCASH_SVN
/* Development version */ /* Development version */
ver_string = g_strdup_printf(_("Version: GnuCash-%s svn (r%s built %s)"), ver_string = g_strdup_printf(_("Version: GnuCash-%s svn (r%s built %s)"),
@ -112,16 +115,20 @@ gnc_show_splash_screen (void)
if a long string is given in gnc_update_splash_screen(); if a long string is given in gnc_update_splash_screen();
presumably it would be better to inhibit size change of the presumably it would be better to inhibit size change of the
top level container, but I don't know how to do this */ top level container, but I don't know how to do this */
gtk_label_set_max_width_chars(GTK_LABEL(progress), 50); gtk_label_set_max_width_chars(GTK_LABEL(progress), 34);
markup = g_markup_printf_escaped(MARKUP_STRING, _("Loading...")); markup = g_markup_printf_escaped(MARKUP_STRING, _("Loading..."));
gtk_label_set_markup(GTK_LABEL(progress), markup); gtk_label_set_markup(GTK_LABEL(progress), markup);
g_free(markup); g_free(markup);
progress_bar = gtk_progress_bar_new ();
gtk_container_add (GTK_CONTAINER (frame), pixmap); gtk_container_add (GTK_CONTAINER (frame), pixmap);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), version, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), version, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), progress, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), progress, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), progress_bar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (splash), vbox); gtk_container_add (GTK_CONTAINER (splash), vbox);
gtk_widget_add_events(splash, GDK_BUTTON_PRESS_MASK); gtk_widget_add_events(splash, GDK_BUTTON_PRESS_MASK);
@ -144,12 +151,13 @@ gnc_destroy_splash_screen (void)
{ {
gtk_widget_destroy (splash); gtk_widget_destroy (splash);
progress = NULL; progress = NULL;
progress_bar = NULL;
splash = NULL; splash = NULL;
} }
} }
void void
gnc_update_splash_screen (const gchar *string) gnc_update_splash_screen (const gchar *string, double percentage)
{ {
gchar *markup; gchar *markup;
@ -166,4 +174,28 @@ gnc_update_splash_screen (const gchar *string)
gtk_main_iteration (); gtk_main_iteration ();
} }
} }
if (progress_bar)
{
if (percentage < 0)
{
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar), 0.0);
}
else
{
if (percentage <= 100)
{
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),
percentage/100);
}
else
{
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar));
}
}
/* make sure new status bar is up */
while (gtk_events_pending ())
gtk_main_iteration ();
}
} }

View File

@ -25,7 +25,9 @@
void gnc_show_splash_screen (void); void gnc_show_splash_screen (void);
void gnc_destroy_splash_screen (void); void gnc_destroy_splash_screen (void);
void gnc_update_splash_screen (const gchar *string); void gnc_update_splash_screen (const gchar *string, double percentage);
void gnc_gui_init_splash (void); void gnc_gui_init_splash (void);
#define GNC_SPLASH_PERCENTAGE_UNKNOWN 101
#endif #endif

View File

@ -175,7 +175,7 @@ gnc_window_show_progress (const char *message, double percentage)
return; return;
} }
gnc_update_splash_screen(message); gnc_update_splash_screen(message, percentage);
if (percentage < 0) { if (percentage < 0) {
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbar), " "); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbar), " ");