Skip to content
Permalink
Browse files

Tweak Zenity/Kdialog selection (#1853)

  • Loading branch information...
time-killer-games authored and JoshDreamland committed Aug 23, 2019
1 parent 2bcceb4 commit 130e67331ad92a6eb42c6f44b832ab5aba03ade3
@@ -32,6 +32,7 @@
using namespace std;
#include "Widget_Systems/widgets_mandatory.h"
#include "Widget_Systems/General/WSdialogs.h"
#include "Platforms/General/PFmain.h"
#include "Universal_System/estring.h"
#include "GameSettings.h"

@@ -420,7 +421,7 @@ static inline string get_open_filenames_helper(string filter, string fname, stri

static inline string get_save_filename_helper(string filter, string fname, string dir, string title) {
OPENFILENAMEW ofn;
ofn = get_filename_or_filenames_helper(filter, fname, dir, title, 0);
ofn = get_filename_or_filenames_helper(filter, fname, dir, title, OFN_OVERWRITEPROMPT);

if (GetSaveFileNameW(&ofn) != 0)
return shorten(wstr_fname);
@@ -436,7 +437,7 @@ static inline string get_directory_helper(string dname, string title) {
selectDirectory->GetOptions(&options);
selectDirectory->SetOptions(options | FOS_PICKFOLDERS | FOS_NOCHANGEDIR | FOS_FORCEFILESYSTEM);

tstring tstr_dname = widen(dname);
tstring tstr_dname = widen((dname == "") ? enigma_user::working_directory : dname);
LPWSTR szFilePath = (wchar_t *)tstr_dname.c_str();

IShellItem* pItem = nullptr;
@@ -5,7 +5,7 @@ Name: Linux X11 Widgets
Identifier: xlib
Build-Platforms: Linux
Represents: Linux
Description: Use KDE with KDialog Widgets by calling "widget_set_system(ws_x11_kdialog)". Use GTK+ with Zenity Widgets by calling "widget_set_system(ws_x11_zenity)". Zenity Widgets is the default. License, documentation, and install instructions: https://enigma-dev.org/docs/Wiki/Dialogs#Zenity_Widgets
Description: Use Qt with KDialog Widgets by calling "widget_set_system(ws_x11_kdialog)". Use GTK+ with Zenity Widgets by calling "widget_set_system(ws_x11_zenity)". The default will match your current Desktop Environment. License, documentation, and install instructions: https://enigma-dev.org/docs/Wiki/Dialogs#Zenity_Widgets
Author: Samuel Venable

Depends:
@@ -18,17 +18,28 @@
#include "dialogs.h"
#include "Widget_Systems/widgets_mandatory.h"
#include "Widget_Systems/General/WSdialogs.h"
#include <X11/Xlib.h>
#include <string>
using std::string;

namespace enigma {

CommandLineWidgetEngine *current_widget_engine = zenity_widgets;

static bool kwin_running() {
Display *d = XOpenDisplay(NULL);
Atom aKWinRunning = XInternAtom(d, "KWIN_RUNNING", True);
bool bKWinRunning = (aKWinRunning != None);
XCloseDisplay(d);
return bKWinRunning;
}

bool widget_system_initialize() {
// Defaults to the GUI toolkit (GTK+/Qt) that matches Desktop Environment.
current_widget_engine = kwin_running() ? kdialog_widgets : zenity_widgets;
return true;
}

CommandLineWidgetEngine *current_widget_engine = zenity_widgets;

} // namespace enigma

namespace enigma_user {
@@ -70,8 +70,8 @@ static string shellscript_evaluate(string command) {
}

static string add_escaping(string str, bool is_caption, string new_caption) {
string result; if (is_caption && str.empty()) result = new_caption;
result = string_replace_all(str, "\"", "\\\""); // kdialog needs this for quotes to show
string result = str; if (is_caption && str.empty()) result = new_caption;
result = string_replace_all(result, "\"", "\\\""); // kdialog needs this for quotes to show
return result;
}

@@ -70,8 +70,8 @@ static string shellscript_evaluate(string command) {
}

static string add_escaping(string str, bool is_caption, string new_caption) {
string result; if (is_caption && str.empty()) result = new_caption;
result = string_replace_all(str, "\"", "\\\""); // zenity needs this for quotes to show
string result = str; if (is_caption && str.empty()) result = new_caption;
result = string_replace_all(result, "\"", "\\\""); // zenity needs this for quotes to show
result = string_replace_all(result, "_", "__"); // zenity needs this for underscores to show
return result;
}

0 comments on commit 130e673

Please sign in to comment.
You can’t perform that action at this time.