aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--AUTHORS3
-rw-r--r--FAQ47
-rw-r--r--INSTALLING60
-rw-r--r--Makefile11
-rw-r--r--README9
-rw-r--r--TODO29
-rw-r--r--examples/configs/sampleconfig20
-rw-r--r--examples/configs/sampleconfig-dev23
-rwxr-xr-xexamples/scripts/insert_bookmark.sh2
-rw-r--r--uzbl.c205
-rw-r--r--uzbl.h106
-rw-r--r--uzblctrl.c1
12 files changed, 385 insertions, 131 deletions
diff --git a/AUTHORS b/AUTHORS
index b57d253..e1e5ca5 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -3,10 +3,13 @@ Developers:
Dieter Plaetinck (Dieter@be) <dieter@plaetinck.be>
Dusan Popovic (dusanx)
Michael Walker (Barrucadu) <mike@barrucadu.co.uk>
+ Přemysl Hrubý, (anydot) <dfenze@gmail.com>
Contributors:
+ Robert Manea - Various improvements
Zane Ashby (HashBox) - Rewrote FIFO interface. Fixed various bugs.
(sentientswitch) - Cleaned up code. Added some commands.
+ Jan Kolkmeier (jouz) - scrolling
Originaly based on http://trac.webkit.org/browser/trunk/WebKitTools/GtkLauncher/main.c
Which is copyrighted:
diff --git a/FAQ b/FAQ
new file mode 100644
index 0000000..5a255b6
--- /dev/null
+++ b/FAQ
@@ -0,0 +1,47 @@
+FAQ
+---
+
+### I just installed uzbl but it doesn't do much. I can load one uri and quit the program but that's it.
+You did not load a configuration. Uzbl does not create a default config file on startup like some other programs do.
+Because we want to give you the freedom to place your config where you want, and to use a config or not.
+Have a look in /usr/share/uzbl/examples/configs.
+Use the --config parameter or save your config as $XDG\_CONFIG\_HOME/uzbl/config to have it auto-loaded.
+
+### Where is the location bar? How do I change the URL ?
+Uzbl has no location bar. All changes to the uri (editing of current uri, typing new uri, loading of uri from bookmarks/history/...) happens *outside* of uzbl.
+Have a look at the sample scripts in /usr/share/uzbl/examples. Most of our examples use dmenu which is a nifty little tool to pick an item from a list of items (very
+useful with history/bookmarks) with a limited set of keystrokes. see man dmenu.
+You can also use it to make edits to a uri (press tab to load it into the
+search field) or type a url from scratch, though dmenu
+is not the most suitable editor. We're looking into a better way to make edits.
+Zenity is also an option, if you want copy-paste support.
+
+### Where are the widgets (forward, back,.. button etc)
+Uzbl's layout only contains what you really need to see. we only have a statusbar, which even can also be disabled. There are no buttons, but we do
+have lots of keybinding possibilities.
+
+### Why can't I type anything in forms? How does the keybinding work?
+You are in command mode, not in insert mode.
+
+* command mode: you can trigger actions inside uzbl with minimum amount of keypresses (eg 'q' to quit) (see config examples), but not to type actual text into forms, because all your keypresses are interpreted.
+* insert mode: after going into insert mode (by default this is the 'i' binding from inside command mode), your keypresses are not interpreted but passed on, so you can enter text into forms. Press Esc to go out of insert mode.
+
+The above method is called "modal" as inspired on VI. If you don't like
+this you can easily change this:
+
+* enable always\_insert\_mode in your config. You will always be in insert mode.
+* configure a modkey. Since your keypresses are not interpreted anymore to trigger actions, you need a modkey to do things (eg alt+'q' to quit instead of just 'q' from command mode)
+
+This method is how many applications work.
+
+Both have their pro's and cons. We don't want to force anyone in using
+either, so by tuning the modkey and always\_insert\_mode settings you can pick
+whichever method you like, or both at the same time (command mode, insert mode, and the modkey to perform actions while in insert mode)
+
+### Why do you depend on gtk?
+Uzbl itself doesn't use much gtk stuff (only the statusbar) so we could do without gtk. But Webkit needs a widget toolkit to create widgets (think javascript popups, html forms etc).
+It also supports QT and wxwigdets. One could argue we don't need no popups or fancy form widgets and you could have a point, but forking webkit would bring us way to far.
+And we don't find the use of gtk *that* disturbing. Besides, a curses/xlib html form wouldn't look too nice, would it?
+
+### What? You call all of this user-friendly?
+Yes. If you don't agree, don't use it :)
diff --git a/INSTALLING b/INSTALLING
index 0d10d24..654bde3 100644
--- a/INSTALLING
+++ b/INSTALLING
@@ -1,23 +1,49 @@
-* Arch Linux:
- pkgbuild @ http://aur.archlinux.org/packages.php?ID=25972
+Arch Linux
+----------
+[Arch Linux](http://www.archlinux.org) is our distro of choice, and the distro we use for testing.
-* From source:
+You can find a [PKGBUILD](http://aur.archlinux.org/packages.php?ID=25972) on the AUR, which installs the latest
+from the master branch. You can edit the PKGBUILD to change to any other
+branch you want.
-$ git clone git://github.com/Dieterbe/uzbl.git
-[ $ git checkout master/experimental ] # master == fairly stable. experimental is more bleeding edge
-$ cd uzbl
-$ make
-$ sudo make install
+From source
+-----------
+ $ git clone git://github.com/Dieterbe/uzbl.git
+ [ $ git checkout master/experimental ] # master == fairly stable. experimental is more bleeding edge
+ $ cd uzbl
+ $ make
+ $ sudo make install
-Dependencies:
-libwebkit 1.1.4 or higher
-gtk 2 something something
-pkgconfig (for Make/gcc)
+Dependencies
+------------
+* git (for building)
+* pkgconfig (for Make/gcc)
+* libwebkit 1.1.4 or higher
+* gtk 2 something something
-Optional:
-dmenu, zenity, bash for the sample scripts
+Optional/Recommended
+--------------------
+The following tools are quite useful, and some of them are used in the
+sample scripts:
-You will have the program in /usr/bin and various sample scripts, a sample config, sample bookmarks file and some documentation in /usr/share/uzbl. You
-will probably want to change the scripts to behave more like you want, so copy the scripts to your home dir. If you save your config as
-$XDG_CONFIG_HOME/uzbl/config (this expands to ~/.config/uzbl/config on most systems) it will be recognized automatically. You can also pass the path to
+* dmenu
+* zenity
+* bash
+
+File locations
+--------------
+After installing - using either method - you will find:
+
+* /usr/bin : uzbl [and uzblctrl]
+* /usr/share/uzbl/docs/ : documentation files included with uzbl. (readme, checklist,..)
+* /usr/share/uzbl/examples: sample scripts, config files and a sample bookmarks file.
+
+You will probably want to change the scripts to behave more like you want, so copy the scripts to your home dir. If you save your config as
+$XDG\_CONFIG\_HOME/uzbl/config (this expands to ~/.config/uzbl/config on most systems) it will be recognized automatically. You can also pass the path to
the config file with the --config parameter.
+
+You're free to store your personal stuff where you want, but we think the [XDG basedir spec](http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html)
+is very useful for keeping a clean home directory, so we recommend:
+
+* $XDG\_CONFIG\_HOME/uzbl/config* (~/.config/uzbl/config on most systems): config file
+* $XDG\_DATA\_HOME/uzbl (~/.local/share/uzbl on most systems): bookmarks file, history file. and "scripts" directory with scripts \ No newline at end of file
diff --git a/Makefile b/Makefile
index fa68594..52d96b6 100644
--- a/Makefile
+++ b/Makefile
@@ -2,13 +2,13 @@ CPPFLAGS=$(shell pkg-config --cflags gtk+-2.0 webkit-1.0) -Wall -W
LDFLAGS=$(shell pkg-config --libs gtk+-2.0 webkit-1.0)
all: uzbl uzblctrl
-test:
+test: uzbl
./uzbl --uri http://www.uzbl.org
-test-config:
+test-config: uzbl
./uzbl --uri http://www.uzbl.org --config examples/configs/sampleconfig-dev
-test-config-real:
+test-config-real: uzbl
./uzbl --uri http://www.uzbl.org --config /usr/share/uzbl/examples/configs/sampleconfig
clean:
@@ -24,3 +24,8 @@ install:
cp -ax examples $(DESTDIR)/usr/share/uzbl/
install -D -m644 CHECKLIST $(DESTDIR)/usr/share/uzbl/docs
install -D -m644 README $(DESTDIR)/usr/share/uzbl/docs
+
+uninstall:
+ rm -rf $(DESTDIR)/usr/bin/uzbl
+ rm -rf $(DESTDIR)/usr/bin/uzblctrl
+ rm -rf $(DESTDIR)/usr/share/uzbl
diff --git a/README b/README
index 31f307a..6c1b23f 100644
--- a/README
+++ b/README
@@ -106,18 +106,17 @@ $2 uzbl-pid
$3 uzbl-x-window-id
$4 uzbl_fifo-filename
$5 uzbl_socket-filename
+$6 current page url
+$7 current page title
.. [ script specific ] (optional)
The script specific arguments are this:
* history:
- $6 page url
- $7 page title
$8 date of visit (Y-m-d H:i:s localtime)
* add bookmark:
- $6 page url
- $7 page title
+ none
* download:
- $6 url
+ $8 url of item to download
KNOWN BUGS
- Segfaults when using zoom commands (happens when max zoom already reached?).
diff --git a/TODO b/TODO
index b4ea639..e22e5f5 100644
--- a/TODO
+++ b/TODO
@@ -1,21 +1,20 @@
ASAP
+* fix bug that causes hang after first fifo command
+
* implement all the ideas from README
* get a logo
-* improve site
* when launching new instance, don't just try 'uzbl' and then './uzbl', rather launch a new uzbl in the same way the current uzbl instance was started. (same command, same arguments, except --uri)
-* where to put proxy config? webkit support?
-* implement XDG basedir spec (config is done, but not cache/data, which I presume we'll need at some point)
-* check configured commands if they end on .sh so users don't need to prepend /bin/<shell>
+* where to put proxy config? webkit support? depend on libsoup?
+* compare libsoup to curl backend. there are probably performance differences
* implement a more advanced dmenu alike that behaves like FF's awesomebar and where you can search in url + window title
* recognize -h with GOption?
* implement a vimperator-like link following scheme. but let user pick his favorite characters to construct the "link identifiers" with.
* add a keybind to hand the current url to an external scrips, so you can edit it and/or store it in the primary and secondary clipboards
-* use http://library.gnome.org/devel/glib/stable/glib-Hash-Tables.html#g-hash-table-insert for tracking bindings and wherever we use structs and ugly loops
-* fifo -> socket. so you can do question-response. socket is slightly more complicated so we'll need to create a uzblctrl (half done - commands can't yet send data back)
+* clean up our structures for settings + sane defaults + don't iterate over struct to fill hasthtable. rather fill hashtable directly
+* implement getting feedback from socket
* select/fork based instead of the pthread stuff -> drops dependency, more lightweight.
-* on website, see if we can <pre><?php include('..'); ?></pre> the documentation inside the uzbl project itself, so we need to maintain the stuff on only 1 place
-* see if we can use the github bugtracker (anonymous posting allowed?)
-* allow user to change bindings for navigation (up,down,left,right, page up, page down etc)and use vim-like defaults
+* scrolling: make page up and page down configurable.
+* show % of location in statusbar/title if page doesn't fit entirely on view.
* put on uzbl.org that you can use http://github.com/Dieterbe/uzbl/issues after registering
* make default size configurable, and optional
* on uzbl.org commits overview: add date+time and repository
@@ -26,24 +25,24 @@ ASAP
* see if/how we can remove /bin/bash from scripts
* unify internal and external bindings.
* unify command triggering, whether they came in through fifo or keybind
-* add to bottom /* vi: set et ts=4: */
* ideal uri editor: awesome mode like FF, some keyb shortcuts (erase search string, go to end/begin of string,..), history (if you patch dmenu to be in vertical mode and you order correctly, that's it), support copy paste
-* get rid of the home page concept. allow user to make keybinds to go to one or more "homepages". a home page is nothing special.
* blinking cursor when not in insert mode is confusing. i suggest dimming it's color if possible
* open in new window -> uzbl: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
-* make it more clear to newbs insert vs command
* note about merging better then patches. because commit names, and code can have changed in meanwhile. also github makes the process quite easy
* check that in new version pageup etc works also in command
* tab key to jump between input fields should probably work in both insert and command mode
* allow to name a uzbl instance, name fifo/socket after it. use xorgwindow id as fallback
* allow to tag , to group instances together
-* document a bit how insert mode, command mode, always_insert_mode, modkey etc work
-* find a simple format (ascii doc, markdow, textile,..) to format uzbl docs (and remain "plaintext") while still being able to generate html for it so we can use them on the website
* allow users to customize order, separating, colors,.. of items in statusbar using pango markup thing
* mention bugtracker in readme, move tickets from github to new bugtracker
-* default value for fifo_dir so we don't need to if(fifo_dir)
+* default value for fifo_dir, socket_dir so we don't need to if(fifo_dir). it will always be set to something?
+* change User-agent to contain uzbl + build date or something. + why is there "Mozilla" in the string
+* backspace key to pop characters from (multichar) command
+* optional logging of http requests, responses with ip/hostname and port. -> how to implement? handler? stdout? (through a socket so you know what corresponds to what?)
+* bench/optimize fifo vs socket performance. measure delays. minimize forks. does glib use a shell? how does it detect the shebang line?
SOMEDAY:
check if we can make the settings loading less hard coded. eg( keep a list of all settings, and for each one, try to load it)
figure out caching with webkit and in general how we can speed up everything
figure out how webkit intercepts key input
+make "disable insert mode" (esc key) configurable
diff --git a/examples/configs/sampleconfig b/examples/configs/sampleconfig
index f6e8688..0f2fa5f 100644
--- a/examples/configs/sampleconfig
+++ b/examples/configs/sampleconfig
@@ -11,8 +11,8 @@
# from insert mode by combining them with the modkey
[behavior]
-history_handler = /bin/bash /usr/share/uzbl/examples/scripts/history.sh
-download_handler = /bin/bash /usr/share/uzbl/examples/scripts/download.sh
+history_handler = /usr/share/uzbl/examples/scripts/history.sh
+download_handler = /usr/share/uzbl/examples/scripts/download.sh
fifo_dir = /tmp
socket_dir = /tmp
always_insert_mode = 0
@@ -21,21 +21,27 @@ show_status = 1
status_top = 0
[bindings]
+j = scroll_down
+k = scroll_up
+h = scroll_left
+l = scroll_right
b = back
m = forward
s = stop
r = refresh
R = reload
-h = uri http://www.uzbl.org
+gh = uri http://www.uzbl.org
f = follow_link_here
F = follow_link_new_tab
w = follow_link_new_window
+ = zoom_in
- = zoom_out
t = toggle_status
-k = exit
-B = spawn /bin/bash /usr/share/uzbl/examples/scripts/insert_bookmark.sh
-u = spawn /bin/bash /usr/share/uzbl/examples/scripts/load_url_from_history.sh
-U = spawn /bin/bash /usr/share/uzbl/examples/scripts/load_url_from_bookmarks.sh
+ZZ = exit
+i = insert_mode
+B = spawn /usr/share/uzbl/examples/scripts/insert_bookmark.sh
+u = spawn /usr/share/uzbl/examples/scripts/load_url_from_history.sh
+U = spawn /usr/share/uzbl/examples/scripts/load_url_from_bookmarks.sh
+
[network]
diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev
index 61ccec9..2d2c5f6 100644
--- a/examples/configs/sampleconfig-dev
+++ b/examples/configs/sampleconfig-dev
@@ -11,8 +11,8 @@
# from insert mode by combining them with the modkey
[behavior]
-history_handler = /bin/bash ./examples/scripts/history.sh
-download_handler = /bin/bash ./examples/scripts/download.sh
+history_handler = ./examples/scripts/history.sh
+download_handler = ./examples/scripts/download.sh
fifo_dir = /tmp
socket_dir = /tmp
always_insert_mode = 0
@@ -21,27 +21,32 @@ show_status = 1
status_top = 0
[bindings]
+j = scroll_down
+k = scroll_up
+h = scroll_left
+l = scroll_right
b = back
m = forward
s = stop
r = refresh
R = reload
-h = uri http://www.uzbl.org
+gh = uri http://www.uzbl.org
f = follow_link_here
F = follow_link_new_tab
w = follow_link_new_window
+ = zoom_in
- = zoom_out
t = toggle_status
-k = exit
-B = spawn /bin/bash ./examples/scripts/insert_bookmark.sh
-u = spawn /bin/bash ./examples/scripts/load_url_from_history.sh
-U = spawn /bin/bash ./examples/scripts/load_url_from_bookmarks.sh
+ZZ = exit
+i = insert_mode
+B = spawn ./examples/scripts/insert_bookmark.sh
+u = spawn ./examples/scripts/load_url_from_history.sh
+U = spawn ./examples/scripts/load_url_from_bookmarks.sh
[network]
-proxy_server =
+proxy_server = http://192.168.1.10:8118
#values 0-3
-http_debug = 0
+http_debug = 1
user-agent = uzbl
max_conns =
max_conns_per_host =
diff --git a/examples/scripts/insert_bookmark.sh b/examples/scripts/insert_bookmark.sh
index be17c05..5d76c35 100755
--- a/examples/scripts/insert_bookmark.sh
+++ b/examples/scripts/insert_bookmark.sh
@@ -10,7 +10,7 @@ fi
which zenity &>/dev/null || exit 2
-entry=`zenity --entry --text="Add bookmark. add tags at the end, separated by commas" --entry-text="$5"`
+entry=`zenity --entry --text="Add bookmark. add tags at the end, separated by commas" --entry-text="$6"`
url=`awk '{print $1}' <<< $entry`
# TODO: check if already exists, if so, and tags are different: ask if you want to replace tags
echo "$entry" >> $file
diff --git a/uzbl.c b/uzbl.c
index e5483df..92278bf 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -36,33 +36,41 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/un.h>
#include <webkit/webkit.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
-#include <sys/types.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <libsoup/soup.h>
+#include "uzbl.h"
/* housekeeping / internal variables */
-static GtkWidget* main_window;
-static GtkWidget* mainbar;
-static GtkWidget* mainbar_label;
+static GtkWidget* main_window;
+static GtkWidget* mainbar;
+static GtkWidget* mainbar_label;
+static GtkScrollbar* scbar_v; // Horizontal and Vertical Scrollbar
+static GtkScrollbar* scbar_h; // (These are still hidden)
+static GtkAdjustment* bar_v; // Information about document length
+static GtkAdjustment* bar_h; // and scrolling position
static WebKitWebView* web_view;
-static gchar* main_title;
-static gchar selected_url[500] = "\0";
-static gint load_progress;
-static Window xwin = 0;
-static char fifo_path[64];
-static char socket_path[108];
+static gchar* main_title;
+static gchar selected_url[500] = "\0";
+static gint load_progress;
+static Window xwin = 0;
+static char fifo_path[64];
+static char socket_path[108];
+static char executable_path[500];
+static GString* keycmd;
/* state variables (initial values coming from command line arguments but may be changed later) */
static gchar* uri = NULL;
@@ -82,17 +90,14 @@ static gboolean status_top = FALSE;
static gchar* modkey = NULL;
static guint modmask = 0;
static guint http_debug = 0;
+static gdouble hscroll = 20;
+static gdouble vscroll = 20;
/* settings from config: group bindings, key -> action */
-static GHashTable *bindings;
+static GHashTable* bindings;
/* command list: name -> Command */
-static GHashTable *commands;
-
-typedef struct {
- char *name;
- char *param;
-} Action;
+static GHashTable* commands;
/* commandline arguments (set initial values for the state variables) */
static GOptionEntry entries[] =
@@ -117,32 +122,6 @@ static char *useragent = NULL;
static gint max_conns;
static gint max_conns_host;
-static void
-update_title (GtkWindow* window);
-
-static void
-load_uri ( WebKitWebView * web_view, const gchar * uri);
-
-static void
-new_window_load_uri (const gchar * uri);
-
-static void
-close_uzbl (WebKitWebView *page, const char *param);
-
-static gboolean
-run_command(const char *command, const char *args);
-
-static void
-spawn(WebKitWebView *web_view, const char *param);
-
-static void
-free_action(gpointer action);
-
-static Action*
-new_action(const gchar *name, const gchar *param);
-
-
-
/* --- CALLBACKS --- */
static gboolean
@@ -184,17 +163,52 @@ download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) {
return (FALSE);
}
+/* scroll a bar in a given direction */
+static void
+scroll (double i, GtkAdjustment* bar) {
+ gtk_adjustment_set_value (bar, gtk_adjustment_get_value(bar)+i);
+}
+
+static void scroll_up (WebKitWebView* page, const char *param) {
+ (void) page;
+ (void) param;
+
+ scroll (-vscroll, bar_v);
+}
+
+static void scroll_left (WebKitWebView* page, const char *param) {
+ (void) page;
+ (void) param;
+
+ scroll (-hscroll, bar_h);
+}
+
+static void scroll_down (WebKitWebView* page, const char *param) {
+ (void) page;
+ (void) param;
+
+ scroll (vscroll, bar_v);
+}
+
+static void scroll_right (WebKitWebView* page, const char *param) {
+ (void) page;
+ (void) param;
+
+ scroll (hscroll, bar_h);
+}
+
static void
toggle_status_cb (WebKitWebView* page, const char *param) {
(void)page;
(void)param;
+
if (show_status) {
gtk_widget_hide(mainbar);
} else {
gtk_widget_show(mainbar);
}
show_status = !show_status;
- update_title (GTK_WINDOW (main_window));
+ update_title();
}
static void
@@ -207,7 +221,7 @@ link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpoin
if (link) {
strcpy (selected_url, link);
}
- update_title (GTK_WINDOW (main_window));
+ update_title();
}
static void
@@ -218,7 +232,7 @@ title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar
if (main_title)
g_free (main_title);
main_title = g_strdup (title);
- update_title (GTK_WINDOW (main_window));
+ update_title();
}
static void
@@ -226,7 +240,7 @@ progress_change_cb (WebKitWebView* page, gint progress, gpointer data) {
(void) page;
(void) data;
load_progress = progress;
- update_title (GTK_WINDOW (main_window));
+ update_title();
}
static void
@@ -255,7 +269,7 @@ log_history_cb () {
timeinfo = localtime ( &rawtime );
strftime (date, 80, "%Y-%m-%d %H:%M:%S", timeinfo);
GString* args = g_string_new ("");
- g_string_printf (args, "'%s' '%s' '%s'", uri, "TODO:page title here", date);
+ g_string_printf (args, "'%s'", date);
run_command(history_handler, args->str);
g_string_free (args, TRUE);
}
@@ -279,6 +293,10 @@ static struct {char *name; Command command;} cmdlist[] =
{
{ "back", view_go_back },
{ "forward", view_go_forward },
+ { "scroll_down", scroll_down },
+ { "scroll_up", scroll_up },
+ { "scroll_left", scroll_left },
+ { "scroll_right", scroll_right },
{ "reload", view_reload, }, //Buggy
{ "refresh", view_reload, }, /* for convenience, will change */
{ "stop", view_stop_loading, },
@@ -288,6 +306,7 @@ static struct {char *name; Command command;} cmdlist[] =
{ "toggle_status", toggle_status_cb },
{ "spawn", spawn },
{ "exit", close_uzbl },
+ { "insert_mode", set_insert_mode }
};
static void
@@ -334,6 +353,15 @@ file_exists (const char * filename) {
return false;
}
+void
+set_insert_mode(WebKitWebView *page, const gchar *param) {
+ (void)page;
+ (void)param;
+
+ insert_mode = TRUE;
+ update_title();
+}
+
static void
load_uri (WebKitWebView * web_view, const gchar *param) {
if (param) {
@@ -348,21 +376,18 @@ load_uri (WebKitWebView * web_view, const gchar *param) {
static void
new_window_load_uri (const gchar * uri) {
GString* to_execute = g_string_new ("");
- if (!config_file) {
- g_string_printf (to_execute, "uzbl --uri '%s'", uri);
- } else {
- g_string_printf (to_execute, "uzbl --uri '%s' --config '%s'", uri, config_file);
- }
- printf("Spawning %s\n",to_execute->str);
- if (!g_spawn_command_line_async (to_execute->str, NULL)) {
- if (!config_file) {
- g_string_printf (to_execute, "./uzbl --uri '%s'", uri);
- } else {
- g_string_printf (to_execute, "./uzbl --uri '%s' --config '%s'", uri, config_file);
+ g_string_append_printf (to_execute, "%s --uri '%s'", executable_path, uri);
+ int i;
+ for (i = 0; entries[i].long_name != NULL; i++) {
+ if ((entries[i].arg == G_OPTION_ARG_STRING) && (strcmp(entries[i].long_name,"uri")!=0)) {
+ gchar** str = (gchar**)entries[i].arg_data;
+ if (*str!=NULL) {
+ g_string_append_printf (to_execute, " --%s '%s'", entries[i].long_name, *str);
+ }
}
- printf("Spawning %s\n",to_execute->str);
- g_spawn_command_line_async (to_execute->str, NULL);
}
+ printf("\n%s\n", to_execute->str);
+ g_spawn_command_line_async (to_execute->str, NULL);
g_string_free (to_execute, TRUE);
}
@@ -380,6 +405,7 @@ run_command(const char *command, const char *args) {
GString* to_execute = g_string_new ("");
gboolean result;
g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s' '%s'", command, config_file, (int) getpid() , (int) xwin, fifo_path, socket_path);
+ g_string_append_printf (to_execute, " '%s' '%s'", uri, "TODO title here");
if(args) {
g_string_append_printf (to_execute, " %s", args);
}
@@ -527,12 +553,15 @@ static void
setup_threading () {
pthread_t control_thread;
pthread_create(&control_thread, NULL, control_socket, NULL);
+ pthread_detach(control_thread);
}
static void
-update_title (GtkWindow* window) {
+update_title (void) {
GString* string_long = g_string_new ("");
GString* string_short = g_string_new ("");
+
+ g_string_append_printf(string_long, "%s ", keycmd->str);
if (!always_insert_mode)
g_string_append (string_long, (insert_mode ? "[I] " : "[C] "));
if (main_title) {
@@ -552,10 +581,10 @@ update_title (GtkWindow* window) {
gchar* title_short = g_string_free (string_short, FALSE);
if (show_status) {
- gtk_window_set_title (window, title_short);
+ gtk_window_set_title (GTK_WINDOW(main_window), title_short);
gtk_label_set_text(GTK_LABEL(mainbar_label), title_long);
} else {
- gtk_window_set_title (window, title_long);
+ gtk_window_set_title (GTK_WINDOW(main_window), title_long);
}
g_free (title_long);
@@ -574,19 +603,36 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event)
|| event->keyval == GDK_Up || event->keyval == GDK_Down || event->keyval == GDK_Left || event->keyval == GDK_Right)
return FALSE;
- //TURN OFF/ON INSERT MODE
- if ((insert_mode && (event->keyval == GDK_Escape)) || (!insert_mode && (event->string[0] == 'i'))) {
- insert_mode = !insert_mode || always_insert_mode;
- update_title (GTK_WINDOW (main_window));
+ /* turn off insert mode (if always_insert_mode is not used) */
+ if (insert_mode && (event->keyval == GDK_Escape)) {
+ insert_mode = always_insert_mode;
+ update_title();
return TRUE;
}
- if ((!insert_mode || (event->state == modmask)) && (action = g_hash_table_lookup(bindings, event->string))) {
- parse_command(action->name, action->param);
+ if (insert_mode && event->state != modmask)
+ return FALSE;
+
+
+ if (event->keyval == GDK_Escape) {
+ g_string_truncate(keycmd, 0);
+
+ update_title();
+
return TRUE;
}
- return !insert_mode;
+ g_string_append(keycmd, event->string);
+
+ if ((action = g_hash_table_lookup(bindings, keycmd->str))) {
+ g_string_truncate(keycmd, 0);
+
+ parse_command(action->name, action->param);
+ }
+
+ update_title();
+
+ return TRUE;
}
static GtkWidget*
@@ -706,7 +752,7 @@ settings_init () {
modkey = g_key_file_get_value (config, "behavior", "modkey", NULL);
status_top = g_key_file_get_boolean (config, "behavior", "status_top", NULL);
if (! fifo_dir)
- fifo_dir = g_key_file_get_value (config, "behavior", "fifodir", NULL);
+ fifo_dir = g_key_file_get_value (config, "behavior", "fifo_dir", NULL);
if (! socket_dir)
socket_dir = g_key_file_get_value (config, "behavior", "socket_dir", NULL);
keys = g_key_file_get_keys (config, "bindings", NULL, NULL);
@@ -802,6 +848,7 @@ main (int argc, char* argv[]) {
g_thread_init (NULL);
printf("Uzbl start location: %s\n", argv[0]);
+ strcpy(executable_path,argv[0]);
strcat ((char *) XDG_CONFIG_HOME_default, getenv ("HOME"));
strcat ((char *) XDG_CONFIG_HOME_default, "/.config");
@@ -815,6 +862,8 @@ main (int argc, char* argv[]) {
bindings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_action);
soup_session = webkit_get_default_session();
+ keycmd = g_string_new("");
+
settings_init ();
commands_hash ();
@@ -839,6 +888,12 @@ main (int argc, char* argv[]) {
printf("window_id %i\n",(int) xwin);
printf("pid %i\n", getpid ());
+ scbar_v = (GtkScrollbar*) gtk_vscrollbar_new (NULL);
+ bar_v = gtk_range_get_adjustment((GtkRange*) scbar_v);
+ scbar_h = (GtkScrollbar*) gtk_hscrollbar_new (NULL);
+ bar_h = gtk_range_get_adjustment((GtkRange*) scbar_h);
+ gtk_widget_set_scroll_adjustments ((GtkWidget*) web_view, bar_h, bar_v);
+
if (!show_status)
gtk_widget_hide(mainbar);
@@ -847,6 +902,8 @@ main (int argc, char* argv[]) {
gtk_main ();
+ g_string_free(keycmd, TRUE);
+
unlink (socket_path);
unlink (fifo_path);
diff --git a/uzbl.h b/uzbl.h
new file mode 100644
index 0000000..7cd35c8
--- /dev/null
+++ b/uzbl.h
@@ -0,0 +1,106 @@
+typedef struct {
+ char* name;
+ char* param;
+} Action;
+
+
+static gboolean
+new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
+
+WebKitWebView*
+create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer user_data);
+
+static gboolean
+download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data);
+
+static void
+toggle_status_cb (WebKitWebView* page, const char *param);
+
+static void
+link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data);
+
+static void
+title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar* title, gpointer data);
+
+static void
+progress_change_cb (WebKitWebView* page, gint progress, gpointer data);
+
+static void
+load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
+
+static void
+destroy_cb (GtkWidget* widget, gpointer data);
+
+static void
+log_history_cb ();
+
+static void
+commands_hash(void);
+
+void
+free_action(gpointer act);
+
+Action*
+new_action(const gchar *name, const gchar *param);
+
+static bool
+file_exists (const char * filename);
+
+void
+set_insert_mode(WebKitWebView *page, const gchar *param);
+
+static void
+load_uri (WebKitWebView * web_view, const gchar *param);
+
+static void
+new_window_load_uri (const gchar * uri);
+
+static void
+close_uzbl (WebKitWebView *page, const char *param);
+
+static gboolean
+run_command(const char *command, const char *args);
+
+static void
+spawn(WebKitWebView *web_view, const char *param);
+
+static void
+parse_command(const char *cmd, const char *param);
+
+static void
+parse_line(char *line);
+
+static void
+control_fifo(GIOChannel *fd);
+
+static void
+create_fifo();
+
+static void
+*control_socket();
+
+static void
+setup_threading ();
+
+static void
+update_title (void);
+
+static gboolean
+key_press_cb (WebKitWebView* page, GdkEventKey* event);
+
+static GtkWidget*
+create_browser ();
+
+static GtkWidget*
+create_mainbar ();
+
+static
+GtkWidget* create_window ();
+
+static void
+add_binding (const gchar *key, const gchar *act);
+
+static void
+settings_init ();
+
+/* vi: set et ts=4: */
diff --git a/uzblctrl.c b/uzblctrl.c
index 5415247..6379606 100644
--- a/uzblctrl.c
+++ b/uzblctrl.c
@@ -61,3 +61,4 @@ main(int argc, char* argv[]) {
return 0;
}
+/* vi: set et ts=4: */