Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional subdirectory for bookmarks #258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lang/cs_CZ.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,10 @@ msg: URL
id: Video
msg: Video

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
3 changes: 3 additions & 0 deletions lang/de_DE.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,9 @@ msg: URL
id: Video
msg: Video

id: Show bookmarks in a subdirectory
msg: Lesezeichen in Unterverzeichnis anzeigen

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/dk_DK.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,10 @@ msg: URL
id: Video
msg: Video

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/el_EL.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,10 @@ msg: URL
id: Video
msg: Βίντεο

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/fi_FI.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,10 @@ msg: URL
id: Video
msg: Video

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/fr_FR.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,10 @@ msg: URL
id: Video
msg: Vidéo

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/hu_HU.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,10 @@ msg: URL
id: Video
msg: Videó

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/it_IT.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,10 @@ msg: URL
id: Video
msg: Video

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/ja_JP.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,10 @@ msg: URL
id: Video
msg: ビデオ

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/mk_MK.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,10 @@ msg: URL
id: Video
msg: Видео

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/nl_NL.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,10 @@ msg: URL
id: Video
msg: Video

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/pl_PL.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,10 @@ msg: Adres URL
id: Video
msg: Video

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/pt_BR.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,10 @@ msg: URL
id: Video
msg: Video

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/pt_PT.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,10 @@ msg: Endereço
id: Video
msg: Vídeo

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/ru_RU.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,10 @@ msg: URL
id: Video
msg: Видео

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/sk_SK.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,10 @@ msg: URL adresa
id: Video
msg: Video

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/sp_SP.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,10 @@ msg: URL
id: Video
msg: Vídeo

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/sv_SV.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,10 @@ msg: URL
id: Video
msg: Video

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/ua_UA.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,10 @@ msg: URL
id: Video
msg: Відео

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
4 changes: 4 additions & 0 deletions lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,10 @@ msg: URL
id: Video
msg: 视频

id: Show bookmarks in a subdirectory
# Missing translation
msg:

