Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
stored queries go in the database, into the BaubleMeta table.
Browse files Browse the repository at this point in the history
they are encoded as stqr_xx, where xx is a number from 00 to 10.
their value is split on ':' into 3 fields, namely:
1) the text that goes on the button - and please keep it short!
2) the tooltip.
3) the query.
there still is no graphic interface to write the queries to the database.
  • Loading branch information
mfrasca committed Jan 1, 2016
1 parent db3d289 commit bd75645
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 10 deletions.
31 changes: 31 additions & 0 deletions bauble/plugins/plants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
logger = logging.getLogger(__name__)
#logger.setLevel(logging.DEBUG)

from functools import partial

import bauble
import bauble.db as db
import bauble.paths as paths
Expand Down Expand Up @@ -140,6 +142,11 @@ def __init__(self):
lambda *a: bauble.gui.send_command(
'location like %'))

for i in range(1, 11):
wname = "stqr_%02d_button" % i
widget = getattr(self.widgets, wname)
widget.connect('clicked', partial(self.on_sqb_clicked, i))

def update(self):
'''
'''
Expand Down Expand Up @@ -199,8 +206,32 @@ def update(self):
self.widgets.splash_nfamtot.set_text(str(famtot))
self.widgets.splash_ngentot.set_text(str(gentot))
self.widgets.splash_nspctot.set_text(str(spctot))

q = ssn.query(bauble.meta.BaubleMeta)
q = q.filter(bauble.meta.BaubleMeta.name.startswith(u'stqr_'))
name_tooltip_query = dict(
(int(i.name[5:]), (i.value.split(':', 2)))
for i in q.all())
ssn.close()

for i in range(1, 11):
wname = "stqr_%02d_button" % i
widget = getattr(self.widgets, wname)
name, tooltip, query = name_tooltip_query.get(
i, (_('<empty>'), '', ''))
widget.set_label(name)
widget.set_tooltip_text(tooltip)

self.name_tooltip_query = name_tooltip_query

def on_sqb_clicked(self, btn_no, *args):
try:
query = self.name_tooltip_query[btn_no][2]
bauble.gui.widgets.main_comboentry.child.set_text(query)
bauble.gui.widgets.go_button.emit("clicked")
except:
pass


class PlantsPlugin(pluginmgr.Plugin):
tools = [TaxonomyCheckTool]
Expand Down
30 changes: 20 additions & 10 deletions bauble/plugins/plants/infoboxes.glade
Original file line number Diff line number Diff line change
Expand Up @@ -1229,13 +1229,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button1">
<object class="GtkButton" id="stqr_01_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
Expand All @@ -1245,13 +1246,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button2">
<object class="GtkButton" id="stqr_03_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
Expand All @@ -1261,13 +1263,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button3">
<object class="GtkButton" id="stqr_05_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
Expand All @@ -1277,13 +1280,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button4">
<object class="GtkButton" id="stqr_07_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
Expand All @@ -1293,13 +1297,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button5">
<object class="GtkButton" id="stqr_09_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
Expand All @@ -1309,13 +1314,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button6">
<object class="GtkButton" id="stqr_02_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
Expand All @@ -1325,13 +1331,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button7">
<object class="GtkButton" id="stqr_04_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
Expand All @@ -1341,13 +1348,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button8">
<object class="GtkButton" id="stqr_06_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
Expand All @@ -1357,13 +1365,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button9">
<object class="GtkButton" id="stqr_08_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
Expand All @@ -1373,13 +1382,14 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button10">
<object class="GtkButton" id="stqr_10_button">
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_sqb_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
Expand Down

0 comments on commit bd75645

Please sign in to comment.