gtk: Map dialog type to message box type
This commit is contained in:
parent
02e28ea758
commit
3e6394a004
4 changed files with 21 additions and 4 deletions
|
@ -9,7 +9,7 @@ fileDialogProperties =
|
||||||
multiSelections: 1 << 2
|
multiSelections: 1 << 2
|
||||||
createDirectory: 1 << 3
|
createDirectory: 1 << 3
|
||||||
|
|
||||||
messageBoxTypes = ['none', 'info', 'warning']
|
messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']
|
||||||
|
|
||||||
parseArgs = (window, options, callback) ->
|
parseArgs = (window, options, callback) ->
|
||||||
unless window is null or window?.constructor is BrowserWindow
|
unless window is null or window?.constructor is BrowserWindow
|
||||||
|
|
|
@ -22,7 +22,9 @@ class NativeWindow;
|
||||||
enum MessageBoxType {
|
enum MessageBoxType {
|
||||||
MESSAGE_BOX_TYPE_NONE = 0,
|
MESSAGE_BOX_TYPE_NONE = 0,
|
||||||
MESSAGE_BOX_TYPE_INFORMATION,
|
MESSAGE_BOX_TYPE_INFORMATION,
|
||||||
MESSAGE_BOX_TYPE_WARNING
|
MESSAGE_BOX_TYPE_WARNING,
|
||||||
|
MESSAGE_BOX_TYPE_ERROR,
|
||||||
|
MESSAGE_BOX_TYPE_QUESTION,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef base::Callback<void(int code)> MessageBoxCallback;
|
typedef base::Callback<void(int code)> MessageBoxCallback;
|
||||||
|
|
|
@ -41,7 +41,7 @@ class GtkMessageBox {
|
||||||
nullptr, // parent
|
nullptr, // parent
|
||||||
modal ? GTK_DIALOG_MODAL : // modal dialog
|
modal ? GTK_DIALOG_MODAL : // modal dialog
|
||||||
static_cast<GtkDialogFlags>(0), // no flags
|
static_cast<GtkDialogFlags>(0), // no flags
|
||||||
GTK_MESSAGE_OTHER, // no icon
|
GetMessageType(type), // type
|
||||||
GTK_BUTTONS_NONE, // no buttons
|
GTK_BUTTONS_NONE, // no buttons
|
||||||
"%s", message.c_str());
|
"%s", message.c_str());
|
||||||
gtk_message_dialog_format_secondary_text(
|
gtk_message_dialog_format_secondary_text(
|
||||||
|
@ -75,6 +75,21 @@ class GtkMessageBox {
|
||||||
gtk_widget_destroy(dialog_);
|
gtk_widget_destroy(dialog_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkMessageType GetMessageType(MessageBoxType type) {
|
||||||
|
switch (type) {
|
||||||
|
case MESSAGE_BOX_TYPE_INFORMATION:
|
||||||
|
return GTK_MESSAGE_INFO;
|
||||||
|
case MESSAGE_BOX_TYPE_WARNING:
|
||||||
|
return GTK_MESSAGE_WARNING;
|
||||||
|
case MESSAGE_BOX_TYPE_QUESTION:
|
||||||
|
return GTK_MESSAGE_QUESTION;
|
||||||
|
case MESSAGE_BOX_TYPE_ERROR:
|
||||||
|
return GTK_MESSAGE_ERROR;
|
||||||
|
default:
|
||||||
|
return GTK_MESSAGE_OTHER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const char* TranslateToStock(int id, const std::string& text) {
|
const char* TranslateToStock(int id, const std::string& text) {
|
||||||
std::string lower = base::StringToLowerASCII(text);
|
std::string lower = base::StringToLowerASCII(text);
|
||||||
if (lower == "cancel") {
|
if (lower == "cancel") {
|
||||||
|
|
|
@ -70,7 +70,7 @@ will be passed via `callback(filename)`
|
||||||
|
|
||||||
* `browserWindow` BrowserWindow
|
* `browserWindow` BrowserWindow
|
||||||
* `options` Object
|
* `options` Object
|
||||||
* `type` String - Can be `"none"`, `"info"` or `"warning"`
|
* `type` String - Can be `"none"`, `"info"`, `"error"`, `"question"` or `"warning"`
|
||||||
* `buttons` Array - Array of texts for buttons
|
* `buttons` Array - Array of texts for buttons
|
||||||
* `title` String - Title of the message box, some platforms will not show it
|
* `title` String - Title of the message box, some platforms will not show it
|
||||||
* `message` String - Content of the message box
|
* `message` String - Content of the message box
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue