Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed functionality of middle-clicking and visual modifications to homepage #123

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ def __page_removed_cb(self, notebook, child, pagenum):
self._update_closing_buttons()
self._update_tab_sizes()

def __new_tab_cb(self, browser, url):
new_browser = self.add_tab(next_to_current=True)
def __new_tab_cb(self, browser, url, maintain_view=False):
new_browser = self.add_tab(next_to_current=True,
maintain_view=maintain_view)
new_browser.load_uri(url)
new_browser.grab_focus()

Expand Down Expand Up @@ -332,7 +333,7 @@ def __crashed_alert_cb(self, alert, response_id, uri):
browser = self.add_tab()
browser.props.uri = uri

def add_tab(self, next_to_current=False):
def add_tab(self, next_to_current=False, maintain_view=False):
browser = Browser(self._activity)
browser.connect('new-tab', self.__new_tab_cb)
browser.connect('web-process-crashed', self.__crashed_cb)
Expand All @@ -343,21 +344,25 @@ def add_tab(self, next_to_current=False):
browser.connect('create', self.__create_web_view_cb)

if next_to_current:
self._insert_tab_next(browser)
self._insert_tab_next(browser, maintain_view)
else:
self._append_tab(browser)
self.emit('focus-url-entry')
if not maintain_view:
self.emit('focus-url-entry')
return browser

def _insert_tab_next(self, browser):
def _insert_tab_next(self, browser, maintain_view=False):
tab_page = TabPage(browser)
label = TabLabel(browser)
label.connect('tab-close', self.__tab_close_cb, tab_page)

next_index = self.get_current_page() + 1
self.insert_page(tab_page, label, next_index)
tab_page.show()
self.set_current_page(next_index)
if maintain_view:
self.set_current_page(next_index - 1)
else:
self.set_current_page(next_index)

def _append_tab(self, browser):
tab_page = TabPage(browser)
Expand Down Expand Up @@ -660,7 +665,7 @@ class Browser(WebKit2.WebView):
__gsignals__ = {
'new-tab': (GObject.SignalFlags.RUN_FIRST,
None,
([str])),
([str, bool])),
'open-pdf': (GObject.SignalFlags.RUN_FIRST,
None,
([str])),
Expand Down Expand Up @@ -804,8 +809,8 @@ def writer(view, result):

self.get_main_resource().get_data(None, writer)

def open_new_tab(self, url):
self.emit('new-tab', url)
def open_new_tab(self, url, maintain_view=False):
self.emit('new-tab', url, maintain_view)

def __run_file_chooser(self, browser, request):
picker = FilePicker(self)
Expand Down Expand Up @@ -847,7 +852,18 @@ def __title_changed_cb(self, widget, param):
self._global_history.set_page_title(uri, title)

def __decide_policy_cb(self, webview, policy_decision, decision_type):
"""Handle downloads and PDF files."""
"""Handle downloads and PDF files and
handles middle-clicking on links"""

if decision_type == WebKit2.PolicyDecisionType.NAVIGATION_ACTION:
navigation_action = policy_decision.get_navigation_action()
request = navigation_action.get_request()
button = navigation_action.get_mouse_button()
if button == 2: # Middle mouse button
uri = request.get_uri()
policy_decision.ignore()
self.open_new_tab(uri, maintain_view=True)
return True

