From e070e77c148aba1e00d2fc5fa4ad507e4cd8f7d3 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 15 Jun 2006 17:17:42 +0000 Subject: [PATCH] In .: * src/DisplayTabs/Makefile.am (pkgdata_PYTHON): Ship new file. * src/DisplayTabs/__init__.py: Import new module. * src/DisplayTabs/_TextTab.py: Add new module. * src/Editors/_EditSourceRef.py (_setup_fields): Remove Text tab; (_create_tabbed_pages): Add Text tab. * src/glade/gramps.glade (source_ref_edit): Remove Text tab. In po: 2006-06-15 Alex Roitman * POTFILES.in: Add new file. svn: r6894 --- gramps2/ChangeLog | 6 ++ gramps2/po/ChangeLog | 3 + gramps2/po/POTFILES.in | 1 + gramps2/src/DisplayTabs/Makefile.am | 1 + gramps2/src/DisplayTabs/_TextTab.py | 108 ++++++++++++++++++++++++++ gramps2/src/DisplayTabs/__init__.py | 1 + gramps2/src/Editors/_EditSourceRef.py | 12 ++- gramps2/src/glade/gramps.glade | 64 +-------------- 8 files changed, 128 insertions(+), 68 deletions(-) create mode 100644 gramps2/src/DisplayTabs/_TextTab.py diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 4ff3ad93f..c85ae179d 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,10 @@ 2006-06-15 Alex Roitman + * src/DisplayTabs/Makefile.am (pkgdata_PYTHON): Ship new file. + * src/DisplayTabs/__init__.py: Import new module. + * src/DisplayTabs/_TextTab.py: Add new module. + * src/Editors/_EditSourceRef.py (_setup_fields): Remove Text tab; + (_create_tabbed_pages): Add Text tab. + * src/glade/gramps.glade (source_ref_edit): Remove Text tab. * src/GrampsDb/_WriteGedcom.py (write_photo): Typo. * src/Exporter.py (build_options): Correctly shift all pages. diff --git a/gramps2/po/ChangeLog b/gramps2/po/ChangeLog index 7db28d37d..9a91d3268 100644 --- a/gramps2/po/ChangeLog +++ b/gramps2/po/ChangeLog @@ -1,3 +1,6 @@ +2006-06-15 Alex Roitman + * POTFILES.in: Add new file. + 2006-06-11 Alex Roitman * POTFILES.in: Remove plugin that is not shipped. * gramps.pot: Update. diff --git a/gramps2/po/POTFILES.in b/gramps2/po/POTFILES.in index e450ec0a7..11a417946 100644 --- a/gramps2/po/POTFILES.in +++ b/gramps2/po/POTFILES.in @@ -130,6 +130,7 @@ src/DisplayTabs/_MediaBackRefList.py src/DisplayTabs/_NameEmbedList.py src/DisplayTabs/_NameModel.py src/DisplayTabs/_NoteTab.py +src/DisplayTabs/_TextTab.py src/DisplayTabs/_PersonEventEmbedList.py src/DisplayTabs/_PersonRefEmbedList.py src/DisplayTabs/_PersonRefModel.py diff --git a/gramps2/src/DisplayTabs/Makefile.am b/gramps2/src/DisplayTabs/Makefile.am index e7688fc05..5d0abce7b 100644 --- a/gramps2/src/DisplayTabs/Makefile.am +++ b/gramps2/src/DisplayTabs/Makefile.am @@ -29,6 +29,7 @@ pkgdata_PYTHON = \ _NameEmbedList.py \ _NameModel.py \ _NoteTab.py \ + _TextTab.py \ _PersonEventEmbedList.py \ _PersonRefEmbedList.py \ _PersonRefModel.py \ diff --git a/gramps2/src/DisplayTabs/_TextTab.py b/gramps2/src/DisplayTabs/_TextTab.py new file mode 100644 index 000000000..9fbaa3af8 --- /dev/null +++ b/gramps2/src/DisplayTabs/_TextTab.py @@ -0,0 +1,108 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-2006 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +#------------------------------------------------------------------------- +# +# Python classes +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GTK libraries +# +#------------------------------------------------------------------------- +import gtk + +#------------------------------------------------------------------------- +# +# GRAMPS classes +# +#------------------------------------------------------------------------- +import Spell +from _GrampsTab import GrampsTab + +#------------------------------------------------------------------------- +# +# NoteTab +# +#------------------------------------------------------------------------- +class TextTab(GrampsTab): + + def __init__(self, dbstate, uistate, track, obj, title=_('Text')): + self.obj = obj + GrampsTab.__init__(self, dbstate, uistate, track, title) + self.show_all() + + def _update_label(self, *obj): + cc = self.buf.get_char_count() + if cc == 0 and not self.empty: + self.empty = True + self._set_label() + elif cc != 0 and self.empty: + self.empty = False + self._set_label() + + def is_empty(self): + """ + Indicates if the tab contains any data. This is used to determine + how the label should be displayed. + """ + return self.buf.get_char_count() == 0 + + def build_interface(self): + vbox = gtk.VBox() + + self.text_view = gtk.TextView() + self.spellcheck = Spell.Spell(self.text_view) + + scroll = gtk.ScrolledWindow() + scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + scroll.add_with_viewport(self.text_view) + scroll.connect('focus-out-event', self.update) + + vbox.pack_start(scroll, True) + vbox.set_spacing(6) + vbox.set_border_width(6) + + self.pack_start(vbox, True) + self.buf = self.text_view.get_buffer() + if self.obj.get_text(): + self.empty = False + self.buf.insert_at_cursor(self.obj.get_text()) + else: + self.empty = True + + self.buf.connect('changed', self.update) + self.rebuild() + + def update(self, obj): + start = self.buf.get_start_iter() + stop = self.buf.get_end_iter() + text = unicode(self.buf.get_text(start, stop)) + self.obj.set_text(text) + self._update_label(obj) + return False + + def rebuild(self): + self._set_label() diff --git a/gramps2/src/DisplayTabs/__init__.py b/gramps2/src/DisplayTabs/__init__.py index 76b88c837..036207318 100644 --- a/gramps2/src/DisplayTabs/__init__.py +++ b/gramps2/src/DisplayTabs/__init__.py @@ -48,6 +48,7 @@ from _LocationEmbedList import LocationEmbedList from _MediaBackRefList import MediaBackRefList from _NameEmbedList import NameEmbedList from _NoteTab import NoteTab +from _TextTab import TextTab from _PersonEventEmbedList import PersonEventEmbedList from _PersonRefEmbedList import PersonRefEmbedList from _PlaceBackRefList import PlaceBackRefList diff --git a/gramps2/src/Editors/_EditSourceRef.py b/gramps2/src/Editors/_EditSourceRef.py index e4c65a49a..446622722 100644 --- a/gramps2/src/Editors/_EditSourceRef.py +++ b/gramps2/src/Editors/_EditSourceRef.py @@ -49,7 +49,7 @@ import const import RelLib from DisplayTabs import \ - NoteTab,GalleryTab,SourceBackRefList,DataEmbedList,RepoEmbedList + NoteTab,TextTab,GalleryTab,SourceBackRefList,DataEmbedList,RepoEmbedList from GrampsWidgets import * from _EditReference import EditReference @@ -107,10 +107,6 @@ class EditSourceRef(EditReference): self.top.get_widget('pub_info'), self.source.set_publication_info, self.source.get_publication_info,False) - self.text_data = MonitoredText( - self.top.get_widget('text'), self.source_ref.set_text, - self.source_ref.get_text,False) - self.type_mon = MonitoredMenu( self.top.get_widget('confidence'), self.source_ref.set_confidence_level, @@ -121,7 +117,6 @@ class EditSourceRef(EditReference): (_('High'), RelLib.SourceRef.CONF_HIGH), (_('Very High'), RelLib.SourceRef.CONF_VERY_HIGH)]) - self.date = MonitoredDate( self.top.get_widget("date"), self.top.get_widget("date_stat"), @@ -167,6 +162,10 @@ class EditSourceRef(EditReference): self.enable_warnbox )) + self.text_tab = self._add_tab( + notebook_ref, + TextTab(self.dbstate, self.uistate, self.track,self.source_ref)) + self.comment_tab = self._add_tab( notebook_ref, NoteTab(self.dbstate, self.uistate, self.track, @@ -195,4 +194,3 @@ class EditSourceRef(EditReference): self.update(self.source_ref,self.source) self.close() - diff --git a/gramps2/src/glade/gramps.glade b/gramps2/src/glade/gramps.glade index 7e5c351ba..33e68e21b 100644 --- a/gramps2/src/glade/gramps.glade +++ b/gramps2/src/glade/gramps.glade @@ -13625,67 +13625,9 @@ Very High True - General + <b>General</b> False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_NONE - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - False - True - - - - - - True - Text - False - False + True GTK_JUSTIFY_LEFT False False @@ -14078,7 +14020,7 @@ Very High True - General + <b>General</b> False True GTK_JUSTIFY_CENTER