* src/gramps_main.py (on_import_activate,on_export_activate):
Add methods. * src/Plugins.py (build_import_menu,build_export_menu): Remove; (register_export): Change to the new scheme. * src/gramps.glade: Add handlers to Import and Export menus. Rename Export to Save As..., add icons. svn: r3232
This commit is contained in:
parent
2fea6471c7
commit
2faa14b1a7
@ -1,3 +1,11 @@
|
|||||||
|
2004-06-24 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
|
* src/gramps_main.py (on_import_activate,on_export_activate):
|
||||||
|
Add methods.
|
||||||
|
* src/Plugins.py (build_import_menu,build_export_menu): Remove;
|
||||||
|
(register_export): Change to the new scheme.
|
||||||
|
* src/gramps.glade: Add handlers to Import and Export menus.
|
||||||
|
Rename Export to Save As..., add icons.
|
||||||
|
|
||||||
2004-06-23 Alex Roitman <shura@alex.neuro.umn.edu>
|
2004-06-23 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
* src/ArgHandler.py (handle_args): Add import callback call.
|
* src/ArgHandler.py (handle_args): Add import callback call.
|
||||||
* src/gramps_main.py: Use open filters, mime types, and handlers
|
* src/gramps_main.py: Use open filters, mime types, and handlers
|
||||||
|
@ -460,18 +460,18 @@ def reload_plugins(obj):
|
|||||||
# Plugin registering
|
# Plugin registering
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def register_export(task, name):
|
def register_export(task, ffilter, pattern_list=None):
|
||||||
"""Register an export filter, taking the task and name"""
|
"""
|
||||||
_exports.append((task, name))
|
Register an export filter, taking the task, file filter,
|
||||||
|
and the list of patterns for the filename matching.
|
||||||
#def register_import(task, name):
|
"""
|
||||||
# """Register an import filter, taking the task and name"""
|
if pattern_list:
|
||||||
# _imports.append((task, name))
|
_exports.append((task, ffilter, pattern_list))
|
||||||
|
|
||||||
def register_import(task, ffilter, mime=None):
|
def register_import(task, ffilter, mime=None):
|
||||||
"""Register an import filter, taking the task and file filter"""
|
"""Register an import filter, taking the task and file filter"""
|
||||||
if mime:
|
if mime:
|
||||||
_imports.append((task, ffilter, mime))
|
_imports.append((task, ffilter, mime))
|
||||||
|
|
||||||
def register_report(task, name,
|
def register_report(task, name,
|
||||||
category=_("Uncategorized"),
|
category=_("Uncategorized"),
|
||||||
@ -641,36 +641,6 @@ def build_report_menu(top_menu,callback):
|
|||||||
def build_tools_menu(top_menu,callback):
|
def build_tools_menu(top_menu,callback):
|
||||||
build_menu(top_menu,_tools,callback)
|
build_menu(top_menu,_tools,callback)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# build_export_menu
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def build_export_menu(top_menu,callback):
|
|
||||||
myMenu = gtk.Menu()
|
|
||||||
|
|
||||||
for report in _exports:
|
|
||||||
item = gtk.MenuItem("%s..." % report[1])
|
|
||||||
item.connect("activate", callback ,report[0])
|
|
||||||
item.show()
|
|
||||||
myMenu.append(item)
|
|
||||||
top_menu.set_submenu(myMenu)
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# build_import_menu
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def build_import_menu(top_menu,callback):
|
|
||||||
myMenu = gtk.Menu()
|
|
||||||
|
|
||||||
for report in _imports:
|
|
||||||
item = gtk.MenuItem("%s..." % report[1])
|
|
||||||
item.connect("activate", callback ,report[0])
|
|
||||||
item.show()
|
|
||||||
myMenu.append(item)
|
|
||||||
top_menu.set_submenu(myMenu)
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# get_text_doc_menu
|
# get_text_doc_menu
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
<accelerator key="N" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="N" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2005">
|
<widget class="GtkImage" id="image2185">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-new</property>
|
<property name="stock">gtk-new</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -78,7 +78,7 @@
|
|||||||
<accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2006">
|
<widget class="GtkImage" id="image2186">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-open</property>
|
<property name="stock">gtk-open</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -98,23 +98,39 @@
|
|||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkMenuItem" id="import1">
|
<widget class="GtkImageMenuItem" id="import1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">_Import</property>
|
<property name="label" translatable="yes">_Import...</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="on_import_activate" last_modification_time="Thu, 24 Jun 2004 20:43:08 GMT"/>
|
||||||
|
<accelerator key="I" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
|
<child internal-child="image">
|
||||||
|
<widget class="GtkImage" id="image2187">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-convert</property>
|
||||||
|
<property name="icon_size">1</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkImageMenuItem" id="export1">
|
<widget class="GtkImageMenuItem" id="export1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">_Export</property>
|
<property name="label" translatable="yes">Save _As...</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="on_export_activate" last_modification_time="Thu, 24 Jun 2004 21:04:14 GMT"/>
|
||||||
|
<accelerator key="S" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2007">
|
<widget class="GtkImage" id="image2188">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-convert</property>
|
<property name="stock">gtk-save-as</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
<property name="xalign">0.5</property>
|
<property name="xalign">0.5</property>
|
||||||
<property name="yalign">0.5</property>
|
<property name="yalign">0.5</property>
|
||||||
@ -140,7 +156,7 @@
|
|||||||
<accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2008">
|
<widget class="GtkImage" id="image2189">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-quit</property>
|
<property name="stock">gtk-quit</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -175,7 +191,7 @@
|
|||||||
<accelerator key="z" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="z" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2009">
|
<widget class="GtkImage" id="image2190">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-undo</property>
|
<property name="stock">gtk-undo</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -212,7 +228,7 @@
|
|||||||
<accelerator key="Insert" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="Insert" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2010">
|
<widget class="GtkImage" id="image2191">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-add</property>
|
<property name="stock">gtk-add</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -235,7 +251,7 @@
|
|||||||
<accelerator key="Delete" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="Delete" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2011">
|
<widget class="GtkImage" id="image2192">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-remove</property>
|
<property name="stock">gtk-remove</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -273,7 +289,7 @@
|
|||||||
<accelerator key="F" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="F" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2012">
|
<widget class="GtkImage" id="image2193">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-find</property>
|
<property name="stock">gtk-find</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -295,7 +311,7 @@
|
|||||||
<accelerator key="M" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="M" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2013">
|
<widget class="GtkImage" id="image2194">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-convert</property>
|
<property name="stock">gtk-convert</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -322,7 +338,7 @@
|
|||||||
<signal name="activate" handler="on_preferences1_activate"/>
|
<signal name="activate" handler="on_preferences1_activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2014">
|
<widget class="GtkImage" id="image2195">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-preferences</property>
|
<property name="stock">gtk-preferences</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -343,7 +359,7 @@
|
|||||||
<signal name="activate" handler="on_column_order_activate" last_modification_time="Wed, 10 Mar 2004 04:36:07 GMT"/>
|
<signal name="activate" handler="on_column_order_activate" last_modification_time="Wed, 10 Mar 2004 04:36:07 GMT"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2015">
|
<widget class="GtkImage" id="image2196">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-properties</property>
|
<property name="stock">gtk-properties</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -364,7 +380,7 @@
|
|||||||
<signal name="activate" handler="on_default_person_activate" last_modification_time="Sat, 16 Aug 2003 01:58:26 GMT"/>
|
<signal name="activate" handler="on_default_person_activate" last_modification_time="Sat, 16 Aug 2003 01:58:26 GMT"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2016">
|
<widget class="GtkImage" id="image2197">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-home</property>
|
<property name="stock">gtk-home</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -450,7 +466,7 @@
|
|||||||
<accelerator key="D" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="D" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2017">
|
<widget class="GtkImage" id="image2198">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-index</property>
|
<property name="stock">gtk-index</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -472,7 +488,7 @@
|
|||||||
<accelerator key="B" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
<accelerator key="B" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2018">
|
<widget class="GtkImage" id="image2199">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gnome-stock-book-open</property>
|
<property name="stock">gnome-stock-book-open</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -545,7 +561,7 @@
|
|||||||
<accelerator key="F1" modifiers="0" signal="activate"/>
|
<accelerator key="F1" modifiers="0" signal="activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2019">
|
<widget class="GtkImage" id="image2200">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-help</property>
|
<property name="stock">gtk-help</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -566,7 +582,7 @@
|
|||||||
<signal name="activate" handler="on_faq_activate" last_modification_time="Wed, 26 Nov 2003 17:59:23 GMT"/>
|
<signal name="activate" handler="on_faq_activate" last_modification_time="Wed, 26 Nov 2003 17:59:23 GMT"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2020">
|
<widget class="GtkImage" id="image2201">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gnome-stock-book-open</property>
|
<property name="stock">gnome-stock-book-open</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -593,7 +609,7 @@
|
|||||||
<signal name="activate" handler="on_gramps_home_page_activate"/>
|
<signal name="activate" handler="on_gramps_home_page_activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2021">
|
<widget class="GtkImage" id="image2202">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-jump-to</property>
|
<property name="stock">gtk-jump-to</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -614,7 +630,7 @@
|
|||||||
<signal name="activate" handler="on_gramps_mailing_lists_activate"/>
|
<signal name="activate" handler="on_gramps_mailing_lists_activate"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2022">
|
<widget class="GtkImage" id="image2203">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gnome-stock-mail</property>
|
<property name="stock">gnome-stock-mail</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
@ -668,7 +684,7 @@
|
|||||||
<signal name="activate" handler="on_about_activate" last_modification_time="Tue, 01 Apr 2003 03:44:24 GMT"/>
|
<signal name="activate" handler="on_about_activate" last_modification_time="Tue, 01 Apr 2003 03:44:24 GMT"/>
|
||||||
|
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="image2023">
|
<widget class="GtkImage" id="image2204">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gnome-stock-about</property>
|
<property name="stock">gnome-stock-about</property>
|
||||||
<property name="icon_size">1</property>
|
<property name="icon_size">1</property>
|
||||||
|
@ -315,6 +315,8 @@ class Gramps:
|
|||||||
"on_notebook1_switch_page" : self.on_views_switch_page,
|
"on_notebook1_switch_page" : self.on_views_switch_page,
|
||||||
"on_ok_button1_clicked" : self.on_ok_button1_clicked,
|
"on_ok_button1_clicked" : self.on_ok_button1_clicked,
|
||||||
"on_open_activate" : self.on_open_activate,
|
"on_open_activate" : self.on_open_activate,
|
||||||
|
"on_import_activate" : self.on_import_activate,
|
||||||
|
"on_export_activate" : self.on_export_activate,
|
||||||
"on_pedigree1_activate" : self.on_pedigree1_activate,
|
"on_pedigree1_activate" : self.on_pedigree1_activate,
|
||||||
"on_person_list1_activate" : self.on_person_list1_activate,
|
"on_person_list1_activate" : self.on_person_list1_activate,
|
||||||
"on_main_key_release_event" : self.on_main_key_release_event,
|
"on_main_key_release_event" : self.on_main_key_release_event,
|
||||||
@ -714,8 +716,6 @@ class Gramps:
|
|||||||
|
|
||||||
Plugins.build_report_menu(self.report_menu,self.menu_report)
|
Plugins.build_report_menu(self.report_menu,self.menu_report)
|
||||||
Plugins.build_tools_menu(self.tools_menu,self.menu_tools)
|
Plugins.build_tools_menu(self.tools_menu,self.menu_tools)
|
||||||
Plugins.build_export_menu(export_menu,self.export_callback)
|
|
||||||
Plugins.build_import_menu(import_menu,self.import_callback)
|
|
||||||
|
|
||||||
self.RelClass = Plugins.relationship_class
|
self.RelClass = Plugins.relationship_class
|
||||||
self.relationship = self.RelClass(self.db)
|
self.relationship = self.RelClass(self.db)
|
||||||
@ -1465,7 +1465,7 @@ class Gramps:
|
|||||||
|
|
||||||
def on_open_activate(self,obj):
|
def on_open_activate(self,obj):
|
||||||
|
|
||||||
choose = gtk.FileChooserDialog('Open GRAMPS database',
|
choose = gtk.FileChooserDialog(_('GRAMPS: Open database'),
|
||||||
self.topWindow,
|
self.topWindow,
|
||||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
(gtk.STOCK_CANCEL,
|
(gtk.STOCK_CANCEL,
|
||||||
@ -1520,6 +1520,115 @@ class Gramps:
|
|||||||
_('The type "%s" is not in the list of known file types') % filetype )
|
_('The type "%s" is not in the list of known file types') % filetype )
|
||||||
choose.destroy()
|
choose.destroy()
|
||||||
|
|
||||||
|
def on_import_activate(self,obj):
|
||||||
|
choose = gtk.FileChooserDialog(_('GRAMPS: Import database'),
|
||||||
|
self.topWindow,
|
||||||
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
|
(gtk.STOCK_CANCEL,
|
||||||
|
gtk.RESPONSE_CANCEL,
|
||||||
|
gtk.STOCK_OPEN,
|
||||||
|
gtk.RESPONSE_OK))
|
||||||
|
|
||||||
|
# Always add automatic (macth all files) filter
|
||||||
|
filter = gtk.FileFilter()
|
||||||
|
filter.set_name(_('Automatic'))
|
||||||
|
filter.add_pattern('*')
|
||||||
|
choose.add_filter(filter)
|
||||||
|
|
||||||
|
# FIXME: Uncomment when we have grdb importer
|
||||||
|
#
|
||||||
|
# # Always add native format filter
|
||||||
|
# filter = gtk.FileFilter()
|
||||||
|
# filter.set_name(_('GRAMPS databases'))
|
||||||
|
# filter.add_mime_type('application/x-gramps')
|
||||||
|
# choose.add_filter(filter)
|
||||||
|
|
||||||
|
for (importData,filter,mime_type) in Plugins._imports:
|
||||||
|
choose.add_filter(filter)
|
||||||
|
|
||||||
|
if GrampsCfg.lastfile:
|
||||||
|
choose.set_filename(GrampsCfg.lastfile)
|
||||||
|
|
||||||
|
response = choose.run()
|
||||||
|
if response == gtk.RESPONSE_OK:
|
||||||
|
filename = choose.get_filename()
|
||||||
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
|
filetype = gnome.vfs.get_mime_type(filename)
|
||||||
|
(junk,the_file) = os.path.split(filename)
|
||||||
|
|
||||||
|
# FIXME: Uncomment when we have grdb importer
|
||||||
|
#
|
||||||
|
# if filetype == 'application/x-gramps':
|
||||||
|
# if self.auto_save_load(filename) == 0:
|
||||||
|
# DbPrompter.DbPrompter(self,0,self.topWindow)
|
||||||
|
# else:
|
||||||
|
if True:
|
||||||
|
opened = 0
|
||||||
|
for (importData,filter,mime_type) in Plugins._imports:
|
||||||
|
if filetype == mime_type or the_file == mime_type:
|
||||||
|
importData(self.db,filename)
|
||||||
|
self.import_tool_callback()
|
||||||
|
opened = 1
|
||||||
|
break
|
||||||
|
if not opened:
|
||||||
|
ErrorDialog( _("Could not open file: %s") % filename,
|
||||||
|
_('The type "%s" is not in the list of known file types') % filetype )
|
||||||
|
choose.destroy()
|
||||||
|
|
||||||
|
def on_export_activate(self,obj):
|
||||||
|
choose = gtk.FileChooserDialog(_('GRAMPS: Export database'),
|
||||||
|
self.topWindow,
|
||||||
|
gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||||
|
(gtk.STOCK_CANCEL,
|
||||||
|
gtk.RESPONSE_CANCEL,
|
||||||
|
gtk.STOCK_OPEN,
|
||||||
|
gtk.RESPONSE_OK))
|
||||||
|
|
||||||
|
# Always add automatic (macth all files) filter
|
||||||
|
filter = gtk.FileFilter()
|
||||||
|
filter.set_name(_('By extension'))
|
||||||
|
filter.add_pattern('*')
|
||||||
|
choose.add_filter(filter)
|
||||||
|
|
||||||
|
# FIXME: Uncomment when we have grdb importer
|
||||||
|
#
|
||||||
|
# # Always add native format filter
|
||||||
|
# filter = gtk.FileFilter()
|
||||||
|
# filter.set_name(_('GRAMPS databases'))
|
||||||
|
# filter.add_mime_type('application/x-gramps')
|
||||||
|
# choose.add_filter(filter)
|
||||||
|
|
||||||
|
for (exportData,filter,pattern_list) in Plugins._exports:
|
||||||
|
choose.add_filter(filter)
|
||||||
|
|
||||||
|
if GrampsCfg.lastfile:
|
||||||
|
choose.set_filename(GrampsCfg.lastfile)
|
||||||
|
|
||||||
|
response = choose.run()
|
||||||
|
if response == gtk.RESPONSE_OK:
|
||||||
|
filename = choose.get_filename()
|
||||||
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
|
(junk,the_file) = os.path.split(filename)
|
||||||
|
|
||||||
|
# FIXME: Uncomment when we have grdb importer
|
||||||
|
#
|
||||||
|
# if filetype == 'application/x-gramps':
|
||||||
|
# if self.auto_save_load(filename) == 0:
|
||||||
|
# DbPrompter.DbPrompter(self,0,self.topWindow)
|
||||||
|
# else:
|
||||||
|
if True:
|
||||||
|
opened = 0
|
||||||
|
for (exportData,filter,pattern_list) in Plugins._exports:
|
||||||
|
for pattern in pattern_list:
|
||||||
|
if filter.filter((filename,None,None,None)):
|
||||||
|
exportData(self.db,filename)
|
||||||
|
opened = 1
|
||||||
|
break
|
||||||
|
if not opened:
|
||||||
|
ErrorDialog( _("Could not write file: %s") % filename,
|
||||||
|
_('The type is not in the list of known file types') )
|
||||||
|
choose.destroy()
|
||||||
|
|
||||||
def on_revert_activate(self,obj):
|
def on_revert_activate(self,obj):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user