From 22bf1fe929e9997f13d0110cba1347d00fdd21cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Fri, 5 Mar 2010 02:42:46 +0100 Subject: Added combo box for selecting the search type to main window --- portato/gui/templates/MainWindow.ui | 16 +++++++++++++--- portato/gui/windows/main.py | 30 +++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 4 deletions(-) (limited to 'portato/gui') diff --git a/portato/gui/templates/MainWindow.ui b/portato/gui/templates/MainWindow.ui index 8e8c3b4..d8b224c 100644 --- a/portato/gui/templates/MainWindow.ui +++ b/portato/gui/templates/MainWindow.ui @@ -29,6 +29,16 @@ True 3 + + + True + + + + False + 0 + + True @@ -38,7 +48,7 @@ 5 - 0 + 1 @@ -54,7 +64,7 @@ False 5 - 1 + 2 @@ -69,7 +79,7 @@ False 5 - 2 + 3 diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index 5a149f8..4a9971f 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -496,6 +496,8 @@ class MainWindow (Window): # search entry self.searchEntry = self.tree.get_widget("searchEntry") + self.typeCombo = self.tree.get_widget("typeCombo") + self.build_type_combo() # queue list self.queueOneshot = self.tree.get_widget("oneshotCB") @@ -871,6 +873,26 @@ class MainWindow (Window): else: # no selCatName -> so no category selected --> ignore debug("No category selected --> should be no harm.") + def build_type_combo (self): + model = gtk.ListStore(int, str) + for k,v in self.db.TYPES.iteritems(): + model.append((k,v)) + + self.typeCombo.set_model(model) + cell = gtk.CellRendererText() + self.typeCombo.pack_start(cell) + self.typeCombo.set_attributes(cell, text = 1) + + + for i, (k, v) in enumerate(model): + if k == self.db.type: break + + self.typeCombo.set_active(i) + + types = self.db.search_types() + if types == 1 or types % 2 == 0: + self.typeCombo.set_sensitive(False) + def load_session(self, sessionEx = None, defaults_only = False): """ Loads the session data. @@ -1562,7 +1584,13 @@ class MainWindow (Window): return False # not again ;) - gobject.timeout_add(100, __update) + gobject.timeout_add(200, __update) + + def cb_type_combo_changed (self, *args): + model = self.typeCombo.get_model() + active = self.typeCombo.get_active() + + self.db.type = model[active][0] def cb_delete_search_clicked (self, *args): self.searchEntry.set_text("") -- cgit v1.2.3