[PATCH 07/17] grilo-test-ui.py: Work on callbacks and ListStores
- From: Simón Pena <spenap gmail com>
- To: grilo-list gnome org
- Subject: [PATCH 07/17] grilo-test-ui.py: Work on callbacks and ListStores
- Date: Sat, 14 Aug 2010 22:07:38 +0200
---
tools/python/grilo-test-ui.py | 37 ++++++++++++++++++++-----------------
1 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/tools/python/grilo-test-ui.py b/tools/python/grilo-test-ui.py
index bf61d3a..09c6004 100644
--- a/tools/python/grilo-test-ui.py
+++ b/tools/python/grilo-test-ui.py
@@ -36,20 +36,18 @@ class MainWindow(Gtk.Window):
hbox = Gtk.HBox()
vbox = Gtk.VBox()
- search_text = Gtk.Entry()
- vbox.add(search_text)
+ self._search_text = Gtk.Entry()
+ vbox.add(self._search_text)
query_text = Gtk.Entry()
vbox.add(query_text)
hbox.add(vbox)
vbox = Gtk.VBox()
- search_combo = SearchComboBox()
- vbox.pack_start(search_combo, False, False, 0)
+ self._search_combo = SearchComboBox()
+ vbox.pack_start(self._search_combo, False, False, 0)
- query_combo = QueryComboBox()
- vbox.pack_start(query_combo, False, False, 0)
-
- self._comboboxes = [query_combo, search_combo]
+ self._query_combo = QueryComboBox()
+ vbox.pack_start(self._query_combo, False, False, 0)
hbox.add(vbox)
vbox = Gtk.VBox()
@@ -134,7 +132,7 @@ class MainWindow(Gtk.Window):
def _source_added_cb(self, plugin_registry, media_source):
self._show_plugins()
- for combo in self._comboboxes:
+ for combo in [self._search_combo, self._query_combo]:
combo.update()
def _source_removed_cb(self, plugin_registry, media_source):
@@ -162,7 +160,12 @@ class MainWindow(Gtk.Window):
pass
def _search_btn_clicked_cb(self, *args):
- pass
+ (success, iter) = self._search_combo.get_active_iter()
+ if success:
+ source = self._search_combo.get_model().get_value(iter,
+ ComboBoxStore.SOURCE_COLUMN)
+ search_text = self._search_text.get_text()
+ print search_text, source
def run(self):
Gtk.main()
@@ -173,11 +176,10 @@ class MainWindow(Gtk.Window):
class TextComboBox(Gtk.ComboBox):
def __init__(self):
super(TextComboBox, self).__init__()
- model = ComboBoxStore()
- self.set_model(model)
cell = Gtk.CellRendererText()
self.pack_start(cell, True)
- self.set_properties(cell, 'text', model.NAME_COLUMN)
+ #After reading pygi demos, found that set_properties doesn't work
+ self.add_attribute(cell, 'text', ComboBoxStore.NAME_COLUMN)
def update(self, operation):
registry = Grl.PluginRegistry.get_default()
@@ -186,6 +188,7 @@ class TextComboBox(Gtk.ComboBox):
model = ComboBoxStore()
self.set_model(model)
model.add(sources)
+ self.set_active(0)
class SearchComboBox(TextComboBox):
def __init__(self):
@@ -208,13 +211,13 @@ class ComboBoxStore(Gtk.ListStore):
def __init__(self):
super(ComboBoxStore, self).__init__(str,
- object)
+ 'GObject')
def add(self, sources):
self.clear()
for source in sources:
row = {self.NAME_COLUMN: source.get_name(),
- self.SOURCE_COLUMN: None,
+ self.SOURCE_COLUMN: source,
}
self.append(row.values())
@@ -253,7 +256,7 @@ class BrowserListStore(Gtk.ListStore):
OBJECT_TYPE_MEDIA = 2
def __init__(self):
- super(BrowserListStore, self).__init__(object,
+ super(BrowserListStore, self).__init__('GObject',
object,
int,
str,
@@ -262,7 +265,7 @@ class BrowserListStore(Gtk.ListStore):
def add(self, sources):
self.clear()
for source in sources:
- row = {self.SOURCE_COLUMN: None, #source,
+ row = {self.SOURCE_COLUMN: source,
self.CONTENT_COLUMN: None,
self.TYPE_COLUMN: self.OBJECT_TYPE_SOURCE,
self.NAME_COLUMN: source.get_name(),
--
1.7.0.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]