2008-02-08 Raphael Ackermann <raphael.ackermann@gmail.com>

* src/Editors/_EditEvent.py:
    * src/Editors/_EditFamily.py:
    * src/Editors/_EditMedia.py:
    * src/Editors/_EditNote.py:
    * src/Editors/_EditPlace.py:
    * src/Editors/_EditPrimary.py:
    * src/Editors/_EditRepository.py:
    * src/Editors/_EditSource.py:
    pylint fixes

svn: r10005
This commit is contained in:
Raphael Ackermann 2008-02-08 15:29:28 +00:00
parent 6776b91ca5
commit 04e16919a1
9 changed files with 259 additions and 224 deletions

View File

@ -1,4 +1,15 @@
2008-02-07 Raphael Ackermann <raphael.ackermann@gmail.com>
2008-02-08 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/Editors/_EditEvent.py:
* src/Editors/_EditFamily.py:
* src/Editors/_EditMedia.py:
* src/Editors/_EditNote.py:
* src/Editors/_EditPlace.py:
* src/Editors/_EditPrimary.py:
* src/Editors/_EditRepository.py:
* src/Editors/_EditSource.py:
pylint fixes
2008-02-08 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/Editors/_EditEvent.py:
* src/Editors/_EditFamily.py:
* src/Editors/_EditMedia.py:

View File

@ -33,6 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import gtk
from gtk import glade
#-------------------------------------------------------------------------
#
@ -43,11 +44,13 @@ import const
import Config
import gen.lib
import GrampsDisplay
from _EditPrimary import EditPrimary
from Editors import EditPrimary
from QuestionDialog import ErrorDialog
from DisplayTabs import SourceEmbedList, NoteTab, GalleryTab, EventBackRefList, AttrEmbedList
from GrampsWidgets import *
from DisplayTabs import (SourceEmbedList, NoteTab, GalleryTab,
EventBackRefList, AttrEmbedList)
from GrampsWidgets import (MonitoredEntry, PlaceEntry, PrivacyButton,
MonitoredDataType, MonitoredDate)
#-------------------------------------------------------------------------
#
@ -90,7 +93,7 @@ class EditEvent(EditPrimary):
self.dbstate.db.get_family_event_types()
def _local_init(self):
self.top = gtk.glade.XML(const.GLADE_FILE, "event_edit","gramps")
self.top = glade.XML(const.GLADE_FILE, "event_edit","gramps")
self.set_window(self.top.get_widget("event_edit"), None,
self.get_menu_title())

View File