#
# ./src/networking/connman.c
#
Expand Down
98 changes: 88 additions & 10 deletions src/navigator.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2007-2015 Lonelycoder AB
* Copyright (C) 2007-2018 Lonelycoder AB
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -163,7 +163,7 @@ typedef struct nav_page {
typedef struct navigator {

LIST_ENTRY(navigator) nav_link;

struct nav_page_queue nav_pages;
struct nav_page_queue nav_history;

Expand Down Expand Up @@ -220,7 +220,7 @@ nav_update_bookmarked(void)
LIST_FOREACH(nav, &navigators, nav_link) {
nav_page_t *np;
TAILQ_FOREACH(np, &nav->nav_pages, np_global_link) {
prop_set_int_ex(np->np_bookmarked,
prop_set_int_ex(np->np_bookmarked,
np->np_bookmarked_sub, nav_page_is_bookmarked(np));
}
}
Expand Down Expand Up @@ -637,7 +637,7 @@ nav_page_setup_prop(nav_page_t *np, const char *view)
np->np_url);

prop_t *prev = prop_create(np->np_prop_root, "previous");

if(np->np_parent_model_src) {
np->np_parent_model_dst = prop_create_r(prev, "parentModel");
prop_link(np->np_parent_model_src, np->np_parent_model_dst);
Expand All @@ -654,7 +654,7 @@ nav_page_setup_prop(nav_page_t *np, const char *view)
prop_set(np->np_prop_root, "how", PROP_SET_STRING, np->np_how);

// XXX Change this into event-style subscription
np->np_close_sub =
np->np_close_sub =
prop_subscribe(0,
PROP_TAG_NAMED_ROOT, np->np_prop_root, "page",
PROP_TAG_NAME("page", "close"),
Expand All @@ -665,15 +665,15 @@ nav_page_setup_prop(nav_page_t *np, const char *view)
prop_set(np->np_prop_root, "url", PROP_SET_STRING, np->np_url);
prop_set(np->np_prop_root, "parentUrl", PROP_SET_STRING, np->np_parent_url);

np->np_direct_close_sub =
np->np_direct_close_sub =
prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
PROP_TAG_NAMED_ROOT, np->np_prop_root, "page",
PROP_TAG_NAME("page", "directClose"),
PROP_TAG_CALLBACK_INT, nav_page_direct_close_set, np,
PROP_TAG_MUTEX, &nav_mutex,
NULL);

np->np_eventsink_sub =
np->np_eventsink_sub =
prop_subscribe(0,
PROP_TAG_NAMED_ROOT, np->np_prop_root, "page",
PROP_TAG_NAME("page", "eventSink"),
Expand All @@ -687,7 +687,7 @@ nav_page_setup_prop(nav_page_t *np, const char *view)

prop_set_int(np->np_bookmarked, nav_page_is_bookmarked(np));

np->np_bookmarked_sub =
np->np_bookmarked_sub =
prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE | PROP_SUB_IGNORE_VOID,
PROP_TAG_ROOT, np->np_bookmarked,
PROP_TAG_CALLBACK_INT, nav_page_bookmarked_set, np,
Expand Down Expand Up @@ -1231,6 +1231,8 @@ bm_delete(void *opaque, prop_event_t event, ...)
}


static int bookmarks_subdir_flag;
static service_t *bookmarks_subdir_service;

/**
*
Expand Down Expand Up @@ -1267,8 +1269,8 @@ bookmark_add(const char *title, const char *url, const char *type,
bm->bm_id = rstr_alloc(id);

bm->bm_service = service_create(rstr_get(bm->bm_id),
title, url, type, icon, 1, 1,
SVC_ORIGIN_BOOKMARK);
title, url, type, icon, 1, !bookmarks_subdir_flag,
SVC_ORIGIN_BOOKMARK);

prop_link(service_get_status_prop(bm->bm_service),
prop_create(p, "status"));
Expand Down Expand Up @@ -1511,6 +1513,70 @@ bookmark_eventsink(void *opaque, event_t *e)
}
}

/**
*
*/
static void
bookmarks_subdir_callback(void *opaque, int value)
{
bookmarks_subdir_flag = value;

prop_set(bookmarks_subdir_service->s_root, "enabled", PROP_SET_INT, value);

bookmark_t *bm;
LIST_FOREACH(bm, &bookmarks, bm_link) {
prop_set(bm->bm_service->s_root, "enabled", PROP_SET_INT, !value);
}
}

/**
*
*/
static int
bookmarks_subdir_canhandle(const char *url)
{
return !strcmp(url, "bookmarks_subdir:");
}

/**
*
*/
static int
bookmarks_subdir_open_url(prop_t *page, const char *url, int sync)
{
prop_t *model = prop_create_r(page, "model");

prop_setv(model, "metadata", "title", NULL,
PROP_SET_LINK, _p("Bookmarks"));

prop_set(model, "type", PROP_SET_STRING, "directory");

prop_t *nodes = prop_create_r(model, "nodes");

bookmark_t *bm;
LIST_FOREACH(bm, &bookmarks, bm_link) {
prop_t *p = prop_create(nodes, NULL);
prop_set(p, "type", PROP_SET_STRING, "directory");
prop_setv(p, "metadata", "title", NULL, PROP_SET_STRING, rstr_get(bm->bm_title));
prop_setv(p, "metadata", "icon", NULL, PROP_SET_STRING, rstr_get(bm->bm_icon));
prop_set(p, "url", PROP_SET_STRING, rstr_get(bm->bm_url));
}

prop_ref_dec(nodes);
prop_ref_dec(model);
return 0;
}

/**
*
*/
static backend_t be_bookmarks_subdir = {
.be_canhandle = bookmarks_subdir_canhandle,
.be_open = bookmarks_subdir_open_url,
};

BE_REGISTER(bookmarks_subdir);

/**
*
*/
Expand All @@ -1525,6 +1591,18 @@ bookmarks_init(void)
_p("Add and remove items on homepage"),
"settings:bookmarks");

bookmarks_subdir_service = service_createp("bookmarks_subdir_service",
_p("Bookmarks"), "bookmarks_subdir:", "directory",
"skin://icons/ic_collections_bookmark_24px.svg", 1,
bookmarks_subdir_flag, SVC_ORIGIN_SYSTEM);

setting_create(SETTING_BOOL, root, SETTINGS_INITIAL_UPDATE,
SETTING_TITLE(_p("Show bookmarks in a subdirectory")),
SETTING_VALUE(0),
SETTING_CALLBACK(bookmarks_subdir_callback, NULL),
SETTING_STORE("bookmarks_settings", "bookmarks_subdir"),
NULL);

bookmark_nodes = prop_create(root, "nodes");
prop_set(root, "mayadd", PROP_SET_INT, 1);

Expand Down