feat: convert bookmarks to tags with color highlighting#1296
feat: convert bookmarks to tags with color highlighting#1296LAfricain wants to merge 1 commit intocrosswire:masterfrom
Conversation
76067f8 to
d6586a8
Compare
|
I will be looking at this closely in a few days. As I've mentioned, I'm traveling for work this week and have little spare time until I'm home again. |
d6586a8 to
2d28e80
Compare
|
One immediate observation: |
99afce5 to
2c7c9dd
Compare
- Add COL_COLOR column to bookmark tree store (bookmarks_treeview.h/c) - Add color attribute to XML folder nodes (xml.c/h) - New folder dialog with color picker (ui/folder.gtkbuilder, ui/folder.glade) - Tag color saved and restored from bookmarks.xml - Verse highlighting in Bible text using tag color (display.cc) - Text color auto-adjusted for dark backgrounds (luminance) - Multi-reference support: semicolons, commas, verse ranges - Popup menu for multi-reference bookmarks navigation - Drag and drop reordering enabled by default - Cairo color dot in treeview for tagged folders - Current verse green highlight disabled when tag color present - Fix bookmark folder labels localization: gettext now initialized before default bookmarks are created, so folder names (Personal, What must I do to be saved?, etc.) are properly translated on first run Closes crosswire#968 Closes crosswire#685
2c7c9dd to
d25230f
Compare
|
I need help for Windows, i'm becoming crasy. It's all the more frustrating because these new tags look great on Ubuntu! See what Claude says: [Windows build] win64: missing webkitgtk-3.0 for mingw64, and folder/edit bookmark dialogs not working Context: Problem 1 — win64 build fails: We tried Question: What is the recommended way to build win64 with GTK3 without webkit? Is there a mingw64 webkit package available, or should we protect all Problem 2 — folder/edit bookmark dialogs do nothing on Windows: if (NOT GTK2)
install (FILES folder.gtkbuilder ... languages ...)This is directly tied to Problem 1 — fixing the win64 GTK3 build would resolve both issues. |
Voici le texte de la PR :
Title: feat: Convert bookmarks to tags with color highlighting
Closes: #968, #685
Summary
This PR converts the existing Bookmarks tab into a Tags system. Tags are a strict superset of bookmarks: every bookmark can be expressed as a tag entry belonging to a named, color-coded folder. This approach resolves both #968 (tags in text) and #685 (color for bookmark folders) in a single coherent feature.
Changes
Data model
COL_COLORcolumn (G_TYPE_STRING) to theGtkTreeStorecolorattribute on<Folder>nodes — fully backward compatible (existing files load without modification)xml_add_folder_to_parent_colored()andxml_get_folder_color()toxml.c/hUI — Tag panel
ui/folder.gtkbuilder(andfolder.gladefor Windows) with a name field, aGtkColorButton, and a "No color" buttonVerse highlighting in the Bible text view
get_tag_color_for_versekey()indisplay.ccwalks theGtkTreeStoreand returns the tag color for the current verse usingVerseKeyOSIS normalization — this handles locale differences between the stored key format and the display engine formatcolor:computed from background luminance (ITU-R BT.709) so text remains readable on dark tag colorsAct 16:31; 16:36): book name is propagated to partial refsEph 2:8,9): expanded to individual verse checks1 Cor 15:1-4): checked numerically (book + chapter + verse range) to avoid lexicographic comparison bugsDesign decisions
Why disable the current-verse green highlight when a tag color is present?
When a verse has a tag color, the green highlight from
settings.versehighlightwould override or mix with the tag color, making the tag color invisible on the current verse. We chose to skip the green highlight whentag_color != NULL, so the tag color takes full visual priority. The user can still see which verse is current via the verse number anchor.Why use
VerseKeynormalization instead of string comparison?Stored bookmark keys use locale-dependent formats (e.g.
"Actes 16:31"in French) whileGTKChapDisp::display()iterates using English OSIS book names ("Act"). Direct string comparison always fails across locales. Normalizing both sides throughVerseKey::getOSISBookName()+ chapter + verse gives a locale-independent comparison.Why use numeric comparison for verse ranges instead of OSIS string comparison?
Lexicographic comparison of OSIS refs like
"1Co.15.10"vs"1Co.15.4"gives wrong results ("10" < "4"alphabetically). We comparevk->getVerse()directly againstvk_start.getVerse()andatoi(dash + 1)as integers.Why move the color picker out of the context menu?
The context menu item "Set folder color" required a two-step interaction (right-click → menu item → color dialog) and did not work on empty folders. Integrating the color picker directly into the "New Folder" and "Edit Item" dialogs makes it discoverable and works consistently regardless of folder contents.
Localization fix
Default bookmark folder names (
Personal,What must I do to be saved?, etc.) were always created in English becausexml_new_bookmark_file()was called beforegui_init()initialized gettext. Fixed by callinggui_init()beforeinit_bookmarks()insettings.c.gui_init()is idempotent (guarded by a static flag) so multiple calls are safe.Backward compatibility
bookmarks.xmlfiles load without modification — folders without acolorattribute simply have no tag colorbookmarks.xml.bakbackup is created on first run after upgrade (copied, not moved)Files changed
src/gtk/bookmark_dialog.c— new folder dialog, fixed button handlingsrc/gtk/bookmarks_menu.c— color-aware save, new/edit folder dialogssrc/gtk/bookmarks_treeview.c— COL_COLOR, Cairo dot, multi-ref navigation, drag & dropsrc/gtk/utilities.c—utilities_parse_treeviewpropagates colorsrc/gui/bookmarks_menu.h—set_colorwidget,on_set_tag_color_activatesrc/gui/bookmarks_treeview.h—COL_COLORenum,colorfield inBOOKMARK_DATAsrc/main/display.cc— tag color lookup, highlighting, luminance-based text colorsrc/main/main.c— backup on first runsrc/main/settings.c—gui_initbeforeinit_bookmarkssrc/main/xml.c/h—xml_add_folder_to_parent_colored,xml_get_folder_colorui/CMakeLists.txt— addedfolder.gtkbuilderandfolder.gladeui/folder.gtkbuilder/ui/folder.glade— new folder dialog UIPlease test!