* src/AddMedia.py: handle "note only" media object

* src/DisplayModels.py: handle media type of None
* src/ImageSelect.py: Add "internal note" check box
* src/MediaView.py: handle media type of None
* src/NoteEdit.py: use glade definition
* src/gramps.glade: add note editor
* src/plubins/NavWebPage.py: Add default pages


svn: r4035
This commit is contained in:
Don Allingham 2005-02-16 05:41:33 +00:00
parent ab8cabe655
commit db6a32af63
9 changed files with 2914 additions and 95 deletions

View File

@ -1,3 +1,12 @@
2005-02-15 Don Allingham <dallingham@users.sourceforge.net>
* src/AddMedia.py: handle "note only" media object
* src/DisplayModels.py: handle media type of None
* src/ImageSelect.py: Add "internal note" check box
* src/MediaView.py: handle media type of None
* src/NoteEdit.py: use glade definition
* src/gramps.glade: add note editor
* src/plubins/NavWebPage.py: Add default pages
2005-02-15 Alex Roitman <shura@alex.neuro.umn.edu>
* doc/gramps-manual/C/authors.xml: Add list of contributors.
* doc/gramps-manual/C/getstart.xml: Update.

View File

@ -83,6 +83,8 @@ class AddMediaObject:
self.description = self.glade.get_widget("photoDescription")
self.image = self.glade.get_widget("image")
self.file_text = self.glade.get_widget("fname")
self.internal = self.glade.get_widget('internal')
self.internal.connect('toggled',self.internal_toggled)
self.update = update
self.temp_name = ""
self.object = None
@ -97,6 +99,9 @@ class AddMediaObject:
self.window.show()
def internal_toggled(self, obj):
self.file_text.set_sensitive(not obj.get_active())
def on_help_imagesel_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
gnome.help_display('gramps-manual','gramps-edit-quick')
@ -107,29 +112,36 @@ class AddMediaObject:
Callback function called with the save button is pressed.
A new media object is created, and added to the database.
"""
filename = self.file_text.get_filename()
description = unicode(self.description.get_text())
if self.internal.get_active():
import NoteEdit
mobj = RelLib.MediaObject()
mobj.set_description(description)
mobj.set_mime_type(None)
else:
filename = self.file_text.get_filename()
if os.path.exists(filename) == 0:
msgstr = _("Cannot import %s")
msgstr2 = _("The filename supplied could not be found.")
ErrorDialog(msgstr % filename, msgstr2)
return
if os.path.exists(filename) == 0:
msgstr = _("Cannot import %s")
msgstr2 = _("The filename supplied could not be found.")
ErrorDialog(msgstr % filename, msgstr2)
return
mtype = GrampsMime.get_type(filename)
if description == "":
description = os.path.basename(filename)
mtype = GrampsMime.get_type(filename)
if description == "":
description = os.path.basename(filename)
mobj = RelLib.MediaObject()
mobj.set_description(description)
mobj.set_mime_type(mtype)
mobj = RelLib.MediaObject()
mobj.set_description(description)
mobj.set_mime_type(mtype)
name = filename
mobj.set_path(name)
trans = self.db.transaction_begin()
self.db.add_object(mobj,trans)
name = filename
mobj.set_path(name)
self.object = mobj
self.db.commit_media_object(mobj,trans)
self.db.transaction_commit(trans,_("Add Media Object"))

View File

@ -395,7 +395,10 @@ class MediaModel(BaseModel):
return unicode(data[2])
def column_mime(self,data):
return unicode(data[3])
if data[3]:
return unicode(data[3])
else:
return _('Note')
def column_id(self,data):
return unicode(data[1])

View File

@ -479,7 +479,9 @@ class EditPerson:
ph = media_list[0]
object_handle = ph.get_reference_handle()
obj = self.db.get_object_from_handle(object_handle)
ImageSelect.LocalMediaProperties(ph,obj.get_path(),self,self.window)
ImageSelect.LocalMediaProperties(ph,obj.get_path(),
self,self.window)
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
media_list = self.person.get_media_list()
if media_list:

View File

@ -112,7 +112,9 @@ class ImageSelect:
self.fname = self.glade.get_widget("fname")
self.image = self.glade.get_widget("image")
self.description = self.glade.get_widget("photoDescription")
self.internal = self.glade.get_widget('internal')
self.temp_name = ""
self.internal.hide()
Utils.set_titles(self.window,self.glade.get_widget('title'),
_('Select a media object'))
@ -122,6 +124,8 @@ class ImageSelect:
"on_help_imagesel_clicked" : self.on_help_imagesel_clicked,
})
self.internal.connect('toggled',self.internal_toggled)
if os.path.isdir(_last_path):
self.fname.set_current_folder(_last_path)
@ -953,24 +957,29 @@ class GlobalMediaProperties:
else:
self.srcreflist = []
self.sourcetab = Sources.SourceTab(self.srcreflist,self,
self.change_dialog,
self.window, self.slist,
self.change_dialog.get_widget('gl_add_src'),
self.change_dialog.get_widget('gl_edit_src'),
self.change_dialog.get_widget('gl_del_src'))
self.sourcetab = Sources.SourceTab(
self.srcreflist,self,
self.change_dialog,
self.window, self.slist,
self.change_dialog.get_widget('gl_add_src'),
self.change_dialog.get_widget('gl_edit_src'),
self.change_dialog.get_widget('gl_del_src'))
self.descr_window.set_text(self.obj.get_description())
mtype = self.obj.get_mime_type()
pb = ImgManip.get_thumbnail_image(self.obj.get_path())
self.pixmap.set_from_pixbuf(pb)
if mtype:
pb = ImgManip.get_thumbnail_image(self.obj.get_path())
self.pixmap.set_from_pixbuf(pb)
descr = Utils.get_mime_description(mtype)
self.change_dialog.get_widget("type").set_text(descr)
else:
self.change_dialog.get_widget("type").set_text(_('Note'))
self.pixmap.hide()
self.change_dialog.get_widget("gid").set_text(self.obj.get_gramps_id())
self.makelocal = self.change_dialog.get_widget("makelocal")
self.update_info()
self.change_dialog.get_widget("type").set_text(Utils.get_mime_description(mtype))
if self.obj.get_note():
self.notes.get_buffer().set_text(self.obj.get_note())
Utils.bold_label(self.notes_label)

View File

@ -181,23 +181,28 @@ class MediaView:
mobj = self.db.get_object_from_handle(handle)
mtype = mobj.get_mime_type()
path = mobj.get_path()
type_name = Utils.get_mime_description(mtype)
image = ImgManip.get_thumbnail_image(path)
if image != None:
self.preview.set_from_pixbuf(image)
if mtype:
type_name = Utils.get_mime_description(mtype)
image = ImgManip.get_thumbnail_image(path)
if image != None:
self.preview.set_from_pixbuf(image)
else:
icon = Utils.find_icon(mtype)
icon_image = gtk.gdk.pixbuf_new_from_file(icon)
self.preview.set_from_pixbuf(icon_image)
else:
icon_image = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(mtype))
icon = Utils.find_icon('text/plain')
icon_image = gtk.gdk.pixbuf_new_from_file(icon)
self.preview.set_from_pixbuf(icon_image)
type_name = _('Note')
self.mid.set_text(mobj.get_gramps_id())
self.mtype.set_text(type_name)
self.mdesc.set_text(mobj.get_description())
if len(path) == 0 or fexists == 0:
self.mpath.set_text(_("The file no longer exists"))
elif path[0] == "/":
self.mpath.set_text(path)
else:
self.mpath.set_text(_("<local>"))
self.mpath.set_text(path)
self.mdetails.set_text(Utils.get_detail_text(mobj,0))
def on_button_press_event(self,obj,event):
@ -230,7 +235,7 @@ class MediaView:
Utils.add_menuitem(menu,_("View in the default viewer"),None,
self.popup_view_photo)
if mime_type[0:5] == "image":
if mime_type and mime_type[0:5] == "image":
Utils.add_menuitem(menu,_("Edit with the GIMP"),
None,self.popup_edit_photo)
item = gtk.MenuItem()
@ -263,9 +268,8 @@ class MediaView:
os.execvp(const.editor,[const.editor, self.obj.get_path()])
def popup_change_description(self, obj):
ImageSelect.GlobalMediaProperties(self.db,self.obj,
self.update_display,
self,self.topWindow)
ImageSelect.GlobalMediaProperties(
self.db, self.obj, self.update_display, self,self.topWindow)
def on_add_clicked(self,obj):
"""Add a new media object to the media list"""
@ -289,9 +293,19 @@ class MediaView:
if node:
handle = list_store.get_value(node,_HANDLE_COL)
obj = self.db.get_object_from_handle(handle)
ImageSelect.GlobalMediaProperties(self.db,obj,
self.update_display,
self,self.topWindow)
if obj.get_mime_type():
ImageSelect.GlobalMediaProperties(
self.db,obj, self.update_display,
self,self.topWindow)
else:
import NoteEdit
NoteEdit.NoteEditor(obj,self.parent,self.topWindow,
self.note_callback)
def note_callback(self,data):
trans = self.db.transaction_begin()
self.db.commit_media_object(data,trans)
self.db.transaction_commit(trans,_("Edit Media Object"))
def on_delete_clicked(self,obj):
store,node = self.selection.get_selected()
@ -357,8 +371,9 @@ class MediaView:
if (const.dnd_images):
handle = store.get_value(node,_HANDLE_COL)
obj = self.db.get_object_from_handle(handle)
image = ImgManip.get_thumbnail_image(obj.get_path())
context.set_icon_pixbuf(image,0,0)
if obj.get_path():
image = ImgManip.get_thumbnail_image(obj.get_path())
context.set_icon_pixbuf(image,0,0)
def on_drag_data_get(self, w, context, selection_data, info, time):
if info == 1:

View File

@ -26,6 +26,7 @@
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
#-------------------------------------------------------------------------
#
@ -33,6 +34,8 @@ import gtk
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import const
import Utils
#-------------------------------------------------------------------------
#
@ -41,9 +44,10 @@ from gettext import gettext as _
#-------------------------------------------------------------------------
class NoteEditor:
"""Displays a simple text editor that allows a person to edit a note"""
def __init__(self,data,parent,parent_window=None):
def __init__(self,data,parent,parent_window=None,callback=None):
self.parent = parent
self.callback = callback
if data:
if self.parent.child_windows.has_key(data):
self.parent.child_windows[data].present(None)
@ -54,45 +58,36 @@ class NoteEditor:
self.win_key = self
self.data = data
self.parent_window = parent_window
self.glade = gtk.glade.XML(const.gladeFile,"note_edit")
self.draw()
def draw(self):
"""Displays the NoteEditor window"""
title = "%s - GRAMPS" % _("Edit Note")
self.top = gtk.Dialog(title)
self.top.set_default_size(450,300)
vbox = gtk.VBox()
self.top.vbox.pack_start(vbox,gtk.TRUE,gtk.TRUE,0)
label = gtk.Label('<span weight="bold" size="larger">%s</span>' % _('Edit Note'))
label.set_use_markup(gtk.TRUE)
vbox.pack_start(label, gtk.FALSE, gtk.FALSE, 10)
self.top = self.glade.get_widget('note_edit')
alt_title = self.glade.get_widget('title_msg')
Utils.set_titles(self.top, alt_title, _('Note Editor'))
self.entry = gtk.TextView()
if self.callback:
self.title_entry = self.glade.get_widget('title')
self.title_entry.set_text(self.data.get_description())
else:
self.glade.get_widget('tbox').hide()
self.entry = self.glade.get_widget('note')
self.entry.set_editable(gtk.TRUE)
self.entry.show()
scroll = gtk.ScrolledWindow()
scroll.add(self.entry)
scroll.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scroll.set_shadow_type(gtk.SHADOW_IN)
scroll.show()
vbox.pack_start(scroll, gtk.TRUE, gtk.TRUE, 0)
self.entry.get_buffer().set_text(self.data.get_note())
cancel_button = self.top.add_button(gtk.STOCK_CANCEL,1)
ok_button = self.top.add_button(gtk.STOCK_OK,0)
cancel_button = self.glade.get_widget('cancel')
ok_button = self.glade.get_widget('ok')
cancel_button.connect("clicked",self.close)
ok_button.connect("clicked",self.on_save_note_clicked)
self.top.connect("delete_event",self.on_delete_event)
self.top.show_all()
if self.parent_window:
self.top.set_transient_for(self.parent_window)
self.add_itself_to_menu()
self.top.show()
def on_delete_event(self,*obj):
self.remove_itself_from_menu()
@ -122,4 +117,7 @@ class NoteEditor:
tbuffer.get_end_iter(),gtk.FALSE))
if text != self.data.get_note():
self.data.set_note(text)
if self.callback:
self.data.set_description(self.title_entry.get_text())
self.callback(self.data)
self.close(obj)

File diff suppressed because it is too large Load Diff

View File

@ -59,6 +59,7 @@ import BaseDoc
from NameDisplay import displayer as _nd
from DateHandler import displayer as _dd
import ReportUtils
import sets
_NARRATIVE = "narrative.css"
@ -134,8 +135,9 @@ class BasePage:
ofile.write('<br>\n')
ofile.write('<br>\n')
ofile.write('<hr>\n')
ofile.write('<div class="footer">')
ofile.write('Generated by <a href="http://gramps.sourceforge.net">GRAMPS</a> on 13 December 2004.')
ofile.write('<div class="footer">Generated by ')
ofile.write('<a href="http://gramps.sourceforge.net">GRAMPS</a> ')
ofile.write('on 13 December 2004.')
ofile.write('</div>\n')
ofile.write('</body>\n')
ofile.write('</html>\n')
@ -225,7 +227,7 @@ class IndividualListPage(BasePage):
#------------------------------------------------------------------------
class PlaceListPage(BasePage):
def __init__(self, db, title, handle_list, html_dir):
def __init__(self, db, title, place_handles, html_dir, src_list):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"places.html")
ofile = open(page_name, "w")
@ -246,6 +248,7 @@ class PlaceListPage(BasePage):
ofile.write('</tr>\n')
self.sort = Sort.Sort(db)
handle_list = list(place_handles)
handle_list.sort(self.sort.by_place_title)
last_name = ""
last_letter = ''
@ -388,7 +391,7 @@ class HomePage(BasePage):
#------------------------------------------------------------------------
class SourcesPage(BasePage):
def __init__(self, db, title, handle_list, html_dir):
def __init__(self, db, title, handle_set, html_dir):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"sources.html")
@ -396,7 +399,19 @@ class SourcesPage(BasePage):
self.display_header(ofile,_('Sources'),
db.get_researcher().get_name())
ofile.write('<h3>%s</h3>\n' % _('Sources'))
handle_list = list(handle_set)
ofile.write('<h3>%s</h3>\n<p>' % _('Sources'))
ofile.write(_('All sources cited in the project.'))
ofile.write('</p>\n<blockquote>\n<table class="infolist">\n')
index = 1
for handle in handle_list:
ofile.write('<tr><td class="category">%d.</td>\n' % index)
ofile.write('<td class="data">')
ofile.write('</td></tr>\n')
ofile.write('</table>\n<blockquote>\n')
self.display_footer(ofile)
ofile.close()
@ -454,19 +469,20 @@ class IndividualPage(BasePage):
RelLib.Person.UNKNOWN : const.unknown,
}
def __init__(self, db, person, title, dirpath, ind_list):
def __init__(self, db, person, title, dirpath, ind_list,
place_list, src_list):
BasePage.__init__(self,title)
self.person = person
self.db = db
self.ind_list = ind_list
self.dirpath = dirpath
gramps_id = self.person.get_gramps_id()
self.src_list = src_list
self.place_list = place_list
self.sort_name = _nd.sorted(self.person)
self.name = _nd.sorted(self.person)
ofile = open(os.path.join(dirpath,"%s.html" % gramps_id), "w")
self.display_header(ofile, 'My Family Tree',
ofile = open(os.path.join(dirpath,"%s.html" % person.gramps_id), "w")
self.display_header(ofile, title,
self.db.get_researcher().get_name())
self.display_ind_general(ofile)
self.display_ind_events(ofile)
@ -488,6 +504,8 @@ class IndividualPage(BasePage):
index = 1
for sref in sreflist:
self.src_list.add(sref.get_base_handle())
source = self.db.get_source_from_handle(sref.get_base_handle())
author = source.get_author()
title = source.get_title()
@ -761,9 +779,12 @@ class IndividualPage(BasePage):
def format_event(self,event):
descr = event.get_description()
place = ReportUtils.place_name(self.db,event.get_place_handle())
date = _dd.display(event.get_date_object())
place_handle = event.get_place_handle()
if place_handle:
self.place_list.add(place_handle)
place = ReportUtils.place_name(self.db,place_handle)
date = _dd.display(event.get_date_object())
tmap = {'description' : descr, 'date' : date, 'place' : place}
if descr and date and place:
@ -903,9 +924,13 @@ class WebReport(Report.Report):
DownloadPage(self.database,self.title,dir_name)
IntroductionPage(self.database,self.title,dir_name)
place_list = sets.Set()
source_list = sets.Set()
for person_handle in ind_list:
person = self.database.get_person_from_handle(person_handle)
idoc = IndividualPage(self.database,person,self.title,dir_name, ind_list)
idoc = IndividualPage(self.database, person, self.title,
dir_name, ind_list, place_list, source_list)
self.progress_bar_step()
while gtk.events_pending():
gtk.main_iteration()
@ -917,10 +942,9 @@ class WebReport(Report.Report):
while gtk.events_pending():
gtk.main_iteration()
SourcesPage(self.database,self.title,
self.database.get_source_handles(),dir_name)
PlaceListPage(self.database,self.title,
self.database.get_place_handles(),dir_name)
PlaceListPage(self.database, self.title, place_list,
dir_name, source_list)
SourcesPage(self.database,self.title, source_list, dir_name)
self.progress_bar_done()
def write_css(self,dir_name):