[ease] Added error_dialog function, replacing various repeated implementations.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Added error_dialog function, replacing various repeated implementations.
- Date: Fri, 4 Jun 2010 09:36:27 +0000 (UTC)
commit a094f0c5588079b9bb0e2182e5091d36b51de978
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 | 12 +-----------
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(+), 61 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index cfaf39b..4b1306c 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 7873314..d0db74c 100644
--- a/src/Document.vala
+++ b/src/Document.vala
@@ -77,8 +77,6 @@ public class Ease.Document : GLib.Object
/**
* Returns whether or not the Document has a { link Slide} after the
* passed in { link Slide}.
- *
- * @param slide
*/
public bool has_next_slide(Slide slide)
{
@@ -147,15 +145,7 @@ public class Ease.Document : GLib.Object
}
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 68ebd2e..e4265a0 100644
--- a/src/EditorWindow.vala
+++ b/src/EditorWindow.vala
@@ -148,16 +148,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 0093c37..8b2467a 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 a3c0b24..9282361 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]