aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Barrucadu <mike@barrucadu.co.uk>2009-05-03 12:21:16 +0100
committerGravatar Barrucadu <mike@barrucadu.co.uk>2009-05-03 12:21:16 +0100
commit7c19691ca1c9c8b191ca8b2670beae33ad81f823 (patch)
treea95e3afebff9d91f7258c7200808ba1f8d24dbbd /uzbl.c
parentd8728e61b587e80efe30f0fc198ed195b8067b3e (diff)
parent83987209217f9b3157c26565fa5521259dea140c (diff)
Merge branch 'dieter/experimental' into experimental
Conflicts: uzbl.c
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c59
1 files changed, 46 insertions, 13 deletions
diff --git a/uzbl.c b/uzbl.c
index b6795f9..debef04 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -479,13 +479,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;
}
@@ -496,18 +509,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) { //TODO: mkfifo blocks (waits for writer)
- printf ("Fifo: disabled. Error when creating %s: %s\n", fifo_path, strerror(errno));
+ if (mkfifo (fifo_path, 0666) == -1) {
+ g_error ("Fifo: 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);
+ 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;
@@ -640,7 +657,7 @@ update_title (void) {
g_free (title_long);
g_free (title_short);
}
-
+
static gboolean
key_press_cb (WebKitWebView* page, GdkEventKey* event)
{
@@ -660,7 +677,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) {
@@ -669,6 +686,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();