2017-02-25 08:15:36 +00:00
|
|
|
#include "compat.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-04-25 01:46:19 +00:00
|
|
|
#include "dynamicgtk.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
#include "baselayer.h"
|
|
|
|
#include "build.h"
|
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#include "gtkbits.h"
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t gtkenabled = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
static GdkPixbuf *appicon = NULL;
|
|
|
|
|
2016-12-29 02:57:33 +00:00
|
|
|
int gtkbuild_msgbox(const char *name, const char *msg)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
GtkWidget *dialog;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!gtkenabled) return -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
dialog = gtk_message_dialog_new(NULL,
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
GTK_BUTTONS_OK,
|
2009-01-10 07:38:50 +00:00
|
|
|
"%s", msg);
|
2006-04-24 19:04:22 +00:00
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog), name);
|
|
|
|
gtk_dialog_run(GTK_DIALOG(dialog));
|
|
|
|
gtk_widget_destroy(dialog);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-12-29 02:57:33 +00:00
|
|
|
int gtkbuild_ynbox(const char *name, const char *msg)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t r;
|
2006-04-24 19:04:22 +00:00
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
if (!gtkenabled) return -1;
|
|
|
|
|
|
|
|
dialog = gtk_message_dialog_new(NULL,
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
GTK_BUTTONS_YES_NO,
|
2009-01-10 07:38:50 +00:00
|
|
|
"%s", msg);
|
2006-04-24 19:04:22 +00:00
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog), name);
|
|
|
|
r = gtk_dialog_run(GTK_DIALOG(dialog));
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
|
|
|
|
if (r == GTK_RESPONSE_YES) return 1;
|
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RENDERTYPESDL
|
|
|
|
#include "sdlayer.h"
|
|
|
|
extern struct sdlappicon sdlappicon;
|
|
|
|
#endif
|
2009-01-09 09:29:17 +00:00
|
|
|
void gtkbuild_init(int32_t *argc, char ***argv)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
gtkenabled = dynamicgtk_init();
|
2007-12-12 17:42:14 +00:00
|
|
|
if (gtkenabled < 0)
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
gtkenabled = 0;
|
|
|
|
return;
|
|
|
|
}
|
2017-06-09 06:38:42 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
gtkenabled = gtk_init_check(argc, argv);
|
|
|
|
if (!gtkenabled) return;
|
2006-04-13 20:47:06 +00:00
|
|
|
#ifdef RENDERTYPESDL
|
2006-04-24 19:04:22 +00:00
|
|
|
appicon = gdk_pixbuf_new_from_data((const guchar *)sdlappicon.pixels,
|
|
|
|
GDK_COLORSPACE_RGB, TRUE, 8, sdlappicon.width, sdlappicon.height,
|
|
|
|
sdlappicon.width*4, NULL, NULL);
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
if (appicon) gtk_window_set_default_icon(appicon);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void gtkbuild_exit(int32_t r)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-03-23 00:06:42 +00:00
|
|
|
UNREFERENCED_PARAMETER(r);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (gtkenabled)
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (appicon) g_object_unref((gpointer)appicon);
|
|
|
|
}
|
2017-06-09 06:38:42 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
dynamicgtk_uninit();
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|