Geography : add printing functionality for all geography views.

svn: r22652
This commit is contained in:
Serge Noiraud 2013-07-05 17:51:38 +00:00
parent 356351f40c
commit b2c233dc94
8 changed files with 93 additions and 6 deletions

View File

@ -67,6 +67,7 @@ from . import constants
from .osmgps import OsmGps
from .selectionlayer import SelectionLayer
from .placeselection import PlaceSelection
from .cairoprint import CairoPrintSave
#------------------------------------------------------------------------
#
@ -238,6 +239,25 @@ class GeoGraphyView(OsmGps, NavigationView):
"""
return True
def define_actions(self):
"""
Required define_actions function for PageView. Builds the action
group information required.
As this function is overriden in some plugins, we need to call
another method.
"""
NavigationView.define_actions(self)
self.define_print_actions()
def define_print_actions(self):
"""
Associate the print button to the PrintView action.
"""
self._add_action('PrintView', Gtk.STOCK_PRINT, _("_Print..."),
accel="<PRIMARY>P",
tip=_("Print or save the Map"),
callback=self.printview)
def config_connect(self):
"""
Overwriten from :class:`~gui.views.pageview.PageView method
@ -724,6 +744,21 @@ class GeoGraphyView(OsmGps, NavigationView):
mnam = _nd.display(mother) if mother else _("Unknown")
return ( fnam, mnam )
#-------------------------------------------------------------------------
#
# Printing functionalities
#
#-------------------------------------------------------------------------
def printview(self, obj):
"""
Print or save the view that is currently shown
"""
req = self.osm.get_allocation()
widthpx = req.width / 0.70
heightpx = req.height / 0.70
prt = CairoPrintSave(widthpx, heightpx, self.osm.do_draw, self.osm)
prt.run()
#-------------------------------------------------------------------------
#
# Specific functionalities

View File

@ -80,6 +80,11 @@ _UI_DEF = '''\
<separator/>
</placeholder>
</menu>
<menu action="EditMenu">
<placeholder name="CommonEdit">
<menuitem action="PrintView"/>
</placeholder>
</menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
@ -94,6 +99,9 @@ _UI_DEF = '''\
<toolitem action="HomePerson"/>
<toolitem action="RefPerson"/>
</placeholder>
<placeholder name="CommonEdit">
<toolitem action="PrintView"/>
</placeholder>
</toolbar>
</ui>
'''
@ -269,6 +277,7 @@ class GeoClose(GeoGraphyView):
"""
NavigationView.define_actions(self)
self.define_print_actions()
self.ref_person = Gtk.ActionGroup(self.title + '/Selection')
self.ref_person.add_actions([
('RefPerson', 'gramps-person', _('reference _Person'), None ,

View File

@ -82,6 +82,11 @@ _UI_DEF = '''\
<separator/>
</placeholder>
</menu>
<menu action="EditMenu">
<placeholder name="CommonEdit">
<menuitem action="PrintView"/>
</placeholder>
</menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
@ -94,6 +99,9 @@ _UI_DEF = '''\
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit">
<toolitem action="PrintView"/>
</placeholder>
</toolbar>
</ui>
'''

View File

@ -78,6 +78,11 @@ _UI_DEF = '''\
<separator/>
</placeholder>
</menu>
<menu action="EditMenu">
<placeholder name="CommonEdit">
<menuitem action="PrintView"/>
</placeholder>
</menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
@ -92,6 +97,9 @@ _UI_DEF = '''\
<toolitem action="HomePerson"/>
<toolitem action="RefFamily"/>
</placeholder>
<placeholder name="CommonEdit">
<toolitem action="PrintView"/>
</placeholder>
</toolbar>
</ui>
'''
@ -259,6 +267,7 @@ class GeoFamClose(GeoGraphyView):
"""
NavigationView.define_actions(self)
self.define_print_actions()
self.ref_family = Gtk.ActionGroup(self.title + '/Selection')
self.ref_family.add_actions([
('RefFamily', 'gramps-family', _('reference _Family'), None ,

View File

@ -82,6 +82,11 @@ _UI_DEF = '''\
<separator/>
</placeholder>
</menu>
<menu action="EditMenu">
<placeholder name="CommonEdit">
<menuitem action="PrintView"/>
</placeholder>
</menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
@ -94,6 +99,9 @@ _UI_DEF = '''\
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit">
<toolitem action="PrintView"/>
</placeholder>
</toolbar>
</ui>
'''

View File

@ -83,6 +83,11 @@ _UI_DEF = '''\
<separator/>
</placeholder>
</menu>
<menu action="EditMenu">
<placeholder name="CommonEdit">
<menuitem action="PrintView"/>
</placeholder>
</menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
@ -96,6 +101,9 @@ _UI_DEF = '''\
<toolitem action="Forward"/>
<toolitem action="HomePerson"/>
</placeholder>
<placeholder name="CommonEdit">
<toolitem action="PrintView"/>
</placeholder>
</toolbar>
</ui>
'''
@ -211,12 +219,6 @@ class GeoMoves(GeoGraphyView):
self._createmap(p1)
self.uistate.modify_statusbar(self.dbstate)
def define_actions(self):
"""
Define action for the reference family button.
"""
NavigationView.define_actions(self)
def build_tree(self):
"""
This is called by the parent class when the view becomes visible. Since

View File

@ -87,6 +87,11 @@ _UI_DEF = '''\
<separator/>
</placeholder>
</menu>
<menu action="EditMenu">
<placeholder name="CommonEdit">
<menuitem action="PrintView"/>
</placeholder>
</menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
@ -100,6 +105,9 @@ _UI_DEF = '''\
<toolitem action="Forward"/>
<toolitem action="HomePerson"/>
</placeholder>
<placeholder name="CommonEdit">
<toolitem action="PrintView"/>
</placeholder>
</toolbar>
</ui>
'''

View File

@ -82,6 +82,11 @@ _UI_DEF = '''\
<separator/>
</placeholder>
</menu>
<menu action="EditMenu">
<placeholder name="CommonEdit">
<menuitem action="PrintView"/>
</placeholder>
</menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
@ -94,6 +99,9 @@ _UI_DEF = '''\
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit">
<toolitem action="PrintView"/>
</placeholder>
</toolbar>
</ui>
'''