2007-07-08 Don Allingham <don@gramps-project.org>
* src/DbManager.py: handle drag-n-drop files in DbManager. Dragging an XML or GEDCOM file into the DbManager will create a new database and import the file. svn: r8708
This commit is contained in:
parent
06620b869e
commit
8f445b7114
@ -1,3 +1,8 @@
|
||||
2007-07-08 Don Allingham <don@gramps-project.org>
|
||||
* src/DbManager.py: handle drag-n-drop files in DbManager. Dragging an
|
||||
XML or GEDCOM file into the DbManager will create a new database and import
|
||||
the file.
|
||||
|
||||
2007-07-08 Brian Matherly <brian@gramps-project.org>
|
||||
Robert Cawley <rjc@cawley.id.au>
|
||||
* src/docgen/ODFDoc.py
|
||||
|
@ -33,6 +33,7 @@ __revision__ = "$Revision: 8197 $"
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import time
|
||||
import Mime
|
||||
import subprocess
|
||||
from gettext import gettext as _
|
||||
|
||||
@ -56,6 +57,7 @@ else:
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gtk.glade
|
||||
from gtk.gdk import ACTION_COPY
|
||||
import pango
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -147,6 +149,14 @@ class DbManager:
|
||||
self.selection.connect('changed', self.__selection_changed)
|
||||
self.dblist.connect('button-press-event', self.__button_press)
|
||||
|
||||
self.top.drag_dest_set(
|
||||
gtk.DEST_DEFAULT_ALL,
|
||||
(('application/x-gramps-xml', 0, 1),
|
||||
('application/x-gedcom', 0, 2),
|
||||
('text/plain', 0, 3)),
|
||||
ACTION_COPY)
|
||||
self.top.connect('drag_data_received', self.drag_data_received)
|
||||
|
||||
def __button_press(self, obj, event):
|
||||
"""
|
||||
Checks for a double click event. In the tree view, we want to
|
||||
@ -632,6 +642,28 @@ class DbManager:
|
||||
start_editing=True)
|
||||
return new_path
|
||||
|
||||
def drag_data_received(self, widget, context, x, y, selection, info, time):
|
||||
drag_value = selection.get_text().strip()
|
||||
if drag_value[0:7] == "file://":
|
||||
filetype = Mime.get_type(drag_value)
|
||||
if filetype in (const.app_gramps_xml, const.app_gedcom):
|
||||
(name, ext) = os.path.splitext(os.path.basename(drag_value))
|
||||
new_path = self.__create_new_db(name)
|
||||
trans = Config.TRANSACTIONS
|
||||
dbtype = 'x-directory/normal'
|
||||
|
||||
self.__start_cursor(_("Importing data..."))
|
||||
dbase = GrampsDb.gramps_db_factory(dbtype)(trans)
|
||||
dbase.load(new_path, None)
|
||||
|
||||
rdr = GrampsDbUtils.gramps_db_reader_factory(filetype)
|
||||
rdr(dbase, drag_value[7:], None)
|
||||
|
||||
self.__end_cursor()
|
||||
dbase.close()
|
||||
|
||||
return True
|
||||
|
||||
def find_next_db_name(name_list):
|
||||
"""
|
||||
Scan the name list, looking for names that do not yet exist.
|
||||
|
Loading…
x
Reference in New Issue
Block a user