summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2010-08-06 13:51:19 +0200
committerportix <portix@gmx.net>2010-08-06 13:51:19 +0200
commit4ab8cde2f53b42735ce5c7fbbb1e211ebe012858 (patch)
tree32674f82859c1fd3f68893e986b08298603c4cc9
parent6fdb583b82044271696153dabd3644f34ea8be2b (diff)
downloaddwb-4ab8cde2f53b42735ce5c7fbbb1e211ebe012858.zip
cleaning
--HG-- branch : entry_per_view
-rw-r--r--data/hints.js21
-rw-r--r--src/commands.c245
-rw-r--r--src/commands.h77
-rw-r--r--src/completion.c256
-rw-r--r--src/completion.h1
-rw-r--r--src/download.c107
-rw-r--r--src/dwb.c385
-rw-r--r--src/dwb.h10
-rw-r--r--src/util.c323
-rw-r--r--src/util.h57
-rw-r--r--src/view.c72
-rw-r--r--src/view.h2
12 files changed, 810 insertions, 746 deletions
diff --git a/data/hints.js b/data/hints.js
index 48daf8ec..ed08c48a 100644
--- a/data/hints.js
+++ b/data/hints.js
@@ -9,6 +9,7 @@ var lastinput;
var styles;
var form_hints = "//form";
var last_entry = null;
+var hints = "//a | //area | //textarea | //select | //link | //input | //button | //frame | //iframe | //*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @role='link' or @href]";
function Hint(element) {
this.element = element;
@@ -149,16 +150,16 @@ function create_stylesheet() {
function get_visibility(e) {
var rects = e.getClientRects()[0];
var r = e.getBoundingClientRect();
- if (!r || r.top > window.innerHeight || r.bottom < 0
- || r.left > window.innerWidth || r < 0 || !rects ) {
+ var style = document.defaultView.getComputedStyle(e, null);
+
+ if (!r || r.top > window.innerHeight || r.bottom < 0 || r.left > window.innerWidth || r < 0 || !rects) {
return false;
}
var style = document.defaultView.getComputedStyle(e, null);
- if (style.getPropertyValue("visibility") != "visible"
- || style.getPropertyValue("display") == "none") {
+ if (style.getPropertyValue("visibility") != "visible" || style.getPropertyValue("display") == "none") {
return false;
- }
- return true;
+ }
+ return true;
}
@@ -167,10 +168,15 @@ function show_hints(w) {
w = window;
}
var doc = w.document;
+
document.activeElement.blur();
+
var res = doc.body.querySelectorAll('a, area, textarea, select, link, input:not([type=hidden]), button, frame, iframe');
+ console.log(res.length);
+
hints = document.createElement("div");
create_stylesheet();
+
for (var i=0; i<res.length; i++) {
if (get_visibility(res[i])) {
var e = hint_style.toLowerCase() == "letter" ? new LetterHint(res[i]) : new NumberHint(res[i]);
@@ -179,6 +185,7 @@ function show_hints(w) {
}
};
elements.sort( function(a,b) { return a.rect.top - b.rect.top; });
+ console.log(elements.length);
for (var i=0; i<elements.length; i++) {
var e = elements[i];
e.getTextHint(i, elements.length);
@@ -190,7 +197,7 @@ function show_hints(w) {
for (var i=0; i<frames.length; i++) {
show_hints(frames[i]);
}
- document.body.appendChild(hints);
+ document.getElementsByTagName("body")[0].appendChild(hints);
}
function is_input(element) {
diff --git a/src/commands.c b/src/commands.c
index b6f86852..4cbf7c83 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -6,10 +6,11 @@
#include "commands.h"
#include "completion.h"
#include "util.h"
+#include "view.h"
-/* dwb_simple_command(keyMap *km) {{{*/
+/* dwb_com_simple_command(keyMap *km) {{{*/
void
-dwb_simple_command(KeyMap *km) {
+dwb_com_simple_command(KeyMap *km) {
gboolean (*func)(void *) = km->map->func;
Arg *arg = &km->map->arg;
arg->e = NULL;
@@ -40,30 +41,27 @@ dwb_simple_command(KeyMap *km) {
/* COMMANDS {{{*/
-/* dwb_set_setting {{{*/
+/* dwb_com_set_setting {{{*/
gboolean
-dwb_set_setting(Arg *arg) {
+dwb_com_set_setting(Arg *arg) {
dwb.state.mode = SettingsMode;
dwb.state.setting_apply = arg->n;
- dwb_focus_entry();
-
- //dwb_settings_completion(0);
-
+ dwb_com_focus_entry();
return true;
}/*}}}*/
-/* dwb_set_key {{{*/
+/* dwb_com_set_key {{{*/
gboolean
-dwb_set_key(Arg *arg) {
+dwb_com_set_key(Arg *arg) {
dwb.state.mode = KeyMode;
- dwb_focus_entry();
+ dwb_com_focus_entry();
return true;
}/*}}}*/
-/* dwb_toggle_custom_encoding {{{*/
+/* dwb_com_toggle_custom_encoding {{{*/
gboolean
-dwb_toggle_custom_encoding(Arg *arg) {
+dwb_com_toggle_custom_encoding(Arg *arg) {
WebKitWebView *web = CURRENT_WEBVIEW();
const gchar *encoding= webkit_web_view_get_custom_encoding(web);
@@ -85,9 +83,9 @@ dwb_toggle_custom_encoding(Arg *arg) {
return true;
}/*}}}*/
-/* dwb_focus_input {{{*/
+/* dwb_com_focus_input {{{*/
gboolean
-dwb_focus_input(Arg *a) {
+dwb_com_focus_input(Arg *a) {
gchar *value;
value = dwb_execute_script("focus_input()");
if (!strcmp(value, "_dwb_no_input_")) {
@@ -96,9 +94,9 @@ dwb_focus_input(Arg *a) {
return true;
}/*}}}*/
-/* dwb_add_search_field(Arg *) {{{*/
+/* dwb_com_add_search_field(Arg *) {{{*/
gboolean
-dwb_add_search_field(Arg *a) {
+dwb_com_add_search_field(Arg *a) {
gchar *value;
gboolean ret = true;
value = dwb_execute_script("add_searchengine()");
@@ -108,15 +106,15 @@ dwb_add_search_field(Arg *a) {
}
}
dwb.state.mode = SearchFieldMode;
- dwb_focus_entry();
+ dwb_com_focus_entry();
g_free(value);
return ret;
}/*}}}*/
-/* dwb_toggle_property {{{*/
+/* dwb_com_toggle_property {{{*/
gboolean
-dwb_toggle_property(Arg *a) {
+dwb_com_toggle_property(Arg *a) {
gchar *prop = a->p;
gboolean value;
WebKitWebSettings *settings = webkit_web_view_get_settings(CURRENT_WEBVIEW());
@@ -128,9 +126,9 @@ dwb_toggle_property(Arg *a) {
return true;
}/*}}}*/
-/* dwb_toggle_proxy {{{*/
+/* dwb_com_toggle_proxy {{{*/
gboolean
-dwb_toggle_proxy(Arg *a) {
+dwb_com_toggle_proxy(Arg *a) {
WebSettings *s = g_hash_table_lookup(dwb.settings, "proxy");
s->arg.b = !s->arg.b;
@@ -139,20 +137,19 @@ dwb_toggle_proxy(Arg *a) {
return true;
}/*}}}*/
-
-/*dwb_find {{{*/
+/*dwb_com_find {{{*/
gboolean
-dwb_find(Arg *arg) {
+dwb_com_find(Arg *arg) {
dwb.state.mode = FindMode;
dwb.state.forward_search = arg->b;
//g_free(CURRENT_VIEW()->status->search_string);
- dwb_focus_entry();
+ dwb_com_focus_entry();
return true;
}/*}}}*/
-/*dwb_resize_master {{{*/
+/*dwb_com_resize_master {{{*/
gboolean
-dwb_resize_master(Arg *arg) {
+dwb_com_resize_master(Arg *arg) {
gboolean ret = true;
gint inc = dwb.state.nummod == 0 ? arg->n : dwb.state.nummod * arg->n;
gint size = dwb.state.size + inc;
@@ -164,22 +161,22 @@ dwb_resize_master(Arg *arg) {
return ret;
}/*}}}*/
-/* dwb_show_hints {{{*/
+/* dwb_com_show_hints {{{*/
gboolean
-dwb_show_hints(Arg *arg) {
+dwb_com_show_hints(Arg *arg) {
dwb.state.nv = arg->n;
if (dwb.state.mode != HintMode) {
gtk_entry_set_text(GTK_ENTRY(dwb.gui.entry), "");
dwb_execute_script("show_hints()");
dwb.state.mode = HintMode;
- dwb_focus_entry();
+ dwb_com_focus_entry();
}
return true;
}/*}}}*/
-/* dwb_show_keys(Arg *arg){{{*/
+/* dwb_com_show_keys(Arg *arg){{{*/
gboolean
-dwb_show_keys(Arg *arg) {
+dwb_com_show_keys(Arg *arg) {
View *v = dwb.state.fview->data;
GString *buffer = g_string_new(NULL);
g_string_append_printf(buffer, SETTINGS_VIEW, dwb.color.settings_bg_color, dwb.color.settings_fg_color, dwb.misc.settings_border);
@@ -204,9 +201,9 @@ dwb_show_keys(Arg *arg) {
return true;
}/*}}}*/
-/* dwb_show_settings(Arg *a) {{{*/
+/* dwb_com_show_settings(Arg *a) {{{*/
gboolean
-dwb_show_settings(Arg *arg) {
+dwb_com_show_settings(Arg *arg) {
View *v = dwb.state.fview->data;
GString *buffer = g_string_new(NULL);
GHashTable *t;
@@ -223,7 +220,7 @@ dwb_show_settings(Arg *arg) {
}
GList *l = g_hash_table_get_values(t);
- l = g_list_sort(l, (GCompareFunc)dwb_web_settings_sort_second);
+ l = g_list_sort(l, (GCompareFunc)dwb_util_web_settings_sort_second);
g_string_append_printf(buffer, SETTINGS_VIEW, dwb.color.settings_bg_color, dwb.color.settings_fg_color, dwb.misc.settings_border);
g_string_append_printf(buffer, HTML_H2, setting_string, dwb.misc.profile);
@@ -240,7 +237,7 @@ dwb_show_settings(Arg *arg) {
g_string_append_printf(buffer, HTML_DIV_SETTINGS_CHECKBOX, m->n.first, value);
}
else {
- gchar *value = dwb_arg_to_char(&m->arg, m->type);
+ gchar *value = dwb_util_arg_to_char(&m->arg, m->type);
g_string_append_printf(buffer, HTML_DIV_SETTINGS_VALUE, m->n.first, value ? value : "");
}
g_string_append(buffer, HTML_DIV_END);
@@ -256,9 +253,9 @@ dwb_show_settings(Arg *arg) {
return true;
}/*}}}*/
-/* dwb_allow_cookie {{{*/
+/* dwb_com_allow_cookie {{{*/
gboolean
-dwb_allow_cookie(Arg *arg) {
+dwb_com_allow_cookie(Arg *arg) {
if (dwb.state.last_cookie) {
dwb.fc.cookies_allow = g_list_append(dwb.fc.cookies_allow, dwb.state.last_cookie->domain);
soup_cookie_jar_add_cookie(dwb.state.cookiejar, dwb.state.last_cookie);
@@ -270,9 +267,9 @@ dwb_allow_cookie(Arg *arg) {
return false;
}/*}}}*/
-/* dwb_bookmark {{{*/
+/* dwb_com_bookmark {{{*/
gboolean
-dwb_bookmark(Arg *arg) {
+dwb_com_bookmark(Arg *arg) {
gboolean noerror;
if ( (noerror = dwb_prepend_navigation(dwb.state.fview, &dwb.fc.bookmarks)) ) {
gchar *message = g_strdup_printf("Saved bookmark: %s", webkit_web_view_get_uri(CURRENT_WEBVIEW()));
@@ -284,34 +281,34 @@ dwb_bookmark(Arg *arg) {
return dwb_prepend_navigation(dwb.state.fview, &dwb.fc.bookmarks);
}/*}}}*/
-/* dwb_quickmark(Arg *arg) {{{*/
+/* dwb_com_quickmark(Arg *arg) {{{*/
gboolean
-dwb_quickmark(Arg *arg) {
+dwb_com_quickmark(Arg *arg) {
dwb.state.nv = arg->i;
dwb.state.mode = arg->n;
return true;
}/*}}}*/
-/* dwb_reload(Arg *){{{*/
+/* dwb_com_reload(Arg *){{{*/
gboolean
-dwb_reload(Arg *arg) {
+dwb_com_reload(Arg *arg) {
WebKitWebView *web = WEBVIEW_FROM_ARG(arg);
webkit_web_view_reload(web);
return true;
}/*}}}*/
-/* dwb_view_source(Arg) {{{*/
+/* dwb_com_view_source(Arg) {{{*/
gboolean
-dwb_view_source(Arg *arg) {
+dwb_com_view_source(Arg *arg) {
WebKitWebView *web = WEBVIEW_FROM_ARG(arg);
webkit_web_view_set_view_source_mode(web, !webkit_web_view_get_view_source_mode(web));
- dwb_reload(arg);
+ dwb_com_reload(arg);
return true;
}/*}}}*/
-/* dwb_zoom_in(void *arg) {{{*/
+/* dwb_com_zoom_in(void *arg) {{{*/
gboolean
-dwb_zoom_in(Arg *arg) {
+dwb_com_zoom_in(Arg *arg) {
View *v = dwb.state.fview->data;
WebKitWebView *web = WEBKIT_WEB_VIEW(v->web);
gint limit = dwb.state.nummod < 1 ? 1 : dwb.state.nummod;
@@ -328,9 +325,9 @@ dwb_zoom_in(Arg *arg) {
return ret;
}/*}}}*/
-/* dwb_zoom_out(void *arg) {{{*/
+/* dwb_com_zoom_out(void *arg) {{{*/
gboolean
-dwb_zoom_out(Arg *arg) {
+dwb_com_zoom_out(Arg *arg) {
View *v = dwb.state.fview->data;
WebKitWebView *web = WEBKIT_WEB_VIEW(v->web);
gint limit = dwb.state.nummod < 1 ? 1 : dwb.state.nummod;
@@ -347,9 +344,9 @@ dwb_zoom_out(Arg *arg) {
return ret;
}/*}}}*/
-/* dwb_scroll {{{*/
+/* dwb_com_scroll {{{*/
gboolean
-dwb_scroll(Arg *arg) {
+dwb_com_scroll(Arg *arg) {
gboolean ret = true;
gdouble scroll;
@@ -384,17 +381,17 @@ dwb_scroll(Arg *arg) {
return ret;
}/*}}}*/
-/* dwb_set_zoom_level(Arg *arg) {{{*/
+/* dwb_com_set_zoom_level(Arg *arg) {{{*/
void
-dwb_set_zoom_level(Arg *arg) {
+dwb_com_set_zoom_level(Arg *arg) {
GList *gl = arg->p ? arg->p : dwb.state.fview;
webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(((View*)gl->data)->web), arg->d);
}/*}}}*/
-/* dwb_set_orientation(Arg *arg) {{{*/
+/* dwb_com_set_orientation(Arg *arg) {{{*/
gboolean
-dwb_set_orientation(Arg *arg) {
+dwb_com_set_orientation(Arg *arg) {
Layout l;
if (arg->n) {
l = arg->n;
@@ -411,7 +408,7 @@ dwb_set_orientation(Arg *arg) {
/* History {{{*/
gboolean
-dwb_history_back(Arg *arg) {
+dwb_com_history_back(Arg *arg) {
gboolean ret = false;
WebKitWebView *w = CURRENT_WEBVIEW();
if (webkit_web_view_can_go_back(w)) {
@@ -421,7 +418,7 @@ dwb_history_back(Arg *arg) {
return ret;
}
gboolean
-dwb_history_forward(Arg *arg) {
+dwb_com_history_forward(Arg *arg) {
gboolean ret = false;
WebKitWebView *w = CURRENT_WEBVIEW();
if (webkit_web_view_can_go_forward(w)) {
@@ -431,9 +428,9 @@ dwb_history_forward(Arg *arg) {
return ret;
}/*}}}*/
-/* dwb_open(Arg *arg) {{{*/
+/* dwb_com_open(Arg *arg) {{{*/
gboolean
-dwb_open(Arg *arg) {
+dwb_com_open(Arg *arg) {
dwb.state.nv = arg->n;
//gtk_widget_grab_focus(dwb.gui.entry);
@@ -441,46 +438,14 @@ dwb_open(Arg *arg) {
dwb_load_uri(arg);
}
else {
- dwb_focus_entry();
+ dwb_com_focus_entry();
}
return true;
} /*}}}*/
-/* dwb_get_search_engine_uri(const gchar *uri) {{{*/
-gchar *
-dwb_get_search_engine_uri(const gchar *uri, const gchar *text) {
- gchar *ret = NULL;
- if (uri) {
- gchar **token = g_strsplit(uri, HINT_SEARCH_SUBMIT, 2);
- ret = g_strconcat(token[0], text, token[1], NULL);
- g_strfreev(token);
- }
- return ret;
-}/* }}} */
-
-/* dwb_get_search_engine(const gchar *uri) {{{*/
-gchar *
-dwb_get_search_engine(const gchar *uri) {
- gchar *ret = NULL;
- if ( (!strstr(uri, ".") || strstr(uri, " ")) && !strstr(uri, "localhost:")) {
- gchar **token = g_strsplit(uri, " ", 2);
- for (GList *l = dwb.fc.searchengines; l; l=l->next) {
- Navigation *n = l->data;
- if (!strcmp(token[0], n->first)) {
- ret = dwb_get_search_engine_uri(n->second, token[1]);
- break;
- }
- }
- if (!ret) {
- ret = dwb_get_search_engine_uri(dwb.misc.default_search, uri);
- }
- }
- return ret;
-}/*}}}*/
-
-/* dwb_toggle_maximized {{{*/
+/* dwb_com_toggle_maximized {{{*/
void
-dwb_maximized_hide_zoom(View *v, View *no) {
+dwb_com_maximized_hide(View *v, View *no) {
if (dwb.misc.factor != 1.0) {
webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(v->web), 1.0);
}
@@ -489,7 +454,7 @@ dwb_maximized_hide_zoom(View *v, View *no) {
}
}
void
-dwb_maximized_show_zoom(View *v) {
+dwb_com_maximized_show(View *v) {
if (dwb.misc.factor != 1.0 && v != dwb.state.views->data) {
webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(v->web), dwb.misc.factor);
}
@@ -497,10 +462,10 @@ dwb_maximized_show_zoom(View *v) {
}
void
-dwb_toggle_maximized(Arg *arg) {
+dwb_com_toggle_maximized(Arg *arg) {
dwb.state.layout ^= Maximized;
if (dwb.state.layout & Maximized) {
- g_list_foreach(dwb.state.views, (GFunc)dwb_maximized_hide_zoom, NULL);
+ g_list_foreach(dwb.state.views, (GFunc)dwb_com_maximized_hide, NULL);
if (dwb.state.views == dwb.state.fview) {
gtk_widget_hide(dwb.gui.right);
}
@@ -513,14 +478,14 @@ dwb_toggle_maximized(Arg *arg) {
gtk_widget_show(dwb.gui.right);
}
gtk_widget_show(dwb.gui.left);
- g_list_foreach(dwb.state.views, (GFunc)dwb_maximized_show_zoom, NULL);
+ g_list_foreach(dwb.state.views, (GFunc)dwb_com_maximized_show, NULL);
}
dwb_resize(dwb.state.size);
}/*}}}*/
-/* dwb_remove_view(Arg *arg) {{{*/
+/* dwb_com_remove_view(Arg *arg) {{{*/
void
-dwb_remove_view(Arg *arg) {
+dwb_com_remove_view(Arg *arg) {
GList *gl;
if (!dwb.state.views->next) {
dwb_exit();
@@ -569,9 +534,9 @@ dwb_remove_view(Arg *arg) {
dwb_update_layout();
}/*}}}*/
-/* dwb_push_master {{{*/
+/* dwb_com_push_master {{{*/
gboolean
-dwb_push_master(Arg *arg) {
+dwb_com_push_master(Arg *arg) {
GList *gl, *l;
View *old = NULL, *new;
if (!dwb.state.views->next) {
@@ -586,7 +551,7 @@ dwb_push_master(Arg *arg) {
return false;
}
CLEAR_COMMAND_TEXT(dwb.state.views);
- dwb_set_normal_style(dwb.state.fview);
+ dwb_view_set_normal_style(dwb.state.fview);
}
else {
gl = dwb.state.fview;
@@ -600,7 +565,7 @@ dwb_push_master(Arg *arg) {
gtk_widget_reparent(new->vbox, dwb.gui.left);
dwb.state.views = g_list_remove_link(dwb.state.views, l);
dwb.state.views = g_list_concat(l, dwb.state.views);
- dwb_focus(l);
+ dwb_com_focus(l);
}
else {
old = dwb.state.views->data;
@@ -623,25 +588,25 @@ dwb_push_master(Arg *arg) {
return true;
}/*}}}*/
-/* dwb_focus(GList *gl) {{{*/
+/* dwb_com_focus(GList *gl) {{{*/
void
-dwb_focus(GList *gl) {
+dwb_com_focus(GList *gl) {
GList *tmp = NULL;
if (dwb.state.fview) {
tmp = dwb.state.fview;
}
if (tmp) {
- dwb_set_normal_style(tmp);
+ dwb_view_set_normal_style(tmp);
dwb_source_remove(tmp);
CLEAR_COMMAND_TEXT(tmp);
}
dwb_grab_focus(gl);
} /*}}}*/
-/* dwb_focus_next(Arg *arg) {{{*/
+/* dwb_com_focus_next(Arg *arg) {{{*/
gboolean
-dwb_focus_next(Arg *arg) {
+dwb_com_focus_next(Arg *arg) {
GList *gl = dwb.state.fview;
if (!dwb.state.views->next) {
return false;
@@ -655,7 +620,7 @@ dwb_focus_next(Arg *arg) {
gtk_widget_show(((View *)gl->next->data)->vbox);
gtk_widget_hide(((View *)gl->data)->vbox);
}
- dwb_focus(gl->next);
+ dwb_com_focus(gl->next);
}
else {
if (dwb.state.layout & Maximized) {
@@ -664,14 +629,14 @@ dwb_focus_next(Arg *arg) {
gtk_widget_show(((View *)dwb.state.views->data)->vbox);
gtk_widget_hide(((View *)gl->data)->vbox);
}
- dwb_focus(g_list_first(dwb.state.views));
+ dwb_com_focus(g_list_first(dwb.state.views));
}
return true;
}/*}}}*/
-/* dwb_focus_prev(Arg *arg) {{{*/
+/* dwb_com_focus_prev(Arg *arg) {{{*/
gboolean
-dwb_focus_prev(Arg *arg) {
+dwb_com_focus_prev(Arg *arg) {
GList *gl = dwb.state.fview;
if (!dwb.state.views->next) {
return false;
@@ -684,7 +649,7 @@ dwb_focus_prev(Arg *arg) {
gtk_widget_show(((View *)last->data)->vbox);
gtk_widget_hide(((View *)gl->data)->vbox);
}
- dwb_focus(last);
+ dwb_com_focus(last);
}
else {
if (dwb.state.layout & Maximized) {
@@ -695,13 +660,14 @@ dwb_focus_prev(Arg *arg) {
gtk_widget_show(((View *)gl->prev->data)->vbox);
gtk_widget_hide(((View *)gl->data)->vbox);
}
- dwb_focus(gl->prev);
+ dwb_com_focus(gl->prev);
}
return true;
}/*}}}*/
+/* dwb_com_yank {{{*/
gboolean
-dwb_yank(Arg *arg) {
+dwb_com_yank(Arg *arg) {
WebKitWebView *w = CURRENT_WEBVIEW();
GdkAtom atom = GDK_POINTER_TO_ATOM(arg->p);
GtkClipboard *old = gtk_clipboard_get(atom);
@@ -727,9 +693,11 @@ dwb_yank(Arg *arg) {
g_free(text);
}
return ret;
-}
+}/*}}}*/
+
+/* dwb_com_paste {{{*/
gboolean
-dwb_paste(Arg *arg) {
+dwb_com_paste(Arg *arg) {
GdkAtom atom = GDK_POINTER_TO_ATOM(arg->p);
GtkClipboard *clipboard = gtk_clipboard_get(atom);
gchar *text = NULL;
@@ -742,17 +710,17 @@ dwb_paste(Arg *arg) {
return true;
}
return false;
-}
+}/*}}}*/
-/* dwb_entry_delete_word {{{*/
+/* dwb_com_entry_delete_word {{{*/
gboolean
-dwb_entry_delete_word(Arg *a) {
+dwb_com_entry_delete_word(Arg *a) {
gint position = gtk_editable_get_position(GTK_EDITABLE(dwb.gui.entry));
gchar *text = g_strdup(GET_TEXT());
if (position > 0) {
gint new = dwb_entry_position_word_back(position);
- dwb_cut_text(text, new, position);
+ dwb_util_cut_text(text, new, position);
gtk_entry_set_text(GTK_ENTRY(dwb.gui.entry), text);
gtk_editable_set_position(GTK_EDITABLE(dwb.gui.entry), new);
g_free(text);
@@ -760,14 +728,14 @@ dwb_entry_delete_word(Arg *a) {
return true;
}/*}}}*/
-/* dwb_entry_delete_word {{{*/
+/* dwb_com_entry_delete_letter {{{*/
gboolean
-dwb_entry_delete_letter(Arg *a) {
+dwb_com_entry_delete_letter(Arg *a) {
gint position = gtk_editable_get_position(GTK_EDITABLE(dwb.gui.entry));
gchar *text = g_strdup(GET_TEXT());
if (position > 0) {
- dwb_cut_text(text, position-1, position);
+ dwb_util_cut_text(text, position-1, position);
gtk_entry_set_text(GTK_ENTRY(dwb.gui.entry), text);
gtk_editable_set_position(GTK_EDITABLE(dwb.gui.entry), position-1);
g_free(text);
@@ -775,9 +743,9 @@ dwb_entry_delete_letter(Arg *a) {
return true;
}/*}}}*/
-/* dwb_entry_delete_line {{{*/
+/* dwb_com_entry_delete_line {{{*/
gboolean
-dwb_entry_delete_line(Arg *a) {
+dwb_com_entry_delete_line(Arg *a) {
gint position = gtk_editable_get_position(GTK_EDITABLE(dwb.gui.entry));
gchar *text = gtk_editable_get_chars(GTK_EDITABLE(dwb.gui.entry), 0, -1);
@@ -786,27 +754,27 @@ dwb_entry_delete_line(Arg *a) {
return true;
}/*}}}*/
-/* dwb_entry_word_forward {{{*/
+/* dwb_com_entry_word_forward {{{*/
gboolean
-dwb_entry_word_forward(Arg *a) {
+dwb_com_entry_word_forward(Arg *a) {
gint position = gtk_editable_get_position(GTK_EDITABLE(dwb.gui.entry));
gtk_editable_set_position(GTK_EDITABLE(dwb.gui.entry), dwb_entry_position_word_forward(position));
return true;
}/*}}}*/
-/* dwb_entry_word_back {{{*/
+/* dwb_com_entry_word_back {{{*/
gboolean
-dwb_entry_word_back(Arg *a) {
+dwb_com_entry_word_back(Arg *a) {
gint position = gtk_editable_get_position(GTK_EDITABLE(dwb.gui.entry));
gtk_editable_set_position(GTK_EDITABLE(dwb.gui.entry), dwb_entry_position_word_back(position));
return true;
}/*}}}*/
-/* dwb_entry_history_forward {{{*/
+/* dwb_com_entry_history_forward {{{*/
gboolean
-dwb_entry_history_forward(Arg *a) {
+dwb_com_entry_history_forward(Arg *a) {
Navigation *n = NULL;
if ( dwb.state.last_com_history && dwb.state.last_com_history->next ) {
n = dwb.state.last_com_history->next->data;
@@ -819,9 +787,9 @@ dwb_entry_history_forward(Arg *a) {
return true;
}/*}}}*/
-/* dwb_entry_history_back {{{*/
+/* dwb_com_entry_history_back {{{*/
gboolean
-dwb_entry_history_back(Arg *a) {
+dwb_com_entry_history_back(Arg *a) {
Navigation *n = NULL;
if (! dwb.state.last_com_history ) {
if ( (dwb.state.last_com_history = g_list_last(dwb.fc.commands)) ) {
@@ -841,6 +809,5 @@ dwb_entry_history_back(Arg *a) {
}
return true;
}/*}}}*/
-
/*}}}*/
diff --git a/src/commands.h b/src/commands.h
index 5506cde5..6d67ac31 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -1,44 +1,43 @@
#ifndef COMMANDS_H
#define COMMANDS_H
-void dwb_simple_command(KeyMap *km);
-gboolean dwb_set_setting(Arg *);
-gboolean dwb_set_key(Arg *);
-gboolean dwb_allow_cookie(Arg *);
+void dwb_com_simple_command(KeyMap *km);
+gboolean dwb_com_set_setting(Arg *);
+gboolean dwb_com_set_key(Arg *);
+gboolean dwb_com_allow_cookie(Arg *);
gboolean dwb_create_hints(Arg *);
-gboolean dwb_find(Arg *);
-gboolean dwb_focus_input(Arg *);
-gboolean dwb_resize_master(Arg *);
-gboolean dwb_show_hints(Arg *);
-gboolean dwb_show_keys(Arg *);
-gboolean dwb_show_settings(Arg *);
-gboolean dwb_quickmark(Arg *);
-gboolean dwb_bookmark(Arg *);
-gboolean dwb_open(Arg *);
-gboolean dwb_focus_next(Arg *);
-gboolean dwb_focus_prev(Arg *);
-gboolean dwb_reload(Arg *);
-gboolean dwb_set_orientation(Arg *);
-void dwb_toggle_maximized(Arg *);
-gboolean dwb_view_source(Arg *);
-gboolean dwb_zoom_in(Arg *);
-gboolean dwb_zoom_out(Arg *);
-void dwb_set_zoom_level(Arg *);
-gboolean dwb_scroll(Arg *);
-gboolean dwb_history_back(Arg *);
-gboolean dwb_history_forward(Arg *);
-gboolean dwb_toggle_property(Arg *);
-gboolean dwb_toggle_proxy(Arg *);
-gboolean dwb_add_search_field(Arg *);
-gboolean dwb_toggle_custom_encoding(Arg *);
-gboolean dwb_yank(Arg *);
-gboolean dwb_paste(Arg *);
-gchar * dwb_get_search_engine(const gchar *);
-gboolean dwb_entry_delete_word(Arg *);
-gboolean dwb_entry_delete_letter(Arg *);
-gboolean dwb_entry_delete_line(Arg *);
-gboolean dwb_entry_word_forward(Arg *);
-gboolean dwb_entry_word_back(Arg *);
-gboolean dwb_entry_history_forward(Arg *);
-gboolean dwb_entry_history_back(Arg *);
+gboolean dwb_com_find(Arg *);
+gboolean dwb_com_focus_input(Arg *);
+gboolean dwb_com_resize_master(Arg *);
+gboolean dwb_com_show_hints(Arg *);
+gboolean dwb_com_show_keys(Arg *);
+gboolean dwb_com_show_settings(Arg *);
+gboolean dwb_com_quickmark(Arg *);
+gboolean dwb_com_bookmark(Arg *);
+gboolean dwb_com_open(Arg *);
+gboolean dwb_com_focus_next(Arg *);
+gboolean dwb_com_focus_prev(Arg *);
+gboolean dwb_com_reload(Arg *);
+gboolean dwb_com_set_orientation(Arg *);
+void dwb_com_toggle_maximized(Arg *);
+gboolean dwb_com_view_source(Arg *);
+gboolean dwb_com_zoom_in(Arg *);
+gboolean dwb_com_zoom_out(Arg *);
+void dwb_com_set_zoom_level(Arg *);
+gboolean dwb_com_scroll(Arg *);
+gboolean dwb_com_history_back(Arg *);
+gboolean dwb_com_history_forward(Arg *);
+gboolean dwb_com_toggle_property(Arg *);
+gboolean dwb_com_toggle_proxy(Arg *);
+gboolean dwb_com_add_search_field(Arg *);
+gboolean dwb_com_toggle_custom_encoding(Arg *);
+gboolean dwb_com_yank(Arg *);
+gboolean dwb_com_paste(Arg *);
+gboolean dwb_com_entry_delete_word(Arg *);
+gboolean dwb_com_entry_delete_letter(Arg *);
+gboolean dwb_com_entry_delete_line(Arg *);
+gboolean dwb_com_entry_word_forward(Arg *);
+gboolean dwb_com_entry_word_back(Arg *);
+gboolean dwb_com_entry_history_forward(Arg *);
+gboolean dwb_com_entry_history_back(Arg *);
#endif
diff --git a/src/completion.c b/src/completion.c
index 285d0b82..873d5b85 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -5,50 +5,46 @@
#include "completion.h"
#include "commands.h"
#include "util.h"
-/* COMPLETION {{{*/
GList * dwb_comp_update_completion(GtkWidget *box, GList *comps, GList *active, gint max, gint back);
typedef gboolean (*Match_Func)(gchar*, const gchar*);
-/* dwb_clean_completion() {{{*/
-void
-dwb_comp_clean_completion() {
- for (GList *l = dwb.comps.completions; l; l=l->next) {
- g_free(l->data);
- }
- g_list_free(dwb.comps.completions);
- gtk_widget_destroy(CURRENT_VIEW()->compbox);
- dwb.comps.completions = NULL;
- dwb.comps.active_comp = NULL;
- dwb.state.mode &= ~CompletionMode;
-}/*}}}*/
-
+/* GUI_FUNCTIONS {{{*/
/* dwb_comp_modify_completion_item(Completion *c, GdkColor *fg, GdkColor *bg, PangoFontDescription *fd) {{{*/
void
dwb_comp_modify_completion_item(Completion *c, GdkColor *fg, GdkColor *bg, PangoFontDescription *fd) {
gtk_widget_modify_fg(c->llabel, GTK_STATE_NORMAL, fg);
gtk_widget_modify_fg(c->rlabel, GTK_STATE_NORMAL, fg);
+ gtk_widget_modify_fg(c->mlabel, GTK_STATE_NORMAL, fg);
gtk_widget_modify_bg(c->event, GTK_STATE_NORMAL, bg);
gtk_widget_modify_font(c->llabel, fd);
+ gtk_widget_modify_font(c->mlabel, fd);
gtk_widget_modify_font(c->rlabel, dwb.font.fd_oblique);
}/*}}}*/
/* dwb_comp_get_completion_item(Navigation *) return: Completion * {{{*/
Completion *
-dwb_comp_get_completion_item(Navigation *n, void *data) {
+dwb_comp_get_completion_item(Navigation *n, void *data, const gchar *value) {
Completion *c = g_malloc(sizeof(Completion));
c->rlabel = gtk_label_new(n->second);
c->llabel = gtk_label_new(n->first);
+ c->mlabel = gtk_label_new(value);
c->event = gtk_event_box_new();
c->data = data;
- GtkWidget *hbox = gtk_hbox_new(false, 0);
+ GtkWidget *hbox = gtk_hbox_new(value ? true :false, 0);
+
+
+
gtk_box_pack_start(GTK_BOX(hbox), c->llabel, true, true, 5);
+ gtk_box_pack_start(GTK_BOX(hbox), c->mlabel, value ? true : false , true, 5);
gtk_box_pack_start(GTK_BOX(hbox), c->rlabel, true, true, 5);
+
gtk_label_set_ellipsize(GTK_LABEL(c->llabel), PANGO_ELLIPSIZE_MIDDLE);
gtk_label_set_ellipsize(GTK_LABEL(c->rlabel), PANGO_ELLIPSIZE_MIDDLE);
gtk_misc_set_alignment(GTK_MISC(c->llabel), 0.0, 0.5);
+ gtk_misc_set_alignment(GTK_MISC(c->mlabel), 0.0, 0.5);
gtk_misc_set_alignment(GTK_MISC(c->rlabel), 1.0, 0.5);
dwb_comp_modify_completion_item(c, &dwb.color.normal_c_fg, &dwb.color.normal_c_bg, dwb.font.fd_normal);
@@ -67,9 +63,9 @@ dwb_comp_init_completion(GList *store, GList *gl, gboolean word_beginnings) {
for (GList *l = gl; l; l=l->next) {
n = l->data;
if (func(n->first, input)) {
- Completion *c = dwb_comp_get_completion_item(n, NULL);
+ Completion *c = dwb_comp_get_completion_item(n, NULL, NULL);
gtk_box_pack_start(GTK_BOX(CURRENT_VIEW()->compbox), c->event, false, false, 0);
- store = g_list_prepend(store, c);
+ store = g_list_append(store, c);
}
}
return store;
@@ -84,86 +80,6 @@ dwb_comp_set_entry_text(Completion *c) {
}/*}}}*/
-/*dwb_comp_eval_autocompletion{{{*/
-void
-dwb_comp_eval_autocompletion() {
- Completion *c = dwb.comps.active_auto_c->data;
- KeyMap *m = c->data;
- dwb_normal_mode(true);
- dwb_simple_command(m);
-}/*}}}*/
-
-/* dwb_set_autcompletion{{{*/
-void
-dwb_comp_set_autcompletion(GList *l, WebSettings *s) {
- dwb.comps.autocompletion = s->arg.b;
-}/*}}}*/
-
-/* dwb_comp_cleanautocompletion{{{*/
-void
-dwb_comp_clean_autocompletion() {
- for (GList *l = dwb.comps.auto_c; l; l=l->next) {
- g_free(l->data);
- }
- g_list_free(dwb.comps.auto_c);
- gtk_widget_destroy(CURRENT_VIEW()->autocompletion);
- dwb.comps.auto_c = NULL;
- dwb.comps.active_auto_c = NULL;
- dwb.state.mode &= ~AutoComplete;
-
- View *v = CURRENT_VIEW();
- gtk_widget_show(v->entry);
- gtk_widget_show(v->rstatus);
-
-}/*}}}*/
-
-/* dwb_comp_init_autocompletion (GList *gl) return: GList * (Completion*){{{*/
-GList *
-dwb_comp_init_autocompletion(GList *gl) {
- View *v = CURRENT_VIEW();
- GList *ret = NULL;
-
- v->autocompletion = gtk_hbox_new(true, 2);
- gint i=0;
- for (GList *l=gl; l; l=l->next, i++) {
- KeyMap *m = l->data;
- Navigation *n = dwb_navigation_new(m->key, m->map->n.second);
- Completion *c = dwb_comp_get_completion_item(n, m);
- ret = g_list_append(ret, c);
- if (i<5) {
- gtk_widget_show_all(c->event);
- }
- dwb_navigation_free(n);
-
- gtk_box_pack_start(GTK_BOX(v->autocompletion), c->event, true, true, 1);
- }
- GtkWidget *hbox = gtk_bin_get_child(GTK_BIN(v->statusbox));
- gtk_box_pack_start(GTK_BOX(hbox), v->autocompletion, true, true, 10);
- gtk_widget_hide(v->entry);
- gtk_widget_hide(v->rstatus);
- gtk_widget_show(v->autocompletion);
- return ret;
-}/*}}}*/
-
-/* dwb_autocomplete GList *gl(KeyMap*) GdkEventKey *{{{*/
-void
-dwb_comp_autocomplete(GList *gl, GdkEventKey *e) {
- if (!dwb.comps.autocompletion) {
- return;
- }
- View *v = CURRENT_VIEW();
-
- if (! (dwb.state.mode & AutoComplete) && gl) {
- dwb.state.mode |= AutoComplete;
- dwb.comps.auto_c = dwb_comp_init_autocompletion(gl);
- dwb.comps.active_auto_c = g_list_first(dwb.comps.auto_c);
- dwb_comp_modify_completion_item(dwb.comps.active_auto_c->data, &dwb.color.active_c_fg, &dwb.color.active_c_bg, dwb.font.fd_bold);
- }
- else if (e) {
- dwb.comps.active_auto_c = dwb_comp_update_completion(v->autocompletion, dwb.comps.auto_c, dwb.comps.active_auto_c, 5, e->state & GDK_CONTROL_MASK);
- }
-}/*}}}*/
-
/* dwb_comp_update_completion(GtkWidget *box, GList *comps, GList *active, gint max, gint back) Return *GList (Completions*){{{*/
GList *
dwb_comp_update_completion(GtkWidget *box, GList *comps, GList *active, gint max, gint back) {
@@ -226,7 +142,23 @@ dwb_comp_update_completion(GtkWidget *box, GList *comps, GList *active, gint max
dwb_comp_set_entry_text(active->data);
return active;
}/*}}}*/
+/*}}}*/
+/* STANDARD_COMPLETION {{{*/
+/* dwb_clean_completion() {{{*/
+void
+dwb_comp_clean_completion() {
+ for (GList *l = dwb.comps.completions; l; l=l->next) {
+ g_free(l->data);
+ }
+ g_list_free(dwb.comps.completions);
+ gtk_widget_destroy(CURRENT_VIEW()->compbox);
+ dwb.comps.completions = NULL;
+ dwb.comps.active_comp = NULL;
+ dwb.state.mode &= ~CompletionMode;
+}/*}}}*/
+
+/* dwb_comp_show_completion(gint back) {{{*/
void
dwb_comp_show_completion(gint back) {
int i=0;
@@ -246,17 +178,17 @@ dwb_comp_show_completion(gint back) {
dwb_comp_set_entry_text(dwb.comps.active_comp->data);
gtk_widget_show(CURRENT_VIEW()->compbox);
-}
+}/*}}}*/
/* dwb_completion_get_normal return: GList *Completions{{{*/
GList *
dwb_comp_get_normal_completion() {
GList *list = NULL;
+ list = dwb_comp_init_completion(list, dwb.fc.commands, true);
+ list = dwb_comp_init_completion(list, dwb.fc.bookmarks, false);
if (GET_BOOL("complete-history")) {
list = dwb_comp_init_completion(list, dwb.fc.history, false);
}
- list = dwb_comp_init_completion(list, dwb.fc.bookmarks, false);
- list = dwb_comp_init_completion(list, dwb.fc.commands, true);
return list;
}/*}}}*/
@@ -264,32 +196,48 @@ dwb_comp_get_normal_completion() {
GList *
dwb_comp_get_settings_completion() {
GList *l = g_hash_table_get_values(dwb.settings);
- l = g_list_sort(l, (GCompareFunc)dwb_web_settings_sort_first);
- GList *data = NULL;
+ l = g_list_sort(l, (GCompareFunc)dwb_util_web_settings_sort_first);
+ const gchar *input = GET_TEXT();
GList *list = NULL;
for (; l; l=l->next) {
WebSettings *s = l->data;
if (dwb.state.setting_apply == Global || !s->global) {
- data = g_list_prepend(data, &s->n);
+ Navigation n = s->n;
+ if (g_str_has_prefix(n.first, input)) {
+ gchar *value = dwb_util_arg_to_char(&s->arg, s->type);
+ Completion *c = dwb_comp_get_completion_item(&n, s, value);
+ gtk_box_pack_start(GTK_BOX(CURRENT_VIEW()->compbox), c->event, false, false, 0);
+ list = g_list_append(list, c);
+ }
}
}
- list = dwb_comp_init_completion(list, data, true);
- g_list_free(data);
return list;
}/*}}}*/
/*dwb_completion_get_keys() return GList *Completions{{{*/
+gint
+dwb_comp_key_sort(Completion *a, Completion *b) {
+ return strcmp(((KeyMap*)a->data)->map->n.first, ((KeyMap*)b->data)->map->n.first);
+}
GList *
dwb_comp_get_key_completion() {
- GList *data = NULL;
GList *list = NULL;
+ const gchar *input = GET_TEXT();
+
+ dwb.keymap = g_list_sort(dwb.keymap, (GCompareFunc)dwb_util_keymap_sort_first);
+
for (GList *l = dwb.keymap; l; l=l->next) {
KeyMap *m = l->data;
- data = g_list_prepend(data, &m->map->n);
+ Navigation n = m->map->n;
+ if (g_str_has_prefix(n.first, input)) {
+ gchar *value = g_strdup_printf("%s %s", dwb_modmask_to_string(m->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);
+ g_free(value);
+ }
}
- list = dwb_comp_init_completion(list, data, true);
- g_list_free(data);
return list;
}/*}}}*/
@@ -319,9 +267,91 @@ dwb_comp_complete(gint back) {
}
}/*}}}*/
+/*}}}*/
+
+/* AUTOCOMPLETION {{{*/
+/*dwb_comp_eval_autocompletion{{{*/
+void
+dwb_comp_eval_autocompletion() {
+ Completion *c = dwb.comps.active_auto_c->data;
+ KeyMap *m = c->data;
+ dwb_normal_mode(true);
+ dwb_com_simple_command(m);
+}/*}}}*/
+
+/* dwb_set_autcompletion{{{*/
+void
+dwb_comp_set_autcompletion(GList *l, WebSettings *s) {
+ dwb.comps.autocompletion = s->arg.b;
+}/*}}}*/
+
+/* dwb_comp_cleanautocompletion{{{*/
+void
+dwb_comp_clean_autocompletion() {
+ for (GList *l = dwb.comps.auto_c; l; l=l->next) {
+ g_free(l->data);
+ }
+ g_list_free(dwb.comps.auto_c);
+ gtk_widget_destroy(CURRENT_VIEW()->autocompletion);
+ dwb.comps.auto_c = NULL;
+ dwb.comps.active_auto_c = NULL;
+ dwb.state.mode &= ~AutoComplete;
+
+ View *v = CURRENT_VIEW();
+ gtk_widget_show(v->entry);
+ gtk_widget_show(v->rstatus);
+
+}/*}}}*/
+
+/* dwb_comp_init_autocompletion (GList *gl) return: GList * (Completion*){{{*/
+GList *
+dwb_comp_init_autocompletion(GList *gl) {
+ View *v = CURRENT_VIEW();
+ GList *ret = NULL;
+
+ v->autocompletion = gtk_hbox_new(true, 2);
+ gint i=0;
+ for (GList *l=gl; l; l=l->next, i++) {
+ KeyMap *m = l->data;
+ Navigation *n = dwb_navigation_new(m->key, m->map->n.second);
+ Completion *c = dwb_comp_get_completion_item(n, m, NULL);
+ ret = g_list_append(ret, c);
+ if (i<5) {
+ gtk_widget_show_all(c->event);
+ }
+ dwb_navigation_free(n);
+
+ gtk_box_pack_start(GTK_BOX(v->autocompletion), c->event, true, true, 1);
+ }
+ GtkWidget *hbox = gtk_bin_get_child(GTK_BIN(v->statusbox));
+ gtk_box_pack_start(GTK_BOX(hbox), v->autocompletion, true, true, 10);
+ gtk_widget_hide(v->entry);
+ gtk_widget_hide(v->rstatus);
+ gtk_widget_show(v->autocompletion);
+ return ret;
+}/*}}}*/
-// Pathcompletion
+/* dwb_autocomplete GList *gl(KeyMap*) GdkEventKey *{{{*/
+void
+dwb_comp_autocomplete(GList *gl, GdkEventKey *e) {
+ if (!dwb.comps.autocompletion) {
+ return;
+ }
+ View *v = CURRENT_VIEW();
+ if (! (dwb.state.mode & AutoComplete) && gl) {
+ dwb.state.mode |= AutoComplete;
+ dwb.comps.auto_c = dwb_comp_init_autocompletion(gl);
+ dwb.comps.active_auto_c = g_list_first(dwb.comps.auto_c);
+ dwb_comp_modify_completion_item(dwb.comps.active_auto_c->data, &dwb.color.active_c_fg, &dwb.color.active_c_bg, dwb.font.fd_bold);
+ }
+ else if (e) {
+ dwb.comps.active_auto_c = dwb_comp_update_completion(v->autocompletion, dwb.comps.auto_c, dwb.comps.active_auto_c, 5, e->state & GDK_CONTROL_MASK);
+ }
+}/*}}}*/
+/*}}}*/
+
+/* PATHCOMPLETION {{{*/
/* dwb_comp_clean_path_completion {{{*/
void
dwb_comp_clean_path_completion() {
@@ -334,6 +364,7 @@ dwb_comp_clean_path_completion() {
}
}/*}}}*/
+/* dwb_comp_get_binaries(GList *list, gchar *text) return GList *{{{*/
GList *
dwb_comp_get_binaries(GList *list, gchar *text) {
GDir *dir;
@@ -385,7 +416,7 @@ dwb_comp_get_path(GList *list, gchar *text) {
g_dir_close(dir);
}
return list;
-}
+}/*}}}*/
/* dwb_comp_init_path_completion {{{*/
void
@@ -435,3 +466,4 @@ dwb_comp_complete_download(gint back) {
dwb_entry_set_text(dwb.comps.active_path->data);
}
}/*}}}*/
+/*}}}*/
diff --git a/src/completion.h b/src/completion.h
index 1949f296..c72e482b 100644
--- a/src/completion.h
+++ b/src/completion.h
@@ -7,6 +7,7 @@ struct _Completion {
GtkWidget *event;
GtkWidget *rlabel;
GtkWidget *llabel;
+ GtkWidget *mlabel;
void *data;
};
diff --git a/src/download.c b/src/download.c
index b7d773fd..75005350 100644
--- a/src/download.c
+++ b/src/download.c
@@ -5,8 +5,6 @@
#include "util.h"
#include "completion.h"
-
-gchar * dwb_get_download_command(const gchar *uri, const gchar *output);
typedef struct _DwbDownload {
GtkWidget *event;
GtkWidget *rlabel;
@@ -16,10 +14,30 @@ typedef struct _DwbDownload {
gchar *path;
} DwbDownload;
-
static GList *downloads = NULL;
+/* dwb_get_download_command {{{*/
+gchar *
+dwb_get_download_command(const gchar *uri, const gchar *output) {
+ gchar *command = g_strdup(GET_CHAR("download-external-command"));
+ gchar *newcommand = NULL;
+ if ( (newcommand = dwb_util_string_replace(command, "dwb_uri", uri)) ) {
+ g_free(command);
+ command = newcommand;
+ }
+ if ( (newcommand = dwb_util_string_replace(command, "dwb_cookies", dwb.files.cookies)) ) {
+ g_free(command);
+ command = newcommand;
+ }
+ if ( (newcommand = dwb_util_string_replace(command, "dwb_output", output)) ) {
+ g_free(command);
+ command = newcommand;
+ }
+ return command;
+}/*}}}*/
+
+/* dwb_dl_get_download_label(WebKitDownload *) {{{*/
GList *
dwb_dl_get_download_label(WebKitDownload *download) {
for (GList *l = downloads; l; l=l->next) {
@@ -29,8 +47,9 @@ dwb_dl_get_download_label(WebKitDownload *download) {
}
}
return NULL;
-}
+}/*}}}*/
+/* dwb_dl_progress_cb(WebKitDownload *) {{{*/
void
dwb_dl_progress_cb(WebKitDownload *download) {
GList *l = dwb_dl_get_download_label(download);
@@ -55,22 +74,26 @@ dwb_dl_progress_cb(WebKitDownload *download) {
gdk_color_parse(colorstring, &color);
gtk_widget_modify_bg(label->event, GTK_STATE_NORMAL, &color);
g_free(colorstring);
-}
+}/*}}}*/
-void
+/* dwb_dl_set_mimetype(const gchar *) {{{*/
+void
dwb_dl_set_mimetype(const gchar *command) {
- for (GList *l = dwb.fc.mimetypes; l; l=l->next) {
- Navigation *n = l->data;
- if (!strcmp(dwb.state.mimetype_request, n->first)) {
- g_free(n->second);
- n->second = g_strdup(command);
- return;
+ if (dwb.state.mimetype_request) {
+ for (GList *l = dwb.fc.mimetypes; l; l=l->next) {
+ Navigation *n = l->data;
+ if (!strcmp(dwb.state.mimetype_request, n->first)) {
+ g_free(n->second);
+ n->second = g_strdup(command);
+ return;
+ }
}
+ Navigation *n = dwb_navigation_new(dwb.state.mimetype_request, command);
+ dwb.fc.mimetypes = g_list_prepend(dwb.fc.mimetypes, n);
}
- Navigation *n = dwb_navigation_new(dwb.state.mimetype_request, command);
- dwb.fc.mimetypes = g_list_prepend(dwb.fc.mimetypes, n);
-}
+}/*}}}*/
+/* dwb_dl_spawn(DwbDownload *) {{{*/
void
dwb_dl_spawn(DwbDownload *dl) {
GError *error = NULL;
@@ -84,9 +107,9 @@ dwb_dl_spawn(DwbDownload *dl) {
dwb_dl_set_mimetype(dl->path);
g_free(command);
g_strfreev(argv);
-}
-
+}/*}}}*/
+/* dwb_dl_status_cb(WebKitDownload *) {{{*/
void
dwb_dl_status_cb(WebKitDownload *download) {
WebKitDownloadStatus status = webkit_download_get_status(download);
@@ -107,8 +130,9 @@ dwb_dl_status_cb(WebKitDownload *download) {
}
g_free(dwb.state.mimetype_request);
}
-}
+}/*}}}*/
+/* dwb_dl_button_press_cb(GtkWidget *w, GdkEventButton *e, GList *) {{{*/
gboolean
dwb_dl_button_press_cb(GtkWidget *w, GdkEventButton *e, GList *gl) {
if (e->button == 3) {
@@ -116,8 +140,9 @@ dwb_dl_button_press_cb(GtkWidget *w, GdkEventButton *e, GList *gl) {
webkit_download_cancel(label->download);
}
return false;
-}
+}/*}}}*/
+/* dwb_dl_add_progress_label (GList *gl, const gchar *filename) {{{*/
DwbDownload *
dwb_dl_add_progress_label(GList *gl, const gchar *filename) {
DwbDownload *l = g_malloc(sizeof(DwbDownload));
@@ -145,11 +170,11 @@ dwb_dl_add_progress_label(GList *gl, const gchar *filename) {
l->download = dwb.state.download;
- //gtk_widget_show_all(l->event);
gtk_widget_show_all(dwb.gui.downloadbar);
return l;
-}
+}/*}}}*/
+/* dwb_dl_start {{{*/
void
dwb_dl_start() {
const gchar *path = GET_TEXT();
@@ -208,8 +233,9 @@ dwb_dl_start() {
dwb_normal_mode(true);
dwb.state.download = NULL;
g_free(fullpath);
-}
+}/*}}}*/
+/* dwb_dl_entry_set_directory() {{{*/
void
dwb_dl_entry_set_directory() {
dwb_set_normal_message(dwb.state.fview, "Downloadpath:", false);
@@ -221,24 +247,25 @@ dwb_dl_entry_set_directory() {
g_free(current_dir);
if (newdir)
g_free(newdir);
-}
+}/*}}}*/
+/* dwb_dl_entry_set_spawn_command{{{*/
void
dwb_dl_entry_set_spawn_command(const gchar *command) {
- if (!command) {
+ if (!command && dwb.state.mimetype_request) {
command = dwb_get_command_from_mimetype(dwb.state.mimetype_request);
}
- gchar *message = g_strdup_printf("Spawn (%s):", dwb.state.mimetype_request);
+ gchar *message = g_strdup_printf("Spawn (%s):", dwb.state.mimetype_request ? dwb.state.mimetype_request : "???");
dwb_set_normal_message(dwb.state.fview, message, false);
g_free(message);
dwb_entry_set_text(command ? command : "");
-}
+}/*}}}*/
-/*{{{*/
+/* dwb_dl_get_path {{{*/
void
dwb_dl_get_path(GList *gl, WebKitDownload *d) {
gchar *command;
- dwb_focus_entry();
+ dwb_com_focus_entry();
dwb.state.mode = DownloadGetPath;
dwb.state.download = d;
@@ -251,7 +278,7 @@ dwb_dl_get_path(GList *gl, WebKitDownload *d) {
}
}/*}}}*/
-
+/* dwb_dl_set_execute {{{*/
void
dwb_dl_set_execute(Arg *arg) {
if (dwb.state.mode == DownloadGetPath) {
@@ -264,24 +291,4 @@ dwb_dl_set_execute(Arg *arg) {
dwb_dl_entry_set_directory();
}
}
-}
-gchar *
-dwb_get_download_command(const gchar *uri, const gchar *output) {
- gchar *command = g_strdup(GET_CHAR("download-external-command"));
- gchar *newcommand = NULL;
-
- if ( (newcommand = dwb_string_replace(command, "dwb_uri", uri)) ) {
- g_free(command);
- command = newcommand;
- }
- if ( (newcommand = dwb_string_replace(command, "dwb_cookies", dwb.files.cookies)) ) {
- g_free(command);
- command = newcommand;
- }
- if ( (newcommand = dwb_string_replace(command, "dwb_output", output)) ) {
- g_free(command);
- command = newcommand;
- }
- return command;
-}
-
+}/*}}}*/
diff --git a/src/dwb.c b/src/dwb.c
index 40d813b6..0c4bc450 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -54,7 +54,6 @@ function checkbox_click(id) { e = document.activeElement; value = e.value ? e.id
/*}}}*/
#define INSERT_MODE "Insert Mode"
-#define CLIPBOARD_PTR
#define HINT_SEARCH_SUBMIT "_dwb_search_submit_"
/* DECLARATIONS {{{*/
@@ -63,9 +62,9 @@ void dwb_clean_buffer(GList *);
gboolean dwb_command_mode(Arg *arg);
void dwb_set_vars(GList *, WebSettings *);
-void dwb_reload_scripts(GList *, WebSettings *);
-void dwb_reload_colors(GList *, WebSettings *);
-void dwb_reload_layout(GList *, WebSettings *);
+void dwb_com_reload_scripts(GList *, WebSettings *);
+void dwb_com_reload_colors(GList *, WebSettings *);
+void dwb_com_reload_layout(GList *, WebSettings *);
gboolean dwb_test_cookie_allowed(const gchar *);
void dwb_save_cookies(void);
void dwb_web_settings_set_value(const gchar *id, Arg *a);
@@ -79,7 +78,7 @@ void dwb_resize(gdouble);
void dwb_tab_label_set_text(GList *, const gchar *);
void dwb_save_quickmark(const gchar *);
-void dwb_open_quickmark(const gchar *);
+void dwb_com_open_quickmark(const gchar *);
GList * dwb_keymap_delete(GList *, KeyValue );
@@ -111,84 +110,82 @@ static gint MAX_COMPLETIONS = 11;
#define NO_URL "No URL in current context"
#define NO_HINTS "No Hints in current context"
static FunctionMap FMAP [] = {
- { { "add_view", "Add a new view", }, (Func)dwb_add_view, NULL, AlwaysSM, { .p = NULL }, },
- { { "allow_cookie", "Cookie allowed", }, (Func)dwb_allow_cookie, "No cookie in current context", PostSM, },
- { { "autoload_images", "Setting: autoload images", }, (Func)dwb_toggle_property, NULL, PostSM, { .p = "auto-load-images" } },
- { { "autoresize_window", "Setting: autoresize window", }, (Func)dwb_toggle_property, NULL, PostSM, { .p = "auto-resize-window" } },
- { { "bookmark", "Bookmark current page", }, (Func)dwb_bookmark, NO_URL, PostSM, },
- { { "command_mode", "Enter command mode", }, (Func)dwb_command_mode, NULL, PostSM, },
- { { "caret_browsing", "Setting: caret browsing", }, (Func)dwb_toggle_property, NULL, PostSM, { .p = "enable-caret-browsing" } },
- { { "decrease_master", "Decrease master area", }, (Func)dwb_resize_master, "Cannot decrease further", AlwaysSM, { .n = 5 } },
- { { "download_hint", "Download via hints", }, (Func)dwb_show_hints, NO_HINTS, NeverSM, { .n = OpenDownload }, },
- { { "find_backward", "Find Backward ", }, (Func)dwb_find, NO_URL, NeverSM, { .b = false }, },
- { { "find_forward", "Find Forward ", }, (Func)dwb_find, NO_URL, NeverSM, { .b = true }, },
- { { "find_next", "Find next", }, (Func)dwb_search, "No matches", AlwaysSM, { .b = true }, },
- { { "find_previous", "Find next", }, (Func)dwb_search, "No matches", AlwaysSM, { .b = false }, },
- { { "focus_input", "Focus input", }, (Func)dwb_focus_input, "No input found in current context", AlwaysSM, },
- { { "focus_next", "Focus next view", }, (Func)dwb_focus_next, "No other view", AlwaysSM, },
- { { "focus_prev", "Focus previous view", }, (Func)dwb_focus_prev, "No other view", AlwaysSM, },
- { { "hint_mode", "Follow hints ", }, (Func)dwb_show_hints, NO_HINTS, NeverSM, { .n = OpenNormal }, },
- { { "hint_mode_nv", "Follow hints in a new view ", }, (Func)dwb_show_hints, NO_HINTS, NeverSM, { .n = OpenNewView }, },
- { { "history_back", "Go Back", }, (Func)dwb_history_back, "Beginning of History", AlwaysSM, },
- { { "history_forward", "Go Forward", }, (Func)dwb_history_forward, "End of History", AlwaysSM, },
- { { "increase_master", "Increase master area", }, (Func)dwb_resize_master, "Cannot increase further", AlwaysSM, { .n = -5 } },
- { { "insert_mode", "Insert Mode", }, (Func)dwb_insert_mode, NULL, AlwaysSM, },
- { { "java_applets", "Setting: java applets", }, (Func)dwb_toggle_property, NULL, PostSM, { .p = "enable-java-applets" } },
- { { "open", "Open URL", }, (Func)dwb_open, NULL, NeverSM, { .n = OpenNormal, .p = NULL } },
- { { "open_nv", "Open URL in a new view", }, (Func)dwb_open, NULL, NeverSM, { .n = OpenNewView, .p = NULL } },
- { { "open_quickmark", "Open quickmark", }, (Func)dwb_quickmark, NO_URL, NeverSM, { .n = QuickmarkOpen, .i=OpenNormal }, },
- { { "open_quickmark_nv", "Open quickmark in a new view", }, (Func)dwb_quickmark, NULL, NeverSM, { .n = QuickmarkOpen, .i=OpenNewView }, },
- { { "plugins", "Setting: plugins", }, (Func)dwb_toggle_property, NULL, PostSM, { .p = "enable-plugins" } },
- { { "private_browsing", "Setting: private browsing", }, (Func)dwb_toggle_property, NULL, PostSM, { .p = "enable-private-browsing" } },
- { { "proxy", "Setting: proxy", }, (Func)dwb_toggle_proxy, NULL, PostSM, { 0 } },
- { { "push_master", "Push to master area", }, (Func)dwb_push_master, "No other view", AlwaysSM, },
- { { "reload", "Reload", }, (Func)dwb_reload, NULL, AlwaysSM, },
- { { "remove_view", "Close view", }, (Func)dwb_remove_view, NULL, AlwaysSM, },
- { { "save_quickmark", "Save a quickmark for this page", }, (Func)dwb_quickmark, NO_URL, NeverSM, { .n = QuickmarkSave }, },
- { { "save_search_field", "Add a new searchengine", }, (Func)dwb_add_search_field, "No input in current context", NeverSM, },
- { { "scripts", "Setting: scripts", }, (Func)dwb_toggle_property, NULL, PostSM, { .p = "enable-scripts" } },
- { { "scroll_bottom", "Scroll to bottom of the page", }, (Func)dwb_scroll, NULL, AlwaysSM, { .n = Bottom }, },
- { { "scroll_down", "Scroll down", }, (Func)dwb_scroll, "Bottom of the page", AlwaysSM, { .n = Down, }, },
- { { "scroll_left", "Scroll left", }, (Func)dwb_scroll, "Left side of the page", AlwaysSM, { .n = Left }, },
- { { "scroll_page_down", "Scroll one page down", }, (Func)dwb_scroll, "Bottom of the page", AlwaysSM, { .n = PageDown, }, },
- { { "scroll_page_up", "Scroll one page up", }, (Func)dwb_scroll, "Top of the page", AlwaysSM, { .n = PageUp, }, },
- { { "scroll_right", "Scroll left", }, (Func)dwb_scroll, "Right side of the page", AlwaysSM, { .n = Right }, },
- { { "scroll_top", "Scroll to the top of the page", }, (Func)dwb_scroll, NULL, AlwaysSM, { .n = Top }, },
- { { "scroll_up", "Scroll up", }, (Func)dwb_scroll, "Top of the page", AlwaysSM, { .n = Up, }, },
- { { "set_global_setting", "Set global property", }, (Func)dwb_set_setting, NULL, NeverSM, { .n = Global } },
- { { "set_key", "Set keybinding", }, (Func)dwb_set_key, NULL, NeverSM, { 0 } },
- { { "set_setting", "Set property", }, (Func)dwb_set_setting, NULL, NeverSM, { .n = PerView } },
- { { "show_global_settings", "Show global settings", }, (Func)dwb_show_settings, NULL, AlwaysSM, { .n = Global } },
- { { "show_keys", "Key configuration", }, (Func)dwb_show_keys, NULL, AlwaysSM, },
- { { "show_settings", "Settings", }, (Func)dwb_show_settings, NULL, AlwaysSM, { .n = PerView } },
- { { "spell_checking", "Setting: spell checking", }, (Func)dwb_toggle_property, NULL, PostSM, { .p = "enable-spell-checking" } },
- { { "toggle_bottomstack", "Toggle bottomstack", }, (Func)dwb_set_orientation, NULL, AlwaysSM, },
- { { "toggle_encoding", "Toggle Custom encoding", }, (Func)dwb_toggle_custom_encoding, NULL, AlwaysSM, },
- { { "toggle_maximized", "Toggle maximized", }, (Func)dwb_toggle_maximized, NULL, AlwaysSM, },
- { { "toggle_shrink_images", "Setting: autoshrink images", }, (Func)dwb_toggle_property, NULL, PostSM, { .p = "auto-shrink-images" } },
- { { "view_source", "View source", }, (Func)dwb_view_source, NULL, AlwaysSM, },
- { { "zoom_in", "Zoom in", }, (Func)dwb_zoom_in, "Cannot zoom in further", AlwaysSM, },
- { { "zoom_normal", "Zoom 100%", }, (Func)dwb_set_zoom_level, NULL, AlwaysSM, { .d = 1.0, .p = NULL } },
- { { "zoom_out", "Zoom out", }, (Func)dwb_zoom_out, "Cannot zoom out further", AlwaysSM, },
- { { "yank", "Yank", }, (Func)dwb_yank, NO_URL, PostSM, { .p = GDK_NONE } },
- { { "yank_primary", "Yank to Primary selection", }, (Func)dwb_yank, NO_URL, PostSM, { .p = GDK_SELECTION_PRIMARY } },
- { { "paste", "Paste", }, (Func)dwb_paste, "Clipboard is empty", AlwaysSM, { .n = OpenNormal, .p = GDK_NONE } },
- { { "paste_primary", "Paste primary selection", }, (Func)dwb_paste, "No primary selection", AlwaysSM, { .n = OpenNormal, .p = GDK_SELECTION_PRIMARY } },
- { { "paste_nv", "Paste, new view", }, (Func)dwb_paste, "Clipboard is empty", AlwaysSM, { .n = OpenNewView, .p = GDK_NONE } },
- { { "paste_primary_nv", "Paste primary selection, new view", }, (Func)dwb_paste, "No primary selection", AlwaysSM, { .n = OpenNewView, .p = GDK_SELECTION_PRIMARY } },
+ { { "add_view", "Add a new view", }, (Func)dwb_add_view, NULL, AlwaysSM, { .p = NULL }, },
+ { { "allow_cookie", "Cookie allowed", }, (Func)dwb_com_allow_cookie, "No cookie in current context", PostSM, },
+ { { "autoload_images", "Setting: autoload images", }, (Func)dwb_com_toggle_property, NULL, PostSM, { .p = "auto-load-images" } },
+ { { "autoresize_window", "Setting: autoresize window", }, (Func)dwb_com_toggle_property, NULL, PostSM, { .p = "auto-resize-window" } },
+ { { "bookmark", "Bookmark current page", }, (Func)dwb_com_bookmark, NO_URL, PostSM, },
+ { { "command_mode", "Enter command mode", }, (Func)dwb_command_mode, NULL, PostSM, },
+ { { "caret_browsing", "Setting: caret browsing", }, (Func)dwb_com_toggle_property, NULL, PostSM, { .p = "enable-caret-browsing" } },
+ { { "decrease_master", "Decrease master area", }, (Func)dwb_com_resize_master, "Cannot decrease further", AlwaysSM, { .n = 5 } },
+ { { "download_hint", "Download via hints", }, (Func)dwb_com_show_hints, NO_HINTS, NeverSM, { .n = OpenDownload }, },
+ { { "find_backward", "Find Backward ", }, (Func)dwb_com_find, NO_URL, NeverSM, { .b = false }, },
+ { { "find_forward", "Find Forward ", }, (Func)dwb_com_find, NO_URL, NeverSM, { .b = true }, },
+ { { "find_next", "Find next", }, (Func)dwb_search, "No matches", AlwaysSM, { .b = true }, },
+ { { "find_previous", "Find next", }, (Func)dwb_search, "No matches", AlwaysSM, { .b = false }, },
+ { { "focus_input", "Focus input", }, (Func)dwb_com_focus_input, "No input found in current context", AlwaysSM, },
+ { { "focus_next", "Focus next view", }, (Func)dwb_com_focus_next, "No other view", AlwaysSM, },
+ { { "focus_prev", "Focus previous view", }, (Func)dwb_com_focus_prev, "No other view", AlwaysSM, },
+ { { "hint_mode", "Follow hints ", }, (Func)dwb_com_show_hints, NO_HINTS, NeverSM, { .n = OpenNormal }, },
+ { { "hint_mode_nv", "Follow hints in a new view ", }, (Func)dwb_com_show_hints, NO_HINTS, NeverSM, { .n = OpenNewView }, },
+ { { "history_back", "Go Back", }, (Func)dwb_com_history_back, "Beginning of History", AlwaysSM, },
+ { { "history_forward", "Go Forward", }, (Func)dwb_com_history_forward, "End of History", AlwaysSM, },
+ { { "increase_master", "Increase master area", }, (Func)dwb_com_resize_master, "Cannot increase further", AlwaysSM, { .n = -5 } },
+ { { "insert_mode", "Insert Mode", }, (Func)dwb_insert_mode, NULL, AlwaysSM, },
+ { { "java_applets", "Setting: java applets", }, (Func)dwb_com_toggle_property, NULL, PostSM, { .p = "enable-java-applets" } },
+ { { "open", "Open URL", }, (Func)dwb_com_open, NULL, NeverSM, { .n = OpenNormal, .p = NULL } },
+ { { "open_nv", "Open URL in a new view", }, (Func)dwb_com_open, NULL, NeverSM, { .n = OpenNewView, .p = NULL } },
+ { { "open_quickmark", "Open quickmark", }, (Func)dwb_com_quickmark, NO_URL, NeverSM, { .n = QuickmarkOpen, .i=OpenNormal }, },
+ { { "open_quickmark_nv", "Open quickmark in a new view", }, (Func)dwb_com_quickmark, NULL, NeverSM, { .n = QuickmarkOpen, .i=OpenNewView }, },
+ { { "plugins", "Setting: plugins", }, (Func)dwb_com_toggle_property, NULL, PostSM, { .p = "enable-plugins" } },
+ { { "private_browsing", "Setting: private browsing", }, (Func)dwb_com_toggle_property, NULL, PostSM, { .p = "enable-private-browsing" } },
+ { { "proxy", "Setting: proxy", }, (Func)dwb_com_toggle_proxy, NULL, PostSM, { 0 } },
+ { { "push_master", "Push to master area", }, (Func)dwb_com_push_master, "No other view", AlwaysSM, },
+ { { "reload", "Reload", }, (Func)dwb_com_reload, NULL, AlwaysSM, },
+ { { "remove_view", "Close view", }, (Func)dwb_com_remove_view, NULL, AlwaysSM, },
+ { { "save_quickmark", "Save a quickmark for this page", }, (Func)dwb_com_quickmark, NO_URL, NeverSM, { .n = QuickmarkSave }, },
+ { { "save_search_field", "Add a new searchengine", }, (Func)dwb_com_add_search_field, "No input in current context", NeverSM, },
+ { { "scripts", "Setting: scripts", }, (Func)dwb_com_toggle_property, NULL, PostSM, { .p = "enable-scripts" } },
+ { { "scroll_bottom", "Scroll to bottom of the page", }, (Func)dwb_com_scroll, NULL, AlwaysSM, { .n = Bottom }, },
+ { { "scroll_down", "Scroll down", }, (Func)dwb_com_scroll, "Bottom of the page", AlwaysSM, { .n = Down, }, },
+ { { "scroll_left", "Scroll left", }, (Func)dwb_com_scroll, "Left side of the page", AlwaysSM, { .n = Left }, },
+ { { "scroll_page_down", "Scroll one page down", }, (Func)dwb_com_scroll, "Bottom of the page", AlwaysSM, { .n = PageDown, }, },
+ { { "scroll_page_up", "Scroll one page up", }, (Func)dwb_com_scroll, "Top of the page", AlwaysSM, { .n = PageUp, }, },
+ { { "scroll_right", "Scroll left", }, (Func)dwb_com_scroll, "Right side of the page", AlwaysSM, { .n = Right }, },
+ { { "scroll_top", "Scroll to the top of the page", }, (Func)dwb_com_scroll, NULL, AlwaysSM, { .n = Top }, },
+ { { "scroll_up", "Scroll up", }, (Func)dwb_com_scroll, "Top of the page", AlwaysSM, { .n = Up, }, },
+ { { "set_global_setting", "Set global property", }, (Func)dwb_com_set_setting, NULL, NeverSM, { .n = Global } },
+ { { "set_key", "Set keybinding", }, (Func)dwb_com_set_key, NULL, NeverSM, { 0 } },
+ { { "set_setting", "Set property", }, (Func)dwb_com_set_setting, NULL, NeverSM, { .n = PerView } },
+ { { "show_global_settings", "Show global settings", }, (Func)dwb_com_show_settings, NULL, AlwaysSM, { .n = Global } },
+ { { "show_keys", "Key configuration", }, (Func)dwb_com_show_keys, NULL, AlwaysSM, },
+ { { "show_settings", "Settings", }, (Func)dwb_com_show_settings, NULL, AlwaysSM, { .n = PerView } },
+ { { "spell_checking", "Setting: spell checking", }, (Func)dwb_com_toggle_property, NULL, PostSM, { .p = "enable-spell-checking" } },
+ { { "toggle_bottomstack", "Toggle bottomstack", }, (Func)dwb_com_set_orientation, NULL, AlwaysSM, },
+ { { "toggle_encoding", "Toggle Custom encoding", }, (Func)dwb_com_toggle_custom_encoding, NULL, AlwaysSM, },
+ { { "toggle_maximized", "Toggle maximized", }, (Func)dwb_com_toggle_maximized, NULL, AlwaysSM, },
+ { { "toggle_shrink_images", "Setting: autoshrink images", }, (Func)dwb_com_toggle_property, NULL, PostSM, { .p = "auto-shrink-images" } },
+ { { "view_source", "View source", }, (Func)dwb_com_view_source, NULL, AlwaysSM, },
+ { { "zoom_in", "Zoom in", }, (Func)dwb_com_zoom_in, "Cannot zoom in further", AlwaysSM, },
+ { { "zoom_normal", "Zoom 100%", }, (Func)dwb_com_set_zoom_level, NULL, AlwaysSM, { .d = 1.0, .p = NULL } },
+ { { "zoom_out", "Zoom out", }, (Func)dwb_com_zoom_out, "Cannot zoom out further", AlwaysSM, },
+ { { "yank", "Yank", }, (Func)dwb_com_yank, NO_URL, PostSM, { .p = GDK_NONE } },
+ { { "yank_primary", "Yank to Primary selection", }, (Func)dwb_com_yank, NO_URL, PostSM, { .p = GDK_SELECTION_PRIMARY } },
+ { { "paste", "Paste", }, (Func)dwb_com_paste, "Clipboard is empty", AlwaysSM, { .n = OpenNormal, .p = GDK_NONE } },
+ { { "paste_primary", "Paste primary selection", }, (Func)dwb_com_paste, "No primary selection", AlwaysSM, { .n = OpenNormal, .p = GDK_SELECTION_PRIMARY } },
+ { { "paste_nv", "Paste, new view", }, (Func)dwb_com_paste, "Clipboard is empty", AlwaysSM, { .n = OpenNewView, .p = GDK_NONE } },
+ { { "paste_primary_nv", "Paste primary selection, new view", }, (Func)dwb_com_paste, "No primary selection", AlwaysSM, { .n = OpenNewView, .p = GDK_SELECTION_PRIMARY } },
//Entry editing
- { { "entry_delete_word", "Delete word", }, (Func)dwb_entry_delete_word, NULL, AlwaysSM, { 0 }, true, },
- { { "entry_delete_letter", "Delete a single letter", }, (Func)dwb_entry_delete_letter, NULL, AlwaysSM, { 0 }, true, },
- { { "entry_delete_line", "Delete to beginning of the line", }, (Func)dwb_entry_delete_line, NULL, AlwaysSM, { 0 }, true, },
- { { "entry_word_forward", "Move cursor forward on word", }, (Func)dwb_entry_word_forward, NULL, AlwaysSM, { 0 }, true, },
- { { "entry_word_back", "Move cursor back on word", }, (Func)dwb_entry_word_back, NULL, AlwaysSM, { 0 }, true, },
- { { "entry_history_back", "Command history back", }, (Func)dwb_entry_history_back, NULL, AlwaysSM, { 0 }, true, },
- { { "entry_history_forward", "Command history forward", }, (Func)dwb_entry_history_forward, NULL, AlwaysSM, { 0 }, true, },
+ { { "entry_delete_word", "Delete word", }, (Func)dwb_com_entry_delete_word, NULL, AlwaysSM, { 0 }, true, },
+ { { "entry_delete_letter", "Delete a single letter", }, (Func)dwb_com_entry_delete_letter, NULL, AlwaysSM, { 0 }, true, },
+ { { "entry_delete_line", "Delete to beginning of the line", }, (Func)dwb_com_entry_delete_line, NULL, AlwaysSM, { 0 }, true, },
+ { { "entry_word_forward", "Move cursor forward on word", }, (Func)dwb_com_entry_word_forward, NULL, AlwaysSM, { 0 }, true, },
+ { { "entry_word_back", "Move cursor back on word", }, (Func)dwb_com_entry_word_back, NULL, AlwaysSM, { 0 }, true, },
+ { { "entry_history_back", "Command history back", }, (Func)dwb_com_entry_history_back, NULL, AlwaysSM, { 0 }, true, },
+ { { "entry_history_forward", "Command history forward", }, (Func)dwb_com_entry_history_forward, NULL, AlwaysSM, { 0 }, true, },
{ { "download_set_execute", "Complete binaries", }, (Func)dwb_dl_set_execute, NULL, AlwaysSM, { 0 }, true, },
- //{ "create_hints", (void*)dwb_create_hints, "Hints", NULL, true, },
-
};/*}}}*/
/* DWB_SETTINGS {{{*/
@@ -243,45 +240,45 @@ static WebSettings DWB_SETTINGS[] = {
{ { "proxy", "HTTP-proxy", }, false, true, Boolean, { .b = true }, (S_Func) dwb_set_proxy, },
{ { "cookie", "All Cookies allowed", }, false, true, Boolean, { .b = false }, (S_Func) dwb_set_websetting, },
- { { "active-fg-color", "UI: Active view foreground", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_reload_layout, },
- { { "active-bg-color", "UI: Active view background", }, false, true, ColorChar, { .p = "#000000" }, (S_Func) dwb_reload_layout, },
- { { "normal-fg-color", "UI: Inactive view foreground", }, false, true, ColorChar, { .p = "#cccccc" }, (S_Func) dwb_reload_layout, },
- { { "normal-bg-color", "UI: Inactive view background", }, false, true, ColorChar, { .p = "#505050" }, (S_Func) dwb_reload_layout, },
+ { { "active-fg-color", "UI: Active view foreground", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_com_reload_layout, },
+ { { "active-bg-color", "UI: Active view background", }, false, true, ColorChar, { .p = "#000000" }, (S_Func) dwb_com_reload_layout, },
+ { { "normal-fg-color", "UI: Inactive view foreground", }, false, true, ColorChar, { .p = "#cccccc" }, (S_Func) dwb_com_reload_layout, },
+ { { "normal-bg-color", "UI: Inactive view background", }, false, true, ColorChar, { .p = "#505050" }, (S_Func) dwb_com_reload_layout, },
- { { "tab-active-fg-color", "UI: Active view tabforeground", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_reload_layout, },
- { { "tab-active-bg-color", "UI: Active view tabbackground", }, false, true, ColorChar, { .p = "#000000" }, (S_Func) dwb_reload_layout, },
- { { "tab-normal-fg-color", "UI: Inactive view tabforeground", }, false, true, ColorChar, { .p = "#cccccc" }, (S_Func) dwb_reload_layout, },
- { { "tab-normal-bg-color", "UI: Inactive view tabbackground", }, false, true, ColorChar, { .p = "#505050" }, (S_Func) dwb_reload_layout, },
+ { { "tab-active-fg-color", "UI: Active view tabforeground", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_com_reload_layout, },
+ { { "tab-active-bg-color", "UI: Active view tabbackground", }, false, true, ColorChar, { .p = "#000000" }, (S_Func) dwb_com_reload_layout, },
+ { { "tab-normal-fg-color", "UI: Inactive view tabforeground", }, false, true, ColorChar, { .p = "#cccccc" }, (S_Func) dwb_com_reload_layout, },
+ { { "tab-normal-bg-color", "UI: Inactive view tabbackground", }, false, true, ColorChar, { .p = "#505050" }, (S_Func) dwb_com_reload_layout, },
- { { "active-comp-fg-color", "UI: Completion active foreground", }, false, true, ColorChar, { .p = "#1793d1" }, (S_Func) dwb_reload_colors, },
- { { "active-comp-bg-color", "UI: Completion active background", }, false, true, ColorChar, { .p = "#000000" }, (S_Func) dwb_reload_colors, },
- { { "normal-comp-fg-color", "UI: Completion inactive foreground", }, false, true, ColorChar, { .p = "#eeeeee" }, (S_Func) dwb_reload_colors, },
- { { "normal-comp-bg-color", "UI: Completion inactive background", }, false, true, ColorChar, { .p = "#151515" }, (S_Func) dwb_reload_colors, },
+ { { "active-comp-fg-color", "UI: Completion active foreground", }, false, true, ColorChar, { .p = "#1793d1" }, (S_Func) dwb_com_reload_colors, },
+ { { "active-comp-bg-color", "UI: Completion active background", }, false, true, ColorChar, { .p = "#000000" }, (S_Func) dwb_com_reload_colors, },
+ { { "normal-comp-fg-color", "UI: Completion inactive foreground", }, false, true, ColorChar, { .p = "#eeeeee" }, (S_Func) dwb_com_reload_colors, },
+ { { "normal-comp-bg-color", "UI: Completion inactive background", }, false, true, ColorChar, { .p = "#151515" }, (S_Func) dwb_com_reload_colors, },
- { { "insert-fg-color", "UI: Insertmode foreground", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_reload_colors, },
- { { "insert-bg-color", "UI: Insertmode background", }, false, true, ColorChar, { .p = "#00008b" }, (S_Func) dwb_reload_colors, },
- { { "error-color", "UI: Error color", }, false, true, ColorChar, { .p = "#ff0000" }, (S_Func) dwb_reload_colors, },
+ { { "insert-fg-color", "UI: Insertmode foreground", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_com_reload_colors, },
+ { { "insert-bg-color", "UI: Insertmode background", }, false, true, ColorChar, { .p = "#00008b" }, (S_Func) dwb_com_reload_colors, },
+ { { "error-color", "UI: Error color", }, false, true, ColorChar, { .p = "#ff0000" }, (S_Func) dwb_com_reload_colors, },
- { { "settings-fg-color", "UI: Settings view foreground", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_reload_colors, },
- { { "settings-bg-color", "UI: Settings view background", }, false, true, ColorChar, { .p = "#151515" }, (S_Func) dwb_reload_colors, },
- { { "settings-border", "UI: Settings view border", }, false, true, Char, { .p = "1px dotted black"}, (S_Func) dwb_reload_colors, },
+ { { "settings-fg-color", "UI: Settings view foreground", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_com_reload_colors, },
+ { { "settings-bg-color", "UI: Settings view background", }, false, true, ColorChar, { .p = "#151515" }, (S_Func) dwb_com_reload_colors, },
+ { { "settings-border", "UI: Settings view border", }, false, true, Char, { .p = "1px dotted black"}, (S_Func) dwb_com_reload_colors, },
- { { "active-font-size", "UI: Active view fontsize", }, false, true, Integer, { .i = 12 }, (S_Func) dwb_reload_layout, },
- { { "normal-font-size", "UI: Inactive view fontsize", }, false, true, Integer, { .i = 10 }, (S_Func) dwb_reload_layout, },
+ { { "active-font-size", "UI: Active view fontsize", }, false, true, Integer, { .i = 12 }, (S_Func) dwb_com_reload_layout, },
+ { { "normal-font-size", "UI: Inactive view fontsize", }, false, true, Integer, { .i = 10 }, (S_Func) dwb_com_reload_layout, },
- { { "font", "UI: Font", }, false, true, Char, { .p = "monospace" }, (S_Func) dwb_reload_layout, },
+ { { "font", "UI: Font", }, false, true, Char, { .p = "monospace" }, (S_Func) dwb_com_reload_layout, },
- { { "hint-letter-seq", "Hints: Letter sequence for letter hints", }, false, true, Char, { .p = "FDSARTGBVECWXQYIOPMNHZULKJ" }, (S_Func) dwb_reload_scripts, },
- { { "hint-style", "Hints: Hintstyle (letter or number)", }, false, true, Char, { .p = "letter" }, (S_Func) dwb_reload_scripts, },
- { { "hint-font-size", "Hints: Font size", }, false, true, Char, { .p = "12px" }, (S_Func) dwb_reload_scripts, },
- { { "hint-font-weight", "Hints: Font weight", }, false, true, Char, { .p = "normal" }, (S_Func) dwb_reload_scripts, },
- { { "hint-font-family", "Hints: Font family", }, false, true, Char, { .p = "monospace" }, (S_Func) dwb_reload_scripts, },
- { { "hint-fg-color", "Hints: Foreground color", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_reload_scripts, },
- { { "hint-bg-color", "Hints: Background color", }, false, true, ColorChar, { .p = "#000088" }, (S_Func) dwb_reload_scripts, },
- { { "hint-active-color", "Hints: Active link color", }, false, true, ColorChar, { .p = "#00ff00" }, (S_Func) dwb_reload_scripts, },
- { { "hint-normal-color", "Hints: Inactive link color", }, false, true, ColorChar, { .p = "#ffff99" }, (S_Func) dwb_reload_scripts, },
- { { "hint-border", "Hints: Hint Border", }, false, true, Char, { .p = "2px dashed #000000" }, (S_Func) dwb_reload_scripts, },
- { { "hint-opacity", "Hints: Hint Opacity", }, false, true, Double, { .d = 0.75 }, (S_Func) dwb_reload_scripts, },
+ { { "hint-letter-seq", "Hints: Letter sequence for letter hints", }, false, true, Char, { .p = "FDSARTGBVECWXQYIOPMNHZULKJ" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-style", "Hints: Hintstyle (letter or number)", }, false, true, Char, { .p = "letter" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-font-size", "Hints: Font size", }, false, true, Char, { .p = "12px" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-font-weight", "Hints: Font weight", }, false, true, Char, { .p = "normal" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-font-family", "Hints: Font family", }, false, true, Char, { .p = "monospace" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-fg-color", "Hints: Foreground color", }, false, true, ColorChar, { .p = "#ffffff" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-bg-color", "Hints: Background color", }, false, true, ColorChar, { .p = "#000088" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-active-color", "Hints: Active link color", }, false, true, ColorChar, { .p = "#00ff00" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-normal-color", "Hints: Inactive link color", }, false, true, ColorChar, { .p = "#ffff99" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-border", "Hints: Hint Border", }, false, true, Char, { .p = "2px dashed #000000" }, (S_Func) dwb_com_reload_scripts, },
+ { { "hint-opacity", "Hints: Hint Opacity", }, false, true, Double, { .d = 0.75 }, (S_Func) dwb_com_reload_scripts, },
{ { "auto-completion", "Show possible keystrokes", }, false, true, Boolean, { .b = true }, (S_Func)dwb_comp_set_autcompletion, },
{ { "startpage", "Default homepage", }, false, true, Char, { .p = "about:blank" }, (S_Func) dwb_set_vars, },
@@ -301,19 +298,14 @@ static WebSettings DWB_SETTINGS[] = {
{ { "layout", "UI: Default layout (Normal, Bottomstack, Maximized)", }, false, true, Char, { .p = "Normal Maximized" }, NULL, },
};/*}}}*/
-
-/* UTIL {{{*/
-/* }}} */
-
/* CALLBACKS {{{*/
-
/* dwb_key_press_cb(GtkWidget *w, GdkEventKey *e, View *v) {{{*/
gboolean
dwb_key_press_cb(GtkWidget *w, GdkEventKey *e, View *v) {
gboolean ret = false;
- gchar *key = dwb_keyval_to_char(e->keyval);
+ gchar *key = dwb_util_keyval_to_char(e->keyval);
if (e->keyval == GDK_Escape) {
dwb_normal_mode(true);
ret = false;
@@ -329,7 +321,7 @@ dwb_key_press_cb(GtkWidget *w, GdkEventKey *e, View *v) {
}
else if (dwb.state.mode == QuickmarkOpen) {
if (key) {
- dwb_open_quickmark(key);
+ dwb_com_open_quickmark(key);
}
ret = true;
}
@@ -383,10 +375,8 @@ dwb_cookie_changed_cb(SoupCookieJar *cookiejar, SoupCookie *old, SoupCookie *new
}
}/*}}}*/
-
/*}}}*/
-
/* COMMAND_TEXT {{{*/
/* dwb_set_status_bar_text(GList *gl, const char *text, GdkColor *fg, PangoFontDescription *fd) {{{*/
@@ -471,6 +461,20 @@ dwb_set_status_text(GList *gl, const gchar *text, GdkColor *fg, PangoFontDescrip
/* FUNCTIONS {{{*/
+/* dwb_get_default_settings() return: GHashTable {{{*/
+GHashTable *
+dwb_get_default_settings() {
+ GHashTable *ret = g_hash_table_new(g_str_hash, g_str_equal);
+ for (GList *l = g_hash_table_get_values(dwb.settings); l; l=l->next) {
+ WebSettings *s = l->data;
+ WebSettings *new = g_malloc(sizeof(WebSettings));
+ *new = *s;
+ gchar *value = g_strdup(s->n.first);
+ g_hash_table_insert(ret, value, new);
+ }
+ return ret;
+}/*}}}*/
+
/* dwb_get_command_from_mimetype(gchar *mimetype){{{*/
gchar *
dwb_get_command_from_mimetype(gchar *mimetype) {
@@ -513,9 +517,9 @@ dwb_entry_set_text(const gchar *text) {
gtk_editable_set_position(GTK_EDITABLE(dwb.gui.entry), -1);
}/*}}}*/
-/* dwb_focus_entry() {{{*/
+/* dwb_com_focus_entry() {{{*/
void
-dwb_focus_entry() {
+dwb_com_focus_entry() {
gtk_widget_grab_focus(dwb.gui.entry);
gtk_entry_set_text(GTK_ENTRY(dwb.gui.entry), "");
//dwb.state.last_com_history = NULL;
@@ -542,7 +546,7 @@ dwb_entry_position_word_back(gint position) {
return position;
}/*}}}*/
-/* dwb_entry_history_forward(gint) {{{*/
+/* dwb_com_entry_history_forward(gint) {{{*/
gint
dwb_entry_position_word_forward(gint position) {
gchar *text = gtk_editable_get_chars(GTK_EDITABLE(dwb.gui.entry), 0, -1);
@@ -586,7 +590,7 @@ dwb_parse_setting(const gchar *text) {
GHashTable *t = dwb.state.setting_apply == Global ? dwb.settings : ((View*)dwb.state.fview->data)->setting;
if (token[0]) {
if ( (s = g_hash_table_lookup(t, token[0])) ) {
- if ( (a = dwb_char_to_arg(token[1], s->type)) ) {
+ if ( (a = dwb_util_char_to_arg(token[1], s->type)) ) {
s->arg = *a;
dwb_apply_settings(s);
gchar *message = g_strdup_printf("Saved setting %s: %s", s->n.first, s->type == Boolean ? ( s->arg.b ? "true" : "false") : token[1]);
@@ -621,41 +625,74 @@ dwb_parse_key_setting(const gchar *text) {
value.key = dwb_strv_to_key(keys, g_strv_length(keys));
dwb.keymap = dwb_keymap_add(dwb.keymap, value);
- dwb.keymap = g_list_sort(dwb.keymap, (GCompareFunc)dwb_keymap_sort_second);
+ dwb.keymap = g_list_sort(dwb.keymap, (GCompareFunc)dwb_util_keymap_sort_second);
g_strfreev(token);
g_strfreev(keys);
dwb_normal_mode(true);
}/*}}}*/
-/* dwb_reload_colors(GList *, WebSettings *s) {{{*/
+/* dwb_com_reload_colors(GList *, WebSettings *s) {{{*/
void
-dwb_reload_scripts(GList *gl, WebSettings *s) {
+dwb_com_reload_scripts(GList *gl, WebSettings *s) {
g_free(dwb.misc.scripts);
dwb_init_scripts();
- dwb_reload(NULL);
+ dwb_com_reload(NULL);
}/*}}}*/
-/* dwb_reload_colors(GList *, WebSettings *s) {{{*/
+/* dwb_com_reload_colors(GList *, WebSettings *s) {{{*/
void
-dwb_reload_colors(GList *gl, WebSettings *s) {
+dwb_com_reload_colors(GList *gl, WebSettings *s) {
dwb_init_style();
}/*}}}*/
-/* dwb_reload_layout(GList *, WebSettings *s) {{{*/
+/* dwb_com_reload_layout(GList *, WebSettings *s) {{{*/
void
-dwb_reload_layout(GList *gl, WebSettings *s) {
+dwb_com_reload_layout(GList *gl, WebSettings *s) {
dwb_init_style();
for (GList *l = dwb.state.views; l; l=l->next) {
if (l == dwb.state.fview) {
- dwb_set_active_style(l);
+ dwb_view_set_active_style(l);
}
else {
- dwb_set_normal_style(l);
+ dwb_view_set_normal_style(l);
}
}
}/*}}}*/
+/* dwb_get_search_engine_uri(const gchar *uri) {{{*/
+gchar *
+dwb_get_search_engine_uri(const gchar *uri, const gchar *text) {
+ gchar *ret = NULL;
+ if (uri) {
+ gchar **token = g_strsplit(uri, HINT_SEARCH_SUBMIT, 2);
+ ret = g_strconcat(token[0], text, token[1], NULL);
+ g_strfreev(token);
+ }
+ return ret;
+}/* }}} */
+
+/* dwb_get_search_engine(const gchar *uri) {{{*/
+gchar *
+dwb_get_search_engine(const gchar *uri) {
+ gchar *ret = NULL;
+ if ( (!strstr(uri, ".") || strstr(uri, " ")) && !strstr(uri, "localhost:")) {
+ gchar **token = g_strsplit(uri, " ", 2);
+ for (GList *l = dwb.fc.searchengines; l; l=l->next) {
+ Navigation *n = l->data;
+ if (!strcmp(token[0], n->first)) {
+ ret = dwb_get_search_engine_uri(n->second, token[1]);
+ break;
+ }
+ }
+ if (!ret) {
+ ret = dwb_get_search_engine_uri(dwb.misc.default_search, uri);
+ }
+ }
+ return ret;
+}/*}}}*/
+
+
/* dwb_save_searchengine {{{*/
void
dwb_save_searchengine(void) {
@@ -941,12 +978,12 @@ dwb_save_quickmark(const gchar *key) {
for (GList *l = dwb.fc.quickmarks; l; l=l->next) {
Quickmark *q = l->data;
if (!strcmp(key, q->key)) {
- dwb_quickmark_free(q);
+ dwb_com_quickmark_free(q);
dwb.fc.quickmarks = g_list_delete_link(dwb.fc.quickmarks, l);
break;
}
}
- dwb.fc.quickmarks = g_list_prepend(dwb.fc.quickmarks, dwb_quickmark_new(uri, title, key));
+ dwb.fc.quickmarks = g_list_prepend(dwb.fc.quickmarks, dwb_com_quickmark_new(uri, title, key));
dwb_normal_mode(false);
gchar *message = g_strdup_printf("Added quickmark: %s - %s", key, uri);
@@ -959,9 +996,9 @@ dwb_save_quickmark(const gchar *key) {
}
}/*}}}*/
-/* dwb_open_quickmark(const gchar *key){{{*/
+/* dwb_com_open_quickmark(const gchar *key){{{*/
void
-dwb_open_quickmark(const gchar *key) {
+dwb_com_open_quickmark(const gchar *key) {
gchar *message = NULL;
for (GList *l = dwb.fc.quickmarks; l; l=l->next) {
Quickmark *q = l->data;
@@ -1026,7 +1063,7 @@ dwb_grab_focus(GList *gl) {
dwb.state.fview = gl;
dwb.gui.entry = v->entry;
gtk_widget_show(v->entry);
- dwb_set_active_style(gl);
+ dwb_view_set_active_style(gl);
gtk_widget_grab_focus(v->scroll);
}/*}}}*/
@@ -1085,7 +1122,7 @@ dwb_eval_editing_key(GdkEventKey *e) {
return false;
}
- gchar *key = dwb_keyval_to_char(e->keyval);
+ gchar *key = dwb_util_keyval_to_char(e->keyval);
gboolean ret = false;
for (GList *l = dwb.keymap; l; l=l->next) {
@@ -1132,7 +1169,7 @@ dwb_eval_key(GdkEventKey *e) {
}
return ret;
}
- gchar *key = dwb_keyval_to_char(keyval);
+ gchar *key = dwb_util_keyval_to_char(keyval);
if (!key) {
return false;
}
@@ -1191,7 +1228,7 @@ dwb_eval_key(GdkEventKey *e) {
dwb_comp_autocomplete(coms, NULL);
}
if (tmp) {
- dwb_simple_command(tmp);
+ dwb_com_simple_command(tmp);
}
g_free(key);
return ret;
@@ -1202,7 +1239,7 @@ dwb_eval_key(GdkEventKey *e) {
gboolean
dwb_command_mode(Arg *arg) {
dwb_set_normal_message(dwb.state.fview, ":", false);
- dwb_focus_entry();
+ dwb_com_focus_entry();
dwb.state.mode = CommandMode;
return true;
}/*}}}*/
@@ -1341,7 +1378,7 @@ dwb_save_navigation_fc(GList *fc, const gchar *filename, gint length) {
g_string_append_printf(string, "%s %s\n", n->first, n->second);
g_free(n);
}
- dwb_set_file_content(filename, string->str);
+ dwb_util_set_file_content(filename, string->str);
g_string_free(string, true);
}/*}}}*/
@@ -1365,9 +1402,9 @@ dwb_save_files() {
Quickmark *q = l->data;
Navigation *n = q->nav;
g_string_append_printf(quickmarks, "%s %s %s\n", q->key, n->first, n->second);
- dwb_quickmark_free(q);
+ dwb_com_quickmark_free(q);
}
- dwb_set_file_content(dwb.files.quickmarks, quickmarks->str);
+ dwb_util_set_file_content(dwb.files.quickmarks, quickmarks->str);
g_string_free(quickmarks, true);
// cookie allow
@@ -1376,7 +1413,7 @@ dwb_save_files() {
g_string_append_printf(cookies_allow, "%s\n", (gchar*)l->data);
g_free(l->data);
}
- dwb_set_file_content(dwb.files.cookies_allow, cookies_allow->str);
+ dwb_util_set_file_content(dwb.files.cookies_allow, cookies_allow->str);
g_string_free(cookies_allow, true);
// save keys
@@ -1413,7 +1450,7 @@ dwb_save_files() {
}
for (GList *l = g_hash_table_get_values(dwb.settings); l; l=l->next) {
WebSettings *s = l->data;
- gchar *value = dwb_arg_to_char(&s->arg, s->type);
+ gchar *value = dwb_util_arg_to_char(&s->arg, s->type);
g_key_file_set_value(keyfile, dwb.misc.profile, s->n.first, value ? value : "" );
g_free(value);
}
@@ -1522,7 +1559,7 @@ dwb_keymap_delete(GList *gl, KeyValue key) {
break;
}
}
- gl = g_list_sort(gl, (GCompareFunc)dwb_keymap_sort_second);
+ gl = g_list_sort(gl, (GCompareFunc)dwb_util_keymap_sort_second);
return gl;
}/*}}}*/
@@ -1618,7 +1655,7 @@ dwb_read_settings() {
if (!strcmp(keys[i], DWB_SETTINGS[j].n.first)) {
WebSettings *s = malloc(sizeof(WebSettings));
*s = DWB_SETTINGS[j];
- if ( (arg = dwb_char_to_arg(value, s->type)) ) {
+ if ( (arg = dwb_util_char_to_arg(value, s->type)) ) {
s->arg = *arg;
}
//ret = g_slist_append(ret, s);
@@ -1647,7 +1684,7 @@ dwb_init_key_map() {
dwb.keymap = dwb_keymap_add(dwb.keymap, KEYS[j]);
}
}
- dwb.keymap = g_list_sort(dwb.keymap, (GCompareFunc)dwb_keymap_sort_second);
+ dwb.keymap = g_list_sort(dwb.keymap, (GCompareFunc)dwb_util_keymap_sort_second);
}/*}}}*/
/* dwb_init_settings() {{{*/
@@ -1692,10 +1729,10 @@ dwb_init_scripts() {
// init system scripts
gchar *dir;
- if ( (dir = dwb_get_data_dir("scripts")) ) {
- dwb_get_directory_content(&buffer, dir);
+ if ( (dir = dwb_util_get_data_dir("scripts")) ) {
+ dwb_util_get_directory_content(&buffer, dir);
}
- dwb_get_directory_content(&buffer, dwb.files.scriptdir);
+ dwb_util_get_directory_content(&buffer, dwb.files.scriptdir);
dwb.misc.scripts = buffer->str;
g_string_free(buffer, false);
}/*}}}*/
@@ -1774,7 +1811,7 @@ dwb_init_gui() {
g_signal_connect(dwb.gui.window, "delete-event", G_CALLBACK(dwb_exit), NULL);
g_signal_connect(dwb.gui.window, "key-press-event", G_CALLBACK(dwb_key_press_cb), NULL);
g_signal_connect(dwb.gui.window, "key-release-event", G_CALLBACK(dwb_key_release_cb), NULL);
- gtk_widget_modify_bg(dwb.gui.window, GTK_STATE_NORMAL, &dwb.color.normal_bg);
+ gtk_widget_modify_bg(dwb.gui.window, GTK_STATE_NORMAL, &dwb.color.active_bg);
// Main
dwb.gui.vbox = gtk_vbox_new(false, 1);
@@ -1820,7 +1857,7 @@ dwb_init_gui() {
/* dwb_init_file_content {{{*/
GList *
dwb_init_file_content(GList *gl, const gchar *filename, Content_Func func) {
- gchar *content = dwb_get_file_content(filename);
+ gchar *content = dwb_util_get_file_content(filename);
if (content) {
gchar **token = g_strsplit(content, "\n", 0);
gint length = MAX(g_strv_length(token) - 1, 0);
@@ -1836,7 +1873,7 @@ dwb_init_file_content(GList *gl, const gchar *filename, Content_Func func) {
/* dwb_init_files() {{{*/
void
dwb_init_files() {
- gchar *path = dwb_build_path();
+ gchar *path = dwb_util_build_path();
gchar *profile_path = g_strconcat(path, dwb.misc.profile, "/", NULL);
if (!g_file_test(profile_path, G_FILE_TEST_IS_DIR)) {
g_mkdir_with_parents(profile_path, 0755);
@@ -1858,7 +1895,7 @@ dwb_init_files() {
dwb.fc.bookmarks = dwb_init_file_content(dwb.fc.bookmarks, dwb.files.bookmarks, (Content_Func)dwb_navigation_new_from_line);
dwb.fc.history = dwb_init_file_content(dwb.fc.history, dwb.files.history, (Content_Func)dwb_navigation_new_from_line);
- dwb.fc.quickmarks = dwb_init_file_content(dwb.fc.quickmarks, dwb.files.quickmarks, (Content_Func)dwb_quickmark_new_from_line);
+ dwb.fc.quickmarks = dwb_init_file_content(dwb.fc.quickmarks, dwb.files.quickmarks, (Content_Func)dwb_com_quickmark_new_from_line);
dwb.fc.searchengines = dwb_init_file_content(dwb.fc.searchengines, dwb.files.searchengines, (Content_Func)dwb_navigation_new_from_line);
dwb.fc.mimetypes = dwb_init_file_content(dwb.fc.mimetypes, dwb.files.mimetypes, (Content_Func)dwb_navigation_new_from_line);
@@ -1887,7 +1924,7 @@ void
dwb_init_proxy() {
const gchar *proxy;
gchar *newproxy;
- if ( (proxy = g_getenv("http_proxy")) && dwb_test_connect(proxy) ) {
+ if ( (proxy = g_getenv("http_proxy")) && dwb_util_test_connect(proxy) ) {
newproxy = g_strrstr(proxy, "http://") ? g_strdup(proxy) : g_strdup_printf("http://%s", proxy);
dwb.misc.proxyuri = soup_uri_new(newproxy);
g_object_set(G_OBJECT(dwb.misc.soupsession), "proxy-uri", dwb.misc.proxyuri, NULL);
@@ -1918,6 +1955,16 @@ dwb_init_vars() {
dwb.state.layout = dwb_layout_from_char(GET_CHAR("layout"));
dwb.comps.autocompletion = GET_BOOL("auto-completion");
}
+
+
+gboolean
+dwb_idle(gpointer *data) {
+ //puts("hallo");
+ gint i=0;
+ i+=1;
+ i-=1;
+ return true;
+}
/* dwb_init() {{{*/
void dwb_init() {
@@ -1944,10 +1991,9 @@ void dwb_init() {
dwb_init_cookies();
dwb_init_vars();
-
if (dwb.state.layout & BottomStack) {
Arg a = { .n = dwb.state.layout };
- dwb_set_orientation(&a);
+ dwb_com_set_orientation(&a);
}
if (dwb.misc.argc > 0) {
for (gint i=0; i<dwb.misc.argc; i++) {
@@ -1960,6 +2006,8 @@ void dwb_init() {
}
} /*}}}*/ /*}}}*/
+/* FIFO {{{*/
+/* dwb_parse_command_line(const gchar *line) {{{*/
void
dwb_parse_command_line(const gchar *line) {
gchar **token = g_strsplit(line, " ", 2);
@@ -1975,15 +2023,16 @@ dwb_parse_command_line(const gchar *line) {
m->map->func(&m->map->arg);
}
else {
- dwb_simple_command(m);
+ dwb_com_simple_command(m);
}
m->map->arg = a;
}
}
g_strfreev(token);
dwb_normal_mode(true);
-}
+}/*}}}*/
+/* dwb_handle_channel {{{*/
gboolean
dwb_handle_channel(GIOChannel *c, GIOCondition condition, void *data) {
gchar *line = NULL;
@@ -1995,13 +2044,14 @@ dwb_handle_channel(GIOChannel *c, GIOCondition condition, void *data) {
g_io_channel_flush(c, NULL);
g_free(line);
}
-
return true;
-}
+}/*}}}*/
+
+/* dwb_init_fifo{{{*/
void
dwb_init_fifo() {
FILE *ff;
- gchar *path = dwb_build_path();
+ gchar *path = dwb_util_build_path();
gchar *unifile = g_strconcat(path, "dwb-uni.fifo", NULL);
if (dwb.misc.single || g_file_test(unifile, G_FILE_TEST_EXISTS)) {
@@ -2031,7 +2081,8 @@ dwb_init_fifo() {
}
exit(EXIT_SUCCESS);
}
-}
+}/*}}}*/
+/*}}}*/
int main(gint argc, gchar *argv[]) {
dwb.misc.name = NAME;
diff --git a/src/dwb.h b/src/dwb.h
index b8a8506d..aa12d3ec 100644
--- a/src/dwb.h
+++ b/src/dwb.h
@@ -407,11 +407,11 @@ gboolean dwb_insert_mode(Arg *);
void dwb_normal_mode(gboolean);
void dwb_load_uri(Arg *);
-void dwb_focus_entry(void);
+void dwb_com_focus_entry(void);
-gboolean dwb_push_master(Arg *);
-void dwb_remove_view(Arg *);
-void dwb_focus(GList *);
+gboolean dwb_com_push_master(Arg *);
+void dwb_com_remove_view(Arg *);
+void dwb_com_focus(GList *);
void dwb_set_normal_message(GList *, const gchar *, gboolean);
void dwb_set_error_message(GList *, const gchar *);
@@ -449,8 +449,8 @@ gchar * dwb_get_command_from_mimetype(gchar *);
gboolean dwb_eval_editing_key(GdkEventKey *);
void dwb_parse_command_line(const gchar *);
+GHashTable * dwb_get_default_settings(void);
void dwb_exit(void);
-int dwb_test_connect(const char *uri);
#endif
diff --git a/src/util.c b/src/util.c
index 15956d03..8b13d87f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -9,8 +9,9 @@
#include "dwb.h"
#include "util.h"
+/* dwb_util_string_replace(const gchar *haystack, const gchar *needle, const gchar *replace) return: gchar * (alloc){{{*/
gchar *
-dwb_string_replace(const gchar *haystack, const gchar *needle, const gchar *replacemant) {
+dwb_util_string_replace(const gchar *haystack, const gchar *needle, const gchar *replacemant) {
gchar **token;
gchar *ret = NULL;
if ( (token = g_regex_split_simple(needle, haystack, 0, 0)) && strcmp(token[0], haystack)) {
@@ -18,10 +19,29 @@ dwb_string_replace(const gchar *haystack, const gchar *needle, const gchar *repl
g_strfreev(token);
}
return ret;
-}
+}/*}}}*/
+/* dwb_util_cut_text(gchar *text, gint start, gint end) {{{*/
+void
+dwb_util_cut_text(gchar *text, gint start, gint end) {
+ gint length = strlen(text);
+ gint del = end - start;
+ memmove(&text[start], &text[end], length - end);
+ memset(&text[length-del], '\0', del);
+}/*}}}*/
+
+/* dwb_util_is_hex(const gchar *string) {{{*/
+gboolean
+dwb_util_is_hex(const gchar *string) {
+ gchar *dup = g_strdup(string);
+ gboolean ret = !strtok(dup, "1234567890abcdefABCDEF");
+
+ g_free(dup);
+ return ret;
+}/*}}}*/
+/* dwb_util_test_connect(const char *uri) return: gint {{{*/
int
-dwb_test_connect(const char *uri) {
+dwb_util_test_connect(const char *uri) {
struct sockaddr_in addr;
gint s;
gint ret;
@@ -42,21 +62,66 @@ dwb_test_connect(const char *uri) {
g_strfreev(token);
return (!ret);
-}
-/*}}}*/
-
-void
-dwb_cut_text(gchar *text, gint start, gint end) {
- gint length = strlen(text);
- gint del = end - start;
+}/*}}}*/
- memmove(&text[start], &text[end], length - end);
- memset(&text[length-del], '\0', del);
-}
+/* dwb_util_modmask_to_char(guint modmask) return gchar*{{{*/
+gchar *
+dwb_modmask_to_string(guint modmask) {
+ gchar *mod[7];
+ int i=0;
+ for (; i<7 && modmask; i++) {
+ if (modmask & GDK_CONTROL_MASK) {
+ mod[i] = "Control";
+ modmask ^= GDK_CONTROL_MASK;
+ }
+ else if (modmask & GDK_MOD1_MASK) {
+ mod[i] = "Mod1";
+ modmask ^= GDK_MOD1_MASK;
+ }
+ else if (modmask & GDK_MOD2_MASK) {
+ mod[i] = "Mod2";
+ modmask ^= GDK_MOD2_MASK;
+ }
+ else if (modmask & GDK_MOD3_MASK) {
+ mod[i] = "Mod3";
+ modmask ^= GDK_MOD3_MASK;
+ }
+ else if (modmask & GDK_MOD4_MASK) {
+ mod[i] = "Mod4";
+ modmask ^= GDK_MOD4_MASK;
+ }
+ else if (modmask & GDK_MOD5_MASK) {
+ mod[i] = "Mod5";
+ modmask ^= GDK_MOD5_MASK;
+ }
+ }
+ mod[i] = NULL;
+ gchar *line = g_strjoinv(" ", mod);
+ return line;
+}/*}}}*/
+/* dwb_util_keyval_to_char (guint keyval) return: char * (alloc) {{{*/
+gchar *
+dwb_util_keyval_to_char(guint keyval) {
+ gchar *key = g_malloc(6);
+ guint32 unichar;
+ gint length;
+ if ( (unichar = gdk_keyval_to_unicode(keyval)) ) {
+ if ( (length = g_unichar_to_utf8(unichar, key)) ) {
+ memset(&key[length], '\0', 6-length);
+ }
+ }
+ if (length && isprint(key[0])) {
+ return key;
+ }
+ else {
+ g_free(key);
+ return NULL;
+ }
+}/*}}}*/
-/* dwb_char_to_arg {{{*/
+/* dwb_util_char_to_arg(gchar *value, DwbType type) return: Arg*{{{*/
Arg *
-dwb_char_to_arg(gchar *value, DwbType type) {
+dwb_util_char_to_arg(gchar *value, DwbType type) {
errno = 0;
Arg *ret = NULL;
if (type == Boolean && !value) {
@@ -98,7 +163,7 @@ dwb_char_to_arg(gchar *value, DwbType type) {
}
else if (type == ColorChar) {
gint length = strlen(value);
- if (value[0] == '#' && (length == 4 || length == 7) && dwb_ishex(&value[1])) {
+ if (value[0] == '#' && (length == 4 || length == 7) && dwb_util_is_hex(&value[1])) {
Arg a = { .p = g_strdup(value) };
ret = &a;
}
@@ -106,61 +171,9 @@ dwb_char_to_arg(gchar *value, DwbType type) {
}
return ret;
}/*}}}*/
-
-/* dwb_get_default_settings {{{*/
-GHashTable *
-dwb_get_default_settings() {
- GHashTable *ret = g_hash_table_new(g_str_hash, g_str_equal);
- for (GList *l = g_hash_table_get_values(dwb.settings); l; l=l->next) {
- WebSettings *s = l->data;
- WebSettings *new = g_malloc(sizeof(WebSettings));
- *new = *s;
- gchar *value = g_strdup(s->n.first);
- g_hash_table_insert(ret, value, new);
- }
- return ret;
-}/*}}}*/
-
-/* dwb_return {{{*/
-gchar *
-dwb_return(const gchar *ret) {
- return g_strdup(ret);
-}/*}}}*/
-
-/* dwb_build_path {{{*/
-gchar *
-dwb_build_path() {
- gchar *path = g_strconcat(g_get_user_config_dir(), "/", dwb.misc.name, "/", NULL);
- if (!g_file_test(path, G_FILE_TEST_IS_DIR)) {
- g_mkdir_with_parents(path, 0755);
- }
- return path;
-}/*}}}*/
-
-/* dwb_ishex{{{*/
-gboolean
-dwb_ishex(const gchar *string) {
- gchar *dup = g_strdup(string);
- gboolean ret = !strtok(dup, "1234567890abcdefABCDEF");
-
- g_free(dup);
- return ret;
-}/*}}}*/
-
-/* dwb_true, dwb_false {{{*/
-gboolean
-dwb_false() {
- return false;
-}
-
-gboolean
-dwb_true() {
- return true;
-}/*}}}*/
-
-/* dwb_arg_to_char(Arg *arg, DwbType type) {{{*/
+/* dwb_util_arg_to_char(Arg *arg, DwbType type) {{{*/
gchar *
-dwb_arg_to_char(Arg *arg, DwbType type) {
+dwb_util_arg_to_char(Arg *arg, DwbType type) {
gchar *value = NULL;
if (type == Boolean) {
if (arg->b)
@@ -183,108 +196,30 @@ dwb_arg_to_char(Arg *arg, DwbType type) {
return value;
}/*}}}*/
-/* dwb_mod_mask_to_string(guint modmask) return gchar*{{{*/
-gchar *
-dwb_modmask_to_string(guint modmask) {
- gchar *mod[7];
- int i=0;
- for (; i<7 && modmask; i++) {
- if (modmask & GDK_CONTROL_MASK) {
- mod[i] = "Control";
- modmask ^= GDK_CONTROL_MASK;
- }
- else if (modmask & GDK_MOD1_MASK) {
- mod[i] = "Mod1";
- modmask ^= GDK_MOD1_MASK;
- }
- else if (modmask & GDK_MOD2_MASK) {
- mod[i] = "Mod2";
- modmask ^= GDK_MOD2_MASK;
- }
- else if (modmask & GDK_MOD3_MASK) {
- mod[i] = "Mod3";
- modmask ^= GDK_MOD3_MASK;
- }
- else if (modmask & GDK_MOD4_MASK) {
- mod[i] = "Mod4";
- modmask ^= GDK_MOD4_MASK;
- }
- else if (modmask & GDK_MOD5_MASK) {
- mod[i] = "Mod5";
- modmask ^= GDK_MOD5_MASK;
- }
- }
- mod[i] = NULL;
- gchar *line = g_strjoinv(" ", mod);
- return line;
-}/*}}}*/
-
-/* dwb_get_data_dir(const gchar *){{{*/
-gchar *
-dwb_get_data_dir(const gchar *dir) {
- gchar *path = NULL;
- const gchar *dirs;
-
- const gchar *const *config = g_get_system_data_dirs();
- gint i = 0;
-
- while ( (dirs = config[i++]) ) {
- path = g_strconcat(dirs, "/", dwb.misc.name, "/", dir, NULL);
- if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
- return path;
- }
- g_free(path);
- }
- return path;
-}/*}}}*/
-
-/* dwb_keyval_to_char (guint keyval) return: char *{{{*/
-gchar *
-dwb_keyval_to_char(guint keyval) {
- gchar *key = g_malloc(6);
- guint32 unichar;
- gint length;
- if ( (unichar = gdk_keyval_to_unicode(keyval)) ) {
- if ( (length = g_unichar_to_utf8(unichar, key)) ) {
- memset(&key[length], '\0', 6-length);
- }
- }
- if (length && isprint(key[0])) {
- return key;
- }
- else {
- g_free(key);
- return NULL;
- }
-}/*}}}*/
-
-/* dwb_keymap_sort_second {{{*/
+/* dwb_util_keymap_sort_first(KeyMap *, KeyMap *) {{{*/
gint
-dwb_keymap_sort_first(KeyMap *a, KeyMap *b) {
+dwb_util_keymap_sort_first(KeyMap *a, KeyMap *b) {
return strcmp(a->map->n.first, b->map->n.first);
}/*}}}*/
-
-/* dwb_keymap_sort_second {{{*/
+/* dwb_util_keymap_sort_second(KeyMap *, KeyMap *) {{{*/
gint
-dwb_keymap_sort_second(KeyMap *a, KeyMap *b) {
+dwb_util_keymap_sort_second(KeyMap *a, KeyMap *b) {
return strcmp(a->map->n.second, b->map->n.second);
}/*}}}*/
-
-/* dwb_web_settings_sort_first{{{*/
+/* dwb_util_web_settings_sort_first(WebSettings *a, WebSettings *b) {{{*/
gint
-dwb_web_settings_sort_first(WebSettings *a, WebSettings *b) {
+dwb_util_web_settings_sort_first(WebSettings *a, WebSettings *b) {
return strcmp(a->n.first, b->n.first);
}/*}}}*/
-
-/* dwb_web_settings_sort_second{{{*/
+/* dwb_util_web_settings_sort_second (WebSettings *a, WebSettings *b) {{{*/
gint
-dwb_web_settings_sort_second(WebSettings *a, WebSettings *b) {
+dwb_util_web_settings_sort_second(WebSettings *a, WebSettings *b) {
return strcmp(a->n.second, b->n.second);
}/*}}}*/
-/* dwb_get_directory_entries(const gchar *) return: GList *{{{*/
+/* dwb_util_get_directory_entries(const gchar *) return: GList * {{{*/
GList *
-dwb_get_directory_entries(const gchar *path, const gchar *text) {
+dwb_util_get_directory_entries(const gchar *path, const gchar *text) {
GList *list = NULL;
GDir *dir;
gchar *filename;
@@ -308,10 +243,9 @@ dwb_get_directory_entries(const gchar *path, const gchar *text) {
list = g_list_sort(list, (GCompareFunc)strcmp);
return list;
}/*}}}*/
-
-/*dwb_get_directory_content(const gchar *filename) {{{*/
+/*dwb_util_get_directory_content(GString **, const gchar *filename) {{{*/
void
-dwb_get_directory_content(GString **buffer, const gchar *dirname) {
+dwb_util_get_directory_content(GString **buffer, const gchar *dirname) {
GDir *dir;
gchar *content;
GError *error = NULL;
@@ -335,10 +269,9 @@ dwb_get_directory_content(GString **buffer, const gchar *dirname) {
}
}/*}}}*/
-
-/* dwb_get_file_content(const gchar *filename){{{*/
+/* dwb_util_get_file_content(const gchar *filename) return: gchar * (alloc) {{{*/
gchar *
-dwb_get_file_content(const gchar *filename) {
+dwb_util_get_file_content(const gchar *filename) {
GError *error = NULL;
gchar *content = NULL;
if (!(g_file_test(filename, G_FILE_TEST_IS_REGULAR) && g_file_get_contents(filename, &content, NULL, &error))) {
@@ -346,16 +279,41 @@ dwb_get_file_content(const gchar *filename) {
}
return content;
}/*}}}*/
-
-/* dwb_set_file_content(const gchar *filename, const gchar *content){{{*/
+/* dwb_util_set_file_content(const gchar *filename, const gchar *content) {{{*/
void
-dwb_set_file_content(const gchar *filename, const gchar *content) {
+dwb_util_set_file_content(const gchar *filename, const gchar *content) {
GError *error = NULL;
if (!g_file_set_contents(filename, content, -1, &error)) {
fprintf(stderr, "Cannot save %s : %s", filename, error->message);
}
}/*}}}*/
+/* dwb_util_build_path() return: gchar * (alloc) {{{*/
+gchar *
+dwb_util_build_path() {
+ gchar *path = g_strconcat(g_get_user_config_dir(), "/", dwb.misc.name, "/", NULL);
+ if (!g_file_test(path, G_FILE_TEST_IS_DIR)) {
+ g_mkdir_with_parents(path, 0755);
+ }
+ return path;
+}/*}}}*/
+/* dwb_util_get_data_dir(const gchar *) return gchar * (alloc) {{{*/
+gchar *
+dwb_util_get_data_dir(const gchar *dir) {
+ gchar *path = NULL;
+ const gchar *dirs;
+ const gchar *const *config = g_get_system_data_dirs();
+ gint i = 0;
+
+ while ( (dirs = config[i++]) ) {
+ path = g_strconcat(dirs, "/", dwb.misc.name, "/", dir, NULL);
+ if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
+ return path;
+ }
+ g_free(path);
+ }
+ return path;
+}/*}}}*/
/* NAVIGATION {{{*/
/* dwb_navigation_new(const gchar *uri, const gchar *title) {{{*/
@@ -394,34 +352,32 @@ dwb_navigation_free(Navigation *n) {
/*}}}*/
/* QUICKMARK {{{*/
-
-/* dwb_quickmark_new(const gchar *uri, const gchar *title, const gchar *key) {{{*/
+/* dwb_com_quickmark_new(const gchar *uri, const gchar *title, const gchar *key) {{{*/
Quickmark *
-dwb_quickmark_new(const gchar *uri, const gchar *title, const gchar *key) {
+dwb_com_quickmark_new(const gchar *uri, const gchar *title, const gchar *key) {
Quickmark *q = malloc(sizeof(Quickmark));
q->key = key ? g_strdup(key) : NULL;
q->nav = dwb_navigation_new(uri, title);
return q;
}/* }}} */
-
-/* dwb_quickmark_new_from_line(const gchar *line) {{{*/
+/* dwb_com_quickmark_new_from_line(const gchar *line) {{{*/
Quickmark *
-dwb_quickmark_new_from_line(const gchar *line) {
+dwb_com_quickmark_new_from_line(const gchar *line) {
Quickmark *q = NULL;
gchar **token;
if (line) {
token = g_strsplit(line, " ", 3);
- q = dwb_quickmark_new(token[1], token[2], token[0]);
+ q = dwb_com_quickmark_new(token[1], token[2], token[0]);
g_strfreev(token);
}
return q;
}/*}}}*/
-/* dwb_quickmark_free(Quickmark *q) {{{*/
+/* dwb_com_quickmark_free(Quickmark *q) {{{*/
void
-dwb_quickmark_free(Quickmark *q) {
+dwb_com_quickmark_free(Quickmark *q) {
if (q->key)
g_free(q->key);
if (q->nav)
@@ -431,3 +387,18 @@ dwb_quickmark_free(Quickmark *q) {
}/*}}}*/
/*}}}*/
+/* dwb_true, dwb_false {{{*/
+gboolean
+dwb_false() {
+ return false;
+}
+
+gboolean
+dwb_true() {
+ return true;
+}/*}}}*/
+/* dwb_return(const gchar *) return gchar * (alloc) {{{*/
+gchar *
+dwb_return(const gchar *ret) {
+ return g_strdup(ret);
+}/*}}}*/
diff --git a/src/util.h b/src/util.h
index 48f06615..fad1544b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,37 +1,48 @@
#ifndef UTIL_H
#define UTIL_H
-void dwb_cut_text(gchar *, gint, gint);
-gchar * dwb_build_path(void);
-gboolean dwb_ishex(const gchar *string);
+// strings
+gchar * dwb_util_string_replace(const gchar *haystack, const gchar *needle, const gchar *replacemant);
+void dwb_util_cut_text(gchar *, gint, gint);
+
+gboolean dwb_util_is_hex(const gchar *string);
+int dwb_util_test_connect(const char *uri);
+
+// keys
gchar * dwb_modmask_to_string(guint );
-gchar * dwb_arg_to_char(Arg *, DwbType );
-gchar * dwb_get_data_dir(const gchar *);
-gboolean dwb_true(void);
-gboolean dwb_false(void);
-gchar * dwb_return(const gchar *);
-GHashTable * dwb_get_default_settings(void);
-Arg * dwb_char_to_arg(gchar *, DwbType );
-gchar * dwb_keyval_to_char(guint );
-gint dwb_keymap_sort_first(KeyMap *, KeyMap *);
-gint dwb_keymap_sort_second(KeyMap *, KeyMap *);
-gint dwb_web_settings_sort_second(WebSettings *, WebSettings *);
-gint dwb_web_settings_sort_first(WebSettings *, WebSettings *);
+gchar * dwb_util_keyval_to_char(guint );
-void dwb_get_directory_content(GString **, const gchar *);
-GList * dwb_get_directory_entries(const gchar *path, const gchar *);
+// arg
+gchar * dwb_util_arg_to_char(Arg *, DwbType );
+Arg * dwb_util_char_to_arg(gchar *, DwbType );
-gchar * dwb_get_file_content(const gchar *);
-void dwb_set_file_content(const gchar *, const gchar *);
+// sort
+gint dwb_util_keymap_sort_first(KeyMap *, KeyMap *);
+gint dwb_util_keymap_sort_second(KeyMap *, KeyMap *);
+gint dwb_util_web_settings_sort_second(WebSettings *, WebSettings *);
+gint dwb_util_web_settings_sort_first(WebSettings *, WebSettings *);
+// files
+void dwb_util_get_directory_content(GString **, const gchar *);
+GList * dwb_util_get_directory_entries(const gchar *path, const gchar *);
+gchar * dwb_util_get_file_content(const gchar *);
+void dwb_util_set_file_content(const gchar *, const gchar *);
+gchar * dwb_util_build_path(void);
+gchar * dwb_util_get_data_dir(const gchar *);
+
+// navigation
Navigation * dwb_navigation_new_from_line(const gchar *);
Navigation * dwb_navigation_new(const gchar *, const gchar *);
void dwb_navigation_free(Navigation *);
-void dwb_quickmark_free(Quickmark *);
-Quickmark * dwb_quickmark_new(const gchar *, const gchar *, const gchar *);
-Quickmark * dwb_quickmark_new_from_line(const gchar *);
-gchar * dwb_string_replace(const gchar *haystack, const gchar *needle, const gchar *replacemant);
+// quickmarks
+void dwb_com_quickmark_free(Quickmark *);
+Quickmark * dwb_com_quickmark_new(const gchar *, const gchar *, const gchar *);
+Quickmark * dwb_com_quickmark_new_from_line(const gchar *);
+// useless
+gboolean dwb_true(void);
+gboolean dwb_false(void);
+gchar * dwb_return(const gchar *);
#endif
diff --git a/src/view.c b/src/view.c
index 7b48292f..5af514cb 100644
--- a/src/view.c
+++ b/src/view.c
@@ -34,10 +34,10 @@ dwb_web_view_button_press_cb(WebKitWebView *web, GdkEventButton *e, GList *gl) {
}
else if (e->button == 1) {
if (e->type == GDK_BUTTON_PRESS) {
- dwb_focus(gl);
+ dwb_com_focus(gl);
}
if (e->type == GDK_2BUTTON_PRESS) {
- dwb_push_master(&arg);
+ dwb_com_push_master(&arg);
}
}
return false;
@@ -47,7 +47,7 @@ dwb_web_view_button_press_cb(WebKitWebView *web, GdkEventButton *e, GList *gl) {
gboolean
dwb_web_view_close_web_view_cb(WebKitWebView *web, GList *gl) {
Arg a = { .p = gl };
- dwb_remove_view(&a);
+ dwb_com_remove_view(&a);
return true;
}/*}}}*/
@@ -67,7 +67,6 @@ dwb_web_view_console_message_cb(WebKitWebView *web, gchar *message, gint line, g
/* dwb_web_view_create_web_view_cb(WebKitWebView *, WebKitWebFrame *, GList *) {{{*/
GtkWidget *
dwb_web_view_create_web_view_cb(WebKitWebView *web, WebKitWebFrame *frame, GList *gl) {
- // TODO implement
dwb_add_view(NULL);
return ((View*)dwb.state.fview->data)->web;
}/*}}}*/
@@ -75,7 +74,6 @@ dwb_web_view_create_web_view_cb(WebKitWebView *web, WebKitWebFrame *frame, GList
/* dwb_web_view_create_web_view_cb(WebKitWebView *, WebKitDownload *, GList *) {{{*/
gboolean
dwb_web_view_download_requested_cb(WebKitWebView *web, WebKitDownload *download, GList *gl) {
- // TODO implement
dwb_dl_get_path(gl, download);
return true;
}/*}}}*/
@@ -83,7 +81,6 @@ dwb_web_view_download_requested_cb(WebKitWebView *web, WebKitDownload *download,
/* dwb_web_view_hovering_over_link_cb(WebKitWebView *, gchar *title, gchar *uri, GList *) {{{*/
void
dwb_web_view_hovering_over_link_cb(WebKitWebView *web, gchar *title, gchar *uri, GList *gl) {
- // TODO implement
VIEW(gl)->status->hover_uri = uri;
if (uri) {
dwb_set_status_text(gl, uri, NULL, NULL);
@@ -97,7 +94,6 @@ dwb_web_view_hovering_over_link_cb(WebKitWebView *web, gchar *title, gchar *uri,
/* dwb_web_view_mime_type_policy_cb {{{*/
gboolean
dwb_web_view_mime_type_policy_cb(WebKitWebView *web, WebKitWebFrame *frame, WebKitNetworkRequest *request, gchar *mimetype, WebKitWebPolicyDecision *policy, GList *gl) {
-
if (webkit_web_view_can_show_mime_type(web, mimetype)) {
return false;
}
@@ -122,7 +118,7 @@ dwb_web_view_navigation_policy_cb(WebKitWebView *web, WebKitWebFrame *frame, Web
? g_strdup_printf("%s?%s=%s", request_uri, dwb.state.form_name, HINT_SEARCH_SUBMIT)
: g_strdup(request_uri);
dwb_set_normal_message(dwb.state.fview, "Enter a keyword for this search:", false);
- dwb_focus_entry();
+ dwb_com_focus_entry();
dwb.state.mode = SearchKeywordMode;
return true;
}
@@ -145,7 +141,26 @@ void
dwb_web_view_resource_request_cb(WebKitWebView *web, WebKitWebFrame *frame,
WebKitWebResource *resource, WebKitNetworkRequest *request,
WebKitNetworkResponse *response, GList *gl) {
-
+ // TODO implement
+#if 0
+ if (response) {
+ puts(webkit_network_response_get_uri(response));
+ SoupMessage *message = webkit_network_response_get_message(response);
+ SoupMessageHeaders *headers = message->response_headers;
+ const gchar *content = soup_message_headers_get_content_type(headers, NULL);
+ if (content)
+ puts(content);
+ }
+ if (request) {
+ SoupMessage *message = webkit_network_request_get_message(request);
+ if (message) {
+ SoupMessageHeaders *headers = message->response_headers;
+ const gchar *content = soup_message_headers_get_content_type(headers, NULL);
+ if (content)
+ puts(content);
+ }
+ }
+#endif
}/*}}}*/
/* dwb_web_view_script_alert_cb {{{*/
@@ -206,11 +221,10 @@ dwb_web_view_load_status_cb(WebKitWebView *web, GParamSpec *pspec, GList *gl) {
}
}/*}}}*/
-/*}}}*/
-
+// Entry
/* dwb_entry_keyrelease_cb {{{*/
gboolean
-dwb_entry_keyrelease_cb(GtkWidget* entry, GdkEventKey *e) {
+dwb_view_entry_keyrelease_cb(GtkWidget* entry, GdkEventKey *e) {
Mode mode = dwb.state.mode;
if (mode == HintMode || mode == SearchFieldMode) {
if (DIGIT(e) || e->keyval == GDK_Tab) {
@@ -225,7 +239,7 @@ dwb_entry_keyrelease_cb(GtkWidget* entry, GdkEventKey *e) {
/* dwb_entry_keypress_cb(GtkWidget* entry, GdkEventKey *e) {{{*/
gboolean
-dwb_entry_keypress_cb(GtkWidget* entry, GdkEventKey *e) {
+dwb_view_entry_keypress_cb(GtkWidget* entry, GdkEventKey *e) {
Mode mode = dwb.state.mode;
if (mode == HintMode || mode == SearchFieldMode) {
if (e->keyval == GDK_BackSpace) {
@@ -264,7 +278,7 @@ dwb_entry_keypress_cb(GtkWidget* entry, GdkEventKey *e) {
/* dwb_entry_activate_cb (GtkWidget *entry) {{{*/
gboolean
-dwb_entry_activate_cb(GtkEntry* entry) {
+dwb_view_entry_activate_cb(GtkEntry* entry) {
gchar *text = g_strdup(gtk_entry_get_text(entry));
gboolean ret = false;
Mode mode = dwb.state.mode;
@@ -302,6 +316,7 @@ dwb_entry_activate_cb(GtkEntry* entry) {
return true;
}/*}}}*/
+/*}}}*/
/* DWB_WEB_VIEW {{{*/
@@ -342,21 +357,22 @@ dwb_view_modify_style(GList *gl, GdkColor *fg, GdkColor *bg, GdkColor *tabfg, Gd
} /*}}}*/
+/* dwb_view_set_active_style (GList *) {{{*/
void
-dwb_set_active_style(GList *gl) {
+dwb_view_set_active_style(GList *gl) {
dwb_view_modify_style(gl, &dwb.color.active_fg, &dwb.color.active_bg, &dwb.color.tab_active_fg, &dwb.color.tab_active_bg, dwb.font.fd_bold, dwb.font.active_size);
-}
+}/*}}}*/
+
+/* dwb_view_set_normal_style {{{*/
void
-dwb_set_normal_style(GList *gl) {
+dwb_view_set_normal_style(GList *gl) {
dwb_view_modify_style(gl, &dwb.color.normal_fg, &dwb.color.normal_bg, &dwb.color.tab_normal_fg, &dwb.color.tab_normal_bg, dwb.font.fd_bold, dwb.font.normal_size);
-}
-
+}/*}}}*/
/* dwb_web_view_init_signals(View *v) {{{*/
void
dwb_web_view_init_signals(GList *gl) {
View *v = gl->data;
- //g_signal_connect(v->vbox, "key-press-event", G_CALLBACK(dwb_key_press_cb), v);
g_signal_connect(v->web, "button-press-event", G_CALLBACK(dwb_web_view_button_press_cb), gl);
g_signal_connect(v->web, "close-web-view", G_CALLBACK(dwb_web_view_close_web_view_cb), gl);
g_signal_connect(v->web, "console-message", G_CALLBACK(dwb_web_view_console_message_cb), gl);
@@ -374,14 +390,14 @@ dwb_web_view_init_signals(GList *gl) {
g_signal_connect(v->web, "notify::title", G_CALLBACK(dwb_web_view_title_cb), gl);
g_signal_connect(v->web, "focus", G_CALLBACK(dwb_web_view_focus_cb), gl);
- g_signal_connect(v->entry, "key-press-event", G_CALLBACK(dwb_entry_keypress_cb), NULL);
- g_signal_connect(v->entry, "key-release-event", G_CALLBACK(dwb_entry_keyrelease_cb), NULL);
- g_signal_connect(v->entry, "activate", G_CALLBACK(dwb_entry_activate_cb), NULL);
+ g_signal_connect(v->entry, "key-press-event", G_CALLBACK(dwb_view_entry_keypress_cb), NULL);
+ g_signal_connect(v->entry, "key-release-event", G_CALLBACK(dwb_view_entry_keyrelease_cb), NULL);
+ g_signal_connect(v->entry, "activate", G_CALLBACK(dwb_view_entry_activate_cb), NULL);
} /*}}}*/
-/* dwb_create_web_view(View *v) {{{*/
+/* dwb_view_create_web_view(View *v) return: GList * {{{*/
GList *
-dwb_create_web_view(GList *gl) {
+dwb_view_create_web_view(GList *gl) {
View *v = g_malloc(sizeof(View));
ViewStatus *status = g_malloc(sizeof(ViewStatus));
@@ -470,7 +486,7 @@ dwb_create_web_view(GList *gl) {
return gl;
} /*}}}*/
-/* dwb_add_view(Arg *arg) ret: View *{{{*/
+/* dwb_add_view(Arg *arg) return: View *{{{*/
void
dwb_add_view(Arg *arg) {
if (dwb.state.views) {
@@ -486,8 +502,8 @@ dwb_add_view(Arg *arg) {
}
}
}
- dwb.state.views = dwb_create_web_view(dwb.state.views);
- dwb_focus(dwb.state.views);
+ dwb.state.views = dwb_view_create_web_view(dwb.state.views);
+ dwb_com_focus(dwb.state.views);
for (GList *l = g_hash_table_get_values(((View*)dwb.state.views->data)->setting); l; l=l->next) {
WebSettings *s = l->data;
diff --git a/src/view.h b/src/view.h
index cc39c2b5..371cc1cc 100644
--- a/src/view.h
+++ b/src/view.h
@@ -2,4 +2,6 @@
#define VIEW_H
void dwb_add_view(Arg *);
+void dwb_view_set_active_style(GList *);
+void dwb_view_set_normal_style(GList *);
#endif