diff options
-rw-r--r-- | lib/head.html | 3 | ||||
-rw-r--r-- | lib/info.html | 5 | ||||
-rw-r--r-- | src/commands.c | 11 | ||||
-rw-r--r-- | src/dwb.c | 11 | ||||
-rw-r--r-- | src/dwb.h | 1 | ||||
-rw-r--r-- | src/html.c | 46 | ||||
-rw-r--r-- | src/html.h | 2 | ||||
-rw-r--r-- | src/view.c | 2 |
8 files changed, 49 insertions, 32 deletions
diff --git a/lib/head.html b/lib/head.html index 61d3ece5..ad345abf 100644 --- a/lib/head.html +++ b/lib/head.html @@ -12,11 +12,10 @@ top: 0pt; left: 0pt; background: #333; - color: #000000; + color: #303030; width: 100%; z-index: 2; -webkit-user-select: none; - background: #000; } .dwb_button, .dwb_sbutton { position: relative; diff --git a/lib/info.html b/lib/info.html index 4c801e5d..ddbd6842 100644 --- a/lib/info.html +++ b/lib/info.html @@ -1,7 +1,10 @@ <!-- vim: set tw=0 --> <body> <div id="bar"> - <img id="dwb_icon" src=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeEAQAAADBqbpqAAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAAAEgAAABIAEbJaz4AAANUSURBVEjH7ZR7TFN3FMc/9wEFQkWpIEwWplUS39EuMINbAdHEZSmawNSQ+WiixOka3dw/Gtkjezi3ZWEmCzhRo5tETSU+olMCUZnLNGi1Yz7Gio+owyIK0sBa2/72RxmPpXcZY2HJxje5yb3nfM/3e3/nnHthCP91SFqJx2UAEXG8GGH2p/JrqyeQG3zWu186Qp3RqMVnJURtwyrndCSheO77TNIt/+ZwfDmc6QcNsHatXrl8+8Pnr3fUum9drd0UbP/sNWWKWq/1ovqVYHdMGn31kj3xuv10dUtL7Svy1wWx/WqD/n2ItloXjC0K/DD+OSHyrglRb6pxPnBGJLlcWlXK+vhme1raeSHGGYR4Ty/E3e3r0rT4arhg+0aAuB8bkScDxGZDUAZ1FuDQMpa/epgw4uTDrqcH20E+CGRrsPvVin8Q/z9jtb8F+qPQ9qViAPV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DhUMjA6NDU6MjMrMDE6MDAWGaRfAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDExLTAyLTA4VDIwOjQ1OjIzKzAxOjAwZ0Qc4wAAAABJRU5ErkJggg== /> + </a> <div class='dwb_button' ><a href="dwb://bookmarks">Bookmarks</a></div> <div class='dwb_button' ><a href="dwb://quickmarks">Quickmarks</a></div> <div class='dwb_button' ><a href="dwb://history">History</a></div> diff --git a/src/commands.c b/src/commands.c index ad7b61c6..654a2b3c 100644 --- a/src/commands.c +++ b/src/commands.c @@ -177,7 +177,7 @@ dwb_com_show_hints(KeyMap *km, Arg *arg) { /* dwb_com_show_keys(KeyMap *km, Arg *arg){{{*/ gboolean dwb_com_show_keys(KeyMap *km, Arg *arg) { - dwb_html_load(CURRENT_WEBVIEW(), "dwb://keys"); + dwb_html_load(dwb.state.fview, "dwb://keys"); return true; }/*}}}*/ @@ -185,7 +185,7 @@ dwb_com_show_keys(KeyMap *km, Arg *arg) { gboolean dwb_com_show_settings(KeyMap *km, Arg *arg) { dwb.state.setting_apply = APPLY_GLOBAL; - dwb_html_load(CURRENT_WEBVIEW(), "dwb://settings"); + dwb_html_load(dwb.state.fview, "dwb://settings"); return true; }/*}}}*/ @@ -446,12 +446,7 @@ dwb_com_open(KeyMap *km, Arg *arg) { /* dwb_com_open(KeyMap *km, Arg *arg) {{{*/ gboolean dwb_com_open_startpage(KeyMap *km, Arg *arg) { - if (!dwb.misc.startpage) - return false; - - Arg a = { .p = dwb.misc.startpage, .b = true }; - dwb_load_uri(NULL, &a); - return true; + return dwb_open_startpage(NULL); } /*}}}*/ /* dwb_com_toggle_maximized {{{*/ @@ -917,6 +917,17 @@ dwb_update_status_text(GList *gl, GtkAdjustment *a) { /* FUNCTIONS {{{*/ +gboolean +dwb_open_startpage(GList *gl) { + if (!dwb.misc.startpage) + return false; + if (gl == NULL) + gl = dwb.state.fview; + + Arg a = { .p = dwb.misc.startpage, .b = true }; + dwb_load_uri(gl, &a); +} + /* dwb_apply_settings(WebSettings *s) {{{*/ static void dwb_apply_settings(WebSettings *s) { @@ -655,5 +655,6 @@ void dwb_focus_view(GList *); void dwb_clean_key_buffer(void); void dwb_set_key(const char *, char *); void dwb_set_setting(const char *, char *value); +gboolean dwb_open_startpage(GList *); #endif @@ -14,14 +14,15 @@ struct _HtmlTable { const char *title; const char *file; int type; - void (*func)(WebKitWebView *, HtmlTable *); + void (*func)(GList *, HtmlTable *); }; -void dwb_html_bookmarks(WebKitWebView *, HtmlTable *); -void dwb_html_history(WebKitWebView *, HtmlTable *); -void dwb_html_quickmarks(WebKitWebView *, HtmlTable *); -void dwb_html_settings(WebKitWebView *, HtmlTable *); -void dwb_html_keys(WebKitWebView *, HtmlTable *); +void dwb_html_bookmarks(GList *, HtmlTable *); +void dwb_html_history(GList *, HtmlTable *); +void dwb_html_quickmarks(GList *, HtmlTable *); +void dwb_html_settings(GList *, HtmlTable *); +void dwb_html_startpage(GList *, HtmlTable *); +void dwb_html_keys(GList *, HtmlTable *); static HtmlTable table[] = { { "dwb://bookmarks", "Bookmarks", INFO_FILE, 0, dwb_html_bookmarks }, @@ -29,6 +30,7 @@ static HtmlTable table[] = { { "dwb://history", "History", INFO_FILE, 0, dwb_html_history }, { "dwb://keys", "Keys", INFO_FILE, 0, dwb_html_keys }, { "dwb://settings", "Settings", INFO_FILE, 0, dwb_html_settings }, + { "dwb://startpage", NULL, NULL, 0, dwb_html_startpage }, }; static char current_uri[BUFFER_LENGTH]; @@ -56,24 +58,24 @@ dwb_html_load_page(WebKitWebView *wv, HtmlTable *t, char *panel) { } } void -dwb_html_navigation(WebKitWebView *wv, GList *gl, HtmlTable *table) { +dwb_html_navigation(GList *gl, GList *data, HtmlTable *table) { int i=0; GString *panels = g_string_new(NULL); - for (GList *l = gl; l; l=l->next, i++, i%=2) { + for (GList *l = data; l; l=l->next, i++, i%=2) { Navigation *n = l->data; g_string_append_printf(panels, "<div class='dwb_line%d'><div><a href='%s'>%s</a></div></div>\n", i, n->first, n->second); } - dwb_html_load_page(wv, table, panels->str); + dwb_html_load_page(WEBVIEW(gl), table, panels->str); g_string_free(panels, true); } void -dwb_html_bookmarks(WebKitWebView *wv, HtmlTable *table) { +dwb_html_bookmarks(GList *gl, HtmlTable *table) { dwb.fc.bookmarks = g_list_sort(dwb.fc.bookmarks, (GCompareFunc)dwb_util_navigation_compare_second); - dwb_html_navigation(wv, dwb.fc.bookmarks, table); + dwb_html_navigation(gl, dwb.fc.bookmarks, table); } void -dwb_html_history(WebKitWebView *wv, HtmlTable *table) { - dwb_html_navigation(wv, dwb.fc.history, table); +dwb_html_history(GList *gl, HtmlTable *table) { + dwb_html_navigation(gl, dwb.fc.history, table); } gboolean dwb_html_settings_changed_cb(WebKitDOMElement *el, WebKitDOMEvent *ev, WebKitWebView *wv) { @@ -118,8 +120,9 @@ dwb_html_settings_load_cb(WebKitWebView *wv, GParamSpec *p, HtmlTable *table) { } } void -dwb_html_settings(WebKitWebView *wv, HtmlTable *table) { +dwb_html_settings(GList *gl, HtmlTable *table) { char *content; + WebKitWebView *wv = WEBVIEW(gl); g_signal_connect(wv, "notify::load-status", G_CALLBACK(dwb_html_settings_load_cb), table); char *path = dwb_util_get_data_file(SETTINGS_FILE); g_file_get_contents(path, &content, NULL, NULL); @@ -161,8 +164,9 @@ dwb_html_keys_load_cb(WebKitWebView *wv, GParamSpec *p, HtmlTable *table) { } } void -dwb_html_keys(WebKitWebView *wv, HtmlTable *table) { +dwb_html_keys(GList *gl, HtmlTable *table) { char *content; + WebKitWebView *wv = WEBVIEW(gl); g_signal_connect(wv, "notify::load-status", G_CALLBACK(dwb_html_keys_load_cb), table); char *path = dwb_util_get_data_file(KEY_FILE); g_file_get_contents(path, &content, NULL, NULL); @@ -171,23 +175,27 @@ dwb_html_keys(WebKitWebView *wv, HtmlTable *table) { g_free(content); } void -dwb_html_quickmarks(WebKitWebView *wv, HtmlTable *table) { +dwb_html_quickmarks(GList *gl, HtmlTable *table) { int i=0; GString *panels = g_string_new(NULL); for (GList *gl = dwb.fc.quickmarks; gl; gl=gl->next, i++, i%=2) { Quickmark *q = gl->data; g_string_append_printf(panels, "<div class='dwb_line%d'><div class=dwb_qm>%s</div><div><a href='%s'>%s</a></div></div>\n", i, q->key, q->nav->first, q->nav->second); } - dwb_html_load_page(wv, table, panels->str); + dwb_html_load_page(WEBVIEW(gl), table, panels->str); g_string_free(panels, true); } +void +dwb_html_startpage(GList *gl, HtmlTable *table) { + dwb_open_startpage(gl); +} gboolean -dwb_html_load(WebKitWebView *wv, const char *uri) { +dwb_html_load(GList *gl, const char *uri) { for (int i=0; i<LENGTH(table); i++) { if (!strncmp(table[i].uri, uri, strlen(table[i].uri))) { strncpy(current_uri, uri, BUFFER_LENGTH - 1); - table[i].func(wv, &table[i]); + table[i].func(gl, &table[i]); return true; } } @@ -1,6 +1,6 @@ #ifndef HTML_H #define HTML_H -gboolean dwb_html_load(WebKitWebView *, const char *); +gboolean dwb_html_load(GList *, const char *); #endif @@ -216,7 +216,7 @@ dwb_web_view_navigation_policy_cb(WebKitWebView *web, WebKitWebFrame *frame, Web gboolean ret = false; if (g_str_has_prefix(uri, "dwb://")) { - dwb_html_load(web, uri); + dwb_html_load(gl, uri); return true; } Arg a = { .p = uri, .b = true }; |