aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl/libui/unix/stddialogs.c
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-09-09 02:30:51 +0200
committerStapleButter <thetotalworm@gmail.com>2017-09-09 02:30:51 +0200
commit70e4841d311d68689724768157cc9cbfbde7a9fc (patch)
treeba9499f77d1258530a7e60aa6e1732c41d98161c /src/libui_sdl/libui/unix/stddialogs.c
parent81747d6c34eb159481a6ca3f283d065fa3568617 (diff)
another UI attempt, I guess.
sorry.
Diffstat (limited to 'src/libui_sdl/libui/unix/stddialogs.c')
-rw-r--r--src/libui_sdl/libui/unix/stddialogs.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/libui_sdl/libui/unix/stddialogs.c b/src/libui_sdl/libui/unix/stddialogs.c
new file mode 100644
index 0000000..93302f7
--- /dev/null
+++ b/src/libui_sdl/libui/unix/stddialogs.c
@@ -0,0 +1,66 @@
+// 26 june 2015
+#include "uipriv_unix.h"
+
+// LONGTERM figure out why, and describe, that this is the desired behavior
+// LONGTERM also point out that font and color buttons also work like this
+
+#define windowWindow(w) (GTK_WINDOW(uiControlHandle(uiControl(w))))
+
+static char *filedialog(GtkWindow *parent, GtkFileChooserAction mode, const gchar *confirm)
+{
+ GtkWidget *fcd;
+ GtkFileChooser *fc;
+ gint response;
+ char *filename;
+
+ fcd = gtk_file_chooser_dialog_new(NULL, parent, mode,
+ "_Cancel", GTK_RESPONSE_CANCEL,
+ confirm, GTK_RESPONSE_ACCEPT,
+ NULL);
+ fc = GTK_FILE_CHOOSER(fcd);
+ gtk_file_chooser_set_local_only(fc, FALSE);
+ gtk_file_chooser_set_select_multiple(fc, FALSE);
+ gtk_file_chooser_set_show_hidden(fc, TRUE);
+ gtk_file_chooser_set_do_overwrite_confirmation(fc, TRUE);
+ gtk_file_chooser_set_create_folders(fc, TRUE);
+ response = gtk_dialog_run(GTK_DIALOG(fcd));
+ if (response != GTK_RESPONSE_ACCEPT) {
+ gtk_widget_destroy(fcd);
+ return NULL;
+ }
+ filename = uiUnixStrdupText(gtk_file_chooser_get_filename(fc));
+ gtk_widget_destroy(fcd);
+ return filename;
+}
+
+char *uiOpenFile(uiWindow *parent)
+{
+ return filedialog(windowWindow(parent), GTK_FILE_CHOOSER_ACTION_OPEN, "_Open");
+}
+
+char *uiSaveFile(uiWindow *parent)
+{
+ return filedialog(windowWindow(parent), GTK_FILE_CHOOSER_ACTION_SAVE, "_Save");
+}
+
+static void msgbox(GtkWindow *parent, const char *title, const char *description, GtkMessageType type, GtkButtonsType buttons)
+{
+ GtkWidget *md;
+
+ md = gtk_message_dialog_new(parent, GTK_DIALOG_MODAL,
+ type, buttons,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(md), "%s", description);
+ gtk_dialog_run(GTK_DIALOG(md));
+ gtk_widget_destroy(md);
+}
+
+void uiMsgBox(uiWindow *parent, const char *title, const char *description)
+{
+ msgbox(windowWindow(parent), title, description, GTK_MESSAGE_OTHER, GTK_BUTTONS_OK);
+}
+
+void uiMsgBoxError(uiWindow *parent, const char *title, const char *description)
+{
+ msgbox(windowWindow(parent), title, description, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK);
+}