aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--examples/config/config2
-rwxr-xr-xexamples/data/scripts/uzbl-tabbed118
-rw-r--r--src/callbacks.c3
-rw-r--r--src/callbacks.h3
-rw-r--r--src/events.c7
-rw-r--r--src/events.h2
-rw-r--r--src/uzbl-core.c2
7 files changed, 47 insertions, 90 deletions
diff --git a/examples/config/config b/examples/config/config
index 6c72594..6a01c54 100644
--- a/examples/config/config
+++ b/examples/config/config
@@ -166,7 +166,7 @@ set ebind = @mode_bind global,-insert
# Commands for editing and traversing the keycmd.
@ebind <Return> = event KEYCMD_EXEC_CURRENT
-@ebind <Home> = event SET_CURSOR_POS
+@ebind <Home> = event SET_CURSOR_POS 0
@ebind <End> = event SET_CURSOR_POS -1
@ebind <Left> = event SET_CURSOR_POS -
@ebind <Right> = event SET_CURSOR_POS +
diff --git a/examples/data/scripts/uzbl-tabbed b/examples/data/scripts/uzbl-tabbed
index f07bae4..3112624 100755
--- a/examples/data/scripts/uzbl-tabbed
+++ b/examples/data/scripts/uzbl-tabbed
@@ -163,6 +163,7 @@ import types
from gobject import io_add_watch, source_remove, timeout_add, IO_IN, IO_HUP
from signal import signal, SIGTERM, SIGINT
from optparse import OptionParser, OptionGroup
+from traceback import print_exc
pygtk.require('2.0')
@@ -213,7 +214,6 @@ config = {
# Session options
'save_session': True, # Save session in file when quit
- 'json_session': False, # Use json to save session.
'saved_sessions_dir': os.path.join(DATA_DIR, 'sessions/'),
'session_file': os.path.join(DATA_DIR, 'session'),
@@ -455,10 +455,11 @@ class UzblInstance:
if type == "EVENT":
type, args = args.split(" ", 1)
if type == "TITLE_CHANGED":
- self.title = args
+ self.title = args.strip()
self.title_changed()
elif type == "VARIABLE_SET":
var, _, val = args.split(" ", 2)
+
try:
val = int(val)
except:
@@ -485,7 +486,7 @@ class UzblInstance:
config[var] = val
if var == "uri":
- self.uri = var
+ self.uri = val.strip()
self.parent.update_tablist()
elif type == "NEW_TAB":
self.parent.new_tab(args)
@@ -571,6 +572,7 @@ class UzblTabbed:
self.window.set_default_size(*window_size)
except:
+ print_exc()
error("Invalid value for default_size in config file.")
self.window.set_title("Uzbl Browser")
@@ -672,6 +674,7 @@ class UzblTabbed:
gtk.main()
except:
+ print_exc()
error("encounted error %r" % sys.exc_info()[1])
# Unlink fifo socket
@@ -834,6 +837,7 @@ class UzblTabbed:
self.parse_command(cmd)
except:
+ print_exc()
error("parse_command: invalid command %s" % ' '.join(cmd))
raise
@@ -1237,48 +1241,35 @@ class UzblTabbed:
def save_session(self, session_file=None):
'''Save the current session to file for restoration on next load.'''
- strip = str.strip
-
if session_file is None:
session_file = config['session_file']
tabs = self.tabs.keys()
- state = []
+ lines = "curtab = %d\n" % self.notebook.get_current_page()
for tab in list(self.notebook):
- if tab not in tabs: continue
- uzbl = self.tabs[tab]
- if not uzbl.uri: continue
- state += [(uzbl.uri, uzbl.title),]
+ if tab not in tabs:
+ continue
- session = {'curtab': self.notebook.get_current_page(),
- 'tabs': state}
-
- if config['json_session']:
- raw = json.dumps(session)
-
- else:
- lines = ["curtab = %d" % session['curtab'],]
- for (uri, title) in session['tabs']:
- lines += ["%s\t%s" % (strip(uri), strip(title)),]
+ uzbl = self.tabs[tab]
+ if not uzbl.uri:
+ continue
- raw = "\n".join(lines)
+ lines += "%s %s\n" % (uzbl.uri, uzbl.title)
if not os.path.isfile(session_file):
dirname = os.path.dirname(session_file)
if not os.path.isdir(dirname):
os.makedirs(dirname)
- h = open(session_file, 'w')
- h.write(raw)
- h.close()
+ fh = open(session_file, 'w')
+ fh.write(lines)
+ fh.close()
def load_session(self, session_file=None):
'''Load a saved session from file.'''
default_path = False
- strip = str.strip
- json_session = config['json_session']
delete_loaded = False
if session_file is None:
@@ -1289,50 +1280,34 @@ class UzblTabbed:
if not os.path.isfile(session_file):
return False
- h = open(session_file, 'r')
- raw = h.read()
- h.close()
- if json_session:
- if sum([1 for s in raw.split("\n") if strip(s)]) != 1:
- error("Warning: The session file %r does not look json. "\
- "Trying to load it as a non-json session file."\
- % session_file)
- json_session = False
-
- if json_session:
- try:
- session = json.loads(raw)
- curtab, tabs = session['curtab'], session['tabs']
+ fh = open(session_file, 'r')
+ raw = fh.read()
+ fh.close()
- except:
- error("Failed to load jsonifed session from %r"\
- % session_file)
- return None
+ tabs = []
+ curtab = 0
- else:
- tabs = []
- strip = str.strip
- curtab, tabs = 0, []
- lines = [s for s in raw.split("\n") if strip(s)]
- if len(lines) < 2:
- error("Warning: The non-json session file %r looks invalid."\
- % session_file)
- return None
+ lines = filter(None, map(str.strip, raw.split('\n')))
+ if len(lines) < 2:
+ error("Error: The session file %r looks invalid." % session_file)
+ if delete_loaded and os.path.exists(session_file):
+ os.remove(session_file)
- try:
- for line in lines:
- if line.startswith("curtab"):
- curtab = int(line.split()[-1])
+ return None
- else:
- uri, title = line.split("\t",1)
- tabs += [(strip(uri), strip(title)),]
+ try:
+ for line in lines:
+ if line.startswith("curtab"):
+ curtab = int(line.split()[-1])
- except:
- error("Warning: failed to load session file %r" % session_file)
- return None
+ else:
+ uri, title = map(str.strip, line.split(" ", 1))
+ tabs += [(uri, title),]
- session = {'curtab': curtab, 'tabs': tabs}
+ except:
+ print_exc()
+ error("Warning: failed to load session file %r" % session_file)
+ return None
# Now populate notebook with the loaded session.
for (index, (uri, title)) in enumerate(tabs):
@@ -1342,11 +1317,6 @@ class UzblTabbed:
if delete_loaded and os.path.exists(session_file):
os.remove(session_file)
- # There may be other state information in the session dict of use to
- # other functions. Of course however the non-json session object is
- # just a dummy object of no use to no one.
- return session
-
def quitrequest(self, *args):
'''Attempt to close all uzbl instances nicely and exit.'''
@@ -1412,16 +1382,6 @@ if __name__ == "__main__":
if options.verbose:
config['verbose'] = True
- if config['json_session']:
- try:
- import simplejson as json
-
- except:
- error("Warning: json_session set but cannot import the python "\
- "module simplejson. Fix: \"set json_session = 0\" or "\
- "install the simplejson python module to remove this warning.")
- config['json_session'] = False
-
if config['verbose']:
import pprint
sys.stderr.write("%s\n" % pprint.pformat(config))
diff --git a/src/callbacks.c b/src/callbacks.c
index ae66ba8..d3545cc 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -311,7 +311,7 @@ cmd_view_source() {
void
cmd_set_zoom_type () {
- if(uzbl.behave.zoom_type)
+ if(uzbl.behave.zoom_type)
webkit_web_view_set_full_content_zoom (uzbl.gui.web_view, TRUE);
else
webkit_web_view_set_full_content_zoom (uzbl.gui.web_view, FALSE);
@@ -764,4 +764,3 @@ populate_popup_cb(WebKitWebView *v, GtkMenu *m, void *c) {
}
}
}
-
diff --git a/src/callbacks.h b/src/callbacks.h
index 6ed8986..278a31a 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -1,4 +1,4 @@
-/*
+/*
** Callbacks
** (c) 2009 by Robert Manea et al.
*/
@@ -207,4 +207,3 @@ button_release_cb (GtkWidget* window, GdkEventButton* event);
gboolean
focus_cb(GtkWidget* window, GdkEventFocus* event, void *ud);
-
diff --git a/src/events.c b/src/events.c
index 1028c30..c209550 100644
--- a/src/events.c
+++ b/src/events.c
@@ -1,5 +1,5 @@
-/*
- ** Uzbl event routines
+/*
+ ** Uzbl event routines
** (c) 2009 by Robert Manea
*/
@@ -84,7 +84,7 @@ send_event_socket(GString *msg) {
tmp->str, tmp->len,
&len, &error);
- if (ret == G_IO_STATUS_ERROR)
+ if (ret == G_IO_STATUS_ERROR)
g_warning ("Error sending event to socket: %s", error->message);
else
g_io_channel_flush(gio, &error);
@@ -205,4 +205,3 @@ key_to_event(guint keyval, gint mode) {
}
}
-
diff --git a/src/events.h b/src/events.h
index fe3ff3b..1bd8804 100644
--- a/src/events.h
+++ b/src/events.h
@@ -1,4 +1,4 @@
-/*
+/*
** Uzbl event routines
** (c) 2009 by Robert Manea
*/
diff --git a/src/uzbl-core.c b/src/uzbl-core.c
index 5ee8243..697bd20 100644
--- a/src/uzbl-core.c
+++ b/src/uzbl-core.c
@@ -1011,7 +1011,7 @@ act_dump_config_as_events() {
void
load_uri (WebKitWebView *web_view, GArray *argv, GString *result) {
(void) web_view; (void) result;
- load_uri_imp (argv_idx (argv, 0));
+ set_var_value("uri", argv_idx(argv, 0));
}
/* Javascript*/