Implemented the dialog changes on the GTK+ backend.

This commit is contained in:
Pietro Gagliardi 2015-11-28 11:02:58 -05:00
parent 81112fe955
commit 3943c2c65e
1 changed files with 16 additions and 12 deletions

View File

@ -1,14 +1,18 @@
// 26 june 2015 // 26 june 2015
#include "uipriv_unix.h" #include "uipriv_unix.h"
static char *filedialog(GtkFileChooserAction mode, const gchar *stock) // TODO while this runs, other windows don't get /any/ events
#define windowWindow(w) (GTK_WINDOW(uiControlHandle(uiControl(w))))
static char *filedialog(GtkWindow *parent, GtkFileChooserAction mode, const gchar *stock)
{ {
GtkWidget *fcd; GtkWidget *fcd;
GtkFileChooser *fc; GtkFileChooser *fc;
gint response; gint response;
char *filename; char *filename;
fcd = gtk_file_chooser_dialog_new(NULL, NULL, mode, fcd = gtk_file_chooser_dialog_new(NULL, parent, mode,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
stock, GTK_RESPONSE_ACCEPT, stock, GTK_RESPONSE_ACCEPT,
NULL); NULL);
@ -28,21 +32,21 @@ static char *filedialog(GtkFileChooserAction mode, const gchar *stock)
return filename; return filename;
} }
char *uiOpenFile(void) char *uiOpenFile(uiWindow *parent)
{ {
return filedialog(GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OPEN); return filedialog(windowWindow(parent), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OPEN);
} }
char *uiSaveFile(void) char *uiSaveFile(uiWindow *parent)
{ {
return filedialog(GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_SAVE); return filedialog(windowWindow(parent), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_SAVE);
} }
static void msgbox(const char *title, const char *description, GtkMessageType type, GtkButtonsType buttons) static void msgbox(GtkWindow *parent, const char *title, const char *description, GtkMessageType type, GtkButtonsType buttons)
{ {
GtkWidget *md; GtkWidget *md;
md = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, md = gtk_message_dialog_new(parent, GTK_DIALOG_MODAL,
type, buttons, type, buttons,
"%s", title); "%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(md), "%s", description); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(md), "%s", description);
@ -50,12 +54,12 @@ static void msgbox(const char *title, const char *description, GtkMessageType ty
gtk_widget_destroy(md); gtk_widget_destroy(md);
} }
void uiMsgBox(const char *title, const char *description) void uiMsgBox(uiWindow *parent, const char *title, const char *description)
{ {
msgbox(title, description, GTK_MESSAGE_OTHER, GTK_BUTTONS_OK); msgbox(windowWindow(parent), title, description, GTK_MESSAGE_OTHER, GTK_BUTTONS_OK);
} }
void uiMsgBoxError(const char *title, const char *description) void uiMsgBoxError(uiWindow *parent, const char *title, const char *description)
{ {
msgbox(title, description, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK); msgbox(windowWindow(parent), title, description, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK);
} }