Add 'get' action, remove GET command. Const correctness fix.
authorDuClare <akarinotengoku@gmail.com>
Fri, 29 May 2009 18:16:38 +0000 (21:16 +0300)
committerDuClare <akarinotengoku@gmail.com>
Fri, 29 May 2009 18:16:38 +0000 (21:16 +0300)
uzbl.c
uzbl.h

diff --git a/uzbl.c b/uzbl.c
index e5498f0..7855353 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -614,6 +614,7 @@ static struct {char *name; Command command[2];} cmdlist[] =
     { "toggle_insert_mode", {toggle_insert_mode, 0}        },
     { "runcmd",             {runcmd, NOSPLIT}              },
     { "set",                {set_var, NOSPLIT}             },
+    { "get",                {get_var, NOSPLIT}             },
     { "dump_config",        {act_dump_config, 0}           },
     { "keycmd",             {keycmd, NOSPLIT}              },
     { "keycmd_nl",          {keycmd_nl, NOSPLIT}           },
@@ -671,6 +672,12 @@ set_var(WebKitWebView *page, GArray *argv) {
 }
 
 static void
+get_var(WebKitWebView *page, GArray *argv) {
+    (void) page;
+    get_var_value(argv_idx(argv, 0));
+}
+
+static void
 act_dump_config() {
     dump_config();
 }
@@ -1262,7 +1269,7 @@ setup_regex() {
 }
 
 static gboolean
-get_var_value(gchar *name) {
+get_var_value(const gchar *name) {
     uzbl_cmdprop *c;
 
     if( (c = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) {
@@ -1593,15 +1600,6 @@ parse_cmd_line(const char *ctl_line) {
             else
                 printf("Error in command: %s\n", tokens[0]);
         }
-        /* GET command */
-        else if(ctl_line[0] == 'g' || ctl_line[0] == 'G') {
-            tokens = g_regex_split(uzbl.comm.get_regex, ctl_line, 0);
-            if(tokens[0][0] == 0) {
-                get_var_value(tokens[1]);
-            }
-            else
-                printf("Error in command: %s\n", tokens[0]);
-        }
         /* BIND command */
         else if(ctl_line[0] == 'b' || ctl_line[0] == 'B') {
             tokens = g_regex_split(uzbl.comm.bind_regex, ctl_line, 0);
diff --git a/uzbl.h b/uzbl.h
index a36b3f7..dd4ceb5 100644 (file)
--- a/uzbl.h
+++ b/uzbl.h
@@ -248,6 +248,9 @@ static gboolean
 set_var_value(gchar *name, gchar *val);
 
 static gboolean
+get_var_value(const gchar *name);
+
+static gboolean
 new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
 
 WebKitWebView*
@@ -430,6 +433,9 @@ static void
 set_var(WebKitWebView *page, GArray *argv);
 
 static void
+get_var(WebKitWebView *page, GArray *argv);
+
+static void
 act_dump_config();
 
 static void