26#include <glib/gi18n.h>
30#include "gnc-splash.h"
33#include "dialog-utils.h"
35#define MARKUP_STRING "<span size='small'>%s</span>"
36#define GNC_PREF_SHOW_SPLASH "show-splash-screen"
38static GtkWidget * splash = NULL;
39static GtkWidget * progress = NULL;
40static GtkWidget * progress_bar = NULL;
43splash_destroy_cb (GtkWidget *
object, gpointer user_data)
49button_press_cb(GtkWidget *widget, GdkEventButton *event, gpointer unused)
52 gtk_window_iconify (GTK_WINDOW (splash));
57gnc_show_splash_screen (
void)
65 gchar *ver_string, *markup;
70 splash = gtk_window_new (GTK_WINDOW_TOPLEVEL);
71 gtk_window_set_decorated(GTK_WINDOW (splash), FALSE);
72 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (splash), TRUE);
75 gtk_widget_set_name (GTK_WIDGET(splash),
"gnc-id-splash");
77 g_signal_connect (splash,
"destroy",
78 G_CALLBACK (splash_destroy_cb), NULL);
80 gtk_window_set_title (GTK_WINDOW (splash),
"GnuCash");
81 gtk_window_set_position (GTK_WINDOW (splash), GTK_WIN_POS_CENTER);
82 gtk_window_set_type_hint (GTK_WINDOW (splash), GDK_WINDOW_TYPE_HINT_DIALOG);
88 g_warning (
"can't find splash pixmap");
89 gtk_widget_destroy (splash);
93 frame = gtk_frame_new (NULL);
94 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
95 gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
96 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
97 gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
99 ver_string = g_strdup_printf (
"%s: %s, %s: %s",
_(
"Version"),
101 version = gtk_label_new(NULL);
102 markup = g_markup_printf_escaped(MARKUP_STRING, ver_string);
103 gtk_label_set_markup(GTK_LABEL(version), markup);
106 separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
108 progress = gtk_label_new(NULL);
113 gtk_label_set_max_width_chars(GTK_LABEL(progress), 34);
114 markup = g_markup_printf_escaped(MARKUP_STRING,
_(
"Loading…"));
115 gtk_label_set_markup(GTK_LABEL(progress), markup);
118 progress_bar = gtk_progress_bar_new ();
120 gtk_container_add (GTK_CONTAINER (frame), pixmap);
121 gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
122 gtk_box_pack_start (GTK_BOX (vbox), version, FALSE, FALSE, 0);
123 gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
124 gtk_box_pack_start (GTK_BOX (hbox), progress, TRUE, TRUE, 0);
125 gtk_box_pack_start (GTK_BOX (hbox), progress_bar, FALSE, FALSE, 0);
126 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
127 gtk_container_add (GTK_CONTAINER (splash), vbox);
129 gtk_widget_add_events(splash, GDK_BUTTON_PRESS_MASK);
130 g_signal_connect(splash,
"button_press_event",
131 G_CALLBACK(button_press_cb), NULL);
133 gtk_window_set_auto_startup_notification (FALSE);
134 gtk_widget_show_all (splash);
135 gtk_window_set_auto_startup_notification (TRUE);
138 while (gtk_events_pending ())
139 gtk_main_iteration ();
143gnc_destroy_splash_screen (
void)
147 gtk_widget_destroy (splash);
155gnc_update_splash_screen (
const gchar *
string,
double percentage)
161 if (
string && strcmp(
string,
""))
163 markup = g_markup_printf_escaped(MARKUP_STRING,
string);
164 gtk_label_set_markup (GTK_LABEL(progress), markup);
168 while (gtk_events_pending ())
169 gtk_main_iteration ();
175 double curr_fraction =
176 round(gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(progress_bar)) * 100.0);
177 if (percentage >= 0 && percentage <= 100.0 &&
178 round(percentage) == curr_fraction)
183 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar), 0.0);
187 if (percentage <= 100)
189 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),
194 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar));
199 while (gtk_events_pending ())
200 gtk_main_iteration ();
204GtkWindow *gnc_get_splash_screen (
void)
206 return GTK_WINDOW(splash);
Gnome specific utility functions.
Generic api to store and retrieve preferences.
functions to query various version related strings that were set at build time.
const char * gnc_version(void)
Parse <prefix>/etc/gnucash/environment and set environment variables based on the contents of that fi...
GtkWidget * gnc_gnome_get_pixmap(const char *name)
Given a file name, find and load the requested pixmap.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.