tazweb rev 192
helper.sh: add bookmarks handler
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu Mar 16 00:20:44 2017 +0100 (2017-03-16) |
parents | 33e0f5920655 |
children | 51b5c8aad18c |
files | lib/helper.sh src/tazweb.c |
line diff
1.1 --- a/lib/helper.sh Wed Mar 15 05:53:39 2017 +0200 1.2 +++ b/lib/helper.sh Thu Mar 16 00:20:44 2017 +0100 1.3 @@ -71,21 +71,46 @@ 1.4 IFS="|" 1.5 while read title url null; do 1.6 echo "<li><a href=\"$url\">$title</a></li>" 1.7 - done < $bm_txt 1.8 + done < ${bm_txt} 1.9 unset IFS 1.10 1.11 echo '</ul>' 1.12 num=$(wc -l < $bm_txt) 1.13 html_footer "$(printf "$(ngettext "%d bookmark" "%d bookmarks" "$num")" "$num") - $(date)" 1.14 - } > $bm_html 1.15 + } > ${bm_html} 1.16 1.17 # Security fix from old cgi-bin bookmarks.cgi 1.18 - chown $USER:$USER $bm_txt; chmod 0600 $bm_txt 1.19 + chown $USER:$USER ${bm_txt}; chmod 0600 ${bm_txt} 1.20 } 1.21 1.22 -edit_bookmarks() { 1.23 - yad --text-info \ 1.24 - --center --width=640 --height=480 --filename=$bm_txt 1.25 +# List all bookmarks 1.26 +bookmarks_list() { 1.27 + cat ${bm_txt} | while read title url; do 1.28 + echo -e "$title\n$url" 1.29 + done | yad --list \ 1.30 + --title="$(gettext 'TazWeb Bookmarks')" \ 1.31 + --text-align=center \ 1.32 + --text="$(gettext 'Click on a value to edit - Right click to remove a bookmark')\n" \ 1.33 + --mouse --width=640 --height=480 \ 1.34 + --skip-taskbar \ 1.35 + --window-icon=/usr/share/icons/hicolor/32x32/apps/tazweb.png \ 1.36 + --editable --print-all \ 1.37 + --tooltip-column=2 \ 1.38 + --search-column=1 \ 1.39 + --column="$(gettext 'Title')" \ 1.40 + --column="$(gettext 'URL')" 1.41 +} 1.42 + 1.43 +# Rebuilt bookmarks.txt since some entry may have been edited and remove 1.44 +# selected (TRUE) entries. 1.45 +bookmarks_handler() { 1.46 + IFS="|" 1.47 + bookmarks_list | while read title url null; do 1.48 + echo "$title|$url" >> ${bm_txt}.tmp 1.49 + done; unset IFS 1.50 + if [ -f "${bm_txt}.tmp" ]; then 1.51 + mv -f ${bm_txt}.tmp ${bm_txt} 1.52 + fi 1.53 } 1.54 1.55 # Generate cookies.html (for direct view of cookies in TazWeb) 1.56 @@ -97,27 +122,26 @@ 1.57 IFS="|" 1.58 while read line; do 1.59 echo "${line#\#HttpOnly_}" 1.60 - done < $cookies_txt 1.61 + done < ${cookies_txt} 1.62 unset IFS 1.63 1.64 echo '</pre>' 1.65 num=$(wc -l < $cookies_txt) 1.66 html_footer "$(printf "$(ngettext "%d cookie" "%d cookies" "$num")" "$num") - $(date)" 1.67 - } > $cookies_html 1.68 + } > ${cookies_html} 1.69 } 1.70 1.71 clean_cookies() { 1.72 - > $cookies_txt 1.73 + rm ${cookies_txt}; touch ${cookies_txt} 1.74 } 1.75 1.76 - 1.77 # 1.78 # Execute any shell_function 1.79 # 1.80 case "$1" in 1.81 1.82 *_*) 1.83 - cmd=$1; shift; $cmd $@ ;; 1.84 + cmd=${1}; shift; ${cmd} ${@} ;; 1.85 1.86 *) grep "[a-z]_*()" $0 | awk '{print $1}' ;; 1.87
2.1 --- a/src/tazweb.c Wed Mar 15 05:53:39 2017 +0200 2.2 +++ b/src/tazweb.c Thu Mar 16 00:20:44 2017 +0100 2.3 @@ -169,7 +169,7 @@ 2.4 static void 2.5 bookmarks_edit_cb(GtkWidget* widget, WebKitWebView* webview) 2.6 { 2.7 - system("/usr/lib/tazweb/helper.sh edit_bookmarks"); 2.8 + system("/usr/lib/tazweb/helper.sh bookmarks_handler &"); 2.9 } 2.10 2.11 static void 2.12 @@ -489,12 +489,14 @@ 2.13 2.14 /* Home button */ 2.15 item = gtk_tool_button_new_from_stock(GTK_STOCK_HOME); 2.16 + gtk_widget_set_tooltip_text(GTK_WIDGET(item), "Home page"); 2.17 g_signal_connect(G_OBJECT(item), "clicked", 2.18 G_CALLBACK(go_home_cb), webview); 2.19 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); 2.20 2.21 /* Bookmark button */ 2.22 item = gtk_tool_button_new_from_stock(GTK_STOCK_PROPERTIES); 2.23 + gtk_widget_set_tooltip_text(GTK_WIDGET(item), "Bookmarks"); 2.24 g_signal_connect(G_OBJECT(item), "clicked", 2.25 G_CALLBACK(go_bookmarks_cb), webview); 2.26 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);