summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2011-06-27 01:01:49 +0200
committerportix <portix@gmx.net>2011-06-27 01:01:49 +0200
commit1c6cbffd6407fec59e518240ec1dcd81dac0a82d (patch)
tree37c94d630f20eb7f25b6fbb3dbf1af92e9570f15 /src
parent8ad841cd1cdebc6fa80bc382f46cada05e365316 (diff)
downloaddwb-1c6cbffd6407fec59e518240ec1dcd81dac0a82d.zip
Seperate keys.html file
Diffstat (limited to 'src')
-rw-r--r--src/completion.c4
-rw-r--r--src/html.c36
2 files changed, 18 insertions, 22 deletions
diff --git a/src/completion.c b/src/completion.c
index 7f03bcca..33b19c19 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -270,11 +270,13 @@ dwb_comp_get_key_completion(gboolean entry) {
}
Navigation n = m->map->n;
if (g_str_has_prefix(n.first, input)) {
- char *value = g_strdup_printf("%s %s", dwb_modmask_to_string(m->mod), m->key);
+ char *mod = dwb_modmask_to_string(m->mod);
+ char *value = g_strdup_printf("%s %s", mod, m->key);
Completion *c = dwb_comp_get_completion_item(&n, m, value);
gtk_box_pack_start(GTK_BOX(CURRENT_VIEW()->compbox), c->event, false, false, 0);
list = g_list_append(list, c);
FREE(value);
+ g_free(mod);
}
}
return list;
diff --git a/src/html.c b/src/html.c
index 4f31ccbb..cebcee7a 100644
--- a/src/html.c
+++ b/src/html.c
@@ -139,6 +139,7 @@ dwb_html_keys_load_cb(WebKitWebView *wv, GParamSpec *p, HtmlTable *table) {
KeyMap *km;
Navigation n;
WebKitDOMElement *input;
+ char *mod, *value;
if (webkit_web_view_get_load_status(wv) == WEBKIT_LOAD_FINISHED) {
WebKitDOMDocument *doc = webkit_web_view_get_dom_document(wv);
@@ -146,7 +147,14 @@ dwb_html_keys_load_cb(WebKitWebView *wv, GParamSpec *p, HtmlTable *table) {
km = l->data;
n = km->map->n;
input = webkit_dom_document_get_element_by_id(doc, n.first);
- webkit_dom_event_target_add_event_listener(WEBKIT_DOM_EVENT_TARGET(input), "change", G_CALLBACK(dwb_html_key_changed_cb), false, wv);
+ if (input != NULL) {
+ mod = dwb_modmask_to_string(km->mod);
+ value = g_strdup_printf("%s %s", mod, km->key ? km->key : "");
+ webkit_dom_html_input_element_set_value(WEBKIT_DOM_HTML_INPUT_ELEMENT(input), value);
+ webkit_dom_event_target_add_event_listener(WEBKIT_DOM_EVENT_TARGET(input), "change", G_CALLBACK(dwb_html_key_changed_cb), false, wv);
+ FREE(mod);
+ g_free(value);
+ }
}
g_signal_handlers_disconnect_by_func(wv, dwb_html_keys_load_cb, table);
}
@@ -154,27 +162,13 @@ dwb_html_keys_load_cb(WebKitWebView *wv, GParamSpec *p, HtmlTable *table) {
}
void
dwb_html_keys(WebKitWebView *wv, HtmlTable *table) {
- GString *buffer = g_string_new(NULL);
- int i = 0;
- KeyMap *km;
- Navigation n;
- for (GList *l = dwb.keymap; l; l=l->next, i++, i%=2) {
- km = l->data;
- n = km->map->n;
- g_string_append_printf(buffer,
- "<div class='dwb_line%d'>\
- <div class='dwb_attr'>%s</div>\
- <div style='float:right;'>\
- <label class='dwb_desc' for='%s'>%s</label>\
- <input id='%s' type='text' value='%s %s'>\
- </div>\
- <div style='clear:both;'></div>\
- </div>", i, n.second, n.first, n.first, n.first, dwb_modmask_to_string(km->mod), km->key ? km->key : "");
-
- }
+ char *content;
g_signal_connect(wv, "notify::load-status", G_CALLBACK(dwb_html_keys_load_cb), table);
- dwb_html_load_page(wv, table, buffer->str);
- g_string_free(buffer, true);
+ char *path = dwb_util_get_data_file(KEY_FILE);
+ g_file_get_contents(path, &content, NULL, NULL);
+ dwb_html_load_page(wv, table, content);
+ g_free(path);
+ g_free(content);
}
void
dwb_html_quickmarks(WebKitWebView *wv, HtmlTable *table) {