From 36e50a408d9544c20d2d2a834ccc430d468969e4 Mon Sep 17 00:00:00 2001 From: Serge Noiraud Date: Sun, 13 Jan 2008 18:36:13 +0000 Subject: [PATCH] Removing GoogleView. Need some more work to be gnome independant. svn: r9795 --- src/DataViews/GoogleView.py | 362 ------------------------------------ src/DataViews/__init__.py | 2 - 2 files changed, 364 deletions(-) delete mode 100644 src/DataViews/GoogleView.py diff --git a/src/DataViews/GoogleView.py b/src/DataViews/GoogleView.py deleted file mode 100644 index 37d11981b..000000000 --- a/src/DataViews/GoogleView.py +++ /dev/null @@ -1,362 +0,0 @@ -# -*- python -*- -# -*- coding: utf-8 -*- -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2001-2007 Donald N. Allingham, Serge Noiraud -# -# 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: GoogleView.py 9598 2007-12-27 15:24:30Z dsblank $ - -#------------------------------------------------------------------------- -# -# Python modules -# -#------------------------------------------------------------------------- -from gettext import gettext as _ -from cgi import escape -import math -import os - -#------------------------------------------------------------------------- -# -# GTK/Gnome modules -# -#------------------------------------------------------------------------- -import gtk - -try: - import cairo - cairo_available = True -except: - cairo_available = False - -#------------------------------------------------------------------------- -# -# Gramps Modules -# -#------------------------------------------------------------------------- -import gen.lib -import PageView -#from BasicUtils import name_displayer -import Utils -#import DateHandler -#import ThumbNails -import Errors -#from ReportBase import ReportUtils -#from Editors import EditPerson, EditFamily -#from DdTargets import DdTargets -#import cPickle as pickle -#import Config -#from QuestionDialog import RunDatabaseRepair, ErrorDialog -try: - import gtkmozembed -except: - pass -import urlparse - - -#------------------------------------------------------------------------- -# -# Constants -# -#------------------------------------------------------------------------- -MOZEMBED_PATH = "/tmp/" -MOZEMBED_SUBPATH = "browser" - -#------------------------------------------------------------------------- -# -# GoogleView -# -#------------------------------------------------------------------------- -class GoogleView(PageView.PersonNavView): - - def __init__(self,dbstate,uistate): - PageView.PersonNavView.__init__(self, _('GoogleView'), dbstate, uistate) - - self.func_list = { - 'J' : self.jump, - } - - self.dbstate = dbstate - - def _on_url(self, widget): - self.m.load_url(widget.get_text()) - - def _quit(self, widget): - gtk.main_quit() - - def set_mozembed_proxy(self): - proxy = os.environ['http_proxy'] - data = "" - if proxy: - host_port = None - parts = urlparse.urlparse(proxy) - if not parts[0] or parts[0] == 'http': - host_port = parts[1] - t = host_port.split(':') - host = t[0].strip() - if host: - try: - port = int(t[1]) - except: - user = host - u = t[1].split('@') - password = u[0] - host = u[1] - port = int(t[2]) - - if port and host: - port = str(port) - data += 'user_pref("network.proxy.type", 1);\r\n' - data += 'user_pref("network.proxy.http", "'+host+'");\r\n' - data += 'user_pref("network.proxy.http_port", '+port+');\r\n' - data += 'user_pref("network.proxy.no_proxies_on", "127.0.0.1,localhost,localhost.localdomain");\r\n' - data += 'user_pref("network.proxy.share_proxy_settings", true);\r\n' - data += 'user_pref("network.http.proxy.pipelining", true);\r\n' - fd = file(MOZEMBED_PATH+MOZEMBED_SUBPATH+"/prefs.js","w+") - fd.write(data) - fd.close() - - def change_page(self): - self.uistate.clear_filter_results() - - def init_parent_signals_cb(self, widget, event): - # required to properly bootstrap the signal handlers. - # This handler is connected by build_widget. After the outside ViewManager - # has placed this widget we are able to access the parent container. - self.notebook.disconnect(self.bootstrap_handler) - self.notebook.parent.connect("size-allocate", self.size_request_cb) - self.size_request_cb(widget.parent,event) - - def add_table_to_notebook( self, table): - frame = gtk.ScrolledWindow(None,None) - frame = gtk.ScrolledWindow(None,None) - frame.set_shadow_type(gtk.SHADOW_NONE) - frame.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) - frame.add_with_viewport(table) - table.get_parent().set_shadow_type(gtk.SHADOW_NONE) - table.set_row_spacings(1) - table.set_col_spacings(0) - try: - self.notebook.append_page(frame,None) - except: - # for PyGtk < 2.4 - self.notebook.append_page(frame,gtk.Label("")) - - def set_active(self): - self.key_active_changed = self.dbstate.connect('active-changed', - self.goto_active_person) - - - def set_inactive(self): - PageView.PersonNavView.set_inactive(self) - self.dbstate.disconnect(self.key_active_changed) - - def get_stock(self): - """ - Returns the name of the stock icon to use for the display. - This assumes that this icon has already been registered with - GNOME as a stock icon. - """ - return 'gramps-place' - - def build_widget(self): - """ - Builds the interface and returns a gtk.Container type that - contains the interface. This containter will be inserted into - a gtk.Notebook page. - """ - self.tooltips = gtk.Tooltips() - self.tooltips.enable() - - self.notebook = gtk.Notebook() - self.notebook.set_show_border(False) - self.notebook.set_show_tabs(False) - - self.table_2 = gtk.Table(1,1,False) - self.add_table_to_notebook( self.table_2) - - if hasattr(gtkmozembed, 'set_profile_path'): - set_profile_path = gtkmozembed.set_profile_path - else: - set_profile_path = gtkmozembed.gtk_moz_embed_set_profile_path - set_profile_path(MOZEMBED_PATH, MOZEMBED_SUBPATH) - self.m = gtkmozembed.MozEmbed() - self.set_mozembed_proxy() - self.m.set_size_request(800,600) - self.table_2.add(self.m) - - #d = {} - #for iteration in dir(self.__class__): - # d[iteration]=getattr(self, iteration) - #ui.signal_autoconnect(d) - self.m.show() - return self.notebook - - def ui_definition(self): - """ - Specifies the UIManager XML code that defines the menus and buttons - associated with the interface. - """ - return ''' - - - - - - ''' - - def define_actions(self): - """ - Required define_actions function for PageView. Builds the action - group information required. We extend beyond the normal here, - since we want to have more than one action group for the PersonView. - Most PageViews really won't care about this. - - Special action groups for Forward and Back are created to allow the - handling of navigation buttons. Forward and Back allow the user to - advance or retreat throughout the history, and we want to have these - be able to toggle these when you are at the end of the history or - at the beginning of the history. - """ - self._add_action('GoogleMaps', gtk.STOCK_JUMP_TO, _('_GoogleMaps'), - callback=self.google_places, - tip=_("Attempt to map places on Google Maps")) - - PageView.PersonNavView.define_actions(self) - - def goto_active_person(self,handle=None): - self.google_places(handle) - - def google_places(self,htmlfile): - htmlfile = MOZEMBED_PATH+"/index.html" - self.createHtml() - self.m.load_url("file://"+htmlfile) - - def createHtml(self): - from PlaceUtils import conv_lat_lon - db=self.dbstate.db - tmpdir = MOZEMBED_PATH - google = "\n" - google += " \n" - google += " \n" - google += " \n" - google += " Google Maps JavaScript API Example\n" - google += " \n" - google += " \n" - google += " \n" - google += " \n" - google += "
\n" - google += " \n" - google += "\n" - fd = file(MOZEMBED_PATH+"/index.html","w+") - fd.write(google) - fd.close() diff --git a/src/DataViews/__init__.py b/src/DataViews/__init__.py index e61c08994..3ba0946e6 100644 --- a/src/DataViews/__init__.py +++ b/src/DataViews/__init__.py @@ -37,7 +37,6 @@ from PlaceView import PlaceView from MediaView import MediaView from RepositoryView import RepositoryView from NoteView import NoteView -from GoogleView import GoogleView try: import Config @@ -57,7 +56,6 @@ except: #MapView, RepositoryView, NoteView, - #GoogleView, ] def get_views():