[PATCH 10/17] grilo-test-ui.py: Implemented clear_panes
- From: Simón Pena <spenap gmail com>
- To: grilo-list gnome org
- Subject: [PATCH 10/17] grilo-test-ui.py: Implemented clear_panes
- Date: Sat, 14 Aug 2010 22:07:41 +0200
---
tools/python/grilo-test-ui.py | 81 +++++++++++++++++++++++++++--------------
1 files changed, 53 insertions(+), 28 deletions(-)
diff --git a/tools/python/grilo-test-ui.py b/tools/python/grilo-test-ui.py
index 5cc5e7e..0c1918a 100644
--- a/tools/python/grilo-test-ui.py
+++ b/tools/python/grilo-test-ui.py
@@ -19,13 +19,12 @@ class MainWindow(Gtk.Window):
self.set_title('Grilo Test UI using introspection')
Grl.init([])
+ self._ui_state = UIState()
self.BROWSE_KEYS = self._lookup_keys()
self._setup_ui()
self._load_plugins()
- self._ui_state = UIState()
-
self.show_all()
def _lookup_keys(self):
@@ -83,9 +82,9 @@ class MainWindow(Gtk.Window):
self._browser_window = self._create_browser_scrolled_window()
left_pane.add(self._browser_window)
- show_button = self._create_button('Show', self._show_btn_clicked_cb)
- show_button.set_sensitive(False)
- right_pane.pack_start(show_button, False, False, 0)
+ self._show_btn = self._create_button('Show', self._show_btn_clicked_cb)
+ self._show_btn.set_sensitive(False)
+ right_pane.pack_start(self._show_btn, False, False, 0)
self._contents_window = self._create_contents_window()
right_pane.add(self._contents_window)
@@ -105,7 +104,16 @@ class MainWindow(Gtk.Window):
self._browser_window.get_browser().add_sources(sources)
def _clear_panes(self):
- pass
+ browser_model = BrowserListStore()
+ self._browser_window.get_browser().set_model(browser_model)
+
+ metadata_model = MetadataListStore()
+ self._contents_window.get_metadata().set_model(metadata_model)
+
+ self._ui_state.last_url = None
+ self._store_btn.set_sensitive(False)
+ self._remove_btn.set_sensitive(False)
+ self._show_btn.set_sensitive(False)
def _create_contents_window(self):
scrolled_window = ContentScrolledWindow()
@@ -121,31 +129,31 @@ class MainWindow(Gtk.Window):
def _create_toolbar_buttons(self):
toolbar_buttons = Gtk.HBox()
- back_btn = Gtk.Button()
- back_btn.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_GO_BACK,
+ self._back_btn = Gtk.Button()
+ self._back_btn.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_GO_BACK,
Gtk.IconSize.BUTTON))
- store_btn = Gtk.Button()
- store_btn.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_ADD,
+ self._store_btn = Gtk.Button()
+ self._store_btn.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_ADD,
Gtk.IconSize.BUTTON))
- remove_btn = Gtk.Button()
- remove_btn.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_REMOVE,
+ self._remove_btn = Gtk.Button()
+ self._remove_btn.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_REMOVE,
Gtk.IconSize.BUTTON))
- toolbar_buttons.pack_start(back_btn, False, False, 0)
- toolbar_buttons.pack_start(store_btn, False, False, 0)
- toolbar_buttons.pack_start(remove_btn, False, False, 0)
+ toolbar_buttons.pack_start(self._back_btn, False, False, 0)
+ toolbar_buttons.pack_start(self._store_btn, False, False, 0)
+ toolbar_buttons.pack_start(self._remove_btn, False, False, 0)
- back_btn.connect('clicked',
+ self._back_btn.connect('clicked',
self._back_btn_clicked_cb)
- store_btn.connect('clicked',
+ self._store_btn.connect('clicked',
self._store_btn_clicked_cb)
- remove_btn.connect('clicked',
+ self._remove_btn.connect('clicked',
self._remove_btn_clicked_cb)
- store_btn.set_sensitive(False)
- remove_btn.set_sensitive(False)
+ self._store_btn.set_sensitive(False)
+ self._remove_btn.set_sensitive(False)
return toolbar_buttons
def _source_added_cb(self, plugin_registry, media_source):
@@ -268,13 +276,22 @@ class MainWindow(Gtk.Window):
Gtk.main_quit()
class UIState(object):
- def __init__(self, op_ongoing=False, cur_op_source=None,
- cur_op_id= -1, multiple=False):
+
+ def __init__(self, source_stack=[], container_stack=[], cur_source=None,
+ cur_container=None, cur_md_source=None, cur_md_media=None,
+ op_ongoing=False, cur_op_source=None, cur_op_id= -1,
+ multiple=False, last_url=None):
+ self.source_stack = source_stack
+ self.container_stack = container_stack
+ self.cur_source = cur_source
+ self.cur_container = cur_container
+ self.cur_md_source = cur_md_source
+ self.cur_md_media = cur_md_media
self.op_ongoing = op_ongoing
self.cur_op_source = cur_op_source
self.cur_op_id = cur_op_id
self.multiple = multiple
-
+ self.last_url = last_url
class OperationState(object):
def __init__(self, text, offset=0, count=0):
@@ -412,23 +429,31 @@ class BrowserTreeView(Gtk.TreeView):
model = self.get_model()
model.add(sources)
+class MetadataListStore(Gtk.ListStore):
+
+ NAME_COLUMN = 0
+ VALUE_COLUMN = 1
+
+ def __init__(self):
+ super(MetadataListStore, self).__init__(str, str)
+
class MetadataTreeView(Gtk.TreeView):
METADATA_MIN_WIDTH = 320
METADATA_MIN_HEIGHT = 400
- METADATA_MODEL_NAME = 0
- METADATA_MODEL_VALUE = 1
-
def __init__(self):
super(MetadataTreeView, self).__init__()
self.set_headers_visible(False)
+ model = MetadataListStore()
+ self.set_model(model)
+
col_renders = [Gtk.CellRendererText(),
Gtk.CellRendererText()]
col_attributes = ['text', 'text']
- col_model = [self.METADATA_MODEL_NAME,
- self.METADATA_MODEL_VALUE]
+ col_model = [model.NAME_COLUMN,
+ model.VALUE_COLUMN]
col = Gtk.TreeViewColumn()
for i in range(2):
--
1.7.0.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]