aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/uzbl-tabbed
diff options
context:
space:
mode:
Diffstat (limited to 'examples/data/scripts/uzbl-tabbed')
-rwxr-xr-xexamples/data/scripts/uzbl-tabbed30
1 files changed, 25 insertions, 5 deletions
diff --git a/examples/data/scripts/uzbl-tabbed b/examples/data/scripts/uzbl-tabbed
index 7bd90d5..f07bae4 100755
--- a/examples/data/scripts/uzbl-tabbed
+++ b/examples/data/scripts/uzbl-tabbed
@@ -371,8 +371,9 @@ class SocketClient:
class UzblInstance:
'''Uzbl instance meta-data/meta-action object.'''
- def __init__(self, parent, tab, name, uri, title, switch):
+ def __init__(self, parent, tab, name, uri, title, switch, process):
+ self.process = process
self.parent = parent
self.tab = tab
self.name = name
@@ -488,6 +489,13 @@ class UzblInstance:
self.parent.update_tablist()
elif type == "NEW_TAB":
self.parent.new_tab(args)
+ elif type == "NEW_BG_TAB":
+ self.parent.new_tab(args, '', 0)
+ elif type == "NEW_TAB_NEXT":
+ self.parent.new_tab(args, next=True)
+ elif type == "NEW_BG_TAB_NEXT":
+ self.parent.new_tab(args, '', 0, next=True)
+
elif type == "NEXT_TAB":
if args:
self.parent.next_tab(int(args))
@@ -521,6 +529,18 @@ class UzblInstance:
self._client.close()
self._client = None
+ pid = self.process.pid
+ timeout = time.time() + 5
+
+ while self.process.poll() is None and time.time() < timeout:
+ # Sleep between polls.
+ time.sleep(0.1)
+
+ if self.process.poll() is None:
+ # uzbl instance didn't exit in time.
+ error("quit timeout expired, sending SIGTERM to uzbl instance")
+ self.process.terminate()
+
class UzblTabbed:
'''A tabbed version of uzbl using gtk.Notebook'''
@@ -966,7 +986,7 @@ class UzblTabbed:
return False
- def new_tab(self, uri='', title='', switch=None):
+ def new_tab(self, uri='', title='', switch=None, next=False):
'''Add a new tab to the notebook and start a new instance of uzbl.
Use the switch option to negate config['switch_to_new_tabs'] option
when you need to load multiple tabs at a time (I.e. like when
@@ -974,7 +994,7 @@ class UzblTabbed:
tab = gtk.Socket()
tab.show()
- self.notebook.append_page(tab)
+ self.notebook.insert_page(tab, position=next and self.notebook.get_current_page() + 1 or -1)
sid = tab.get_id()
uri = uri.strip()
name = "%d-%d" % (os.getpid(), self.next_pid())
@@ -987,9 +1007,9 @@ class UzblTabbed:
cmd = ['uzbl-browser', '-n', name, '-s', str(sid),
'--connect-socket', self.socket_path, '--uri', uri]
- subprocess.Popen(cmd) # TODO: do i need close_fds=True ?
+ process = subprocess.Popen(cmd) # TODO: do i need close_fds=True ?
- uzbl = UzblInstance(self, tab, name, uri, title, switch)
+ uzbl = UzblInstance(self, tab, name, uri, title, switch, process)
SocketClient.instances_queue[name] = uzbl
self.tabs[tab] = uzbl