summaryrefslogtreecommitdiff
path: root/src/html.c
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2011-03-17 00:18:42 +0100
committerportix <portix@gmx.net>2011-03-17 00:18:42 +0100
commit9b12bfe0c13ea638b0ecab96eac64b4f365b42e4 (patch)
treeb166df1227e3459278b3be5afd4027ed42d7a33a /src/html.c
parented7e50c7f3a1dab193089276c57f6ef06e78e3f0 (diff)
downloaddwb-9b12bfe0c13ea638b0ecab96eac64b4f365b42e4.zip
added settings.html
--HG-- branch : html
Diffstat (limited to 'src/html.c')
-rw-r--r--src/html.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/html.c b/src/html.c
index bcf3fdca..22d35d8e 100644
--- a/src/html.c
+++ b/src/html.c
@@ -2,37 +2,51 @@
#include "html.h"
#include "util.h"
+#define INFO_FILE "info.html"
+#define SETTINGS_FILE "settings.html"
+#define HEAD_FILE "head.html"
+
typedef struct _HtmlTable HtmlTable;
struct _HtmlTable {
const char *uri;
const char *title;
- const char *state;
+ const char *file;
+ int type;
void (*func)(WebKitWebView *, 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 *);
static HtmlTable table[] = {
- { "dwb://bookmarks", "Bookmarks", "aiii", dwb_html_bookmarks },
- { "dwb://quickmarks", "Quickmarks", "iaii", dwb_html_quickmarks },
- { "dwb://history", "History", "iiai", dwb_html_history },
- { "dwb://settings", "Settings", "iiia", dwb_html_history },
+ { "dwb://bookmarks", "Bookmarks", INFO_FILE, 0, dwb_html_bookmarks },
+ { "dwb://quickmarks", "Quickmarks", INFO_FILE, 0, dwb_html_quickmarks },
+ { "dwb://history", "History", INFO_FILE, 0, dwb_html_history },
+ { "dwb://settings", "Settings", SETTINGS_FILE, 0, dwb_html_settings },
};
void
dwb_html_load_page(WebKitWebView *wv, HtmlTable *t, char *panel) {
- char *filecontent, *content;
- char *path = dwb_util_get_data_file("info.html");
- if (path) {
+ char *filecontent;
+ GString *content = g_string_new(NULL);
+ char *path = dwb_util_get_data_file(t->file);
+ char *headpath = dwb_util_get_data_file(HEAD_FILE);
+ if (path && headpath) {
+ /* load head */
+ g_file_get_contents(headpath, &filecontent, NULL, NULL);
+ g_string_append_printf(content, filecontent, t->title);
+ g_free(filecontent);
+ FREE(headpath);
+ /* load content */
g_file_get_contents(path, &filecontent, NULL, NULL);
- content = g_strdup_printf(filecontent, t->title, t->state[0], t->state[1], t->state[2], t->state[3], panel);
- webkit_web_frame_load_alternate_string(webkit_web_view_get_main_frame(wv), content, t->uri, "about:blank");
- g_free(content);
+ g_string_append_printf(content, filecontent, panel);
+ webkit_web_frame_load_alternate_string(webkit_web_view_get_main_frame(wv), content->str, t->uri, "about:blank");
+ g_string_free(content, true);
g_free(filecontent);
- g_free(path);
+ FREE(path);
}
}
void
@@ -56,6 +70,10 @@ dwb_html_history(WebKitWebView *wv, HtmlTable *table) {
dwb_html_navigation(wv, dwb.fc.history, table);
}
void
+dwb_html_settings(WebKitWebView *wv, HtmlTable *table) {
+ dwb_html_load_page(wv, table, "blub");
+}
+void
dwb_html_quickmarks(WebKitWebView *wv, HtmlTable *table) {
int i=0;
GString *panels = g_string_new(NULL);