From 1f8dc39aa795029d85397717821184583d6d62a4 Mon Sep 17 00:00:00 2001 From: DuClare Date: Sat, 16 May 2009 20:09:30 +0300 Subject: Add variable: default_font_size --- uzbl.c | 5 +++++ uzbl.h | 1 + 2 files changed, 6 insertions(+) diff --git a/uzbl.c b/uzbl.c index 5dd1da3..f053301 100644 --- a/uzbl.c +++ b/uzbl.c @@ -80,6 +80,7 @@ const struct { { "fifo_dir", (void *)&uzbl.behave.fifo_dir }, { "socket_dir", (void *)&uzbl.behave.socket_dir }, { "http_debug", (void *)&uzbl.behave.http_debug }, + { "default_font_size", (void *)&uzbl.behave.default_font_size }, { "proxy_url", (void *)&uzbl.net.proxy_url }, { "max_conns", (void *)&uzbl.net.max_conns }, { "max_conns_host", (void *)&uzbl.net.max_conns_host }, @@ -903,6 +904,10 @@ set_var_value(gchar *name, gchar *val) { else if (var_is("status_top", name)) { move_statusbar(); } + else if (var_is("default_font_size", name)) { + WebKitWebSettings *ws = webkit_web_view_get_settings(uzbl.gui.web_view); + g_object_set (G_OBJECT(ws), "default-font-size", *ip, NULL); + } } } return TRUE; diff --git a/uzbl.h b/uzbl.h index 9c8a65a..0b014cc 100644 --- a/uzbl.h +++ b/uzbl.h @@ -136,6 +136,7 @@ typedef struct { gchar* modkey; guint modmask; guint http_debug; + guint default_font_size; /* command list: name -> Command */ GHashTable* commands; -- cgit v1.2.3 From 6c45107e12bc8a3971cad1b0a6d5cd59d4366315 Mon Sep 17 00:00:00 2001 From: DuClare Date: Sat, 16 May 2009 20:12:40 +0300 Subject: Add variable: minimum_font_size --- uzbl.c | 5 +++++ uzbl.h | 1 + 2 files changed, 6 insertions(+) diff --git a/uzbl.c b/uzbl.c index f053301..4b64a09 100644 --- a/uzbl.c +++ b/uzbl.c @@ -81,6 +81,7 @@ const struct { { "socket_dir", (void *)&uzbl.behave.socket_dir }, { "http_debug", (void *)&uzbl.behave.http_debug }, { "default_font_size", (void *)&uzbl.behave.default_font_size }, + { "minimum_font_size", (void *)&uzbl.behave.minimum_font_size }, { "proxy_url", (void *)&uzbl.net.proxy_url }, { "max_conns", (void *)&uzbl.net.max_conns }, { "max_conns_host", (void *)&uzbl.net.max_conns_host }, @@ -908,6 +909,10 @@ set_var_value(gchar *name, gchar *val) { WebKitWebSettings *ws = webkit_web_view_get_settings(uzbl.gui.web_view); g_object_set (G_OBJECT(ws), "default-font-size", *ip, NULL); } + else if (var_is("minimum_font_size", name)) { + WebKitWebSettings *ws = webkit_web_view_get_settings(uzbl.gui.web_view); + g_object_set (G_OBJECT(ws), "minimum-font-size", *ip, NULL); + } } } return TRUE; diff --git a/uzbl.h b/uzbl.h index 0b014cc..0a01328 100644 --- a/uzbl.h +++ b/uzbl.h @@ -137,6 +137,7 @@ typedef struct { guint modmask; guint http_debug; guint default_font_size; + guint minimum_font_size; /* command list: name -> Command */ GHashTable* commands; -- cgit v1.2.3 From 10431d4146cdd27c46db1dc9f2b54cb44fab4797 Mon Sep 17 00:00:00 2001 From: DuClare Date: Sat, 16 May 2009 20:31:49 +0300 Subject: Add action: sh, add var: shell_cmd --- uzbl.c | 14 ++++++++++++++ uzbl.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/uzbl.c b/uzbl.c index 4b64a09..3d86892 100644 --- a/uzbl.c +++ b/uzbl.c @@ -82,6 +82,7 @@ const struct { { "http_debug", (void *)&uzbl.behave.http_debug }, { "default_font_size", (void *)&uzbl.behave.default_font_size }, { "minimum_font_size", (void *)&uzbl.behave.minimum_font_size }, + { "shell_cmd", (void *)&uzbl.behave.shell_cmd }, { "proxy_url", (void *)&uzbl.net.proxy_url }, { "max_conns", (void *)&uzbl.net.max_conns }, { "max_conns_host", (void *)&uzbl.net.max_conns_host }, @@ -401,6 +402,7 @@ static struct {char *name; Command command;} cmdlist[] = { "script", run_js }, { "toggle_status", toggle_status_cb }, { "spawn", spawn }, + { "sh", spawn_sh }, { "exit", close_uzbl }, { "search", search_text }, { "insert_mode", set_insert_mode }, @@ -734,6 +736,14 @@ spawn(WebKitWebView *web_view, const char *param) { run_command(param, NULL, FALSE, NULL); } +static void +spawn_sh(WebKitWebView *web_view, const char *param) { + (void)web_view; + gchar *cmd = g_strdup_printf(uzbl.behave.shell_cmd, param); + spawn(NULL, cmd); + g_free(cmd); +} + static void parse_command(const char *cmd, const char *param) { Command c; @@ -869,6 +879,10 @@ set_var_value(gchar *name, gchar *val) { if(*p) free(*p); *p = set_useragent(g_strdup(val)); } + else if(var_is("shell_cmd", name)) { + if(*p) free(*p); + *p = g_strdup(val); + } /* variables that take int values */ else { int *ip = (int *)p; diff --git a/uzbl.h b/uzbl.h index 0a01328..39d94a3 100644 --- a/uzbl.h +++ b/uzbl.h @@ -138,6 +138,7 @@ typedef struct { guint http_debug; guint default_font_size; guint minimum_font_size; + gchar* shell_cmd; /* command list: name -> Command */ GHashTable* commands; @@ -246,6 +247,9 @@ run_command(const char *command, const char *args, const gboolean sync, char **s static void spawn(WebKitWebView *web_view, const char *param); +static void +spawn_sh(WebKitWebView *web_view, const char *param); + static void parse_command(const char *cmd, const char *param); -- cgit v1.2.3 From e4a23d55521aff58cd0c4b4b4db42f81f869b698 Mon Sep 17 00:00:00 2001 From: DuClare Date: Sat, 16 May 2009 20:51:11 +0300 Subject: Added examples of some new features in sampleconfig-dev --- examples/configs/sampleconfig-dev | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index d196c92..7653407 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -11,6 +11,13 @@ set history_handler = ./examples/scripts/history.sh set download_handler = ./examples/scripts/download.sh set cookie_handler = ./examples/scripts/cookies.sh +set minimum_font_size = 6 +set default_font_size = 11 + +# use with bind ... = sh +# notice the '' - it's a spacer to keep bash and sh from shifting the positional parameters +# by one, so they will appear in the same position as with scripts invoked via spawn +set shell_cmd = sh -c %s '' @@ -44,6 +51,8 @@ bind j = scroll_vert 20 bind k = scroll_vert -20 bind h = scroll_horz -20 bind l = scroll_horz 20 +bind << = scroll_begin +bind >> = scroll_end bind b = back bind m = forward bind s = stop @@ -52,8 +61,9 @@ bind R = reload_ign_cache bind + = zoom_in bind - = zoom_out bind t = toggle_status -#hilight matches -bind /_ = search %s +# Hilight matches. Notice the * after the slash - it makes the command incremental, i.e. gets called +# on every character you type. You can do `bind /_ = search %s' if you want it less interactive. +bind /* = search %s #jump to next bind ; = search bind gh = uri http://www.uzbl.org @@ -68,6 +78,10 @@ bind U = spawn ./examples/scripts/load_url_from_history.sh bind u = spawn ./examples/scripts/load_url_from_bookmarks.sh bind ZZ = exit bind S = script alert("hi"); +# example showing how to use sh +# it sends a command to the fifo, whose path is told via a positional param +# if fifo_dir is not set, it'll echo to a file named (null) somewhere >:) remember to delete it +bind XS = sh 'echo "act script alert (\"This is sent by the shell via a fifo\")" > "$4"' # Keyboard based link following: work in progress! No C DOM bindings yet, no click() event for hyperlinks so no referrer set..Quite basic but does the job for now... #hit F to toggle the Hints (now in form of link numbering) bind F= script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} -- cgit v1.2.3 From b933e2c86926e02c658fdbc74aefbda90e954e8b Mon Sep 17 00:00:00 2001 From: DuClare Date: Sat, 16 May 2009 21:41:31 +0300 Subject: run_command: strip the command and add error reporting --- uzbl.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/uzbl.c b/uzbl.c index 3d86892..3af2901 100644 --- a/uzbl.c +++ b/uzbl.c @@ -713,9 +713,11 @@ static gboolean run_command (const char *command, const char *args, const gboolean sync, char **stdout) { //command [args] GString* to_execute = g_string_new (""); + GError *err = NULL; + gchar* cmd = g_strstrip(g_strdup(command)); gboolean result; g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s' '%s'", - command, (uzbl.state.config_file ? uzbl.state.config_file : "(null)"), + cmd, (uzbl.state.config_file ? uzbl.state.config_file : "(null)"), (int) getpid(), (int) uzbl.xwin, uzbl.comm.fifo_path, uzbl.comm.socket_path); g_string_append_printf (to_execute, " '%s' '%s'", @@ -723,10 +725,15 @@ run_command (const char *command, const char *args, const gboolean sync, char ** if(args) g_string_append_printf (to_execute, " %s", args); if (sync) { - result = g_spawn_command_line_sync (to_execute->str, stdout, NULL, NULL, NULL); - } else result = g_spawn_command_line_async (to_execute->str, NULL); + result = g_spawn_command_line_sync (to_execute->str, stdout, NULL, NULL, &err); + } else result = g_spawn_command_line_async (to_execute->str, &err); printf("Called %s. Result: %s\n", to_execute->str, (result ? "TRUE" : "FALSE" )); g_string_free (to_execute, TRUE); + if (err) { + g_printerr("error on run_command: %s\n", err->message); + g_error_free (err); + } + g_free (cmd); return result; } -- cgit v1.2.3 From 46f674f7d970f12b55afc66e9615445d0d0ba574 Mon Sep 17 00:00:00 2001 From: DuClare Date: Sat, 16 May 2009 21:51:54 +0300 Subject: Free some GError structures --- uzbl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index 3af2901..c029363 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1046,8 +1046,10 @@ control_fifo(GIOChannel *gio, GIOCondition condition) { g_error ("Fifo: GIOChannel broke\n"); ret = g_io_channel_read_line(gio, &ctl_line, NULL, NULL, &err); - if (ret == G_IO_STATUS_ERROR) + if (ret == G_IO_STATUS_ERROR) { g_error ("Fifo: Error reading: %s\n", err->message); + g_error_free (err); + } parse_cmd_line(ctl_line); g_free(ctl_line); @@ -1088,6 +1090,7 @@ init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */ } else g_warning ("init_fifo: can't create %s: file exists\n", path); /* if we got this far, there was an error; cleanup */ + if (error) g_error_free (error); g_free(path); g_free(dir); return NULL; @@ -1130,6 +1133,7 @@ create_stdin () { } else { g_error ("Stdin: Error while opening: %s\n", error->message); } + if (error) g_error_free (error); } static gboolean -- cgit v1.2.3 From 3378bda958e4b536573b24966ea8509a6776784c Mon Sep 17 00:00:00 2001 From: DuClare Date: Sat, 16 May 2009 21:53:00 +0300 Subject: Remove unused code from setup_regex --- uzbl.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/uzbl.c b/uzbl.c index c029363..5b69ef1 100644 --- a/uzbl.c +++ b/uzbl.c @@ -764,18 +764,16 @@ parse_command(const char *cmd, const char *param) { /* command parser */ static void setup_regex() { - GError *err=NULL; - uzbl.comm.get_regex = g_regex_new("^[Gg][a-zA-Z]*\\s+([^ \\n]+)$", - G_REGEX_OPTIMIZE, 0, &err); + G_REGEX_OPTIMIZE, 0, NULL); uzbl.comm.set_regex = g_regex_new("^[Ss][a-zA-Z]*\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", - G_REGEX_OPTIMIZE, 0, &err); + G_REGEX_OPTIMIZE, 0, NULL); uzbl.comm.bind_regex = g_regex_new("^[Bb][a-zA-Z]*\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$", - G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, &err); + G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, NULL); uzbl.comm.act_regex = g_regex_new("^[Aa][a-zA-Z]*\\s+([^ \\n]+)\\s*([^\\n]*)?$", - G_REGEX_OPTIMIZE, 0, &err); + G_REGEX_OPTIMIZE, 0, NULL); uzbl.comm.keycmd_regex = g_regex_new("^[Kk][a-zA-Z]*\\s+([^\\n]+)$", - G_REGEX_OPTIMIZE, 0, &err); + G_REGEX_OPTIMIZE, 0, NULL); } static gboolean -- cgit v1.2.3 From cefa62dafcfb846dc505dfe5bd8c2c6f8ddc28a3 Mon Sep 17 00:00:00 2001 From: DuClare Date: Sat, 16 May 2009 21:57:35 +0300 Subject: Get rid of error ptrs whose contents are not used --- uzbl.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/uzbl.c b/uzbl.c index 5b69ef1..78e6631 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1099,14 +1099,13 @@ control_stdin(GIOChannel *gio, GIOCondition condition) { gchar *ctl_line = NULL; gsize ctl_line_len = 0; GIOStatus ret; - GError *err = NULL; if (condition & G_IO_HUP) { - ret = g_io_channel_shutdown (gio, FALSE, &err); + ret = g_io_channel_shutdown (gio, FALSE, NULL); return FALSE; } - ret = g_io_channel_read_line(gio, &ctl_line, &ctl_line_len, NULL, &err); + ret = g_io_channel_read_line(gio, &ctl_line, &ctl_line_len, NULL, NULL); if ( (ret == G_IO_STATUS_ERROR) || (ret == G_IO_STATUS_EOF) ) return FALSE; @@ -1517,11 +1516,10 @@ settings_init () { if (s->config_file) { GIOChannel *chan = NULL; - GError *error = NULL; gchar *readbuf = NULL; gsize len; - chan = g_io_channel_new_file(s->config_file, "r", &error); + chan = g_io_channel_new_file(s->config_file, "r", NULL); if (chan) { while (g_io_channel_read_line(chan, &readbuf, &len, NULL, NULL) @@ -1603,11 +1601,10 @@ main (int argc, char* argv[]) { strcat ((char *) XDG_CONFIG_HOME_default, getenv ("HOME")); strcat ((char *) XDG_CONFIG_HOME_default, "/.config"); - GError *error = NULL; GOptionContext* context = g_option_context_new ("- some stuff here maybe someday"); g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); - g_option_context_parse (context, &argc, &argv, &error); + g_option_context_parse (context, &argc, &argv, NULL); /* initialize hash table */ uzbl.bindings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_action); -- cgit v1.2.3