[kupfer: 2/38] commatrick: Introduce an object stack per Pane in the data model
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer: 2/38] commatrick: Introduce an object stack per Pane in the data model
- Date: Sat, 16 Jan 2010 17:11:58 +0000 (UTC)
commit 54ba4f48bc808240b572540cb08ba7707cc699e3
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sat Jan 16 01:17:58 2010 +0100
commatrick: Introduce an object stack per Pane in the data model
kupfer/core/data.py | 33 +++++++++++++++++++++++++++++++++
kupfer/ui/browser.py | 19 ++++++++++++++++++-
2 files changed, 51 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/core/data.py b/kupfer/core/data.py
index e236515..0c971b5 100644
--- a/kupfer/core/data.py
+++ b/kupfer/core/data.py
@@ -191,6 +191,7 @@ class LeafPane (Pane, pretty.OutputMixin):
super(LeafPane, self).__init__()
self.source_stack = []
self.source = None
+ self.object_stack = []
def _load_source(self, src):
"""Try to get a source from the SourceController,
@@ -223,6 +224,12 @@ class LeafPane (Pane, pretty.OutputMixin):
"""Return True if we have no source stack"""
return not self.source_stack
+ def object_stack_push(self, obj):
+ self.object_stack.append(obj)
+
+ def object_stack_pop(self):
+ return self.object_stack.pop()
+
def get_can_enter_text_mode(self):
return self.is_at_source_root()
@@ -747,6 +754,7 @@ class DataController (gobject.GObject, pretty.OutputMixin):
self._insert_object(SourcePane, ret)
else:
return
+ self.object_stack_clear()
self.emit("command-result", result_type)
def find_object(self, url):
@@ -771,6 +779,27 @@ class DataController (gobject.GObject, pretty.OutputMixin):
obj = compose.ComposedLeaf(leaf, action, iobj)
self._insert_object(SourcePane, obj)
+ def object_stack_push(self, object_):
+ """
+ Push @object_ onto the stack
+ """
+ self.source_pane.object_stack_push(object_)
+ self.emit("object-stack-changed", SourcePane)
+
+
+ def object_stack_pop(self):
+ obj = self.source_pane.object_stack_pop()
+ self._insert_object(SourcePane, obj)
+ self.emit("object-stack-changed", SourcePane)
+
+ def object_stack_clear(self):
+ while self.source_pane.object_stack:
+ self.source_pane.object_stack_pop()
+ self.emit("object-stack-changed", SourcePane)
+
+ def get_object_stack(self):
+ return self.source_pane.object_stack
+
# pane cleared or set with new item
# pane, item
gobject.signal_new("pane-reset", DataController, gobject.SIGNAL_RUN_LAST,
@@ -787,6 +816,10 @@ gobject.signal_new("source-changed", DataController, gobject.SIGNAL_RUN_LAST,
gobject.signal_new("mode-changed", DataController, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_BOOLEAN, (gobject.TYPE_INT, gobject.TYPE_PYOBJECT,))
+# object stack update signal
+# arguments: pane
+gobject.signal_new("object-stack-changed", DataController, gobject.SIGNAL_RUN_LAST,
+ gobject.TYPE_BOOLEAN, (gobject.TYPE_INT, ))
# when an command returned a result
# arguments: result type
gobject.signal_new("command-result", DataController, gobject.SIGNAL_RUN_LAST,
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index 8d97452..32f6174 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -819,6 +819,7 @@ class Interface (gobject.GObject):
self.data_controller.connect("source-changed", self._new_source)
self.data_controller.connect("pane-reset", self._pane_reset)
self.data_controller.connect("mode-changed", self._show_hide_third)
+ self.data_controller.connect("object-stack-changed", self._object_stack_changed)
self.widget_to_pane = {
id(self.search) : data.SourcePane,
id(self.action) : data.ActionPane,
@@ -939,6 +940,11 @@ class Interface (gobject.GObject):
keyv = key_book["Down"]
elif keyv == ord("/") and has_selection:
keyv = key_book["Right"]
+ elif keyv == ord(",") and has_selection:
+ cur = self.current.get_current()
+ self.data_controller.object_stack_push(cur)
+ self._relax_search_terms()
+ return True
elif keyv in init_text_keys:
if self.try_enable_text_mode():
# swallow if it is the direct key
@@ -1077,6 +1083,8 @@ class Interface (gobject.GObject):
else:
self.reset_current()
else:
+ if self.current == self.search:
+ self.data_controller.object_stack_clear()
if self.get_in_text_mode():
self.toggle_text_mode(False)
elif not self.current.get_table_visible():
@@ -1089,7 +1097,9 @@ class Interface (gobject.GObject):
"""Handle leftarrow and backspace
Go up back through browsed sources.
"""
- if self.current.is_showing_result():
+ if self.current == self.search and self.data_controller.get_object_stack():
+ self.data_controller.object_stack_pop()
+ elif self.current.is_showing_result():
self.reset_current(populate=True)
else:
if self._browse_up():
@@ -1303,6 +1313,13 @@ class Interface (gobject.GObject):
def _pane_for_widget(self, widget):
return self.widget_to_pane[id(widget)]
+ def _object_stack_changed(self, controller, pane):
+ """
+ Stack of objects (for comma trick) changed in @pane
+ """
+ wid = self._widget_for_pane(pane)
+ wid.set_object_stack(controller.get_object_stack())
+
def _selection_changed(self, widget, match):
pane = self._pane_for_widget(widget)
self.data_controller.select(pane, match)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]