[Sugar-devel] [PATCH] Fix for Follow link in new tab
Manuel Quiñones
manuq at laptop.org
Sun Sep 11 09:33:23 EDT 2011
Proper code, using signals, instead of adding a reference of
TabbedView to Browse objects.
Signed-off-by: Manuel Quiñones <manuq at laptop.org>
---
browser.py | 14 ++++++++++++++
palettes.py | 4 +---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/browser.py b/browser.py
index eac9e6a..e1d8990 100644
--- a/browser.py
+++ b/browser.py
@@ -177,6 +177,7 @@ class TabbedView(BrowserNotebook):
return browser.containerWindow
else:
browser = Browser()
+ browser.connect('new-tab', self.__new_tab_cb)
self._append_tab(browser)
return browser.browser.containerWindow
@@ -192,8 +193,14 @@ class TabbedView(BrowserNotebook):
self._update_closing_buttons()
self._update_tab_sizes()
+ def __new_tab_cb(self, browser, url):
+ new_browser = self.add_tab(next_to_current=True)
+ new_browser.load_uri(url)
+ new_browser.grab_focus()
+
def add_tab(self, next_to_current=False):
browser = Browser()
+ browser.connect('new-tab', self.__new_tab_cb)
label = TabLabel(browser)
label.connect('tab-close', self.__tab_close_cb)
@@ -298,6 +305,7 @@ class TabbedView(BrowserNotebook):
for tab_session in tab_sessions:
browser = Browser()
+ browser.connect('new-tab', self.__new_tab_cb)
self._append_tab(browser)
sessionstore.set_session(browser, tab_session)
@@ -384,6 +392,9 @@ class Browser(WebView):
'is-setup': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
([])),
+ 'new-tab': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ([str])),
}
def __init__(self):
@@ -474,6 +485,9 @@ class Browser(WebView):
return
self.web_navigation.gotoIndex(index)
+ def open_new_tab(self, url):
+ self.emit('new-tab', url)
+
class PopupDialog(gtk.Window):
def __init__(self):
diff --git a/palettes.py b/palettes.py
index 3872c4b..3c8eebb 100644
--- a/palettes.py
+++ b/palettes.py
@@ -169,9 +169,7 @@ class LinkPalette(Palette):
def __follow_activate_cb(self, menu_item, new_tab=False):
if new_tab:
- new_browser = self._browser.tabbed_view.add_tab(next_to_current=True)
- new_browser.load_uri(self._url)
- new_browser.grab_focus()
+ new_browser = self._browser.open_new_tab(self._url)
else:
self._browser.load_uri(self._url)
self._browser.grab_focus()
--
1.7.4.4
More information about the Sugar-devel
mailing list