[ease/inspector] Added error_dialog function, replacing various repeated implementations.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease/inspector] Added error_dialog function, replacing various repeated implementations.
- Date: Wed, 9 Jun 2010 21:57:26 +0000 (UTC)
commit 422f8a87e535bbf44b1dd8830feabe09e371bbed
Author: Nate Stedman <natesm gmail com>
Date: Fri Jun 4 05:35:56 2010 -0400
Added error_dialog function, replacing various repeated implementations.
Makefile.am | 1 +
src/Document.vala | 10 +---------
src/EditorWindow.vala | 11 +----------
src/ErrorDialog.vala | 37 +++++++++++++++++++++++++++++++++++++
src/HTMLExporter.vala | 11 +----------
src/Main.vala | 23 ++---------------------
src/PDFExporter.vala | 10 +---------
7 files changed, 44 insertions(+), 59 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 01daec7..743a530 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,6 +21,7 @@ ease_SOURCES = \
src/ElementMapValue.vala \
src/Element.vala \
src/Enums.vala \
+ src/ErrorDialog.vala \
src/Handle.vala \
src/HTMLExporter.vala \
src/ImageActor.vala \
diff --git a/src/Document.vala b/src/Document.vala
index c186c5b..e21f8cb 100644
--- a/src/Document.vala
+++ b/src/Document.vala
@@ -139,15 +139,7 @@ public class Ease.Document : SlideSet
}
catch (GLib.Error e)
{
- var dialog = new Gtk.MessageDialog(null,
- Gtk.DialogFlags.NO_SEPARATOR,
- Gtk.MessageType.ERROR,
- Gtk.ButtonsType.CLOSE,
- _("Error exporting: %s"),
- e. message);
- dialog.title = _("Error Exporting");
- dialog.border_width = 5;
- dialog.run();
+ error_dialog(_("Error exporting as HTML"), e.message);
}
exporter.finish();
diff --git a/src/EditorWindow.vala b/src/EditorWindow.vala
index e42e611..50a577b 100644
--- a/src/EditorWindow.vala
+++ b/src/EditorWindow.vala
@@ -167,16 +167,7 @@ public class Ease.EditorWindow : Gtk.Window
try { JSONParser.document_write(document); }
catch (GLib.Error e)
{
- var dialog = new Gtk.MessageDialog(null,
- Gtk.DialogFlags.NO_SEPARATOR,
- Gtk.MessageType.ERROR,
- Gtk.ButtonsType.CLOSE,
- _("Error saving: %s"),
- e. message);
-
- dialog.title = _("Error Saving");
- dialog.border_width = 5;
- dialog.run();
+ error_dialog(_("Error Saving Document"), e.message);
}
});
diff --git a/src/ErrorDialog.vala b/src/ErrorDialog.vala
new file mode 100644
index 0000000..e6b5cbf
--- /dev/null
+++ b/src/ErrorDialog.vala
@@ -0,0 +1,37 @@
+/* Ease, a GTK presentation application
+ Copyright (C) 2010 Nate Stedman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+namespace Ease
+{
+ /**
+ * Display a simple error message.
+ *
+ * @param title The title of the dialog.
+ * @param message The error message.
+ */
+ public void error_dialog(string title, string message)
+ {
+ var dialog = new Gtk.MessageDialog(null, 0,
+ Gtk.MessageType.ERROR,
+ Gtk.ButtonsType.CLOSE,
+ "%s", message);
+ dialog.title = title;
+ dialog.border_width = 5;
+ dialog.run();
+ dialog.destroy();
+ }
+}
diff --git a/src/HTMLExporter.vala b/src/HTMLExporter.vala
index 8adfab3..bcdf6c5 100644
--- a/src/HTMLExporter.vala
+++ b/src/HTMLExporter.vala
@@ -130,16 +130,7 @@ public class Ease.HTMLExporter : GLib.Object
}
catch (GLib.Error e)
{
- var dialog = new Gtk.MessageDialog(null,
- Gtk.DialogFlags.NO_SEPARATOR,
- Gtk.MessageType.ERROR,
- Gtk.ButtonsType.CLOSE,
- _("Error copying: %s"),
- e. message);
- dialog.title = _("Error Copying File");
- dialog.border_width = 5;
- dialog.run();
- dialog.destroy();
+ error_dialog(_("Error Copying File"), e.message);
}
}
diff --git a/src/Main.vala b/src/Main.vala
index f698cf1..a05dc36 100644
--- a/src/Main.vala
+++ b/src/Main.vala
@@ -110,16 +110,7 @@ public static class Ease.Main : GLib.Object
}
catch (Error e)
{
- var dialog = new Gtk.MessageDialog(null,
- Gtk.DialogFlags.NO_SEPARATOR,
- Gtk.MessageType.ERROR,
- Gtk.ButtonsType.CLOSE,
- _("Error playing: %s"),
- e.message);
-
- dialog.title = _("Error Playing");
- dialog.border_width = 5;
- dialog.run();
+ error_dialog(_("Error Playing Document"), e.message);
}
}
@@ -162,17 +153,7 @@ public static class Ease.Main : GLib.Object
}
catch (Error e)
{
- var dialog = new Gtk.MessageDialog(null,
- Gtk.DialogFlags.NO_SEPARATOR,
- Gtk.MessageType.ERROR,
- Gtk.ButtonsType.CLOSE,
- _("Error loading: %s"),
- e.message);
-
- dialog.title = _("Error Loading");
- dialog.border_width = 5;
- dialog.run();
-
+ error_dialog(_("Error Opening Document"), e.message);
return;
}
}
diff --git a/src/PDFExporter.vala b/src/PDFExporter.vala
index a2ca2d7..169211f 100644
--- a/src/PDFExporter.vala
+++ b/src/PDFExporter.vala
@@ -61,15 +61,7 @@ public static class Ease.PDFExporter : Object
}
catch (Error e)
{
- var error = new Gtk.MessageDialog(null,
- 0,
- Gtk.MessageType.ERROR,
- Gtk.ButtonsType.CLOSE,
- _("Error exporting: %s"),
- e.message);
-
- error.title = _("Error Exporting to PDF");
- error.run();
+ error_dialog(_("Error Exporting to PDF"), e.message);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]