* src/gramps.glade: Add LED button widgets to the sourceref editor.

* src/Sources.py (SourceEditor.__init__): Use DateEdit to support
LED functionality; (SourceEditor.on_sourceok_clicked): Set date using
date object, instead of parsing text.


svn: r3561
This commit is contained in:
Alex Roitman 2004-09-20 23:26:41 +00:00
parent 1487014730
commit 446449de7d
3 changed files with 236 additions and 190 deletions

View File

@ -5,6 +5,11 @@
(on_sourceok_clicked): Properly parse date for sourceref
(closes # 1031156).
* src/gramps.glade: Add LED button widgets to the sourceref editor.
* src/Sources.py (SourceEditor.__init__): Use DateEdit to support
LED functionality; (SourceEditor.on_sourceok_clicked): Set date using
date object, instead of parsing text.
2004-09-19 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Date.py (is_equal): Add method -- needed to compare dates
for being identical, since __cmp__ only compares the sorting value

View File

@ -20,6 +20,13 @@
# $Id$
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
@ -38,8 +45,9 @@ import gnome
import const
import Utils
import RelLib
import Date
import DateEdit
import DateHandler
from gettext import gettext as _
#-------------------------------------------------------------------------
#
@ -335,13 +343,23 @@ class SourceEditor:
self.author_field = self.get_widget("sauthor")
self.pub_field = self.get_widget("spubinfo")
self.dd = DateHandler.create_display()
self.date_entry_field = self.get_widget("sdate")
if self.source_ref:
self.active_source = self.db.get_source_from_handle(self.source_ref.get_base_handle())
self.date_obj = self.source_ref.get_date()
self.date_entry_field.set_text(self.dd.display(self.date_obj))
else:
self.date_obj = Date.Date()
self.active_source = None
self.dd = DateHandler.create_display()
self.dp = DateHandler.create_parser()
date_stat = self.get_widget("date_stat")
self.date_check = DateEdit.DateEdit(self.date_obj,
self.date_entry_field,
date_stat,
self.sourceDisplay)
self.draw(self.active_source)
self.set_button()
@ -411,9 +429,6 @@ class SourceEditor:
if self.source_ref:
spage = self.get_widget("spage")
spage.get_buffer().set_text(self.source_ref.get_page())
date = self.source_ref.get_date()
if date:
self.get_widget("sdate").set_text(self.dd.display(date))
text = self.get_widget("stext")
text.get_buffer().set_text(self.source_ref.get_text())
@ -461,7 +476,6 @@ class SourceEditor:
if self.active_source != self.db.get_source_from_handle(self.source_ref.get_base_handle()):
self.source_ref.set_base_handle(self.active_source.get_handle())
date = unicode(self.get_widget("sdate").get_text())
conf = self.get_widget("conf").get_menu().get_active().get_data('a')
buf = self.get_widget("scomment").get_buffer()
@ -477,7 +491,7 @@ class SourceEditor:
buf.get_end_iter(),gtk.FALSE))
self.source_ref.set_page(page)
self.source_ref.get_date().copy(self.dp.parse(date))
self.source_ref.set_date(self.date_obj)
self.source_ref.set_text(text)
self.source_ref.set_comments(comments)
self.source_ref.set_confidence_level(conf)

View File

@ -19569,7 +19569,7 @@ Other</property>
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="n_rows">11</property>
<property name="n_columns">4</property>
<property name="n_columns">5</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
@ -19849,186 +19849,6 @@ Other</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button143">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Creates a new source</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_New...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_add_src_clicked" last_modification_time="Sun, 23 Mar 2003 23:22:04 GMT"/>
</widget>
<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="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkOptionMenu" id="conf">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="history">0</property>
<child internal-child="menu">
<widget class="GtkMenu" id="convertwidget8">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="convertwidget9">
<property name="visible">True</property>
<property name="label" translatable="yes">Very Low</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="convertwidget10">
<property name="visible">True</property>
<property name="label" translatable="yes">Low</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="convertwidget11">
<property name="visible">True</property>
<property name="label" translatable="yes">Normal</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="convertwidget12">
<property name="visible">True</property>
<property name="label" translatable="yes">High</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="convertwidget13">
<property name="visible">True</property>
<property name="label" translatable="yes">Very High</property>
<property name="use_underline">True</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="sdate">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow21">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="stext">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow20">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="scomment">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="sauthor">
<property name="visible">True</property>
@ -20125,6 +19945,27 @@ Other</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="sdate">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow31">
<property name="visible">True</property>
@ -20156,13 +19997,199 @@ Other</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
<property name="right_attach">5</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkOptionMenu" id="conf">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="history">0</property>
<child internal-child="menu">
<widget class="GtkMenu" id="convertwidget8">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="convertwidget9">
<property name="visible">True</property>
<property name="label" translatable="yes">Very Low</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="convertwidget10">
<property name="visible">True</property>
<property name="label" translatable="yes">Low</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="convertwidget11">
<property name="visible">True</property>
<property name="label" translatable="yes">Normal</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="convertwidget12">
<property name="visible">True</property>
<property name="label" translatable="yes">High</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="convertwidget13">
<property name="visible">True</property>
<property name="label" translatable="yes">Very High</property>
<property name="use_underline">True</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">5</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow21">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="stext">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">5</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow20">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="scomment">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">5</property>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button143">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Creates a new source</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_New...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_add_src_clicked" last_modification_time="Sun, 23 Mar 2003 23:22:04 GMT"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">5</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="date_stat">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="date_stat_child">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>