diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-04-29 12:11:35 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-04-29 12:11:35 +0200 |
commit | dcef13a23c06398c0c9b3145c08b28d1110bc169 (patch) | |
tree | df8d3227b3d71fdd356b3c1e69c62533d1759f72 /app/wlib/gtklib/splash.c | |
parent | 3e11d9c0e6173fce8a482efed8d7f965e8bd6dfa (diff) | |
parent | 16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff) |
Merge tag 'upstream/4.3.0'
Upstream version 4.3.0
Diffstat (limited to 'app/wlib/gtklib/splash.c')
-rw-r--r-- | app/wlib/gtklib/splash.c | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/app/wlib/gtklib/splash.c b/app/wlib/gtklib/splash.c new file mode 100644 index 0000000..0d5be50 --- /dev/null +++ b/app/wlib/gtklib/splash.c @@ -0,0 +1,144 @@ +/** \file splash.c + * Handling of the Splash Window functions + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) 2007 Martin Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#define GTK_DISABLE_SINGLE_INCLUDES +#define GDK_DISABLE_DEPRECATED +#define GTK_DISABLE_DEPRECATED +#define GSEAL_ENABLE + +#include <gtk/gtk.h> + +#include "gtkint.h" + +#define LOGOFILENAME "logo.bmp" + +static GtkWidget *window; /**< splash window handle */ +static GtkWidget *message; /**< window handle for progress message */ + +/** + * Create the splash window shown during startup. The function loads the logo + * bitmap and displays the program name and version as passed. + * + * \param IN appName the product name to be shown + * \param IN appVer the product version to be shown + * \return TRUE if window was created, FALSE if an error occured + */ + +int +wCreateSplash(char *appName, char *appVer) +{ + GtkWidget *vbox; + GtkWidget *image; + GtkWidget *label; + char *temp; + char logoPath[BUFSIZ]; + + /* create the basic window */ + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_decorated(GTK_WINDOW(window), FALSE); + gtk_window_set_title(GTK_WINDOW(window), appName); + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); + gtk_window_set_resizable(GTK_WINDOW(window), FALSE); + gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); +#if GTK_MINOR_VERSION > 5 + gtk_window_set_focus_on_map(GTK_WINDOW(window), FALSE); +#endif + + vbox = gtk_vbox_new(FALSE, 0); + gtk_widget_show(vbox); + gtk_container_add(GTK_CONTAINER(window), vbox); + + /* add the logo image to the top of the splash window */ + sprintf(logoPath, "%s/" LOGOFILENAME, wGetAppLibDir()); + image = gtk_image_new_from_file(logoPath); + gtk_widget_show(image); + gtk_box_pack_start(GTK_BOX(vbox), image, TRUE, TRUE, 0); + gtk_misc_set_alignment(GTK_MISC(image), 0, 0); + + /* put the product name into the window */ + + temp = malloc(strlen(appName) + strlen(appVer) + 2); + + if (!temp) { + return (FALSE); + } + + sprintf(temp, "%s %s", appName, appVer); + + label = gtk_label_new(temp); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_FILL); + gtk_label_set_selectable(GTK_LABEL(label), FALSE); + gtk_misc_set_padding(GTK_MISC(label), 6, 2); + + free(temp); + + label = gtk_label_new("Application is starting..."); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + gtk_label_set_line_wrap(GTK_LABEL(label), FALSE); + gtk_misc_set_padding(GTK_MISC(label), 6, 2); +#if GTK_MINOR_VERSION > 5 + gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_START); +#endif + message = label; + + gtk_widget_show(window); + + return (TRUE); +} + +/** + * Update the progress message inside the splash window + * msg text message to display + * return nonzero if ok + */ + +int +wSetSplashInfo(char *msg) +{ + if (msg) { + gtk_label_set_text((GtkLabel *)message, msg); + wFlush(); + return TRUE; + } + + return FALSE; +} + +/** + * Destroy the splash window. + * + */ + +void +wDestroySplash(void) +{ + /* kill window */ + gtk_widget_destroy(window); + return; +} |