Add source fields to citation editor
This commit is contained in:
parent
cdff0daff1
commit
447113bf9f
@ -174,7 +174,8 @@ class EditCitation(EditPrimary):
|
||||
self.glade.get_object("source"),
|
||||
self.obj.set_reference_handle,
|
||||
self.obj.get_reference_handle,
|
||||
self.add_del_btn, self.share_btn)
|
||||
self.add_del_btn, self.share_btn,
|
||||
callback=self.source_changed)
|
||||
|
||||
self.date = MonitoredDate(
|
||||
self.glade.get_object("date_entry"),
|
||||
@ -249,6 +250,21 @@ class EditCitation(EditPrimary):
|
||||
notebook.show_all()
|
||||
self.glade.get_object('vbox').pack_start(notebook, True, True, 0)
|
||||
|
||||
def source_changed(self):
|
||||
handle = self.obj.get_reference_handle()
|
||||
if handle:
|
||||
source = self.db.get_source_from_handle(handle)
|
||||
author = source.get_author()
|
||||
pub_info = source.get_publication_info()
|
||||
abbrev = source.get_abbreviation()
|
||||
else:
|
||||
author = ''
|
||||
pub_info = ''
|
||||
abbrev = ''
|
||||
self.glade.get_object("author").set_text(author)
|
||||
self.glade.get_object("pub_info").set_text(pub_info)
|
||||
self.glade.get_object("abbrev").set_text(abbrev)
|
||||
|
||||
def build_menu_names(self, source):
|
||||
"""
|
||||
Provide the information needed by the base class to define the
|
||||
|
@ -78,7 +78,7 @@ class ObjEntry(object):
|
||||
DEL_STR = ""
|
||||
|
||||
def __init__(self, dbstate, uistate, track, label, set_val,
|
||||
get_val, add_edt, share):
|
||||
get_val, add_edt, share, callback=None):
|
||||
"""Pass the dbstate and uistate and present track.
|
||||
label is a Gtk.Label that shows the persent value
|
||||
set_val is function that is called when handle changes, use it
|
||||
@ -98,6 +98,7 @@ class ObjEntry(object):
|
||||
self.set_val = set_val
|
||||
self.uistate = uistate
|
||||
self.track = track
|
||||
self.callback = callback
|
||||
|
||||
#connect drag and drop
|
||||
self._init_dnd()
|
||||
@ -141,6 +142,8 @@ class ObjEntry(object):
|
||||
else:
|
||||
self.label.set_text(name)
|
||||
self.label.set_ellipsize(Pango.EllipsizeMode.END)
|
||||
if self.callback:
|
||||
self.callback()
|
||||
|
||||
def _init_dnd(self):
|
||||
"""inheriting objects must set this
|
||||
@ -167,6 +170,8 @@ class ObjEntry(object):
|
||||
def after_edit(self, obj):
|
||||
name = self.get_label(obj)
|
||||
self.label.set_text(name)
|
||||
if self.callback:
|
||||
self.callback()
|
||||
|
||||
def add_edt_clicked(self, obj):
|
||||
""" if value, edit, if no value, call editor on new object
|
||||
@ -198,6 +203,8 @@ class ObjEntry(object):
|
||||
self.set_val(data.handle)
|
||||
self.label.set_text(self.get_label(data))
|
||||
self.set_button(True)
|
||||
if self.callback:
|
||||
self.callback()
|
||||
|
||||
def share_clicked(self, obj):
|
||||
""" if value, delete connect, in no value, select existing object
|
||||
@ -207,6 +214,8 @@ class ObjEntry(object):
|
||||
self.label.set_text(self.EMPTY_TEXT)
|
||||
self.label.set_use_markup(True)
|
||||
self.set_button(False)
|
||||
if self.callback:
|
||||
self.callback()
|
||||
else:
|
||||
select = self.call_selector()
|
||||
obj = select.run()
|
||||
@ -315,9 +324,9 @@ class SourceEntry(ObjEntry):
|
||||
DEL_STR = _('Remove source')
|
||||
|
||||
def __init__(self, dbstate, uistate, track, label, set_val,
|
||||
get_val, add_edt, share):
|
||||
get_val, add_edt, share, callback):
|
||||
ObjEntry.__init__(self, dbstate, uistate, track, label, set_val,
|
||||
get_val, add_edt, share)
|
||||
get_val, add_edt, share, callback)
|
||||
|
||||
def _init_dnd(self):
|
||||
"""connect drag and drop of sources
|
||||
|
@ -79,13 +79,28 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">12</property>
|
||||
<property name="n_rows">5</property>
|
||||
<property name="n_rows">8</property>
|
||||
<property name="n_columns">4</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label612">
|
||||
<property name="visible">True</property>
|
||||
@ -97,8 +112,8 @@
|
||||
<property name="mnemonic_widget">date_entry</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
@ -133,8 +148,8 @@
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
<property name="right_attach">4</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
@ -151,8 +166,8 @@
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="top_attach">5</property>
|
||||
<property name="bottom_attach">6</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
@ -167,8 +182,8 @@
|
||||
<property name="mnemonic_widget">volume</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="top_attach">5</property>
|
||||
<property name="bottom_attach">6</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
@ -183,8 +198,8 @@
|
||||
<property name="justify">center</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="top_attach">6</property>
|
||||
<property name="bottom_attach">7</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
@ -201,8 +216,8 @@
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
@ -268,8 +283,8 @@ Very High =Direct and primary evidence used, or by dominance of the evidence </p
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="top_attach">6</property>
|
||||
<property name="bottom_attach">7</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
@ -365,15 +380,12 @@ Very High =Direct and primary evidence used, or by dominance of the evidence </p
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
<property name="right_attach">4</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="top_attach">5</property>
|
||||
<property name="bottom_attach">6</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
@ -382,8 +394,8 @@ Very High =Direct and primary evidence used, or by dominance of the evidence </p
|
||||
<property name="label" translatable="yes">Tags:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="top_attach">7</property>
|
||||
<property name="bottom_attach">8</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
@ -398,8 +410,8 @@ Very High =Direct and primary evidence used, or by dominance of the evidence </p
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="top_attach">7</property>
|
||||
<property name="bottom_attach">8</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
@ -420,6 +432,93 @@ Very High =Direct and primary evidence used, or by dominance of the evidence </p
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Author:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Publication Info.:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label6">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Abbreviation:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="author">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="pub_info">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="abbrev">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user