From ef63c461326460f5a757c4ff1a79e2086a6a64b6 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 2 May 2009 22:55:14 +0200 Subject: some fixes for socket & fifo. fifo is still broken though --- uzbl.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'uzbl.c') diff --git a/uzbl.c b/uzbl.c index ca4f733..b9e7876 100644 --- a/uzbl.c +++ b/uzbl.c @@ -503,15 +503,24 @@ control_fifo(GIOChannel *fd) { static void create_fifo() { GIOChannel *chan = NULL; + GError *error = NULL; build_stream_name(FIFO); - printf ("Control fifo opened in %s\n", fifo_path); - if (mkfifo (fifo_path, 0666) == -1) { - printf ("Possible error creating fifo\n"); + if (file_exists(fifo_path)) { + printf ("Fifo: disabled. Error when creating %s: File exists\n", fifo_path); + return; + } + if (mkfifo (fifo_path, 0666) == -1) { //TODO: mkfifo blocks (waits for writer) + printf ("Fifo: disabled. Error when creating %s: %s\n", fifo_path, strerror(errno)); + } else { + chan = g_io_channel_new_file((gchar *) fifo_path, "r", &error); + if (chan) { + printf ("Fifo: created successfully as %s\n", fifo_path); + g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, chan); + } else { + g_error ("Fifo: error while opening: %s\n", error->message); + } } - - if( (chan = g_io_channel_new_file((gchar *) fifo_path, "r+", NULL)) ) - g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, chan); return; } @@ -586,16 +595,14 @@ create_socket() { bind (sock, (struct sockaddr *) &local, len); if (errno == -1) { - printf ("Socket: Could not open in %s\n", socket_path); + printf ("Socket: Could not open in %s: %s\n", socket_path, strerror(errno)); } else { printf ("Socket: Opened in %s\n", socket_path); - } - - listen (sock, 5); + listen (sock, 5); - if( (chan = g_io_channel_unix_new(sock)) ) - g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_socket, chan); - + if( (chan = g_io_channel_unix_new(sock)) ) + g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_socket, chan); + } } static void -- cgit v1.2.3 From c77c6157cd33eeff6b0c0e3cb37d36dd13c2c34e Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 2 May 2009 23:01:29 +0200 Subject: make output from bindings nicer --- uzbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'uzbl.c') diff --git a/uzbl.c b/uzbl.c index b9e7876..da81fb3 100644 --- a/uzbl.c +++ b/uzbl.c @@ -778,7 +778,7 @@ add_binding (const gchar *key, const gchar *act) { return; //Debug: - printf ("@%s@ @%s@ @%s@\n", key, parts[0], parts[1]); + printf ("Binding %-10s : %s\n", key, act); action = new_action(parts[0], parts[1]); g_hash_table_insert(bindings, g_strdup(key), action); -- cgit v1.2.3 From d77bbddf2458c0b3ba8c9d4cc3c6214d63d706b8 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 3 May 2009 10:37:08 +0200 Subject: fix for blocking on open(fifo) waiting for a writer --- uzbl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'uzbl.c') diff --git a/uzbl.c b/uzbl.c index da81fb3..7e28f59 100644 --- a/uzbl.c +++ b/uzbl.c @@ -510,10 +510,11 @@ create_fifo() { printf ("Fifo: disabled. Error when creating %s: File exists\n", fifo_path); return; } - if (mkfifo (fifo_path, 0666) == -1) { //TODO: mkfifo blocks (waits for writer) + if (mkfifo (fifo_path, 0666) == -1) { printf ("Fifo: disabled. Error when creating %s: %s\n", fifo_path, strerror(errno)); } else { - chan = g_io_channel_new_file((gchar *) fifo_path, "r", &error); + // we don't really need to write to the file, but if we open the file as 'r' we will block here, waiting for a writer to open the file. + chan = g_io_channel_new_file((gchar *) fifo_path, "r+", &error); if (chan) { printf ("Fifo: created successfully as %s\n", fifo_path); g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, chan); -- cgit v1.2.3 From bf2026cfd20fc2f0a8ea67f6a81816734f625473 Mon Sep 17 00:00:00 2001 From: dusanx Date: Sun, 3 May 2009 11:03:02 +0200 Subject: Insert = paste clipboard, shitf+insert = paste primary --- uzbl.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'uzbl.c') diff --git a/uzbl.c b/uzbl.c index aeb8be0..9c41988 100644 --- a/uzbl.c +++ b/uzbl.c @@ -307,20 +307,20 @@ VIEWFUNC(go_forward) static struct {char *name; Command command;} cmdlist[] = { - { "back", view_go_back }, - { "forward", view_go_forward }, - { "scroll_vert", scroll_vert }, - { "scroll_horz", scroll_horz }, - { "reload", view_reload, }, //Buggy - { "refresh", view_reload, }, /* for convenience, will change */ - { "stop", view_stop_loading, }, - { "zoom_in", view_zoom_in, }, //Can crash (when max zoom reached?). - { "zoom_out", view_zoom_out, }, - { "uri", load_uri }, - { "toggle_status", toggle_status_cb }, - { "spawn", spawn }, - { "exit", close_uzbl }, - { "insert_mode", set_insert_mode } + { "back", view_go_back }, + { "forward", view_go_forward }, + { "scroll_vert", scroll_vert }, + { "scroll_horz", scroll_horz }, + { "reload", view_reload, }, //Buggy + { "refresh", view_reload, }, /* for convenience, will change */ + { "stop", view_stop_loading, }, + { "zoom_in", view_zoom_in, }, //Can crash (when max zoom reached?). + { "zoom_out", view_zoom_out, }, + { "uri", load_uri }, + { "toggle_status", toggle_status_cb }, + { "spawn", spawn }, + { "exit", close_uzbl }, + { "insert_mode", set_insert_mode } }; static void @@ -634,7 +634,7 @@ update_title (void) { g_free (title_long); g_free (title_short); } - + static gboolean key_press_cb (WebKitWebView* page, GdkEventKey* event) { @@ -654,7 +654,7 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event) return TRUE; } - if (insert_mode && event->state != modmask) + if (insert_mode && (event->state & modmask)) return FALSE; if (event->keyval == GDK_Escape) { @@ -663,6 +663,22 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event) return TRUE; } + //Insert without shift - insert from clipboard; Insert with shift - insert from primary + if (event->keyval == GDK_Insert) { + gchar * str; + if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) { + str = gtk_clipboard_wait_for_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY)); + } else { + str = gtk_clipboard_wait_for_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD)); + } + if (str) { + g_string_append_printf (keycmd, "%s", str); + update_title (); + free (str); + } + return TRUE; + } + if ((event->keyval == GDK_BackSpace) && (keycmd->len > 0)) { g_string_truncate(keycmd, keycmd->len - 1); update_title(); -- cgit v1.2.3 From 0536ddbc7d0b2b749664ec148d6a1d3be5973390 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 3 May 2009 11:08:57 +0200 Subject: somewhat improved fifo code. bug still not fixed --- uzbl.c | 34 +++++++++++++++++++++++++--------- uzbl.h | 2 +- 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'uzbl.c') diff --git a/uzbl.c b/uzbl.c index 7e28f59..c28b18c 100644 --- a/uzbl.c +++ b/uzbl.c @@ -490,13 +490,26 @@ build_stream_name(int type) { } static void -control_fifo(GIOChannel *fd) { +control_fifo(GIOChannel *gio, GIOCondition condition) { + printf("triggered\n"); gchar *ctl_line; - if(!fd) - return; - g_io_channel_read_line(fd, &ctl_line, NULL, NULL, NULL); + GIOStatus ret; + GError *err = NULL; + + if (condition & G_IO_HUP) + g_error ("Fifo: Read end of pipe died!\n"); + + if(!gio) + g_error ("Fifo: GIOChannel broke\n"); + + ret = g_io_channel_read_line(gio, &ctl_line, NULL, NULL, &err); + if (ret == G_IO_STATUS_ERROR) + g_error ("Fifo: Error reading: %s\n", err->message); + + parse_line(ctl_line); g_free(ctl_line); + printf("...done\n"); return; } @@ -507,19 +520,22 @@ create_fifo() { build_stream_name(FIFO); if (file_exists(fifo_path)) { - printf ("Fifo: disabled. Error when creating %s: File exists\n", fifo_path); + g_error ("Fifo: Error when creating %s: File exists\n", fifo_path); return; } if (mkfifo (fifo_path, 0666) == -1) { - printf ("Fifo: disabled. Error when creating %s: %s\n", fifo_path, strerror(errno)); + g_error ("Fifo: Error when creating %s: %s\n", fifo_path, strerror(errno)); } else { // we don't really need to write to the file, but if we open the file as 'r' we will block here, waiting for a writer to open the file. chan = g_io_channel_new_file((gchar *) fifo_path, "r+", &error); if (chan) { - printf ("Fifo: created successfully as %s\n", fifo_path); - g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, chan); + if (!g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, NULL)) { + g_error ("Fifo: could not add watch on %s\n", fifo_path); + } else { + printf ("Fifo: created successfully as %s\n", fifo_path); + } } else { - g_error ("Fifo: error while opening: %s\n", error->message); + g_error ("Fifo: Error while opening: %s\n", error->message); } } return; diff --git a/uzbl.h b/uzbl.h index 652f2f0..d0d6ec7 100644 --- a/uzbl.h +++ b/uzbl.h @@ -83,7 +83,7 @@ void build_stream_name(int type); static void -control_fifo(GIOChannel *fd); +control_fifo(GIOChannel *gio, GIOCondition condition); static void create_fifo(); -- cgit v1.2.3 From 871baf52aa5c5a3d0c2e73c26959e202278d40f7 Mon Sep 17 00:00:00 2001 From: dusanx Date: Sun, 3 May 2009 14:49:47 +0200 Subject: Insert mode bugfix --- uzbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'uzbl.c') diff --git a/uzbl.c b/uzbl.c index 4793dd3..ffae493 100644 --- a/uzbl.c +++ b/uzbl.c @@ -688,7 +688,7 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event) return TRUE; } - if (insert_mode && (event->state & modmask)) + if (insert_mode && ((event->state & modmask) != modmask)) return FALSE; if (event->keyval == GDK_Escape) { -- cgit v1.2.3