summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
Diffstat (limited to 'portato')
-rw-r--r--portato/db/sql.py2
-rw-r--r--portato/gui/templates/MainWindow.ui16
-rw-r--r--portato/gui/windows/main.py30
3 files changed, 43 insertions, 5 deletions
diff --git a/portato/db/sql.py b/portato/db/sql.py
index 02ce172..f6e24f0 100644
--- a/portato/db/sql.py
+++ b/portato/db/sql.py
@@ -267,7 +267,7 @@ class SQLDatabase (Database):
if self._type & self.SEARCH_DESCRIPTION:
r = "descr LIKE '%%%(restrict)s%%'" % {"restrict":restrict}
- if not rest:
+ if rest:
rest = "(%s OR %s)" % (r, rest)
else:
rest = r
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
@@ -30,6 +30,16 @@
<property name="visible">True</property>
<property name="border_width">3</property>
<child>
+ <object class="GtkComboBox" id="typeCombo">
+ <property name="visible">True</property>
+ <signal name="changed" handler="cb_type_combo_changed"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkEntry" id="searchEntry">
<property name="visible">True</property>
<signal name="changed" handler="cb_search_changed"/>
@@ -38,7 +48,7 @@
</object>
<packing>
<property name="padding">5</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -54,7 +64,7 @@
<packing>
<property name="expand">False</property>
<property name="padding">5</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -69,7 +79,7 @@
<packing>
<property name="expand">False</property>
<property name="padding">5</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
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("")