Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--browser.py34
-rw-r--r--places.py18
2 files changed, 27 insertions, 25 deletions
diff --git a/browser.py b/browser.py
index 1d4124d..8b7b941 100644
--- a/browser.py
+++ b/browser.py
@@ -19,6 +19,7 @@
import os
import time
import logging
+import urlparse
from gettext import gettext as _
import gobject
@@ -33,8 +34,6 @@ from sugar.graphics import style
import sessionstore
from palettes import ContentInvoker
-#from sessionhistory import HistoryListener
-#from progresslistener import ProgressListener
_ZOOM_AMOUNT = 0.1
@@ -55,9 +54,10 @@ class TabbedView(gtk.Notebook):
self.new_tab()
- def new_tab(self):
+ def new_tab(self, uri=None):
browser = Browser()
self._append_tab(browser)
+ browser.load_uri(uri)
def _append_tab(self, browser):
label = TabLabel(browser)
@@ -74,6 +74,9 @@ class TabbedView(gtk.Notebook):
settings.set_property('user-stylesheet-uri', 'file:///' +
TabbedView.USER_SHEET)
+ # improves browsing on some buggy websites
+ settings.set_property('enable-site-specific-quirks', True)
+
self.append_page(browser, label)
browser.show()
@@ -133,7 +136,9 @@ class TabLabel(gtk.HBox):
gobject.GObject.__init__(self)
self._browser = browser
- self._browser.connect('is-setup', self.__browser_is_setup_cb)
+ self._browser.connect('notify::load-status', self.__browser_is_setup_cb)
+ self._browser.connect('notify::title', self.__title_changed_cb)
+ self._browser.connect('notify::uri', self.__location_changed_cb)
self._label = gtk.Label('')
self.pack_start(self._label)
@@ -160,16 +165,11 @@ class TabLabel(gtk.HBox):
self.__location_changed_cb)
browser.connect('notify::title', self.__title_changed_cb)
- #def __location_changed_cb(self, progress_listener, pspec):
- # uri = progress_listener.location
- # cls = components.classes['@mozilla.org/intl/texttosuburi;1']
- # texttosuburi = cls.getService(interfaces.nsITextToSubURI)
- # ui_uri = texttosuburi.unEscapeURIForUI(uri.originCharset, uri.spec)
- #
- # self._label.set_text(ui_uri)
+ def __location_changed_cb(self, browser):
+ sefl._label.set_text(browser.props.uri)
- #def __title_changed_cb(self, browser, pspec):
- # self._label.set_text(browser.props.title)
+ def __title_changed_cb(self, browser, pspec):
+ self._label.set_text(browser.props.title)
class Browser(webkit.WebView):
@@ -182,7 +182,11 @@ class Browser(webkit.WebView):
#self.progress = ProgressListener()
def load_uri(self, uri):
- pass
+ p_uri = urlparse.urlparse(uri)
+ if p_uri.schema == '' and p_uri.netloc == '':
+ return urlparse.urlparse(p_uri.path, 'http')
+
+ return uri
def get_session(self):
return sessionstore.get_session(self)
@@ -223,7 +227,7 @@ class PopupDialog(gtk.Window):
self.set_default_size(gtk.gdk.screen_width() - border * 2,
gtk.gdk.screen_height() - border * 2)
- self.view = WebView()
+ self.view = webkit.WebView()
self.view.connect('notify::visibility', self.__notify_visibility_cb)
self.add(self.view)
self.view.realize()
diff --git a/places.py b/places.py
index 38fa7b2..19065ca 100644
--- a/places.py
+++ b/places.py
@@ -28,7 +28,6 @@ class Place(object):
self.uri = uri
self.title = None
self.bookmark = False
- self.gecko_flags = 0
self.visits = 0
self.last_visit = datetime.now()
@@ -50,7 +49,6 @@ class SqliteStore(object):
uri text,
title text,
bookmark boolean,
- gecko_flags integer,
visits integer,
last_visit timestamp
);
@@ -63,7 +61,7 @@ class SqliteStore(object):
try:
text = '%' + text + '%'
- cursor.execute('select uri, title, bookmark, gecko_flags, ' \
+ cursor.execute('select uri, title, bookmark, ' \
'visits, last_visit from places ' \
'where uri like ? or title like ? ' \
'order by visits desc limit 0, ?',
@@ -80,10 +78,10 @@ class SqliteStore(object):
try:
cursor.execute('insert into places (uri, title, bookmark, ' \
- 'gecko_flags, visits, last_visit) ' \
- 'values (?, ?, ?, ?, ?, ?)', \
+ 'visits, last_visit) ' \
+ 'values (?, ?, ?, ?, ?)', \
(place.uri, place.title, place.bookmark,
- place.gecko_flags, place.visits, place.last_visit))
+ place.visits, place.last_visit))
self._connection.commit()
finally:
cursor.close()
@@ -92,7 +90,7 @@ class SqliteStore(object):
cursor = self._connection.cursor()
try:
- cursor.execute('select uri, title, bookmark, gecko_flags,visits, ' \
+ cursor.execute('select uri, title, bookmark, visits, ' \
'last_visit from places where uri=?', (uri,))
row = cursor.fetchone()
@@ -107,9 +105,9 @@ class SqliteStore(object):
cursor = self._connection.cursor()
try:
- cursor.execute('update places set title=?, gecko_flags=?, '
+ cursor.execute('update places set title=?, '
'visits=?, last_visit=?, bookmark=? where uri=?',
- (place.title, place.gecko_flags, place.visits,
+ (place.title, place.visits,
place.last_visit, place.bookmark, place.uri))
self._connection.commit()
finally:
@@ -118,7 +116,7 @@ class SqliteStore(object):
def _place_from_row(self, row):
place = Place()
- place.uri, place.title, place.bookmark, place.gecko_flags, \
+ place.uri, place.title, place.bookmark, \
place.visits, place.last_visit = row
return place