if decision_type != WebKit2.PolicyDecisionType.RESPONSE:
return False
Expand Down
39 changes: 21 additions & 18 deletions data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@
}
</script>
<style type="text/css">
html { margin-right: 8px; margin-left: 8px; font-family: Helvetica, Arial, sans-serif;}
.links-container { padding-bottom: 4px; padding-top: 4px; display: block; text-align: right;}
.link1 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #006e00;}
html { margin-right: 8px; margin-left: 8px; font-family: Helvetica, Arial, sans-serif;}
.links-container { padding-bottom: 4px; padding-top: 4px; display: block; text-align: right;}
.link1 { padding:8px; text-decoration: none; color: #006e00; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link1:hover { color: white; background-color: #006e00;}
.link2 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #033cd2;}
.link2 { padding:8px; text-decoration: none; color: #033cd2; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link2:hover { color: white; background-color: #033cd2;}
.link3 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #006e00;}
.link3 { padding:8px; text-decoration: none; color: #006e00; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link3:hover { color: white; background-color: #006e00;}
.link4 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #033cd2;}
.link4 { padding:8px; text-decoration: none; color: #033cd2; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link4:hover { color: white; background-color: #033cd2;}
.link5 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #6e008c;}
.link5 { padding:8px; text-decoration: none; color: #6e008c; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link5:hover { color: white; background-color: #6e008c;}
.link6 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #a00000;}
.link6 { padding:8px; text-decoration: none; color: #a00000; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link6:hover { color: white; background-color: #a00000;}
.link7 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #033cd2;}
.link7 { padding:8px; text-decoration: none; color: #033cd2; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link7:hover { color: white; background-color: #033cd2;}
.link8 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #6e008c;}
.link8 { padding:8px; text-decoration: none; color: #6e008c; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link8:hover { color: white; background-color: #6e008c;}
.link9 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #6e008c;}
.link9 { padding:8px; text-decoration: none; color: #6e008c; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link9:hover { color: white; background-color: #6e008c;}
.link10 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #033cd2;}
.link10 { padding:8px; text-decoration: none; color: #033cd2; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link10:hover { color: white; background-color: #033cd2;}
.link11 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #006e00;}
.link11 { padding:8px; text-decoration: none; color: #006e00; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link11:hover { color: white; background-color: #006e00; }
.link12 { padding-bottom: 4px; padding-top: 4px; text-decoration: none; color: #033cd2;}
.link12 { padding:8px; text-decoration: none; color: #033cd2; background-color: rgba(211, 211, 211, 0.2); border-radius: 10px; transition: background-color 0.5s;}
.link12:hover { color: white; background-color: #033cd2;}
.center {text-align: center; position: static; border: 0}
.search{background: #FFFFFF; border-radius: 25px; border-width: 1px; border-color: #686868; height: 32px; width: 45%; outline: 0; padding: 0; padding-left: 5px; padding-right: 5px; margin: 0}
.btn{background: #5A89EB; border-radius: 25px; width: 15%; height: 32px; color:#FFFFFF; font-style: normal; border-color: #FFFFFF; padding:0; margin: 0; margin-left: 5px; outline: 0; cursor: pointer}
.search{background: #0000; border-radius: 25px; border-width: 1px; border-color: #686868; height: 32px; width: 45%; outline: 0; padding: 0; padding-left: 5px; padding-right: 5px; margin: 0;}
.btn{background: #4285F4; border-radius: 25px; width: 15%; height: 32px; color:#FFFFFF; font-style: normal; border-color: #FFFFFF; padding:0; margin: 0; margin-left: 5px; outline: 0; cursor: pointer;}
</style>
<title>Sugar Labs</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
Expand All @@ -52,7 +52,10 @@
<body>
<div class="links-container">
<script type="text/javascript" language="JavaScript">
document.write("<a class='" + link_colour() + "' href='https://www.sugarlabs.org/'>sugar labs</a> / <a class='" + link_colour() + "' href='https://wiki.sugarlabs.org/'>wiki</a> / <a class='" + link_colour() + "' href='http://schoolserver/'>school</a> / <a class='" + link_colour() + "' href='https://v4.activities.sugarlabs.org/'>activities</a>")
document.write("<a class='" + link_colour() + "' href='https://www.sugarlabs.org/'>Sugar Labs</a> <a class='" +
link_colour() + "' href='https://wiki.sugarlabs.org/'>Wiki</a> <a class='" +
link_colour() + "' href='http://schoolserver/'>School</a> <a class='" +
link_colour() + "' href='https://v4.activities.sugarlabs.org/'>Activities</a>")
</script>
</div>
<div class="center">
Expand All @@ -67,7 +70,7 @@
<form style="width: 100%" action="http://google.com/search" name="f" target="_top">
<div>
<input class="search" type="search" maxlength="2048" name="q" title="Google Search" value="" autofocus>
<input class= "btn" name="btnG" type="submit" value="Google Search">
<input class="btn" name="btnG" type="submit" value="Google Search">
</div>
</form>
</td></tr>
Expand Down
3 changes: 2 additions & 1 deletion webtoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def _search_update(self):

search_text = self.props.text
for place in places.get_store().search(search_text):
title = '<span weight="bold" >%s</span>' % (GLib.markup_escape_text(place.title))
title = '<span weight="bold" >%s</span>' % \
(GLib.markup_escape_text(place.title))
place.uri = GLib.markup_escape_text(place.uri)
list_store.append([title + '\n' + place.uri, place.uri])

Expand Down