2006-04-27 Don Allingham <don@gramps-project.org>

* src/Editors/_EditReference.py: fix warn_box call
	* src/DisplayTabs.py: handle canceled edit box for media
	* src/AddMedia.py: ManagedWindow support
	* src/SelectPerson.py: ManagedWindow support



svn: r6478
This commit is contained in:
Don Allingham 2006-04-28 00:33:44 +00:00
parent 5f7cf6a91a
commit 81f6548c5c
5 changed files with 54 additions and 44 deletions

View File

@ -1,3 +1,9 @@
2006-04-27 Don Allingham <don@gramps-project.org>
* src/Editors/_EditReference.py: fix warn_box call
* src/DisplayTabs.py: handle canceled edit box for media
* src/AddMedia.py: ManagedWindow support
* src/SelectPerson.py: ManagedWindow support
2006-04-27 Alex Roitman <shura@gramps-project.org>
* src/ViewManager.py (reports_clicked, tools_clicked): handle
exception.

View File

@ -56,27 +56,36 @@ import Utils
import RelLib
import Mime
import GrampsDisplay
import ManagedWindow
#-------------------------------------------------------------------------
#
# AddMediaObject
#
#-------------------------------------------------------------------------
class AddMediaObject:
class AddMediaObject(ManagedWindow.ManagedWindow):
"""
Displays the Add Media Dialog window, allowing the user to select
a media object from the file system, while providing a description.
"""
def __init__(self,db):
def __init__(self,dbstate, uistate, track):
"""
Creates and displays the dialog box
db - the database in which the new object is to be stored
"""
self.db = db
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
self.db = dbstate.db
self.glade = gtk.glade.XML(const.gladeFile,"imageSelect","gramps")
self.window = self.glade.get_widget("imageSelect")
self.set_window(
self.glade.get_widget("imageSelect"),
self.glade.get_widget('title'),
_('Select a media object'))
self.description = self.glade.get_widget("photoDescription")
self.image = self.glade.get_widget("image")
self.file_text = self.glade.get_widget("fname")
@ -86,12 +95,12 @@ class AddMediaObject:
self.temp_name = ""
self.object = None
Utils.set_titles(self.window,self.glade.get_widget('title'),
_('Select a media object'))
self.glade.get_widget('fname').connect('update_preview',
self.on_name_changed)
self.window.show()
self.show()
def build_menu_names(self, obj):
return(_('Select media object'),None)
def internal_toggled(self, obj):
self.file_text.set_sensitive(not obj.get_active())
@ -173,12 +182,12 @@ class AddMediaObject:
if val == gtk.RESPONSE_OK:
self.on_savephoto_clicked()
self.window.destroy()
self.close()
return self.object
elif val == gtk.RESPONSE_HELP:
self.on_help_imagesel_clicked(None)
else:
self.window.destroy()
self.close()
return None
return None

View File

@ -1622,7 +1622,8 @@ class GalleryTab(ButtonTab):
self._connect_icon_model()
self._set_label()
self._selection_changed()
self.update()
if self.update:
self.update()
def get_selected(self):
node = self.iconlist.get_selected_items()
@ -1633,18 +1634,19 @@ class GalleryTab(ButtonTab):
def add_button_clicked(self, obj):
import AddMedia
am = AddMedia.AddMediaObject(self.dbstate.db)
am = AddMedia.AddMediaObject(self.dbstate, self.uistate, self.track)
am.run()
src = am.object
sref = RelLib.MediaRef()
try:
from Editors import EditMediaRef
EditMediaRef(self.dbstate, self.uistate, self.track,
src, sref, self.add_callback)
except Errors.WindowActiveError:
pass
if src:
sref = RelLib.MediaRef()
try:
from Editors import EditMediaRef
EditMediaRef(self.dbstate, self.uistate, self.track,
src, sref, self.add_callback)
except Errors.WindowActiveError:
pass
def add_callback(self, media_ref, media):
media_ref.ref = media.handle

View File

@ -89,7 +89,7 @@ class EditReference(ManagedWindow.ManagedWindow):
self.warn_box = box
def enable_warnbox(self):
self.warn_box.show_all()
self.warn_box.show()
def define_expander(self,expander):
expander.set_expanded(True)

View File

@ -44,37 +44,30 @@ import pango
import const
import Utils
import PeopleModel
import ManagedWindow
#-------------------------------------------------------------------------
#
# SelectPerson
#
#-------------------------------------------------------------------------
class SelectPerson:
class SelectPerson(ManagedWindow.ManagedWindow):
def __init__(self, db, title, filter=None, skip=[]):
def __init__(self, dbstate, uistate, title, filter=None, skip=[]):
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
self.renderer = gtk.CellRendererText()
self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END)
self.db = db
self.db = dbstate.db
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
self.top = self.glade.get_widget('select_person')
self.plist = self.glade.get_widget('plist')
self.notebook = self.glade.get_widget('notebook')
Utils.set_titles(self.top,
self.glade.get_widget('title'),
title)
# import hotshot, hotshot.stats
# pr = hotshot.Profile('profile.data')
# pr.runcall(self.foo)
# pr.close()
# stats = hotshot.stats.load('profile.data')
# stats.strip_dirs()
# stats.sort_stats('time','calls')
# stats.print_stats(35)
self.set_window(
self.glade.get_widget('select_person'),
self.glade.get_widget('title'),
title)
self.model = PeopleModel.PeopleModel(self.db,
data_filter=filter,
@ -82,10 +75,10 @@ class SelectPerson:
self.add_columns(self.plist)
self.plist.set_model(self.model)
self.top.show()
self.show()
def foo(self):
PeopleModel.PeopleModel(self.db)
def build_menu_names(self,obj):
return (_('Select Person'), None)
def add_columns(self,tree):
tree.set_fixed_height_mode(True)
@ -113,15 +106,15 @@ class SelectPerson:
return mlist
def run(self):
val = self.top.run()
val = self.window.run()
if val == gtk.RESPONSE_OK:
idlist = self.get_selected_ids()
self.top.destroy()
self.close()
if idlist and idlist[0]:
return_value = self.db.get_person_from_handle(idlist[0])
else:
return_value = None
return return_value
else:
self.top.destroy()
self.close()
return None