@ -26,6 +26,9 @@
#
#-------------------------------------------------------------------------
from bsddb import db as bsddb_db
from gettext import gettext as _
from DdTargets import DdTargets
import pickle
#-------------------------------------------------------------------------
#
# enable logging for error handling
@ -39,7 +42,9 @@ log = logging.getLogger(".")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gtk import glade
from gtk import gdk
#-------------------------------------------------------------------------
#
@ -47,26 +52,27 @@ from gtk import glade
#
#-------------------------------------------------------------------------
import Utils
import const
import Config
from BasicUtils import name_displayer
import gen.lib
import Errors
from _EditPrimary import EditPrimary
from Editors import EditPrimary
from ReportBase import ReportUtils
from DisplayTabs import \
EmbeddedList,EventEmbedList,SourceEmbedList,FamilyAttrEmbedList,\
NoteTab,GalleryTab,FamilyLdsEmbedList, ChildModel
from GrampsWidgets import *
from DisplayTabs import (EmbeddedList, EventEmbedList, SourceEmbedList,
FamilyAttrEmbedList, NoteTab, GalleryTab,
FamilyLdsEmbedList, ChildModel)
from GrampsWidgets import (PrivacyButton, MonitoredEntry, MonitoredDataType,
IconButton, LinkBox, BasicLabel)
from ReportBase import CATEGORY_QR_FAMILY
import QuestionDialog
#from ObjectSelector import PersonSelector,PersonFilterSpec
from Selectors import selector_factory
SelectPerson = selector_factory('Person')
_RETURN = gtk.gdk.keyval_from_name("Return")
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
_RETURN = gdk.keyval_from_name("Return")
_KP_ENTER = gdk.keyval_from_name("KP_Enter")
class ChildEmbedList(EmbeddedList):
"""
@ -187,7 +193,8 @@ class ChildEmbedList(EmbeddedList):
return self.family
def column_order(self):
return [(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(0,8),(0,9)]
return [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
(0, 8), (0, 9)]
def add_button_clicked(self, obj):
from Editors import EditPerson
@ -289,16 +296,16 @@ class ChildEmbedList(EmbeddedList):
if handle:
pos = self.find_index(handle)
if pos > 0 :
self._move_up(pos,self.family.get_child_ref_list()[pos]
,selmethod=self.family.get_child_ref_list)
self._move_up(pos,self.family.get_child_ref_list()[pos],
selmethod=self.family.get_child_ref_list)
def down_button_clicked(self, obj):
ref = self.get_selected()
if ref:
pos = self.find_index(ref)
if pos >=0 and pos < len(self.family.get_child_ref_list())-1:
self._move_down(pos,self.family.get_child_ref_list()[pos]
,selmethod=self.family.get_child_ref_list)
self._move_down(pos,self.family.get_child_ref_list()[pos],
selmethod=self.family.get_child_ref_list)
def drag_data_received(self, widget, context, x, y, sel_data, info, time):
@ -579,13 +586,16 @@ class EditFamily(EditPrimary):
notebook,
ChildEmbedList(self.dbstate,self.uistate, self.track, self.obj))
self.event_embed = EventEmbedList(self.dbstate,self.uistate, self.track,self.obj)
self.event_embed = EventEmbedList(self.dbstate, self.uistate,
self.track,self.obj)
self.event_list = self._add_tab(notebook, self.event_embed)
self.source_embed = SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj)
self.source_embed = SourceEmbedList(self.dbstate, self.uistate,
self.track, self.obj)
self.src_list = self._add_tab(notebook, self.source_embed)
self.attr_embed = FamilyAttrEmbedList(self.dbstate, self.uistate, self.track,
self.attr_embed = FamilyAttrEmbedList(self.dbstate, self.uistate,
self.track,
self.obj.get_attribute_list())
self.attr_list = self._add_tab(notebook, self.attr_embed)
@ -600,7 +610,8 @@ class EditFamily(EditPrimary):
GalleryTab(self.dbstate, self.uistate, self.track,
self.obj.get_media_list()))
self.lds_embed = FamilyLdsEmbedList(self.dbstate, self.uistate, self.track,
self.lds_embed = FamilyLdsEmbedList(self.dbstate, self.uistate,
self.track,
self.obj.get_lds_ord_list())
self.lds_list = self._add_tab(notebook, self.lds_embed)

View File

@ -27,7 +27,6 @@
#-------------------------------------------------------------------------
from gettext import gettext as _
import os
import sys
#-------------------------------------------------------------------------
#
@ -35,6 +34,7 @@ import sys
#
#-------------------------------------------------------------------------
import gtk
from gtk import glade
#-------------------------------------------------------------------------
#
@ -47,12 +47,11 @@ import gen.lib
import Mime
import ThumbNails
import Utils
from _EditPrimary import EditPrimary
from AddMedia import AddMediaObject
from GrampsWidgets import *
from DisplayTabs import SourceEmbedList,AttrEmbedList,NoteTab,MediaBackRefList
from Editors import EditPrimary
from GrampsWidgets import MonitoredDate, MonitoredEntry, PrivacyButton
from DisplayTabs import (SourceEmbedList, AttrEmbedList, NoteTab,
MediaBackRefList)
from Editors.AddMedia import AddMediaObject
#-------------------------------------------------------------------------
#
# EditMedia
@ -88,7 +87,7 @@ class EditMedia(EditPrimary):
def _local_init(self):
assert(self.obj)
self.glade = gtk.glade.XML(const.GLADE_FILE,
self.glade = glade.XML(const.GLADE_FILE,
"change_global","gramps")
self.set_window(self.glade.get_widget('change_global'),
@ -197,7 +196,6 @@ class EditMedia(EditPrimary):
mime_type = ref_obj.get_mime_type()
app = Mime.get_application(mime_type)
if app:
import Utils
Utils.launch(app[0], ref_obj.get_path())
def select_file(self, val):

View File

@ -27,13 +27,17 @@
#-------------------------------------------------------------------------
from gettext import gettext as _
import logging
log = logging.getLogger(".")
#-------------------------------------------------------------------------
#
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from pango import WEIGHT_BOLD, STYLE_ITALIC, UNDERLINE_SINGLE
from gtk import glade
import gobject
from pango import UNDERLINE_SINGLE
#-------------------------------------------------------------------------
#
@ -45,9 +49,10 @@ import Spell
import Config
import GrampsDisplay
import MarkupText
from _EditPrimary import EditPrimary
from Editors._EditPrimary import EditPrimary
from DisplayTabs import GrampsTab, NoteBackRefList
from GrampsWidgets import *
from GrampsWidgets import (MonitoredDataType, MonitoredCheckbox,
MonitoredEntry, PrivacyButton)
from gen.lib import Note
#-------------------------------------------------------------------------
@ -174,7 +179,7 @@ class EditNote(EditPrimary):
and overridden here.
"""
self.top = gtk.glade.XML(const.GLADE_FILE, "edit_note", "gramps")
self.top = glade.XML(const.GLADE_FILE, "edit_note", "gramps")
win = self.top.get_widget("edit_note")
self.set_window(win, None, self.get_menu_title())
@ -275,22 +280,22 @@ class EditNote(EditPrimary):
</ui>
'''
buffer = MarkupText.MarkupBuffer()
buffer.create_tag('hyperlink',
buffer_ = MarkupText.MarkupBuffer()
buffer_.create_tag('hyperlink',
underline=UNDERLINE_SINGLE,
foreground='blue')
buffer.match_add("(www|ftp)[" + HOSTCHARS + "]*\\.[" + HOSTCHARS +
buffer_.match_add("(www|ftp)[" + HOSTCHARS + "]*\\.[" + HOSTCHARS +
".]+" + "(:[0-9]+)?(" + URLPATH + ")?/?", HTTP)
buffer.match_add("(mailto:)?[a-z0-9][a-z0-9.-]*@[a-z0-9][a-z0-9-]*"
buffer_.match_add("(mailto:)?[a-z0-9][a-z0-9.-]*@[a-z0-9][a-z0-9-]*"
"(\\.[a-z0-9][a-z0-9-]*)+", MAIL)
buffer.match_add(SCHEME + "//(" + USER + "@)?[" + HOSTCHARS + ".]+" +
buffer_.match_add(SCHEME + "//(" + USER + "@)?[" + HOSTCHARS + ".]+" +
"(:[0-9]+)?(" + URLPATH + ")?/?", GENERAL)
self.match = None
self.last_match = None
self.text = self.top.get_widget('text')
self.text.set_editable(not self.dbstate.db.readonly)
self.text.set_buffer(buffer)
self.text.set_buffer(buffer_)
self.text.connect('key-press-event',
self.on_textview_key_press_event)
self.text.connect('insert-at-cursor',
@ -328,7 +333,7 @@ class EditNote(EditPrimary):
# create a formatting toolbar
if not self.dbstate.db.readonly:
uimanager = gtk.UIManager()
uimanager.insert_action_group(buffer.format_action_group, 0)
uimanager.insert_action_group(buffer_.format_action_group, 0)
uimanager.add_ui_from_string(FORMAT_TOOLBAR)
uimanager.ensure_update()
@ -337,12 +342,12 @@ class EditNote(EditPrimary):
vbox = self.top.get_widget('container')
vbox.pack_start(toolbar)
# setup initial values for textview and buffer
# setup initial values for textview and buffer_
if self.obj:
self.empty = False
self.flow_changed(self.obj.get_format())
buffer.set_text(self.obj.get(markup=True))
log.debug("Initial Note: %s" % buffer.get_text())
buffer_.set_text(self.obj.get(markup=True))
log.debug("Initial Note: %s" % buffer_.get_text())
else:
self.empty = True
@ -374,20 +379,20 @@ class EditNote(EditPrimary):
x, y = textview.window_to_buffer_coords(gtk.TEXT_WINDOW_WIDGET,
int(event.x), int(event.y))
iter = textview.get_iter_at_location(x, y)
buffer = textview.get_buffer()
self.match = buffer.match_check(iter.get_offset())
buffer_ = textview.get_buffer()
self.match = buffer_.match_check(iter.get_offset())
if self.match != self.last_match:
start, end = buffer.get_bounds()
buffer.remove_tag_by_name('hyperlink', start, end)
start, end = buffer_.get_bounds()
buffer_.remove_tag_by_name('hyperlink', start, end)
if self.match:
start_offset = self.match[MarkupText.MATCH_START]
end_offset = self.match[MarkupText.MATCH_END]
start = buffer.get_iter_at_offset(start_offset)
end = buffer.get_iter_at_offset(end_offset)
start = buffer_.get_iter_at_offset(start_offset)
end = buffer_.get_iter_at_offset(end_offset)
buffer.apply_tag_by_name('hyperlink', start, end)
buffer_.apply_tag_by_name('hyperlink', start, end)
window.set_cursor(self.hand_cursor)
else:
window.set_cursor(self.regular_cursor)
@ -462,9 +467,9 @@ class EditNote(EditPrimary):
def update_note(self):
"""Update the Note object with current value."""
if self.obj:
buffer = self.text.get_buffer()
(start, stop) = buffer.get_bounds()
text = buffer.get_text(start, stop)
buffer_ = self.text.get_buffer()
(start, stop) = buffer_.get_bounds()
text = buffer_.get_text(start, stop)
self.obj.set(text)
log.debug(text)

View File

@ -36,6 +36,7 @@ log = logging.getLogger(".")
#
#-------------------------------------------------------------------------
import gtk
from gtk import glade
#-------------------------------------------------------------------------
#
@ -45,10 +46,11 @@ import gtk
import const
import Config
import gen.lib
from _EditPrimary import EditPrimary
from DisplayTabs import *
from GrampsWidgets import *
from Editors._EditPrimary import EditPrimary
from DisplayTabs import (GrampsTab, LocationEmbedList, SourceEmbedList,
GalleryTab, NoteTab, WebEmbedList, PlaceBackRefList)
from GrampsWidgets import MonitoredEntry, PrivacyButton
from Errors import ValidationError
from PlaceUtils import conv_lat_lon
#-------------------------------------------------------------------------
@ -109,7 +111,7 @@ class EditPlace(EditPrimary):
return gen.lib.Place()
def _local_init(self):
self.top = gtk.glade.XML(const.GLADE_FILE,"place_editor","gramps")
self.top = glade.XML(const.GLADE_FILE, "place_editor","gramps")
self.set_window(self.top.get_widget("place_editor"), None,
self.get_menu_title())
@ -259,7 +261,6 @@ class EditPlace(EditPrimary):
def save(self, *obj):
self.ok_button.set_sensitive(False)
title = self.obj.get_title()
trans = self.db.transaction_begin()
if not self.obj.get_handle():
@ -283,8 +284,8 @@ class EditPlace(EditPrimary):
#-------------------------------------------------------------------------
class DeletePlaceQuery:
def __init__(self,dbstate,uistate,
place,person_list,family_list,event_list):
def __init__(self, dbstate, uistate, place, person_list, family_list,
event_list):
self.db = dbstate.db
self.uistate = uistate
self.obj = place

View File

@ -34,7 +34,8 @@ class EditPrimary(ManagedWindow.ManagedWindow):
QR_CATEGORY = -1
def __init__(self, state, uistate, track, obj, get_from_handle, callback=None):
def __init__(self, state, uistate, track, obj, get_from_handle,
callback=None):
"""Creates an edit window. Associates a person with the window."""
self.dp = DateHandler.parser
@ -101,7 +102,8 @@ class EditPrimary(ManagedWindow.ManagedWindow):
page_no)
child.set_parent_notebook(notebook)
def _switch_page_on_dnd(self, widget, context, x, y, time, notebook, page_no):
def _switch_page_on_dnd(self, widget, context, x, y, time, notebook,
page_no):
if notebook.get_current_page() != page_no:
notebook.set_current_page(page_no)

View File

@ -33,6 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import gtk
from gtk import glade
#-------------------------------------------------------------------------
#
@ -43,9 +44,9 @@ import const
import Config
import gen.lib
from GrampsWidgets import *
from GrampsWidgets import MonitoredEntry, MonitoredDataType, PrivacyButton
from DisplayTabs import AddrEmbedList, WebEmbedList, NoteTab, SourceBackRefList
from _EditPrimary import EditPrimary
from Editors._EditPrimary import EditPrimary
class EditRepository(EditPrimary):
@ -69,9 +70,10 @@ class EditRepository(EditPrimary):
return title
def _local_init(self):
self.glade = gtk.glade.XML(const.GLADE_FILE,"repository_editor","gramps")
self.glade = glade.XML(const.GLADE_FILE, "repository_editor","gramps")
self.set_window(self.glade.get_widget("repository_editor"), None, self.get_menu_title())
self.set_window(self.glade.get_widget("repository_editor"), None,
self.get_menu_title())
width = Config.get(Config.REPO_WIDTH)
height = Config.get(Config.REPO_HEIGHT)

View File

@ -35,7 +35,8 @@ log = logging.getLogger(".")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk.glade
import gtk
from gtk import glade
#-------------------------------------------------------------------------
#
@ -45,11 +46,11 @@ import gtk.glade
import const
import Config
import gen.lib
from _EditPrimary import EditPrimary
from Editors._EditPrimary import EditPrimary
from DisplayTabs import \
NoteTab,GalleryTab,DataEmbedList,SourceBackRefList,RepoEmbedList
from GrampsWidgets import *
from DisplayTabs import (NoteTab, GalleryTab, DataEmbedList,
SourceBackRefList, RepoEmbedList)
from GrampsWidgets import MonitoredEntry, PrivacyButton
#-------------------------------------------------------------------------
#
@ -77,9 +78,10 @@ class EditSource(EditPrimary):
def _local_init(self):
assert(self.obj)
self.glade = gtk.glade.XML(const.GLADE_FILE,"source_editor","gramps")
self.glade = glade.XML(const.GLADE_FILE, "source_editor","gramps")
self.set_window(self.glade.get_widget("source_editor"), None, self.get_menu_title())
self.set_window(self.glade.get_widget("source_editor"), None,
self.get_menu_title())
width = Config.get(Config.SOURCE_WIDTH)
height = Config.get(Config.SOURCE_HEIGHT)
self.window.resize(width, height)