mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
Use Zenity to add Linux support
This commit is contained in:
parent
a2e6cedf42
commit
8b88d3e575
@ -10,6 +10,7 @@
|
|||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/extensions/XInput2.h>
|
#include <X11/extensions/XInput2.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
#define CC_BUILD_XIM
|
#define CC_BUILD_XIM
|
||||||
@ -967,7 +968,43 @@ static void ShowDialogCore(const char* title, const char* msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cc_result Window_OpenFileDialog(const char* const* filters, OpenFileDialogCallback callback) {
|
cc_result Window_OpenFileDialog(const char* const* filters, OpenFileDialogCallback callback) {
|
||||||
return ERR_NOT_SUPPORTED;
|
cc_string path; char pathBuffer[1024];
|
||||||
|
char result[4096] = { 0 };
|
||||||
|
int len, i;
|
||||||
|
FILE* fp;
|
||||||
|
|
||||||
|
String_InitArray_NT(path, pathBuffer);
|
||||||
|
String_AppendConst(&path, "zenity --file-selection --file-filter='All supported files (");
|
||||||
|
|
||||||
|
for (i = 0; filters[i]; i++)
|
||||||
|
{
|
||||||
|
if (i) String_Append(&path, ',');
|
||||||
|
String_Format1(&path, "*%c", filters[i]);
|
||||||
|
}
|
||||||
|
String_AppendConst(&path, ") |");
|
||||||
|
|
||||||
|
for (i = 0; filters[i]; i++)
|
||||||
|
{
|
||||||
|
String_Format1(&path, " *%c", filters[i]);
|
||||||
|
}
|
||||||
|
String_AppendConst(&path, "'");
|
||||||
|
path.buffer[path.length] = '\0';
|
||||||
|
|
||||||
|
/* TODO this doesn't detect when Zenity doesn't exist */
|
||||||
|
fp = popen(path.buffer, "r");
|
||||||
|
if (!fp) return 0;
|
||||||
|
|
||||||
|
/* result is normally just one string */
|
||||||
|
while (fgets(result, sizeof(result), fp)) { }
|
||||||
|
len = String_Length(result);
|
||||||
|
|
||||||
|
if (len) {
|
||||||
|
String_InitArray(path, pathBuffer);
|
||||||
|
String_AppendUtf8(&path, result, len);
|
||||||
|
callback(&path);
|
||||||
|
}
|
||||||
|
pclose(fp);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GC fb_gc;
|
static GC fb_gc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user