aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-04-26 09:59:24 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-04-26 09:59:24 +0200
commit301c206143319ce7f00ffdfeb873cf51507b25b4 (patch)
tree39b11dce9b374e21218f78b23c80baaa1a860a71 /uzbl.c
parent6a38fa22be4777446c2f766592da505e0dc5d26f (diff)
more compact way to control allowing 1 or 2 params, by checking the function pointers themselves
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/uzbl.c b/uzbl.c
index ded6184..05b0582 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -69,8 +69,6 @@ typedef struct
const char *command;
void (*func_1_param)(WebKitWebView*);
void (*func_2_params)(WebKitWebView*, char *);
- const gboolean param_allow;
- const gboolean param_optional;
} Command;
@@ -156,13 +154,13 @@ log_history_cb () {
// TODO: reload, home, quit
static Command commands[] =
{
- { "back", &go_back_cb, NULL, false, false },
- { "forward", &go_forward_cb, NULL, false, false },
- { "refresh", &webkit_web_view_reload, NULL, false, false }, //Buggy
- { "stop", &webkit_web_view_stop_loading, NULL, false, false },
- { "zoom_in", &webkit_web_view_zoom_in, NULL, false, false }, //Can crash (when max zoom reached?).
- { "zoom_out", &webkit_web_view_zoom_out, NULL, false, false } ,
- { "uri", NULL, &webkit_web_view_load_uri, true, false }
+ { "back", &go_back_cb, NULL },
+ { "forward", &go_forward_cb, NULL },
+ { "refresh", &webkit_web_view_reload, NULL }, //Buggy
+ { "stop", &webkit_web_view_stop_loading, NULL },
+ { "zoom_in", &webkit_web_view_zoom_in, NULL }, //Can crash (when max zoom reached?).
+ { "zoom_out", &webkit_web_view_zoom_out, NULL } ,
+ { "uri", NULL, &webkit_web_view_load_uri }
//{ "get uri", &webkit_web_view_get_uri},
};
@@ -183,19 +181,19 @@ parse_command(const char *command) {
}
}
if (c != NULL) {
- if (c->param_allow) {
+ if (c->func_2_params != NULL) {
if(command_param != NULL) {
printf("command executing: \"%s %s\"\n", command_name, command_param);
c->func_2_params (web_view, command_param);
} else {
- if(c->param_optional) {
+ if(c->func_1_param != NULL) {
printf("command executing: \"%s\"\n", command_name);
c->func_1_param (web_view);
} else {
fprintf(stderr, "command needs a parameter. \"%s\" is not complete\n", command_name);
}
}
- } else {
+ } else if(c->func_1_param != NULL) {
printf("command executing: \"%s\"\n", command_name);
c->func_1_param (web_view);
}