Merge trunk changes

svn: r20750
This commit is contained in:
Nick Hall 2012-12-02 17:59:28 +00:00
parent 0758e411fd
commit 3eb9594a98
5 changed files with 99 additions and 27 deletions

View File

@ -31,7 +31,7 @@ Base view for Place Views
# Global modules # Global modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from __future__ import print_function
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -128,7 +128,7 @@ class PlaceBaseView(ListView):
'<PRIMARY>J' : self.jump, '<PRIMARY>J' : self.jump,
'<PRIMARY>BackSpace' : self.key_delete, '<PRIMARY>BackSpace' : self.key_delete,
}) })
self.maptoolbtn = None
self.additional_uis.append(self.additional_ui()) self.additional_uis.append(self.additional_ui())
def navigation_type(self): def navigation_type(self):
@ -139,11 +139,6 @@ class PlaceBaseView(ListView):
def define_actions(self): def define_actions(self):
ListView.define_actions(self) ListView.define_actions(self)
self._add_toolmenu_action('MapsList', _('Loading...'),
_("Attempt to see selected locations with a Map "
"Service (OpenstreetMap, Google Maps, ...)"),
self.gotomap,
_('Select a Map Service'))
self._add_action('GotoMap', Gtk.STOCK_JUMP_TO, self._add_action('GotoMap', Gtk.STOCK_JUMP_TO,
_('_Look up with Map Service'), _('_Look up with Map Service'),
callback=self.gotomap, callback=self.gotomap,
@ -153,6 +148,13 @@ class PlaceBaseView(ListView):
callback=self.filter_editor) callback=self.filter_editor)
self._add_action('QuickReport', None, _("Quick View"), None, None, None) self._add_action('QuickReport', None, _("Quick View"), None, None, None)
def set_inactive(self):
"""called by viewmanager when moving away from the page
Here we need to remove the menutoolbutton from the menu
"""
tb = self.uistate.viewmanager.uimanager.get_widget('/ToolBar')
tb.remove(self.maptoolbtn)
def change_page(self): def change_page(self):
""" """
Called by viewmanager at end of realization when arriving on the page Called by viewmanager at end of realization when arriving on the page
@ -164,11 +166,18 @@ class PlaceBaseView(ListView):
5. store label so it can be changed when selection changes 5. store label so it can be changed when selection changes
""" """
ListView.change_page(self) ListView.change_page(self)
#menutoolbutton actions are stored in PageView class, #menutoolbutton has to be made and added in correct place on toolbar
# obtain the widgets where we need to add to menu if not self.maptoolbtn:
actionservices = self.action_toolmenu['MapsList'] self.maptoolbtn = Gtk.MenuToolButton.new_from_stock(Gtk.STOCK_JUMP_TO)
widgets = actionservices.get_proxies() self.maptoolbtn.connect('clicked', self.gotomap)
mmenu = self.__create_maps_menu_actions() self.mmenu = self.__create_maps_menu_actions()
self.maptoolbtn.set_menu(self.mmenu)
self.maptoolbtn.show()
tb = self.uistate.viewmanager.uimanager.get_widget('/ToolBar')
ind = tb.get_item_index(self.uistate.viewmanager.uimanager.get_widget(
'/ToolBar/CommonEdit/Merge'))
tb.insert(self.maptoolbtn, ind+1)
widget = self.maptoolbtn
if not self.mapservicedata: if not self.mapservicedata:
return return
@ -176,13 +185,14 @@ class PlaceBaseView(ListView):
self.mapslistlabel = [] self.mapslistlabel = []
if not self.mapservice in self.mapservicedata: if not self.mapservice in self.mapservicedata:
#stored val no longer exists, use the first key instead #stored val no longer exists, use the first key instead
self.set_mapservice(self.mapservicedata.keys()[0]) self.set_mapservice(list(self.mapservicedata.keys())[0])
#store all gtk labels to be able to update label on selection change #store all gtk labels to be able to update label on selection change_('Loading...'),
for widget in widgets : widget.set_menu(self.mmenu)
if isinstance(widget, Gtk.MenuToolButton): widget.set_arrow_tooltip_text(_('Select a Map Service'))
widget.set_menu(mmenu) widget.set_tooltip_text(
widget.set_arrow_tooltip_text(actionservices.arrowtooltip) _("Attempt to see selected locations with a Map "
"Service (OpenstreetMap, Google Maps, ...)"))
lbl = Gtk.Label(label=self.mapservice_label()) lbl = Gtk.Label(label=self.mapservice_label())
lbl.show() lbl.show()
self.mapslistlabel.append(lbl) self.mapslistlabel.append(lbl)
@ -196,7 +206,7 @@ class PlaceBaseView(ListView):
tglist.add(self.drag_info().atom_drag_type, tglist.add(self.drag_info().atom_drag_type,
self.drag_info().target_flags, self.drag_info().target_flags,
self.drag_info().app_id) self.drag_info().app_id)
tglist.add_text_targets (0L) tglist.add_text_targets (0)
self.list.drag_source_set_target_list(tglist) self.list.drag_source_set_target_list(tglist)
def __create_maps_menu_actions(self): def __create_maps_menu_actions(self):
@ -269,7 +279,7 @@ class PlaceBaseView(ListView):
servfunc = eval('mod.' + serv.mapservice) servfunc = eval('mod.' + serv.mapservice)
servfunc()(self.dbstate.db, places) servfunc()(self.dbstate.db, places)
else: else:
print 'Failed to load map plugin, see Plugin Manager' print('Failed to load map plugin, see Plugin Manager')
def drag_info(self): def drag_info(self):
return DdTargets.PLACE_LINK return DdTargets.PLACE_LINK
@ -319,7 +329,6 @@ class PlaceBaseView(ListView):
<toolitem action="Remove"/> <toolitem action="Remove"/>
<toolitem action="Merge"/> <toolitem action="Merge"/>
<separator/> <separator/>
<toolitem action="MapsList"/>
</placeholder> </placeholder>
</toolbar> </toolbar>
<popup name="Popup"> <popup name="Popup">

View File

@ -1,3 +1,24 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#
import sys import sys
if sys.version_info[0] < 3: if sys.version_info[0] < 3:
from urllib2 import (urlopen, Request, HTTPCookieProcessor, from urllib2 import (urlopen, Request, HTTPCookieProcessor,

View File

@ -1,3 +1,24 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#
from .person import * from .person import *
from .family import * from .family import *
from .event import * from .event import *

View File

@ -1,3 +1,24 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#
#### This sets up Django so you can interact with it via the Python #### This sets up Django so you can interact with it via the Python
#### command line. #### command line.
#### Start with something like: #### Start with something like: