{"source", view_source},
};
-static void command_sharg_append(GArray* a, const gchar* str);
-
-
void command_init()
{
guint i;
}
}
-void command_parse_line(const gchar* line, GString* result)
+void command_parse_line(const gchar* line)
{
gchar* string = g_strdup(line);
if (strcmp(string, "")) {
/* ignore comment lines */
if ((string[0] != '#')) {
- GArray* a = g_array_new(TRUE, FALSE, sizeof(gchar*));
+ Arg* a = NULL;
const CommandInfo* c = command_parse_parts(string, a);
if (c) {
- command_run_command(c, a, result);
+ command_run_command(c, a);
}
- g_array_free(a, TRUE);
+ g_free(a->s);
}
}
}
/* static? */
-const CommandInfo* command_parse_parts(const gchar* line, GArray* a)
+const CommandInfo* command_parse_parts(const gchar* line, Arg* arg)
{
CommandInfo* c = NULL;
return NULL;
}
- gchar* p = g_strdup(tokens[1]);
- command_sharg_append(a, p);
-
+ arg->s = g_strdup(tokens[2]);
g_strfreev(tokens);
- g_free(p);
return c;
}
-void command_run_command(const CommandInfo* c, GArray* a, GString* result)
-{
- c->function(a, result);
-}
-
-static void command_sharg_append(GArray* a, const gchar* str)
+void command_run_command(const CommandInfo* c, Arg* arg)
{
- const gchar* s = (str ? str : "");
- g_array_append_val(a, s);
+ c->function(arg);
}
-void quit(GArray* argv, GString* result)
+void quit(Arg* arg)
{
vp_close_browser();
}
-void view_source(GArray* argv, GString* result)
+void view_source(Arg* arg)
{
gboolean mode = webkit_web_view_get_view_source_mode(vp.gui.webview);
webkit_web_view_set_view_source_mode(vp.gui.webview, !mode);
#include "main.h"
#include <webkit/webkit.h>
-typedef void (*Command)(GArray *argv, GString *result);
+typedef void (*Command)(Arg* arg);
typedef struct {
const gchar* name;
void command_init(void);
-void command_parse_line(const gchar* line, GString* result);
-const CommandInfo* command_parse_parts(const gchar* line, GArray* a);
-void command_run_command(const CommandInfo* c, GArray* a, GString* result);
+void command_parse_line(const gchar* line);
+const CommandInfo* command_parse_parts(const gchar* line, Arg* arg);
+void command_run_command(const CommandInfo* c, Arg* arg);
-void quit(GArray* argv, GString* result);
-void view_source(GArray* argv, GString* result);
+void quit(Arg* arg);
+void view_source(Arg* arg);
#endif /* end of include guard: COMMAND_H */
&& keybind->modkey == vp.state.modkey
&& keybind->command
) {
- GArray* a = g_array_new(TRUE, FALSE, sizeof(gchar*));
+ Arg* a = NULL;
const CommandInfo* c = command_parse_parts(keybind->command, a);
if (c) {
- command_run_command(c, a, NULL);
+ command_run_command(c, a);
}
- g_array_free(a, TRUE);
+ g_free(a->s);
/* if key binding used, remove the modkey */
vp.state.modkey = 0;
gboolean vp_load_uri(const Arg* arg)
{
char* u;
- const char* uri = arg->c;
+ const char* uri = arg->s;
if (strcmp(uri, "") == 0) {
return FALSE;
/* command line argument: URL */
Arg arg;
if (argc > 1) {
- arg.c = g_strdup(argv[argc - 1]);
+ arg.s = g_strdup(argv[argc - 1]);
} else {
- arg.c = g_strdup(START_PAGE);
+ arg.s = g_strdup(START_PAGE);
}
vp_load_uri(&arg);
- g_free(arg.c);
+ g_free(arg.s);
/* Run the main GTK+ event loop */
gtk_main();