Skip to content

Commit

Permalink
very minimal presenter, and it still does not save anything.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrasca committed Jan 28, 2016
1 parent c24d733 commit a40c370
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 127 deletions.
290 changes: 163 additions & 127 deletions bauble/plugins/garden/acc_editor.glade
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,123 @@
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="acc_codes_dialog">
<property name="width_request">360</property>
<property name="height_request">240</property>
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Accession Code Formats</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button2">
<property name="label">gtk-cancel</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="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-ok</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="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">1</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="height_request">180</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">acc_codes_liststore</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title" translatable="yes">item</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="title" translatable="yes">accession code format</property>
<child>
<object class="GtkCellRendererText" id="acc_cf_renderer">
<property name="editable">True</property>
<signal name="edited" handler="on_acc_cf_renderer_edited" swapped="no"/>
</object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button2</action-widget>
<action-widget response="0">button1</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="acc_codes_liststore">
<columns>
<!-- column-name index -->
<column type="gint"/>
<!-- column-name content -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="accession_dialog">
<property name="can_focus">False</property>
<property name="title">Accession Editor</property>
Expand Down Expand Up @@ -333,7 +450,7 @@
<object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-add</property>
<property name="stock">gtk-new</property>
</object>
<packing>
<property name="expand">False</property>
Expand Down Expand Up @@ -696,21 +813,53 @@
</packing>
</child>
<child>
<object class="GtkComboBoxEntry" id="acc_code_format_comboentry">
<object class="GtkHBox" id="hbox29x">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">acc_code_format_liststore</property>
<property name="text_column">0</property>
<signal name="changed" handler="on_acc_code_format_comboentry_changed" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxentry-entry10">
<child>
<object class="GtkComboBoxEntry" id="acc_code_format_comboentry">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="invisible_char">•</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
<property name="model">acc_code_format_liststore</property>
<property name="text_column">0</property>
<signal name="changed" handler="on_acc_code_format_comboentry_changed" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxentry-entry10">
<property name="can_focus">False</property>
<property name="invisible_char">•</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="acc_code_format_edit_btn">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="on_acc_code_format_edit_btn_clicked" swapped="no"/>
<child>
<object class="GtkImage" id="image15">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-edit</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
Expand Down Expand Up @@ -830,7 +979,7 @@
<object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-add</property>
<property name="stock">gtk-new</property>
</object>
<packing>
<property name="expand">False</property>
Expand Down Expand Up @@ -927,7 +1076,7 @@
<object class="GtkImage" id="image12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-add</property>
<property name="stock">gtk-new</property>
</object>
<packing>
<property name="expand">False</property>
Expand Down Expand Up @@ -2835,119 +2984,6 @@
<placeholder/>
</child>
</object>
<object class="GtkDialog" id="dialog1">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Accession Code Formats</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button2">
<property name="label">gtk-cancel</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="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-ok</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="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">1</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">liststore1</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title" translatable="yes">item</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="title" translatable="yes">accession code format</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2">
<signal name="edited" handler="on_cellrenderertext2_edited" swapped="no"/>
</object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button2</action-widget>
<action-widget response="0">button1</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
<!-- column-name gchararray2 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="source_details_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
Expand Down
31 changes: 31 additions & 0 deletions bauble/plugins/garden/accession.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,37 @@ def on_acc_code_format_comboentry_changed(self, widget, *args):
code = Accession.get_next_code(code_format)
self.view.widget_set_value('acc_code_entry', code)

def on_acc_code_format_edit_btn_clicked(self, widget, *args):
view = editor.GenericEditorView(
os.path.join(paths.lib_dir(), 'plugins', 'garden',
'acc_editor.glade'),
root_widget_name='acc_codes_dialog')
ls = view.widgets.acc_codes_liststore
ls.clear()
query = self.session.\
query(meta.BaubleMeta).\
filter(meta.BaubleMeta.name.like(u'acidf_%')).\
order_by(meta.BaubleMeta.name)
for i, row in enumerate(query):
ls.append([i+1, row.value])
ls.append([len(ls)+1, ''])

class Presenter(editor.GenericEditorPresenter):
def on_acc_cf_renderer_edited(self, widget, iter, value):
i = ls.get_iter_from_string(str(iter))
ls.set_value(i, 1, value)
if ls.iter_next(i) is None:
if value:
ls.append([len(ls)+1, ''])
elif value == '':
ls.remove(i)
while i:
ls.set_value(i, 0, ls.get_value(i, 0)-1)
i = ls.iter_next(i)

presenter = Presenter(ls, view)
presenter.start() # does not save them yet

def refresh_id_qual_rank_combo(self):
"""
Populate the id_qual_rank_combo with the parts of the species string
Expand Down

1 comment on commit a40c370

@mfrasca
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.