commit 9a20e5af58438d75e0bb1102ba607bced4d78291
parent fa065aff830eb90a9bb42e0bc2849c4c2f31f7bb
Author: Kyle Milz <kmilz@ucalgary.ca>
Date: Tue, 13 Nov 2012 17:33:21 -0700
hist: store protocol separately from url
do this to allow direct tab completion of host names without having to
specify the protocol.
Diffstat:
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -118,21 +118,39 @@ session_restore(App_Data *ad)
static void
hist_nav_cb(const Evas_Object *view, Ewk_Navigation_Data *nav_data, void *data)
{
- // printf("logging item to history.\n");
Hist_Item *item;
App_Data *ad = data;
- const char *title = ewk_navigation_data_title_get(nav_data);
- const char *url = ewk_navigation_data_url_get(nav_data);
+ Eina_Strbuf *proto = eina_strbuf_new();
+ Eina_Stringshare *title = ewk_navigation_data_title_get(nav_data);
+ Eina_Stringshare *url = ewk_navigation_data_url_get(nav_data);
+
+ if (strncmp(url, "http://", 7) == 0) {
+ eina_strbuf_append(proto, "http");
+ url += 7;
+ }
+ else if (strncmp(url, "https://", 8) == 0) {
+ eina_strbuf_append(proto, "https");
+ url += 8;
+ }
item = hist_items_get(ad->history, url);
if (item && hist_item_enabled_get(item)) {
hist_item_visit_count_set(item, hist_item_visit_count_get(item) + 1);
hist_item_last_visit_set(item, ecore_time_unix_get());
hist_item_title_set(item, title);
+ hist_item_proto_set(item, eina_strbuf_string_get(proto));
}
else if (!item && config_enable_history_get(ad->config)) {
- hist_items_add(ad->history, url, hist_item_new(EINA_TRUE, title, url, 1, ecore_time_unix_get()));
+ hist_items_add(ad->history, url, hist_item_new(
+ EINA_TRUE,
+ title,
+ url,
+ eina_strbuf_string_get(proto),
+ 1,
+ ecore_time_unix_get()));
}
+
+ eina_strbuf_free(proto);
}
static void
@@ -201,12 +219,18 @@ hist_visited_cb(void *data)
{
App_Data *ad = data;
void *hash_data;
+ Eina_Strbuf *url_buf = eina_strbuf_new();
Eina_Iterator *it = eina_hash_iterator_tuple_new(hist_items_hash_get(ad->history));
while (eina_iterator_next(it, &hash_data)) {
Eina_Hash_Tuple *t = hash_data;
Hist_Item *hist_item = t->data;
- ewk_context_visited_link_add(ewk_context_default_get(), hist_item_url_get(hist_item));
+
+ eina_strbuf_append(url_buf, hist_item_proto_get(hist_item));
+ eina_strbuf_append(url_buf, "://");
+ eina_strbuf_append(url_buf, hist_item_url_get(hist_item));
+ ewk_context_visited_link_add(ewk_context_default_get(), eina_strbuf_string_get(url_buf));
+ eina_strbuf_reset(url_buf);
}
eina_iterator_free(it);
diff --git a/src/viking_state.geneet b/src/viking_state.geneet
@@ -19,6 +19,7 @@ Hist_Item {
enabled : uchar;
title : str default "Untitled";
url : str default "about:blank";
+ proto : str default "http";
visit_count : uint;
last_visit : double;
}