[ease] Allow only one EditorWindow for each file.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Allow only one EditorWindow for each file.
- Date: Sat, 29 May 2010 07:26:15 +0000 (UTC)
commit 517cace7cd4c86c767b049a7e54b28c42a564ae0
Author: Nate Stedman <natesm gmail com>
Date: Fri May 28 22:56:45 2010 -0400
Allow only one EditorWindow for each file.
Instead of opening a second EditorWindow, the existing window is now
presented.
src/Main.vala | 25 ++++++++++++++++++++++---
src/OpenDialog.vala | 2 +-
2 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/src/Main.vala b/src/Main.vala
index 29e9ea7..778dfa2 100644
--- a/src/Main.vala
+++ b/src/Main.vala
@@ -88,7 +88,7 @@ public static class Ease.Main : GLib.Object
{
for (int i = 0; filenames[i] != null; i++)
{
- test_editor(filenames[i]);
+ open_file(filenames[i]);
}
}
@@ -118,8 +118,27 @@ public static class Ease.Main : GLib.Object
return 0;
}
- public static void test_editor(string path)
+ /**
+ * Creates a new { link EditorWindow}, or raises an existing one.
+ *
+ * If the passed filename does not have a window associated with it,
+ * a new window will be created to edit that file. Otherwise, the currently
+ * existing window will be raised.
+ *
+ * @param path The filename
+ */
+ public static void open_file(string path)
{
+ foreach (var w in windows)
+ {
+ if (w.document.path == path)
+ {
+ w.present();
+
+ return;
+ }
+ }
+
add_window(new EditorWindow(path));
}
@@ -151,7 +170,7 @@ public static class Ease.Main : GLib.Object
*
* @param win The { link EditorWindow}.
*/
- public static void add_window(EditorWindow win)
+ private static void add_window(EditorWindow win)
{
windows.add(win);
}
diff --git a/src/OpenDialog.vala b/src/OpenDialog.vala
index b2ec66d..9c50781 100644
--- a/src/OpenDialog.vala
+++ b/src/OpenDialog.vala
@@ -54,7 +54,7 @@ public class Ease.OpenDialog : GLib.Object
if (dialog.run() == Gtk.ResponseType.ACCEPT)
{
- Main.test_editor(dialog.get_filename() + "/");
+ Main.open_file(dialog.get_filename() + "/");
}
dialog.destroy();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]