* src/EditPerson.py: use Steve Swales' method for handling
locale determination * src/GrampsBSDDB.py: added remove_object task * src/MediaView.py: Handle drag and drop better svn: r3771
This commit is contained in:
parent
d978556a2c
commit
eb1dd7dc59
@ -1,3 +1,9 @@
|
||||
2004-11-30 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/EditPerson.py: use Steve Swales' method for handling
|
||||
locale determination
|
||||
* src/GrampsBSDDB.py: added remove_object task
|
||||
* src/MediaView.py: Handle drag and drop better
|
||||
|
||||
2004-11-30 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||
* NEWS: Update.
|
||||
|
||||
|
@ -37,6 +37,7 @@ import gtk
|
||||
import gtk.glade
|
||||
import gobject
|
||||
import gnome
|
||||
import locale
|
||||
|
||||
from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file
|
||||
|
||||
@ -95,7 +96,7 @@ _use_patronymic = [
|
||||
#-------------------------------------------------------------------------
|
||||
class EditPerson:
|
||||
|
||||
use_patronymic = os.environ.get('LANG').split('.')[0] in _use_patronymic
|
||||
use_patronymic = locale.getlocale(locale.LC_TIME)[0] in _use_patronymic
|
||||
|
||||
def __init__(self,parent,person,db,callback=None):
|
||||
"""Creates an edit window. Associates a person with the window."""
|
||||
|
@ -227,6 +227,12 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
transaction.add(PLACE_KEY,handle,old_data)
|
||||
self.place_map.delete(str(handle))
|
||||
|
||||
def remove_object(self,handle,transaction):
|
||||
if transaction != None:
|
||||
old_data = self.media_map.get(handle)
|
||||
transaction.add(PLACE_KEY,handle,old_data)
|
||||
self.media_map.delete(str(handle))
|
||||
|
||||
def get_person_from_gramps_id(self,val):
|
||||
"""finds a Person in the database from the passed gramps' ID.
|
||||
If no such Person exists, a new Person is added to the database."""
|
||||
|
@ -77,7 +77,6 @@ class MediaView:
|
||||
self.parent = parent
|
||||
self.db = db
|
||||
self.list = glade.get_widget("media_list")
|
||||
#self.list.set_property('fixed-height-mode',True)
|
||||
self.mid = glade.get_widget("mid")
|
||||
self.mtype = glade.get_widget("mtype")
|
||||
self.mdesc = glade.get_widget("mdesc")
|
||||
@ -86,33 +85,49 @@ class MediaView:
|
||||
self.preview = glade.get_widget("preview")
|
||||
self.topWindow = glade.get_widget("gramps")
|
||||
self.renderer = gtk.CellRendererText()
|
||||
|
||||
# self.model = gtk.TreeModelSort(DisplayModels.MediaModel(self.db))
|
||||
self.model = DisplayModels.MediaModel(self.db)
|
||||
|
||||
self.selection = self.list.get_selection()
|
||||
|
||||
self.list.set_model(self.model)
|
||||
|
||||
t = [ ('STRING', 0, 0),
|
||||
('text/plain',0,0),
|
||||
('text/uri-list',0,2),
|
||||
('application/x-rootwin-drop',0,1)]
|
||||
DND_TARGETS = [
|
||||
('STRING', 0, 0),
|
||||
('text/plain',0,0),
|
||||
('text/uri-list',0,2),
|
||||
('application/x-rootwin-drop',0,1)]
|
||||
|
||||
self.list.drag_source_set(gtk.gdk.BUTTON1_MASK|gtk.gdk.BUTTON3_MASK,
|
||||
t,gtk.gdk.ACTION_COPY)
|
||||
self.list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
|
||||
t,gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE)
|
||||
self.list.enable_model_drag_source(
|
||||
gtk.gdk.BUTTON1_MASK,
|
||||
DND_TARGETS,
|
||||
gtk.gdk.ACTION_DEFAULT|gtk.gdk.ACTION_COPY
|
||||
)
|
||||
|
||||
self.list.drag_source_set(
|
||||
gtk.gdk.BUTTON1_MASK|gtk.gdk.BUTTON3_MASK,
|
||||
DND_TARGETS,
|
||||
gtk.gdk.ACTION_COPY
|
||||
)
|
||||
|
||||
self.list.connect("drag_data_received", self.on_drag_data_received)
|
||||
self.list.connect("drag_data_get", self.on_drag_data_get)
|
||||
self.list.connect("drag_begin", self.on_drag_begin)
|
||||
self.list.enable_model_drag_dest(
|
||||
DND_TARGETS,
|
||||
gtk.gdk.ACTION_DEFAULT
|
||||
)
|
||||
self.list.drag_dest_set(
|
||||
gtk.DEST_DEFAULT_ALL,
|
||||
DND_TARGETS,
|
||||
gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE
|
||||
)
|
||||
|
||||
self.list.connect("drag-data-received", self.on_drag_data_received)
|
||||
self.list.connect("drag-data-get", self.on_drag_data_get)
|
||||
self.list.connect("drag-begin", self.on_drag_begin)
|
||||
self.list.connect("drag-drop", self.on_drag_drop)
|
||||
|
||||
self.update = update
|
||||
self.list.connect('button-press-event',self.on_button_press_event)
|
||||
self.list.connect('key-press-event',self.key_press)
|
||||
|
||||
self.selection.connect('changed',self.on_select_row)
|
||||
self.update = update
|
||||
self.columns = []
|
||||
self.build_columns()
|
||||
self.build_tree()
|
||||
@ -146,9 +161,7 @@ class MediaView:
|
||||
self.build_tree()
|
||||
|
||||
def build_tree(self):
|
||||
#self.model = gtk.TreeModelSort(DisplayModels.MediaModel(self.parent.db))
|
||||
self.model = DisplayModels.MediaModel(self.parent.db)
|
||||
|
||||
self.list.set_model(self.model)
|
||||
self.selection = self.list.get_selection()
|
||||
|
||||
@ -269,6 +282,9 @@ class MediaView:
|
||||
def update_display(self,mobj):
|
||||
self.model.update_row_by_handle(mobj.get_handle())
|
||||
|
||||
def add_to_display(self,mobj):
|
||||
self.model.add_row_by_handle(mobj.get_handle())
|
||||
|
||||
def on_edit_clicked(self,obj):
|
||||
"""Edit the properties of an existing media object in the media list"""
|
||||
|
||||
@ -310,7 +326,7 @@ class MediaView:
|
||||
|
||||
def is_object_used(self,mobj):
|
||||
mhandle = mobj.get_handle()
|
||||
for family_handle in self.db.get_family_handles(sort_handles=False):
|
||||
for family_handle in self.db.get_family_handles():
|
||||
p = self.db.get_family_from_handle(family_handle)
|
||||
for o in p.get_media_list():
|
||||
if o.get_reference_handle() == mhandle:
|
||||
@ -332,6 +348,11 @@ class MediaView:
|
||||
return True
|
||||
return False
|
||||
|
||||
def on_drag_drop(self, tree, context, x, y, time):
|
||||
self.list.emit_stop_by_name('drag-drop')
|
||||
self.list.drag_get_data(context,context.targets[-1],time)
|
||||
return 1
|
||||
|
||||
def on_drag_begin(self,obj,context):
|
||||
store,node = self.selection.get_selected()
|
||||
if not node:
|
||||
@ -342,7 +363,7 @@ class MediaView:
|
||||
image = self.db.get_thumbnail_image(obj.get_handle())
|
||||
context.set_icon_pixbuf(image,0,0)
|
||||
|
||||
def on_drag_data_get(self,w, context, selection_data, info, time):
|
||||
def on_drag_data_get(self, w, context, selection_data, info, time):
|
||||
if info == 1:
|
||||
return
|
||||
|
||||
@ -353,8 +374,9 @@ class MediaView:
|
||||
selection_data.set(selection_data.target, 8, handle)
|
||||
|
||||
def on_drag_data_received(self,w, context, x, y, data, info, time):
|
||||
print "on_drag_data_received"
|
||||
import urlparse
|
||||
|
||||
self.list.emit_stop_by_name('drag-data-received')
|
||||
if data and data.format == 8:
|
||||
d = string.strip(string.replace(data.data,'\0',' '))
|
||||
protocol,site,name, j,k,l = urlparse.urlparse(d)
|
||||
@ -372,7 +394,7 @@ class MediaView:
|
||||
|
||||
self.db.commit_media_object(photo,trans)
|
||||
self.db.transaction_commit(trans,_("Add Media Object"))
|
||||
|
||||
self.build_tree()
|
||||
if GrampsGconfKeys.get_media_global():
|
||||
ImageSelect.GlobalMediaProperties(self.db,photo,
|
||||
self.update_display,
|
||||
|
Loading…
Reference in New Issue
Block a user