aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Barrucadu <mike@barrucadu.co.uk>2009-04-26 14:17:12 +0100
committerGravatar Barrucadu <mike@barrucadu.co.uk>2009-04-26 14:17:12 +0100
commitb5067190845cf16a12d14c0fedc5e33a17a0c2c6 (patch)
treee9d974d0cd96df025f0ee04450738c9b538fe311 /uzbl.c
parent9474bb8edd588e458dff418e5aaec44cc735f851 (diff)
parent8fd8038469121da41fa8d436dcc47a8fe2f31a63 (diff)
Merge branch 'master' of git://github.com/dusanx/uzbl into dusanx/master
Conflicts: AUTHORS uzbl.c
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/uzbl.c b/uzbl.c
index ca8b40f..c22a5fc 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -30,6 +30,7 @@
#define LENGTH(x) (sizeof x / sizeof x[0])
+#define GDK_Escape 0xff1b
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
@@ -52,7 +53,8 @@ static gchar selected_url[500];
static gchar* history_file = NULL;
static gchar* fifodir = NULL;
static gchar* download_handler = NULL;
-static gboolean always_insert_mode = 0;
+static gboolean always_insert_mode = FALSE;
+static gboolean insert_mode = FALSE;
static gchar* modkey = NULL;
static char fifopath[64];
@@ -115,10 +117,9 @@ link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpoin
//ADD HOVER URL TO WINDOW TITLE
selected_url[0] = '\0';
if (link) {
- strcpy (selected_url, link);
+ strcpy (selected_url, link);
}
update_title (GTK_WINDOW (main_window));
-
}
static void
@@ -247,8 +248,7 @@ static void
}
return NULL;
-}
-
+}
static void
setup_threading () {
@@ -258,7 +258,10 @@ setup_threading () {
static void
update_title (GtkWindow* window) {
- GString* string = g_string_new (main_title);
+ GString* string = g_string_new ("");
+ if (!always_insert_mode)
+ g_string_append (string, (insert_mode ? "[I] " : "[C] "));
+ g_string_append (string, main_title);
g_string_append (string, " - Uzbl browser");
if (load_progress < 100)
g_string_append_printf (string, " (%d%%)", load_progress);
@@ -291,13 +294,32 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event)
if (event->type != GDK_KEY_PRESS)
return result;
- for (i = 0; i < num_internal_bindings; i++) {
- if (event->string[0] == internal_bindings[i].binding[0]) {
- parse_command (internal_bindings[i].action);
- result = FALSE;
- }
+ //TURN OFF INSERT MODE
+ if (insert_mode && (event->keyval == GDK_Escape)) {
+ insert_mode = FALSE;
+ update_title (GTK_WINDOW (main_window));
+ return TRUE;
+ }
+
+ //TURN ON INSERT MODE
+ if (!insert_mode && (event->string[0] == 'i')) {
+ insert_mode = TRUE;
+ update_title (GTK_WINDOW (main_window));
+ return TRUE;
}
+ //INTERNAL KEYS
+ if (always_insert_mode || !insert_mode) {
+ for (i = 0; i < num_internal_bindings; i++) {
+ if (event->string[0] == internal_bindings[i].binding[0]) {
+ parse_command (internal_bindings[i].action);
+ result = TRUE;
+ }
+ }
+ }
+ if (!result)
+ result = (insert_mode ? FALSE : TRUE);
+
return result;
}
@@ -382,12 +404,8 @@ settings_init () {
printf ("Fifo directory: /tmp\n");
}
- always_insert_mode = g_key_file_get_value (config, "behavior", "always_insert_mode", NULL);
- if (always_insert_mode) {
- printf ("Always insert mode: %s\n", always_insert_mode);
- } else {
- printf ("Always insert mode disabled/\n");
- }
+ always_insert_mode = g_key_file_get_boolean (config, "behavior", "always_insert_mode", NULL);
+ printf ("Always insert mode: %s\n", (always_insert_mode ? "TRUE" : "FALSE"));
modkey = g_key_file_get_value (config, "behavior", "modkey", NULL);
if (modkey) {
@@ -421,6 +439,8 @@ main (int argc, char* argv[]) {
g_thread_init (NULL);
settings_init ();
+ if (always_insert_mode)
+ insert_mode = TRUE;
GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), create_mainbar (), FALSE, TRUE, 0);