Fix some blank messageboxes that shows no context except the 'OK' button (#3214)

* fix empty error msg box

* free markup escaped strings
upstream-master
Vivek Thazhathattil 5 years ago committed by GitHub
parent 9f4637f808
commit 33cb59e5c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/util/XojMsgBox.cpp

@ -22,12 +22,15 @@ void XojMsgBox::showErrorToUser(GtkWindow* win, const string& msg) {
GtkWidget* dialog =
gtk_message_dialog_new_with_markup(win, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, nullptr);
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog), msg.c_str());
char* formattedMsg = g_markup_escape_text(msg.c_str(), -1);
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog), formattedMsg);
if (win != nullptr) {
gtk_window_set_transient_for(GTK_WINDOW(dialog), win);
}
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_free(formattedMsg);
}
auto XojMsgBox::showPluginMessage(const string& pluginName, const string& msg, const map<int, string>& button,
@ -40,7 +43,8 @@ auto XojMsgBox::showPluginMessage(const string& pluginName, const string& msg, c
GtkWidget* dialog = gtk_message_dialog_new_with_markup(defaultWindow, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
GTK_BUTTONS_NONE, nullptr);
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog), header.c_str());
char* formattedHeader = g_markup_escape_text(header.c_str(), -1);
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog), formattedHeader);
if (defaultWindow != nullptr) {
gtk_window_set_transient_for(GTK_WINDOW(dialog), defaultWindow);
@ -52,12 +56,11 @@ auto XojMsgBox::showPluginMessage(const string& pluginName, const string& msg, c
g_object_set_property(G_OBJECT(dialog), "secondary-text", &val);
g_value_unset(&val);
for (auto& kv: button) {
gtk_dialog_add_button(GTK_DIALOG(dialog), kv.second.c_str(), kv.first);
}
for (auto& kv: button) { gtk_dialog_add_button(GTK_DIALOG(dialog), kv.second.c_str(), kv.first); }
int res = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_free(formattedHeader);
return res;
}

Loading…
Cancel
Save