Merge pull request #32 from gergelypolonkai/own-message-dialogs

Refactor all `gtk_message_dialog()` calls to `ag_app_message_dialog()`
This commit is contained in:
Gergely Polonkai 2014-07-11 00:36:32 +02:00
commit a9da77b60a
2 changed files with 19 additions and 42 deletions

View File

@ -223,18 +223,12 @@ show_help(const gchar *topic, GtkWindow *parent)
} }
if (!gtk_show_uri(screen, uri, gtk_get_current_event_time(), &err)) { if (!gtk_show_uri(screen, uri, gtk_get_current_event_time(), &err)) {
GtkWidget *dialog; ag_app_message_dialog(
GTK_WIDGET(parent),
dialog = gtk_message_dialog_new(
parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING, GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
"Unable to display help: %s", "Unable to display help: %s",
err->message err->message
); );
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
} }
g_free(uri); g_free(uri);

View File

@ -107,17 +107,11 @@ ag_window_save_as(AgWindow *window, GError **err)
// We should never enter here, but who knows... // We should never enter here, but who knows...
if (priv->chart == NULL) { if (priv->chart == NULL) {
GtkWidget *dialog; ag_app_message_dialog(
GTK_WIDGET(window),
dialog = gtk_message_dialog_new(
GTK_WINDOW(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Chart cannot be calculated.") _("Chart cannot be calculated.")
); );
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_set_error( g_set_error(
err, err,
AG_WINDOW_ERROR, AG_WINDOW_ERROR_EMPTY_CHART, AG_WINDOW_ERROR, AG_WINDOW_ERROR_EMPTY_CHART,
@ -130,19 +124,13 @@ ag_window_save_as(AgWindow *window, GError **err)
name = ag_chart_get_name(priv->chart); name = ag_chart_get_name(priv->chart);
if ((name == NULL) || (*name == 0)) { if ((name == NULL) || (*name == 0)) {
GtkWidget *dialog;
g_free(name); g_free(name);
dialog = gtk_message_dialog_new( ag_app_message_dialog(
GTK_WINDOW(window), GTK_WIDGET(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("You must enter a name before saving a chart.") _("You must enter a name before saving a chart.")
); );
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_set_error( g_set_error(
err, err,
AG_WINDOW_ERROR, AG_WINDOW_ERROR_NO_NAME, AG_WINDOW_ERROR, AG_WINDOW_ERROR_NO_NAME,
@ -243,17 +231,11 @@ ag_window_export_svg(AgWindow *window, GError **err)
// We should never enter here, but who knows... // We should never enter here, but who knows...
if (priv->chart == NULL) { if (priv->chart == NULL) {
GtkWidget *dialog; ag_app_message_dialog(
GTK_WIDGET(window),
dialog = gtk_message_dialog_new(
GTK_WINDOW(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Chart cannot be calculated.") _("Chart cannot be calculated.")
); );
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_set_error( g_set_error(
err, err,
AG_WINDOW_ERROR, AG_WINDOW_ERROR_EMPTY_CHART, AG_WINDOW_ERROR, AG_WINDOW_ERROR_EMPTY_CHART,
@ -266,13 +248,13 @@ ag_window_export_svg(AgWindow *window, GError **err)
name = ag_chart_get_name(priv->chart); name = ag_chart_get_name(priv->chart);
if ((name == NULL) || (*name == 0)) { if ((name == NULL) || (*name == 0)) {
GtkWidget *dialog;
g_free(name); g_free(name);
dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("You must enter a name before saving a chart.")); ag_app_message_dialog(
gtk_dialog_run(GTK_DIALOG(dialog)); GTK_WIDGET(window),
gtk_widget_destroy(dialog); GTK_MESSAGE_ERROR,
_("You must enter a name before saving a chart.")
);
g_set_error(err, AG_WINDOW_ERROR, AG_WINDOW_ERROR_NO_NAME, "No name specified"); g_set_error(err, AG_WINDOW_ERROR, AG_WINDOW_ERROR_NO_NAME, "No name specified");
return; return;
@ -561,11 +543,12 @@ ag_window_redraw_chart(AgWindow *window)
gchar *svg_content = ag_chart_create_svg(priv->chart, NULL, &err); gchar *svg_content = ag_chart_create_svg(priv->chart, NULL, &err);
if (svg_content == NULL) { if (svg_content == NULL) {
GtkWidget *dialog; ag_app_message_dialog(
GTK_WIDGET(window),
dialog = gtk_message_dialog_new(GTK_WINDOW(window), 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Unable to draw chart: %s", err->message); GTK_MESSAGE_WARNING,
gtk_dialog_run(GTK_DIALOG(dialog)); "Unable to draw chart: %s",
gtk_widget_destroy(dialog); err->message
);
} else { } else {
webkit_web_view_load_html( webkit_web_view_load_html(
WEBKIT_WEB_VIEW(priv->chart_web_view), WEBKIT_WEB_VIEW(priv->chart_web_view),