Permalink
Browse files

very basic proof-of-concept

  • Loading branch information...
baverman committed Sep 24, 2010
1 parent ee12671 commit 8d95d48927a5b380213d26aef2e1b2b9251ef399
View
@@ -0,0 +1,3 @@
+/.ropeproject
+*.pyc
+*.pyo
View
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+from snaked.core.run import run
+
+run()
View
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__)
View
No changes.
View
@@ -0,0 +1,62 @@
+import gtk
+import gtksourceview2
+
+from gsignals import connect_all
+
+from .signals import EditorSignals
+
+class Editor(object):
+ """
+ The main editor window.
+
+ Editor can be both standalone window and embedded into tab.
+ """
+
+ def __init__(self, filename):
+ self.signals = EditorSignals()
+
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.connect('delete-event', self.on_delete_event)
+ self.window.connect('destroy', self.on_destroy)
+
+ self.buffer = gtksourceview2.Buffer()
+ self.view = gtksourceview2.View()
+
+ self.view.props.buffer = self.buffer
+
+ self.window.add(self.view)
+
+ if filename:
+ self.window.set_title(filename)
+
+ self.window.show_all()
+
+ def on_destroy(self, *args):
+ self.signals.editor_closed.emit(self)
+
+ def on_delete_event(self, *args):
+ return False
+
+ def close(self):
+ del self.window
+
+
+class EditorManager(object):
+ """
+ Keeps window editor list
+ """
+
+ def __init__(self):
+ self.editors = []
+
+ def open(self, filename):
+ editor = Editor(filename)
+ self.editors.append(editor)
+ connect_all(self, editor.signals)
+ return editor
+
+ @EditorSignals.editor_closed(idle=True)
+ def editor_closed(self, sender, editor):
+ self.editors.remove(editor)
+ if not self.editors:
+ gtk.main_quit()
View
@@ -0,0 +1,13 @@
+import gtk
+import sys
+
+from .editor import EditorManager
+
+def run():
+ manager = EditorManager()
+
+ filename = sys.argv[1] if len(sys.argv) > 1 else None
+
+ manager.open(filename)
+
+ gtk.main()
View
@@ -0,0 +1,4 @@
+from gsignals import SignalManager, Signal
+
+class EditorSignals(SignalManager):
+ editor_closed = Signal(object)
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__)
View
@@ -0,0 +1,9 @@
+import gobject
+
+def idle_callback(callable, args):
+ args, kwargs = args
+ callable(*args, **kwargs)
+ return False
+
+def idle(callable, *args, **kwargs):
+ return gobject.idle_add(idle_callback, callable, (args, kwargs))

0 comments on commit 8d95d48

Please sign in to comment.