aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-07-25 19:06:10 +0000
committerGravatar Brendan Taylor <whateley@gmail.com>2011-09-17 17:03:53 +0000
commit65ace942fdabfd6116163a21eec7cd7bbd3cbcb1 (patch)
tree40b1bce4290125bfa3d3695b85fd213f2bb15f77 /src
parent1cbac1d7fb292adc0e3e07d206370aeb5ac8e7e0 (diff)
introduce getter and setter functions.
some variables didn't always have a value reflecting the browser's internal state. for example, if `default_encoding` was never set then `print @default_encoding` would always print a blank string. this introduces getter functions that ensure the value of a variable is always in sync with the internal state of the browser. also: setters, because sometimes you need to process user input before storing it.
Diffstat (limited to 'src')
-rw-r--r--src/callbacks.c16
-rw-r--r--src/commands.c11
-rw-r--r--src/type.h30
-rw-r--r--src/util.c4
-rw-r--r--src/uzbl-core.c24
-rw-r--r--src/uzbl-core.h35
-rw-r--r--src/variables.c602
-rw-r--r--src/variables.h20
8 files changed, 445 insertions, 297 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index 446e868..ae5c2e3 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -8,6 +8,7 @@
#include "events.h"
#include "menu.h"
#include "type.h"
+#include "variables.h"
void
link_hover_cb (WebKitWebView *page, const gchar *title, const gchar *link, gpointer data) {
@@ -113,16 +114,15 @@ destroy_cb (GtkWidget* widget, gpointer data) {
gboolean
configure_event_cb(GtkWidget* window, GdkEventConfigure* event) {
- (void) window;
- (void) event;
- gchar *lastgeo = NULL;
+ (void) window; (void) event;
+
+ gchar *last_geo = uzbl.gui.geometry;
+ gchar *current_geo = get_geometry();
- lastgeo = g_strdup(uzbl.gui.geometry);
- retrieve_geometry();
+ if(!last_geo || strcmp(last_geo, current_geo))
+ send_event(GEOMETRY_CHANGED, NULL, TYPE_STR, current_geo, NULL);
- if(strcmp(lastgeo, uzbl.gui.geometry))
- send_event(GEOMETRY_CHANGED, NULL, TYPE_STR, uzbl.gui.geometry, NULL);
- g_free(lastgeo);
+ g_free(current_geo);
return FALSE;
}
diff --git a/src/commands.c b/src/commands.c
index 7b327e6..8717bd8 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -98,17 +98,18 @@ VIEWFUNC(go_forward)
void
toggle_zoom_type (WebKitWebView* page, GArray *argv, GString *result) {
- (void)argv; (void)result;
- webkit_web_view_set_full_content_zoom (page, !webkit_web_view_get_full_content_zoom (page));
+ (void)page; (void)argv; (void)result;
+
+ int current_type = get_zoom_type();
+ set_zoom_type(!current_type);
}
void
toggle_status (WebKitWebView* page, GArray *argv, GString *result) {
(void)page; (void)argv; (void)result;
- uzbl.behave.show_status = !uzbl.behave.show_status;
-
- set_show_status();
+ int current_status = uzbl.behave.show_status;
+ set_show_status(!current_status);
}
/*
diff --git a/src/type.h b/src/type.h
index 20de0b4..eda02c1 100644
--- a/src/type.h
+++ b/src/type.h
@@ -2,6 +2,9 @@
* Uzbl Types
*/
+#ifndef __UZBL_TYPE__
+#define __UZBL_TYPE__
+
enum ptr_type {
TYPE_INT = 1,
TYPE_STR,
@@ -12,15 +15,30 @@ enum ptr_type {
TYPE_STR_ARRAY
};
+// I'm doing this instead of just using "uzbl_value *" because this way our
+// list of variables can be:
+// { .ptr = { .s = &some_char_star }, ... }
+// instead of
+// { .ptr = (uzbl_value *)&some_char_star, ... }
+// which works here, but I suspect has portability issues.
+typedef union uzbl_value_ptr_t {
+ int *i;
+ float *f;
+ gchar **s;
+} uzbl_value_ptr;
+
+/* a really generic function pointer. */
+typedef void (*uzbl_fp)(void);
+
typedef struct {
enum ptr_type type;
- union {
- int *i;
- float *f;
- gchar **s;
- } ptr;
+ uzbl_value_ptr ptr;
int dump;
int writeable;
- /*@null@*/ void (*func)(void);
+
+ /* the various get_/set_ functions cast these back into something useful. */
+ uzbl_fp getter;
+ uzbl_fp setter;
} uzbl_cmdprop;
+#endif
diff --git a/src/util.c b/src/util.c
index 42ae39e..eab176a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -151,8 +151,8 @@ argv_idx(const GArray *a, const guint idx) {
GString *
append_escaped (GString *dest, const gchar *src) {
- g_assert(dest);
- g_assert(src);
+ g_assert(dest);
+ g_assert(src);
// Hint that we are going to append another string.
int oldlen = dest->len;
diff --git a/src/uzbl-core.c b/src/uzbl-core.c
index b233f8b..8449c28 100644
--- a/src/uzbl-core.c
+++ b/src/uzbl-core.c
@@ -926,21 +926,6 @@ void handle_authentication (SoupSession *session, SoupMessage *msg, SoupAuth *au
}
}
-void
-retrieve_geometry() {
- int w, h, x, y;
- GString *buf = g_string_new("");
-
- gtk_window_get_size(GTK_WINDOW(uzbl.gui.main_window), &w, &h);
- gtk_window_get_position(GTK_WINDOW(uzbl.gui.main_window), &x, &y);
-
- g_string_printf(buf, "%dx%d+%d+%d", w, h, x, y);
-
- if(uzbl.gui.geometry)
- g_free(uzbl.gui.geometry);
- uzbl.gui.geometry = g_string_free(buf, FALSE);
-}
-
/* Set up gtk, gobject, variable defaults and other things that tests and other
* external applications need to do anyhow */
void
@@ -1097,11 +1082,10 @@ main (int argc, char* argv[]) {
builtins();
/* Check uzbl is in window mode before getting/setting geometry */
- if (uzbl.gui.main_window) {
- if (uzbl.gui.geometry)
- set_geometry();
- else
- retrieve_geometry();
+ if (uzbl.gui.main_window && uzbl.gui.geometry) {
+ gchar *geometry = g_strdup(uzbl.gui.geometry);
+ set_geometry(geometry);
+ g_free(geometry);
}
gchar *uri_override = (uzbl.state.uri ? g_strdup(uzbl.state.uri) : NULL);
diff --git a/src/uzbl-core.h b/src/uzbl-core.h
index b5afa3a..1beb11f 100644
--- a/src/uzbl-core.h
+++ b/src/uzbl-core.h
@@ -74,7 +74,6 @@ typedef struct {
WebKitWebView* web_view;
gchar* main_title;
gchar* icon;
- gchar* window_role;
/* WebInspector */
GtkWidget* inspector_window;
@@ -154,49 +153,17 @@ typedef struct {
gchar* scheme_handler;
gchar* download_handler;
- /* Fonts */
- gchar* default_font_family;
- gchar* monospace_font_family;
- gchar* sans_serif_font_family;
- gchar* serif_font_family;
- gchar* fantasy_font_family;
- gchar* cursive_font_family;
-
gboolean forward_keys;
guint http_debug;
gchar* shell_cmd;
guint view_source;
- /* WebKitWebSettings exports */
- guint font_size;
- guint monospace_size;
- guint minimum_font_size;
- gfloat zoom_level;
- gboolean zoom_type;
- guint enable_pagecache;
- guint disable_plugins;
- guint disable_scripts;
- guint autoload_img;
- guint autoshrink_img;
- guint enable_spellcheck;
- gchar* spellcheck_languages;
- guint enable_private;
- guint print_bg;
- gchar* style_uri;
- guint resizable_txt;
- gchar* default_encoding;
- gchar* current_encoding;
- guint enforce_96dpi;
- gchar *inject_html;
- guint caret_browsing;
- guint cross_file_access;
- guint javascript_windows;
gboolean print_version;
/* command list: (key)name -> (value)Command */
GHashTable* commands;
/* variables: (key)name -> (value)uzbl_cmdprop */
- GHashTable *proto_var;
+ GHashTable* proto_var;
} Behaviour;
diff --git a/src/variables.c b/src/variables.c
index cb9523e..272ca50 100644
--- a/src/variables.c
+++ b/src/variables.c
@@ -4,31 +4,34 @@
#include "events.h"
#include "io.h"
#include "util.h"
-#include "type.h"
void
send_set_var_event(const char *name, const uzbl_cmdprop *c) {
/* check for the variable type */
switch(c->type) {
case TYPE_STR:
+ {
+ gchar *v = get_var_value_string_c(c);
send_event (VARIABLE_SET, NULL,
TYPE_NAME, name,
TYPE_NAME, "str",
- TYPE_STR, *c->ptr.s ? *c->ptr.s : " ",
+ TYPE_STR, v,
NULL);
+ g_free(v);
break;
+ }
case TYPE_INT:
send_event (VARIABLE_SET, NULL,
TYPE_NAME, name,
TYPE_NAME, "int",
- TYPE_INT, *c->ptr.i,
+ TYPE_INT, get_var_value_int_c(c),
NULL);
break;
case TYPE_FLOAT:
send_event (VARIABLE_SET, NULL,
TYPE_NAME, name,
TYPE_NAME, "float",
- TYPE_FLOAT, *c->ptr.f,
+ TYPE_FLOAT, get_var_value_float_c(c),
NULL);
break;
default:
@@ -40,79 +43,151 @@ void
expand_variable(GString *buf, const gchar *name) {
uzbl_cmdprop* c;
if((c = g_hash_table_lookup(uzbl.behave.proto_var, name))) {
- if(c->type == TYPE_STR && *c->ptr.s != NULL) {
- g_string_append(buf, (gchar *)*c->ptr.s);
- }
- else if(c->type == TYPE_INT) {
- g_string_append_printf(buf, "%d", *c->ptr.i);
- }
- else if(c->type == TYPE_FLOAT) {
- g_string_append_printf(buf, "%f", *c->ptr.f);
- }
+ if(c->type == TYPE_STR) {
+ gchar *v = get_var_value_string_c(c);
+ g_string_append(buf, v);
+ g_free(v);
+ } else if(c->type == TYPE_INT)
+ g_string_append_printf(buf, "%d", get_var_value_int_c(c));
+ else if(c->type == TYPE_FLOAT)
+ g_string_append_printf(buf, "%f", get_var_value_float_c(c));
}
}
gboolean
set_var_value(const gchar *name, gchar *val) {
uzbl_cmdprop *c = NULL;
- char *endp = NULL;
- char *buf = NULL;
g_assert(val != NULL);
if( (c = g_hash_table_lookup(uzbl.behave.proto_var, name)) ) {
if(!c->writeable) return FALSE;
- switch(c->type) {
- case TYPE_STR:
- buf = g_strdup(val);
- g_free(*c->ptr.s);
- *c->ptr.s = buf;
- break;
- case TYPE_INT:
- *c->ptr.i = (int)strtoul(val, &endp, 10);
- break;
- case TYPE_FLOAT:
- *c->ptr.f = strtod(val, &endp);
- break;
- default:
- g_assert_not_reached();
+ if(c->setter) {
+ switch(c->type) {
+ case TYPE_STR:
+ ((void (*)(const gchar *))c->setter)(val);
+ break;
+ case TYPE_INT:
+ {
+ int i = (int)strtoul(val, NULL, 10);
+ ((void (*)(int))c->setter)(i);
+ break;
+ }
+ case TYPE_FLOAT:
+ {
+ float f = strtod(val, NULL);
+ ((void (*)(float))c->setter)(f);
+ break;
+ }
+ default:
+ g_assert_not_reached();
+ }
+ } else {
+ switch(c->type) {
+ case TYPE_STR:
+ g_free(*(c->ptr.s));
+ *(c->ptr.s) = g_strdup(val);
+ break;
+ case TYPE_INT:
+ *(c->ptr.i) = (int)strtoul(val, NULL, 10);
+ break;
+ case TYPE_FLOAT:
+ *(c->ptr.f) = strtod(val, NULL);
+ break;
+ default:
+ g_assert_not_reached();
+ }
}
send_set_var_event(name, c);
-
- /* invoke a command specific function */
- if(c->func) c->func();
} else {
- /* check wether name violates our naming scheme */
+ /* a custom var that has not been set. */
+ /* check whether name violates our naming scheme */
if(!valid_name(name)) {
if (uzbl.state.verbose)
printf("Invalid variable name: %s\n", name);
return FALSE;
}
- /* custom vars */
+ /* create the cmdprop */
c = g_malloc(sizeof(uzbl_cmdprop));
- c->type = TYPE_STR;
- c->dump = 0;
- c->func = NULL;
- c->writeable = 1;
- buf = g_strdup(val);
- c->ptr.s = g_malloc(sizeof(char *));
- *c->ptr.s = buf;
+ c->type = TYPE_STR;
+ c->dump = 0;
+ c->getter = NULL;
+ c->setter = NULL;
+ c->writeable = 1;
+
+ c->ptr.s = g_malloc(sizeof(gchar*));
+
g_hash_table_insert(uzbl.behave.proto_var,
g_strdup(name), (gpointer) c);
- send_event (VARIABLE_SET, NULL,
- TYPE_NAME, name,
- TYPE_NAME, "str",
- TYPE_STR, buf,
- NULL);
+ /* set the value. */
+ *(c->ptr.s) = g_strdup(val);
+
+ send_set_var_event(name, c);
}
update_title();
return TRUE;
}
+gchar*
+get_var_value_string_c(const uzbl_cmdprop *c) {
+ if(!c) return NULL;
+
+ gchar *result = NULL;
+
+ if(c->getter) {
+ result = ((gchar *(*)())c->getter)();
+ } else if(c->ptr.s)
+ result = g_strdup(*(c->ptr.s));
+
+ return result ? result : g_strdup("");
+}
+
+gchar*
+get_var_value_string(const gchar *name) {
+ uzbl_cmdprop *c = g_hash_table_lookup(uzbl.behave.proto_var, name);
+ return get_var_value_string_c(c);
+}
+
+int
+get_var_value_int_c(const uzbl_cmdprop *c) {
+ if(!c) return 0;
+
+ if(c->getter) {
+ return ((int (*)())c->getter)();
+ } else if(c->ptr.i)
+ return *(c->ptr.i);
+
+ return 0;
+}
+
+int
+get_var_value_int(const gchar *name) {
+ uzbl_cmdprop *c = g_hash_table_lookup(uzbl.behave.proto_var, name);
+ return get_var_value_int_c(c);
+}
+
+float
+get_var_value_float_c(const uzbl_cmdprop *c) {
+ if(!c) return 0;
+
+ if(c->getter) {
+ return ((float (*)())c->getter)();
+ } else if(c->ptr.f)
+ return *(c->ptr.f);
+
+ return 0;
+}
+
+float
+get_var_value_float(const gchar *name) {
+ uzbl_cmdprop *c = g_hash_table_lookup(uzbl.behave.proto_var, name);
+ return get_var_value_float_c(c);
+}
+
void
dump_var_hash(gpointer k, gpointer v, gpointer ud) {
(void) ud;
@@ -121,12 +196,14 @@ dump_var_hash(gpointer k, gpointer v, gpointer ud) {
if(!c->dump)
return;
- if(c->type == TYPE_STR)
- printf("set %s = %s\n", (char *)k, *c->ptr.s ? *c->ptr.s : " ");
- else if(c->type == TYPE_INT)
- printf("set %s = %d\n", (char *)k, *c->ptr.i);
+ if(c->type == TYPE_STR) {
+ gchar *v = get_var_value_string_c(c);
+ printf("set %s = %s\n", (char *)k, v);
+ g_free(v);
+ } else if(c->type == TYPE_INT)
+ printf("set %s = %d\n", (char *)k, get_var_value_int_c(c));
else if(c->type == TYPE_FLOAT)
- printf("set %s = %f\n", (char *)k, *c->ptr.f);
+ printf("set %s = %f\n", (char *)k, get_var_value_float_c(c));
}
void
@@ -186,7 +263,9 @@ uri_change_cb (WebKitWebView *web_view, GParamSpec param_spec) {
}
void
-cmd_load_uri() {
+set_uri(const gchar *val) {
+ g_free(uzbl.state.uri);
+ uzbl.state.uri = g_strdup(val);
const gchar *uri = uzbl.state.uri;
gchar *newuri;
@@ -238,19 +317,25 @@ cmd_load_uri() {
}
void
-cmd_max_conns() {
+set_max_conns(int max_conns) {
+ uzbl.net.max_conns = max_conns;
+
g_object_set(G_OBJECT(uzbl.net.soup_session),
SOUP_SESSION_MAX_CONNS, uzbl.net.max_conns, NULL);
}
void
-cmd_max_conns_host() {
+set_max_conns_host(int max_conns_host) {
+ uzbl.net.max_conns_host = max_conns_host;
+
g_object_set(G_OBJECT(uzbl.net.soup_session),
SOUP_SESSION_MAX_CONNS_PER_HOST, uzbl.net.max_conns_host, NULL);
}
void
-cmd_http_debug() {
+set_http_debug(int debug) {
+ uzbl.behave.http_debug = debug;
+
if(uzbl.net.soup_logger) {
soup_session_remove_feature
(uzbl.net.soup_session, SOUP_SESSION_FEATURE(uzbl.net.soup_logger));
@@ -262,67 +347,57 @@ cmd_http_debug() {
SOUP_SESSION_FEATURE(uzbl.net.soup_logger));
}
-void
-cmd_font_size() {
- GObject *ws = view_settings();
- if (uzbl.behave.font_size > 0) {
- g_object_set (ws, "default-font-size", uzbl.behave.font_size, NULL);
- }
-
- if (uzbl.behave.monospace_size > 0) {
- g_object_set (ws, "default-monospace-font-size",
- uzbl.behave.monospace_size, NULL);
- } else {
- g_object_set (ws, "default-monospace-font-size",
- uzbl.behave.font_size, NULL);
- }
-}
-
-void
-cmd_zoom_level() {
- webkit_web_view_set_zoom_level (uzbl.gui.web_view, uzbl.behave.zoom_level);
+#define EXPOSE_WEBKIT_VIEW_SETTINGS(SYM, PROPERTY, TYPE) \
+void set_##SYM(TYPE val) { \
+ g_object_set(view_settings(), (PROPERTY), val, NULL); \
+} \
+TYPE get_##SYM() { \
+ TYPE val; \
+ g_object_get(view_settings(), (PROPERTY), &val, NULL); \
+ return val; \
}
-#define EXPOSE_WEBKIT_VIEW_SETTINGS(SYM, STORAGE, PROPERTY) void cmd_##SYM() { \
- g_object_set(view_settings(), (PROPERTY), (STORAGE), NULL); \
-}
-
-EXPOSE_WEBKIT_VIEW_SETTINGS(default_font_family, uzbl.behave.default_font_family, "default-font-family")
-EXPOSE_WEBKIT_VIEW_SETTINGS(monospace_font_family, uzbl.behave.monospace_font_family, "monospace-font-family")
-EXPOSE_WEBKIT_VIEW_SETTINGS(sans_serif_font_family, uzbl.behave.sans_serif_font_family, "sans_serif-font-family")
-EXPOSE_WEBKIT_VIEW_SETTINGS(serif_font_family, uzbl.behave.serif_font_family, "serif-font-family")
-EXPOSE_WEBKIT_VIEW_SETTINGS(cursive_font_family, uzbl.behave.cursive_font_family, "cursive-font-family")
-EXPOSE_WEBKIT_VIEW_SETTINGS(fantasy_font_family, uzbl.behave.fantasy_font_family, "fantasy-font-family")
+EXPOSE_WEBKIT_VIEW_SETTINGS(default_font_family, "default-font-family", gchar *)
+EXPOSE_WEBKIT_VIEW_SETTINGS(monospace_font_family, "monospace-font-family", gchar *)
+EXPOSE_WEBKIT_VIEW_SETTINGS(sans_serif_font_family, "sans_serif-font-family", gchar *)
+EXPOSE_WEBKIT_VIEW_SETTINGS(serif_font_family, "serif-font-family", gchar *)
+EXPOSE_WEBKIT_VIEW_SETTINGS(cursive_font_family, "cursive-font-family", gchar *)
+EXPOSE_WEBKIT_VIEW_SETTINGS(fantasy_font_family, "fantasy-font-family", gchar *)
-EXPOSE_WEBKIT_VIEW_SETTINGS(minimum_font_size, uzbl.behave.minimum_font_size, "minimum_font_size")
+EXPOSE_WEBKIT_VIEW_SETTINGS(minimum_font_size, "minimum-font-size", int)
+EXPOSE_WEBKIT_VIEW_SETTINGS(font_size, "default-font-size", int)
+EXPOSE_WEBKIT_VIEW_SETTINGS(monospace_size, "default-monospace-font-size", int)
-EXPOSE_WEBKIT_VIEW_SETTINGS(disable_plugins, !uzbl.behave.disable_plugins, "enable-plugins")
-EXPOSE_WEBKIT_VIEW_SETTINGS(disable_scripts, !uzbl.behave.disable_scripts, "enable-scripts")
+EXPOSE_WEBKIT_VIEW_SETTINGS(enable_plugins, "enable-plugins", int)
+EXPOSE_WEBKIT_VIEW_SETTINGS(enable_scripts, "enable-scripts", int)
-EXPOSE_WEBKIT_VIEW_SETTINGS(javascript_windows, uzbl.behave.javascript_windows, "javascript-can-open-windows-automatically")
+EXPOSE_WEBKIT_VIEW_SETTINGS(javascript_windows, "javascript-can-open-windows-automatically", int)
-EXPOSE_WEBKIT_VIEW_SETTINGS(autoload_img, uzbl.behave.autoload_img, "auto-load-images")
-EXPOSE_WEBKIT_VIEW_SETTINGS(autoshrink_img, uzbl.behave.autoshrink_img, "auto-shrink-images")
+EXPOSE_WEBKIT_VIEW_SETTINGS(autoload_images, "auto-load-images", int)
+EXPOSE_WEBKIT_VIEW_SETTINGS(autoshrink_images, "auto-shrink-images", int)
-EXPOSE_WEBKIT_VIEW_SETTINGS(enable_pagecache, uzbl.behave.enable_pagecache, "enable-page-cache")
-EXPOSE_WEBKIT_VIEW_SETTINGS(enable_private, uzbl.behave.enable_private, "enable-private-browsing")
+EXPOSE_WEBKIT_VIEW_SETTINGS(enable_pagecache, "enable-page-cache", int)
+EXPOSE_WEBKIT_VIEW_SETTINGS(enable_private, "enable-private-browsing", int)
-EXPOSE_WEBKIT_VIEW_SETTINGS(enable_spellcheck, uzbl.behave.enable_spellcheck, "enable-spell-checking")
-EXPOSE_WEBKIT_VIEW_SETTINGS(spellcheck_languages, uzbl.behave.spellcheck_languages, "spell-checking-languages")
-EXPOSE_WEBKIT_VIEW_SETTINGS(resizable_txt, uzbl.behave.resizable_txt, "resizable-text-areas")
+EXPOSE_WEBKIT_VIEW_SETTINGS(enable_spellcheck, "enable-spell-checking", int)
+EXPOSE_WEBKIT_VIEW_SETTINGS(spellcheck_languages, "spell-checking-languages", gchar *)
+EXPOSE_WEBKIT_VIEW_SETTINGS(resizable_text_areas, "resizable-text-areas", int)
-EXPOSE_WEBKIT_VIEW_SETTINGS(style_uri, uzbl.behave.style_uri, "user-stylesheet-uri")
-EXPOSE_WEBKIT_VIEW_SETTINGS(print_bg, uzbl.behave.print_bg, "print-backgrounds")
-EXPOSE_WEBKIT_VIEW_SETTINGS(enforce_96dpi, uzbl.behave.enforce_96dpi, "enforce-96-dpi")
+EXPOSE_WEBKIT_VIEW_SETTINGS(stylesheet_uri, "user-stylesheet-uri", gchar *)
+EXPOSE_WEBKIT_VIEW_SETTINGS(print_bg, "print-backgrounds", int)
+EXPOSE_WEBKIT_VIEW_SETTINGS(enforce_96_dpi, "enforce-96-dpi", int)
-EXPOSE_WEBKIT_VIEW_SETTINGS(caret_browsing, uzbl.behave.caret_browsing, "enable-caret-browsing")
+EXPOSE_WEBKIT_VIEW_SETTINGS(caret_browsing, "enable-caret-browsing", int)
-EXPOSE_WEBKIT_VIEW_SETTINGS(cross_file_access, uzbl.behave.cross_file_access, "enable-file-access-from-file-uris")
+EXPOSE_WEBKIT_VIEW_SETTINGS(enable_cross_file_access, "enable-file-access-from-file-uris", int)
-EXPOSE_WEBKIT_VIEW_SETTINGS(default_encoding, uzbl.behave.default_encoding, "default-encoding")
+EXPOSE_WEBKIT_VIEW_SETTINGS(default_encoding, "default-encoding", gchar *)
void
-set_proxy_url() {
+set_proxy_url(const gchar *proxy_url) {
+ g_free(uzbl.net.proxy_url);
+ uzbl.net.proxy_url = g_strdup(proxy_url);
+
const gchar *url = uzbl.net.proxy_url;
SoupSession *session = uzbl.net.soup_session;
SoupURI *soup_uri = NULL;
@@ -336,14 +411,16 @@ set_proxy_url() {
soup_uri_free(soup_uri);
}
-
void
-set_authentication_handler() {
+set_authentication_handler(const gchar *handler) {
/* Check if WEBKIT_TYPE_SOUP_AUTH_DIALOG feature is set */
GSList *flist = soup_session_get_features (uzbl.net.soup_session, (GType) WEBKIT_TYPE_SOUP_AUTH_DIALOG);
guint feature_is_set = g_slist_length(flist);
g_slist_free(flist);
+ g_free(uzbl.behave.authentication_handler);
+ uzbl.behave.authentication_handler = g_strdup(handler);
+
if (uzbl.behave.authentication_handler == NULL || *uzbl.behave.authentication_handler == 0) {
if (!feature_is_set)
soup_session_add_feature_by_type
@@ -353,16 +430,18 @@ set_authentication_handler() {
soup_session_remove_feature_by_type
(uzbl.net.soup_session, (GType) WEBKIT_TYPE_SOUP_AUTH_DIALOG);
}
- return;
}
void
-set_status_background() {
+set_status_background(const gchar *background) {
/* labels and hboxes do not draw their own background. applying this
* on the vbox/main_window is ok as the statusbar is the only affected
* widget. (if not, we could also use GtkEventBox) */
GtkWidget* widget = uzbl.gui.main_window ? uzbl.gui.main_window : GTK_WIDGET (uzbl.gui.plug);
+ g_free(uzbl.behave.status_background);
+ uzbl.behave.status_background = g_strdup(background);
+
#if GTK_CHECK_VERSION(2,91,0)
GdkRGBA color;
gdk_rgba_parse (&color, uzbl.behave.status_background);
@@ -375,48 +454,81 @@ set_status_background() {
}
void
-set_icon() {
- if(file_exists(uzbl.gui.icon)) {
- if (uzbl.gui.main_window)
- gtk_window_set_icon_from_file (GTK_WINDOW (uzbl.gui.main_window), uzbl.gui.icon, NULL);
+set_icon(const gchar *icon) {
+ if(file_exists(uzbl.gui.icon) && uzbl.gui.main_window) {
+ g_free(uzbl.gui.icon);
+ uzbl.gui.icon = g_strdup(icon);
+
+ gtk_window_set_icon_from_file (GTK_WINDOW (uzbl.gui.main_window), uzbl.gui.icon, NULL);
} else {
- g_printerr ("Icon \"%s\" not found. ignoring.\n", uzbl.gui.icon);
+ g_printerr ("Icon \"%s\" not found. ignoring.\n", icon);
}
}
void
-set_window_role() {
- if (uzbl.gui.main_window)
- gtk_window_set_role(GTK_WINDOW (uzbl.gui.main_window), uzbl.gui.window_role);
+set_window_role(const gchar *role) {
+ if (!uzbl.gui.main_window)
+ return;
+
+ gtk_window_set_role(GTK_WINDOW (uzbl.gui.main_window), role);
+}
+
+gchar *
+get_window_role() {
+ if (!uzbl.gui.main_window)
+ return NULL;
+
+ const gchar* role = gtk_window_get_role(GTK_WINDOW (uzbl.gui.main_window));
+ return g_strdup(role);
+}
+
+gchar *
+get_geometry() {
+ int w, h, x, y;
+ GString *buf = g_string_new("");
+
+ gtk_window_get_size(GTK_WINDOW(uzbl.gui.main_window), &w, &h);
+ gtk_window_get_position(GTK_WINDOW(uzbl.gui.main_window), &x, &y);
+
+ g_string_printf(buf, "%dx%d+%d+%d", w, h, x, y);
+
+ return g_string_free(buf, FALSE);
}
void
-set_geometry() {
- int ret=0, x=0, y=0;
- unsigned int w=0, h=0;
- if(uzbl.gui.geometry) {
- if(uzbl.gui.geometry[0] == 'm') { /* m/maximize/maximized */
- gtk_window_maximize((GtkWindow *)(uzbl.gui.main_window));
- } else {
- /* we used to use gtk_window_parse_geometry() but that didn't work how it was supposed to */
- ret = XParseGeometry(uzbl.gui.geometry, &x, &y, &w, &h);
- if(ret & XValue)
- gtk_window_move((GtkWindow *)uzbl.gui.main_window, x, y);
- if(ret & WidthValue)
- gtk_window_resize((GtkWindow *)uzbl.gui.main_window, w, h);
- }
+set_geometry(const gchar *geometry) {
+ if(!geometry)
+ return;
+
+ if(geometry[0] == 'm') { /* m/maximize/maximized */
+ gtk_window_maximize((GtkWindow *)(uzbl.gui.main_window));
+ } else {
+ int x=0, y=0;
+ unsigned int w=0, h=0;
+
+ /* we used to use gtk_window_parse_geometry() but that didn't work
+ * how it was supposed to. */
+ int ret = XParseGeometry(uzbl.gui.geometry, &x, &y, &w, &h);
+
+ if(ret & XValue)
+ gtk_window_move((GtkWindow *)uzbl.gui.main_window, x, y);
+
+ if(ret & WidthValue)
+ gtk_window_resize((GtkWindow *)uzbl.gui.main_window, w, h);
}
- /* update geometry var with the actual geometry
- this is necessary as some WMs don't seem to honour
- the above setting and we don't want to end up with
- wrong geometry information
- */
- retrieve_geometry();
+ /* get the actual geometry (which might be different from what was
+ * specified) and store it (since the GEOMETRY_CHANGED event needs to
+ * know what it changed from) */
+ g_free(uzbl.gui.geometry);
+ uzbl.gui.geometry = get_geometry();
}
void
-set_show_status() {
+set_show_status(int show_status) {
+ /* todo: use gtk_widget_set_visible */
+ uzbl.behave.show_status = show_status;
+
if (!uzbl.behave.show_status)
gtk_widget_hide(uzbl.gui.status_bar);
else
@@ -426,10 +538,12 @@ set_show_status() {
}
void
-set_status_top() {
+set_status_top(int status_top) {
if (!uzbl.gui.scrolled_win && !uzbl.gui.status_bar)
return;
+ uzbl.behave.status_top = status_top;
+
g_object_ref(uzbl.gui.scrolled_win);
g_object_ref(uzbl.gui.status_bar);
gtk_container_remove(GTK_CONTAINER(uzbl.gui.vbox), uzbl.gui.scrolled_win);
@@ -451,55 +565,67 @@ set_status_top() {
}
void
-set_current_encoding() {
- gchar *encoding = uzbl.behave.current_encoding;
+set_current_encoding(const gchar *encoding) {
if(strlen(encoding) == 0)
encoding = NULL;
webkit_web_view_set_custom_encoding(uzbl.gui.web_view, encoding);
}
+gchar *
+get_current_encoding() {
+ const gchar *encoding = webkit_web_view_get_custom_encoding(uzbl.gui.web_view);
+ return g_strdup(encoding);
+}
+
void
-cmd_fifo_dir() {
- if(!init_fifo(uzbl.behave.fifo_dir)) {
- g_free(uzbl.behave.fifo_dir);
+set_fifo_dir(const gchar *fifo_dir) {
+ g_free(uzbl.behave.fifo_dir);
+
+ if(init_fifo(fifo_dir))
+ uzbl.behave.fifo_dir = g_strdup(fifo_dir);
+ else
uzbl.behave.fifo_dir = NULL;
- }
}
void
-cmd_socket_dir() {
- if(!init_socket(uzbl.behave.socket_dir)) {
- g_free(uzbl.behave.socket_dir);
+set_socket_dir(const gchar *socket_dir) {
+ g_free(uzbl.behave.socket_dir);
+
+ if(init_socket(socket_dir))
+ uzbl.behave.socket_dir = g_strdup(socket_dir);
+ else
uzbl.behave.socket_dir = NULL;
- }
}
void
-cmd_inject_html() {
- if(uzbl.behave.inject_html) {
- webkit_web_view_load_html_string (uzbl.gui.web_view,
- uzbl.behave.inject_html, NULL);
- }
+set_inject_html(const gchar *html) {
+ webkit_web_view_load_html_string (uzbl.gui.web_view, html, NULL);
}
void
-cmd_useragent() {
- if (*uzbl.net.useragent == ' ') {
- g_free (uzbl.net.useragent);
+set_useragent(const gchar *useragent) {
+ g_free(uzbl.net.useragent);
+
+ if (*useragent == ' ') {
uzbl.net.useragent = NULL;
} else {
+ uzbl.net.useragent = g_strdup(useragent);
+
g_object_set(G_OBJECT(uzbl.net.soup_session), SOUP_SESSION_USER_AGENT,
uzbl.net.useragent, NULL);
}
}
void
-set_accept_languages() {
+set_accept_languages(const gchar *accept_languages) {
+ g_free(uzbl.net.accept_languages);
+
if (*uzbl.net.accept_languages == ' ') {
- g_free (uzbl.net.accept_languages);
uzbl.net.accept_languages = NULL;
} else {
+ uzbl.net.accept_languages = g_strdup(accept_languages);
+
g_object_set(G_OBJECT(uzbl.net.soup_session),
SOUP_SESSION_ACCEPT_LANGUAGE, uzbl.net.accept_languages, NULL);
}
@@ -507,26 +633,48 @@ set_accept_languages() {
/* requires webkit >=1.1.14 */
void
-cmd_view_source() {
+set_view_source(int view_source) {
+ uzbl.behave.view_source = view_source;
+
webkit_web_view_set_view_source_mode(uzbl.gui.web_view,
(gboolean) uzbl.behave.view_source);
}
void
-cmd_set_zoom_type () {
- if(uzbl.behave.zoom_type)
- webkit_web_view_set_full_content_zoom (uzbl.gui.web_view, TRUE);
- else
- webkit_web_view_set_full_content_zoom (uzbl.gui.web_view, FALSE);
+set_zoom_type (int type) {
+ webkit_web_view_set_full_content_zoom (uzbl.gui.web_view, type);
+}
+
+int
+get_zoom_type () {
+ return webkit_web_view_get_full_content_zoom (uzbl.gui.web_view);
+}
+
+void
+set_zoom_level(float zoom_level) {
+ webkit_web_view_set_zoom_level (uzbl.gui.web_view, zoom_level);
+}
+
+float
+get_zoom_level() {
+ return webkit_web_view_get_zoom_level (uzbl.gui.web_view);
}
/* abbreviations to help keep the table's width humane */
-#define PTR_V_STR(var, d, fun) { .ptr.s = &(var), .type = TYPE_STR, .dump = d, .writeable = 1, .func = fun }
-#define PTR_V_INT(var, d, fun) { .ptr.i = (int*)&(var), .type = TYPE_INT, .dump = d, .writeable = 1, .func = fun }
-#define PTR_V_FLOAT(var, d, fun) { .ptr.f = &(var), .type = TYPE_FLOAT, .dump = d, .writeable = 1, .func = fun }
-#define PTR_C_STR(var, fun) { .ptr.s = &(var), .type = TYPE_STR, .dump = 0, .writeable = 0, .func = fun }
-#define PTR_C_INT(var, fun) { .ptr.i = (int*)&(var), .type = TYPE_INT, .dump = 0, .writeable = 0, .func = fun }
-#define PTR_C_FLOAT(var, fun) { .ptr.f = &(var), .type = TYPE_FLOAT, .dump = 0, .writeable = 0, .func = fun }
+
+/* variables */
+#define PTR_V_STR(var, d, set) { .ptr = { .s = &(var) }, .type = TYPE_STR, .dump = d, .writeable = 1, .getter = NULL, .setter = (uzbl_fp)set }
+#define PTR_V_INT(var, d, set) { .ptr = { .i = (int*)&(var) }, .type = TYPE_INT, .dump = d, .writeable = 1, .getter = NULL, .setter = (uzbl_fp)set }
+#define PTR_V_FLOAT(var, d, set) { .ptr = { .f = &(var) }, .type = TYPE_FLOAT, .dump = d, .writeable = 1, .getter = NULL, .setter = (uzbl_fp)set }
+
+#define PTR_V_STR_GETSET(var) { .type = TYPE_STR, .dump = 1, .writeable = 1, .getter = (uzbl_fp) get_##var, .setter = (uzbl_fp)set_##var }
+#define PTR_V_INT_GETSET(var) { .type = TYPE_INT, .dump = 1, .writeable = 1, .getter = (uzbl_fp) get_##var, .setter = (uzbl_fp)set_##var }
+#define PTR_V_FLOAT_GETSET(var) { .type = TYPE_FLOAT, .dump = 1, .writeable = 1, .getter = (uzbl_fp) get_##var, .setter = (uzbl_fp)set_##var }
+
+/* constants */
+#define PTR_C_STR(var) { .ptr = { .s = &(var) }, .type = TYPE_STR, .dump = 0, .writeable = 0, .getter = NULL, .setter = NULL }
+#define PTR_C_INT(var) { .ptr = { .i = (int*)&(var) }, .type = TYPE_INT, .dump = 0, .writeable = 0, .getter = NULL, .setter = NULL }
+#define PTR_C_FLOAT(var) { .ptr = { .f = &(var) }, .type = TYPE_FLOAT, .dump = 0, .writeable = 0, .getter = NULL, .setter = NULL }
const struct var_name_to_ptr_t {
const char *name;
@@ -534,11 +682,11 @@ const struct var_name_to_ptr_t {
} var_name_to_ptr[] = {
/* variable name pointer to variable in code dump callback function */
/* ---------------------------------------------------------------------------------------------- */
- { "uri", PTR_V_STR(uzbl.state.uri, 1, cmd_load_uri)},
+ { "uri", PTR_V_STR(uzbl.state.uri, 1, set_uri)},
+
{ "verbose", PTR_V_INT(uzbl.state.verbose, 1, NULL)},
{ "print_events", PTR_V_INT(uzbl.state.events_stdout, 1, NULL)},
- { "inject_html", PTR_V_STR(uzbl.behave.inject_html, 0, cmd_inject_html)},
- { "geometry", PTR_V_STR(uzbl.gui.geometry, 1, set_geometry)},
+
{ "show_status", PTR_V_INT(uzbl.behave.show_status, 1, set_show_status)},
{ "status_top", PTR_V_INT(uzbl.behave.status_top, 1, set_status_top)},
{ "status_format", PTR_V_STR(uzbl.behave.status_format, 1, NULL)},
@@ -546,67 +694,81 @@ const struct var_name_to_ptr_t {
{ "status_background", PTR_V_STR(uzbl.behave.status_background, 1, set_status_background)},
{ "title_format_long", PTR_V_STR(uzbl.behave.title_format_long, 1, NULL)},
{ "title_format_short", PTR_V_STR(uzbl.behave.title_format_short, 1, NULL)},
+
+ { "geometry", PTR_V_STR_GETSET(geometry)},
{ "icon", PTR_V_STR(uzbl.gui.icon, 1, set_icon)},
- { "window_role", PTR_V_STR(uzbl.gui.window_role, 1, set_window_role)},
+ { "window_role", PTR_V_STR_GETSET(window_role)},
+
{ "forward_keys", PTR_V_INT(uzbl.behave.forward_keys, 1, NULL)},
+
{ "authentication_handler", PTR_V_STR(uzbl.behave.authentication_handler, 1, set_authentication_handler)},
{ "scheme_handler", PTR_V_STR(uzbl.behave.scheme_handler, 1, NULL)},
{ "download_handler", PTR_V_STR(uzbl.behave.download_handler, 1, NULL)},
- { "fifo_dir", PTR_V_STR(uzbl.behave.fifo_dir, 1, cmd_fifo_dir)},
- { "socket_dir", PTR_V_STR(uzbl.behave.socket_dir, 1, cmd_socket_dir)},
- { "http_debug", PTR_V_INT(uzbl.behave.http_debug, 1, cmd_http_debug)},
+
+ { "fifo_dir", PTR_V_STR(uzbl.behave.fifo_dir, 1, set_fifo_dir)},
+ { "socket_dir", PTR_V_STR(uzbl.behave.socket_dir, 1, set_socket_dir)},
+
{ "shell_cmd", PTR_V_STR(uzbl.behave.shell_cmd, 1, NULL)},
+
+ { "http_debug", PTR_V_INT(uzbl.behave.http_debug, 1, set_http_debug)},
{ "proxy_url", PTR_V_STR(uzbl.net.proxy_url, 1, set_proxy_url)},
- { "max_conns", PTR_V_INT(uzbl.net.max_conns, 1, cmd_max_conns)},
- { "max_conns_host", PTR_V_INT(uzbl.net.max_conns_host, 1, cmd_max_conns_host)},
- { "useragent", PTR_V_STR(uzbl.net.useragent, 1, cmd_useragent)},
+ { "max_conns", PTR_V_INT(uzbl.net.max_conns, 1, set_max_conns)},
+ { "max_conns_host", PTR_V_INT(uzbl.net.max_conns_host, 1, set_max_conns_host)},
+ { "useragent", PTR_V_STR(uzbl.net.useragent, 1, set_useragent)},
{ "accept_languages", PTR_V_STR(uzbl.net.accept_languages, 1, set_accept_languages)},
- { "javascript_windows", PTR_V_INT(uzbl.behave.javascript_windows, 1, cmd_javascript_windows)},
- /* requires webkit >=1.1.14 */
- { "view_source", PTR_V_INT(uzbl.behave.view_source, 0, cmd_view_source)},
+
+ { "view_source", PTR_V_INT(uzbl.behave.view_source, 0, set_view_source)},
/* exported WebKitWebSettings properties */
- { "zoom_level", PTR_V_FLOAT(uzbl.behave.zoom_level, 1, cmd_zoom_level)},
- { "zoom_type", PTR_V_INT(uzbl.behave.zoom_type, 1, cmd_set_zoom_type)},
- { "font_size", PTR_V_INT(uzbl.behave.font_size, 1, cmd_font_size)},
- { "default_font_family", PTR_V_STR(uzbl.behave.default_font_family, 1, cmd_default_font_family)},
- { "monospace_font_family", PTR_V_STR(uzbl.behave.monospace_font_family, 1, cmd_monospace_font_family)},
- { "cursive_font_family", PTR_V_STR(uzbl.behave.cursive_font_family, 1, cmd_cursive_font_family)},
- { "sans_serif_font_family", PTR_V_STR(uzbl.behave.sans_serif_font_family, 1, cmd_sans_serif_font_family)},
- { "serif_font_family", PTR_V_STR(uzbl.behave.serif_font_family, 1, cmd_serif_font_family)},
- { "fantasy_font_family", PTR_V_STR(uzbl.behave.fantasy_font_family, 1, cmd_fantasy_font_family)},
- { "monospace_size", PTR_V_INT(uzbl.behave.monospace_size, 1, cmd_font_size)},
- { "minimum_font_size", PTR_V_INT(uzbl.behave.minimum_font_size, 1, cmd_minimum_font_size)},
- { "enable_pagecache", PTR_V_INT(uzbl.behave.enable_pagecache, 1, cmd_enable_pagecache)},
- { "disable_plugins", PTR_V_INT(uzbl.behave.disable_plugins, 1, cmd_disable_plugins)},
- { "disable_scripts", PTR_V_INT(uzbl.behave.disable_scripts, 1, cmd_disable_scripts)},
- { "autoload_images", PTR_V_INT(uzbl.behave.autoload_img, 1, cmd_autoload_img)},
- { "autoshrink_images", PTR_V_INT(uzbl.behave.autoshrink_img, 1, cmd_autoshrink_img)},
- { "enable_spellcheck", PTR_V_INT(uzbl.behave.enable_spellcheck, 1, cmd_enable_spellcheck)},
- { "spellcheck_languages", PTR_V_STR(uzbl.behave.spellcheck_languages, 1, cmd_spellcheck_languages)},
- { "enable_private", PTR_V_INT(uzbl.behave.enable_private, 1, cmd_enable_private)},
- { "print_backgrounds", PTR_V_INT(uzbl.behave.print_bg, 1, cmd_print_bg)},
- { "stylesheet_uri", PTR_V_STR(uzbl.behave.style_uri, 1, cmd_style_uri)},
- { "resizable_text_areas", PTR_V_INT(uzbl.behave.resizable_txt, 1, cmd_resizable_txt)},
- { "default_encoding", PTR_V_STR(uzbl.behave.default_encoding, 1, cmd_default_encoding)},
- { "current_encoding", PTR_V_STR(uzbl.behave.current_encoding, 1, set_current_encoding)},
- { "enforce_96_dpi", PTR_V_INT(uzbl.behave.enforce_96dpi, 1, cmd_enforce_96dpi)},
- { "caret_browsing", PTR_V_INT(uzbl.behave.caret_browsing, 1, cmd_caret_browsing)},
- { "enable_cross_file_access", PTR_V_INT(uzbl.behave.cross_file_access, 1, cmd_cross_file_access)},
+ { "javascript_windows", PTR_V_INT_GETSET(javascript_windows)},
+ { "zoom_level", PTR_V_FLOAT_GETSET(zoom_level)},
+ { "zoom_type", PTR_V_INT_GETSET(zoom_type)},
+
+ { "default_font_family", PTR_V_STR_GETSET(default_font_family)},
+ { "monospace_font_family", PTR_V_STR_GETSET(monospace_font_family)},
+ { "cursive_font_family", PTR_V_STR_GETSET(cursive_font_family)},
+ { "sans_serif_font_family", PTR_V_STR_GETSET(sans_serif_font_family)},
+ { "serif_font_family", PTR_V_STR_GETSET(serif_font_family)},
+ { "fantasy_font_family", PTR_V_STR_GETSET(fantasy_font_family)},
+
+ { "monospace_size", PTR_V_INT_GETSET(monospace_size)},
+ { "font_size", PTR_V_INT_GETSET(font_size)},
+ { "minimum_font_size", PTR_V_INT_GETSET(minimum_font_size)},
+
+ { "enable_pagecache", PTR_V_INT_GETSET(enable_pagecache)},
+ { "enable_plugins", PTR_V_INT_GETSET(enable_plugins)},
+ { "enable_scripts", PTR_V_INT_GETSET(enable_scripts)},
+ { "autoload_images", PTR_V_INT_GETSET(autoload_images)},
+ { "autoshrink_images", PTR_V_INT_GETSET(autoshrink_images)},
+ { "enable_spellcheck", PTR_V_INT_GETSET(enable_spellcheck)},
+ { "spellcheck_languages", PTR_V_STR_GETSET(spellcheck_languages)},
+ { "enable_private", PTR_V_INT_GETSET(enable_private)},
+ { "print_backgrounds", PTR_V_INT_GETSET(print_bg)},
+ { "stylesheet_uri", PTR_V_STR_GETSET(stylesheet_uri)},
+ { "resizable_text_areas", PTR_V_INT_GETSET(resizable_text_areas)},
+ { "default_encoding", PTR_V_STR_GETSET(default_encoding)},
+ { "current_encoding", PTR_V_STR_GETSET(current_encoding)},
+ { "enforce_96_dpi", PTR_V_INT_GETSET(enforce_96_dpi)},
+ { "caret_browsing", PTR_V_INT_GETSET(caret_browsing)},
+ { "enable_cross_file_access", PTR_V_INT_GETSET(enable_cross_file_access)},
+
+ { "inject_html", { .type = TYPE_STR, .dump = 0, .writeable = 1, .getter = NULL, .setter = (uzbl_fp) set_inject_html }},
/* constants (not dumpable or writeable) */
- { "WEBKIT_MAJOR", PTR_C_INT(uzbl.info.webkit_major, NULL)},
- { "WEBKIT_MINOR", PTR_C_INT(uzbl.info.webkit_minor, NULL)},
- { "WEBKIT_MICRO", PTR_C_INT(uzbl.info.webkit_micro, NULL)},
- { "ARCH_UZBL", PTR_C_STR(uzbl.info.arch, NULL)},
- { "COMMIT", PTR_C_STR(uzbl.info.commit, NULL)},
- { "TITLE", PTR_C_STR(uzbl.gui.main_title, NULL)},
- { "SELECTED_URI", PTR_C_STR(uzbl.state.selected_url, NULL)},
- { "NAME", PTR_C_STR(uzbl.state.instance_name, NULL)},
- { "PID", PTR_C_STR(uzbl.info.pid_str, NULL)},
- { "_", PTR_C_STR(uzbl.state.last_result, NULL)},
-
- { NULL, {.ptr.s = NULL, .type = TYPE_INT, .dump = 0, .writeable = 0, .func = NULL}}
+ { "WEBKIT_MAJOR", PTR_C_INT(uzbl.info.webkit_major)},
+ { "WEBKIT_MINOR", PTR_C_INT(uzbl.info.webkit_minor)},
+ { "WEBKIT_MICRO", PTR_C_INT(uzbl.info.webkit_micro)},
+ { "ARCH_UZBL", PTR_C_STR(uzbl.info.arch)},
+ { "COMMIT", PTR_C_STR(uzbl.info.commit)},
+ { "TITLE", PTR_C_STR(uzbl.gui.main_title)},
+ { "SELECTED_URI", PTR_C_STR(uzbl.state.selected_url)},
+ { "NAME", PTR_C_STR(uzbl.state.instance_name)},
+ { "PID", PTR_C_STR(uzbl.info.pid_str)},
+ { "_", PTR_C_STR(uzbl.state.last_result)},
+
+ /* and we terminate the whole thing with the closest thing we have to NULL.
+ * it's important that dump = 0. */
+ { NULL, {.ptr = { .i = NULL }, .type = TYPE_INT, .dump = 0, .writeable = 0}}
};
/* construct a hash from the var_name_to_ptr array for quick access */
diff --git a/src/variables.h b/src/variables.h
index 6aa0ab0..ea3bdcf 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -8,14 +8,30 @@
#include <glib.h>
#include <webkit/webkit.h>
+#include "type.h"
+
gboolean set_var_value(const gchar *name, gchar *val);
void expand_variable(GString *buf, const gchar *name);
void variables_hash();
+
+gchar *get_var_value_string_c(const uzbl_cmdprop *c);
+gchar *get_var_value_string(const char *name);
+int get_var_value_int_c(const uzbl_cmdprop *c);
+int get_var_value_int(const char *name);
+float get_var_value_float_c(const uzbl_cmdprop *c);
+float get_var_value_float(const char *name);
+
void dump_config();
void dump_config_as_events();
void uri_change_cb (WebKitWebView *web_view, GParamSpec param_spec);
-void set_show_status();
-void set_geometry();
+
+void set_show_status(int);
+
+void set_zoom_type(int);
+int get_zoom_type();
+
+gchar *get_geometry();
+void set_geometry(const gchar *);
#endif