From: Olaf Wintermann Date: Sun, 23 Feb 2025 13:22:45 +0000 (+0100) Subject: implement note selection X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=45dbb5c6eb592ded2decc4063f7c295c182e8c28;p=note.git implement note selection --- diff --git a/application/Makefile b/application/Makefile index 2df7deb..63a742b 100644 --- a/application/Makefile +++ b/application/Makefile @@ -39,6 +39,7 @@ SRC += types.c SRC += store.c SRC += store_sqlite.c SRC += notebook.c +SRC += note.c OBJ = $(SRC:%.c=../build/application/%.$(OBJ_EXT)) diff --git a/application/application.h b/application/application.h index e2889a8..895b786 100644 --- a/application/application.h +++ b/application/application.h @@ -40,8 +40,7 @@ extern "C" { #define APP_STATE_NOTE_SELECTED 100 - -typedef struct NotebookModel NotebookModel; +// typedefs for NotebookModel and NoteModel are in types.h typedef struct MainWindow { UiObject *obj; @@ -91,11 +90,25 @@ struct NotebookModel { */ UiList *notes; + /* + * currently attached note + */ + Note *current_note; + /* * The mempool used to allocate the current list of notes */ CxMempool *current_notes_pool; }; + +struct NoteModel { + UiContext *ctx; + + UiInteger *type; + UiString *title; + UiText *text; + UiGeneric *html; +}; void application_init(); diff --git a/application/note.c b/application/note.c new file mode 100644 index 0000000..7ac8e4f --- /dev/null +++ b/application/note.c @@ -0,0 +1,58 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "note.h" + +NoteModel* notemodel_create() { + NoteModel *model = ui_document_new(sizeof(NoteModel)); + model->ctx = ui_document_context(model); + + model->type = ui_int_new(model->ctx, "note_type"); + model->title = ui_string_new(model->ctx, "note_title"); + model->text = ui_text_new(model->ctx, "note_text"); + model->html = ui_generic_new(model->ctx, "note_html"); + + ui_set(model->type, 1); + //ui_set_group(model->ctx, APP_STATE_NOTE_SELECTED); + + return model; +} + +void notemodel_set_note(NoteModel *model, Note *note) { + note->model = model; + + ui_set(model->title, note->title); + + if(note->content_loaded) { + // TODO: when multiple note types are implemented, chec contenttype + // and set model->text, model->html or something else + if(!note->contenttype) { + ui_set(model->text, note->content.ptr); + } + } +} diff --git a/application/note.h b/application/note.h new file mode 100644 index 0000000..a5beafb --- /dev/null +++ b/application/note.h @@ -0,0 +1,47 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NOTE_H +#define NOTE_H + +#include "application.h" + +#ifdef __cplusplus +extern "C" { +#endif + +NoteModel* notemodel_create(); +void notemodel_set_note(NoteModel *model, Note *note); + + +#ifdef __cplusplus +} +#endif + +#endif /* NOTE_H */ + diff --git a/application/notebook.c b/application/notebook.c index 9863a24..50d3a9d 100644 --- a/application/notebook.c +++ b/application/notebook.c @@ -29,6 +29,7 @@ #include "notebook.h" #include "store.h" +#include "note.h" NotebookModel* notebookmodel_create() { NotebookModel *model = ui_document_new(sizeof(NotebookModel)); @@ -80,3 +81,33 @@ static void notebook_loaded(UiEvent *event, AsyncListResult *result, void *data) void notebookmodel_reload(UiObject *obj, NotebookModel *model) { note_store_get_notes_async(obj, model->collection_id, notebook_loaded, model); } + + +void notebookmodel_attach_note(NotebookModel *model, Note *note) { + if(model->current_note == note) { + return; // NOOP + } + + if(note && !note->model) { + NoteModel *notemodel = notemodel_create(); + notemodel_set_note(notemodel, note); + } + + notebookmodel_detach_current_note(model); + ui_attach_document(model->window->obj->ctx, note->model); + // TODO: this is only a workaround and should be removed when + // sub-document groups are supported + ui_set_group(model->window->obj->ctx, APP_STATE_NOTE_SELECTED); + model->current_note = note; + + if(!note->content_loaded) { + // TODO: load content + } +} + +void notebookmodel_detach_current_note(NotebookModel *model) { + if(model->current_note && model->current_note->model) { + ui_detach_document2(model->window->obj->ctx, model->current_note->model); + model->current_note = NULL; + } +} diff --git a/application/notebook.h b/application/notebook.h index 4d9a5d4..084d909 100644 --- a/application/notebook.h +++ b/application/notebook.h @@ -46,6 +46,9 @@ void notebookmodel_set_collection(NotebookModel *model, Collection *collection); void notebookmodel_reload(UiObject *obj, NotebookModel *model); +void notebookmodel_attach_note(NotebookModel *model, Note *note); +void notebookmodel_detach_current_note(NotebookModel *model); + #ifdef __cplusplus } diff --git a/application/types.c b/application/types.c index 3d3cd86..23d1273 100644 --- a/application/types.c +++ b/application/types.c @@ -68,4 +68,5 @@ void register_types() { dbuClassAdd(notes_class, Note, content); dbuClassAdd(notes_class, Note, bin_content); dbuClassAdd(notes_class, Note, created_by); + dbuClassAdd(notes_class, Note, content_loaded); } \ No newline at end of file diff --git a/application/types.h b/application/types.h index 48e064a..ad4ea21 100644 --- a/application/types.h +++ b/application/types.h @@ -35,6 +35,11 @@ #ifdef __cplusplus extern "C" { #endif + + +typedef struct NotebookModel NotebookModel; +typedef struct NoteModel NoteModel; + typedef struct UserSettings UserSettings; typedef struct Repository Repository; @@ -84,6 +89,18 @@ struct Note { cxmutstr content; cxmutstr bin_content; char *created_by; + + /* + * indicates, whether content or bin_content was queried + * content_loaded is not a column in the Notes table, however it can be + * included in a Notes query result + */ + bool content_loaded; + + /* + * non-db member, UI model + */ + NoteModel *model; }; extern DBUClass *usersettings_class; diff --git a/application/window.c b/application/window.c index 8b1bdc5..c187074 100644 --- a/application/window.c +++ b/application/window.c @@ -57,15 +57,23 @@ void window_create() { UiModel* model = ui_model(obj->ctx, UI_STRING, "Name", UI_STRING_FREE, "Last Modified", -1); model->columnsize[0] = -1; model->getvalue = window_notelist_getvalue; - ui_table(obj, .model = model, .varname = "notes",); + ui_table(obj, .model = model, .varname = "notes", .onactivate = action_note_selected); // splitpane right: content - ui_grid(obj, .columnspacing = 10, .rowspacing = 10, .def_vfill = TRUE) { - ui_label(obj, .label = "Title", .vfill = TRUE); - ui_textfield(obj, .varname = "note_title", .hexpand = TRUE, .groups = UI_GROUPS(APP_STATE_NOTE_SELECTED)); - ui_newline(obj); - - ui_textarea(obj, .varname = "note_content", .vfill = TRUE, .hfill = TRUE, .hexpand = TRUE, .vexpand = TRUE, .colspan = 2, .groups = UI_GROUPS(APP_STATE_NOTE_SELECTED)); + ui_tabview(obj, .tabview = UI_TABVIEW_INVISIBLE, .varname = "note_type") { + ui_tab(obj, "empty") { + + } + ui_tab(obj, "textnote") { + ui_vbox0(obj) { + ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .def_vfill = TRUE, .fill = UI_OFF) { + ui_label(obj, .label = "Title", .vfill = TRUE); + ui_textfield(obj, .varname = "note_title", .hexpand = TRUE, .groups = UI_GROUPS(APP_STATE_NOTE_SELECTED)); + ui_newline(obj); + } + ui_textarea(obj, .varname = "note_content", .vfill = TRUE, .hfill = TRUE, .hexpand = TRUE, .vexpand = TRUE, .colspan = 2, .groups = UI_GROUPS(APP_STATE_NOTE_SELECTED), .fill = UI_ON); + } + } } } @@ -190,3 +198,20 @@ void action_notebook_selected(UiEvent *event, void *userdata) { } notebookmodel_attach(window, notebook); } + +void action_note_selected(UiEvent *event, void *userdata) { + UiListSelection *sel = event->eventdata; + MainWindow *window = event->window; + NotebookModel *notebook = window->current_notebook; + + if(!notebook) { + return; // should not happen + } + + if(sel->count == 0) { + return; // should not happen + } + + Note *note = ui_list_get(notebook->notes, sel->rows[0]); + notebookmodel_attach_note(notebook, note); +} diff --git a/application/window.h b/application/window.h index cd6ae98..bf9b215 100644 --- a/application/window.h +++ b/application/window.h @@ -47,6 +47,7 @@ void update_sublists(UiContext *ctx, UiList *sublists); void* window_notelist_getvalue(void *data, int col); void action_notebook_selected(UiEvent *event, void *userdata); +void action_note_selected(UiEvent *event, void *userdata); #ifdef __cplusplus diff --git a/configure b/configure index 27e4652..27c5b60 100755 --- a/configure +++ b/configure @@ -273,32 +273,6 @@ print_check_msg() fi } -dependency_error_gtk2legacy() -{ - print_check_msg "$dep_checked_gtk2legacy" "checking for gtk2legacy... " - # dependency gtk2legacy - while true - do - if [ -z "$PKG_CONFIG" ]; then - break - fi - if test_pkg_config "gtk+-2.0" "" "" "" ; then - TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`" - TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`" - else - break - fi - TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK2 -DUI_GTK2LEGACY" - TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" - print_check_msg "$dep_checked_gtk2legacy" "yes\n" - dep_checked_gtk2legacy=1 - return 1 - done - - print_check_msg "$dep_checked_gtk2legacy" "no\n" - dep_checked_gtk2legacy=1 - return 0 -} dependency_error_curl() { print_check_msg "$dep_checked_curl" "checking for curl... " @@ -427,9 +401,9 @@ dependency_error_gtk3() if [ -z "$PKG_CONFIG" ]; then break fi - if test_pkg_config "gtk+-3.0" "" "" "" ; then - TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-3.0`" - TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-3.0`" + if test_pkg_config "gtk3" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk3`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk3`" else break fi @@ -470,123 +444,37 @@ dependency_error_gtk4() dep_checked_gtk4=1 return 0 } -dependency_error_openssl() -{ - print_check_msg "$dep_checked_openssl" "checking for openssl... " - # dependency openssl platform="windows" - while true - do - if notisplatform "windows"; then - break - fi - TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" - print_check_msg "$dep_checked_openssl" "yes\n" - dep_checked_openssl=1 - return 1 - done - - # dependency openssl platform="macos" - while true - do - if notisplatform "macos"; then - break - fi - TEMP_LDFLAGS="$TEMP_LDFLAGS -framework CoreFoundation" - print_check_msg "$dep_checked_openssl" "yes\n" - dep_checked_openssl=1 - return 1 - done - - # dependency openssl platform="bsd" - while true - do - if notisplatform "bsd"; then - break - fi - if isplatform "macos" || istoolchain "macos"; then - break - fi - TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" - print_check_msg "$dep_checked_openssl" "yes\n" - dep_checked_openssl=1 - return 1 - done - - # dependency openssl - while true - do - if [ -z "$PKG_CONFIG" ]; then - break - fi - if test_pkg_config "openssl" "" "" "" ; then - TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`" - TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`" - else - break - fi - print_check_msg "$dep_checked_openssl" "yes\n" - dep_checked_openssl=1 - return 1 - done - - print_check_msg "$dep_checked_openssl" "no\n" - dep_checked_openssl=1 - return 0 -} -dependency_error_libadwaita() +dependency_error_webkitgtk6() { - print_check_msg "$dep_checked_libadwaita" "checking for libadwaita... " - # dependency libadwaita + print_check_msg "$dep_checked_webkitgtk6" "checking for webkitgtk6... " + # dependency webkitgtk6 while true do if [ -z "$PKG_CONFIG" ]; then break fi - if test_pkg_config "libadwaita-1" "" "" "" ; then - TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libadwaita-1`" - TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libadwaita-1`" + if test_pkg_config "webkitgtk-6.0" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags webkitgtk-6.0`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs webkitgtk-6.0`" else break fi - TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK4 -DUI_LIBADWAITA" - TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" - print_check_msg "$dep_checked_libadwaita" "yes\n" - dep_checked_libadwaita=1 + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_WEBVIEW" + print_check_msg "$dep_checked_webkitgtk6" "yes\n" + dep_checked_webkitgtk6=1 return 1 done - print_check_msg "$dep_checked_libadwaita" "no\n" - dep_checked_libadwaita=1 - return 0 -} -dependency_error_motif() -{ - print_check_msg "$dep_checked_motif" "checking for motif... " - # dependency motif platform="bsd" + # dependency webkitgtk6 while true do - if notisplatform "bsd"; then - break - fi - TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF -I/usr/local/include/X11" - TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread" - print_check_msg "$dep_checked_motif" "yes\n" - dep_checked_motif=1 + print_check_msg "$dep_checked_webkitgtk6" "yes\n" + dep_checked_webkitgtk6=1 return 1 done - # dependency motif - while true - do - TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF" - TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread" - print_check_msg "$dep_checked_motif" "yes\n" - dep_checked_motif=1 - return 1 - done - - print_check_msg "$dep_checked_motif" "no\n" - dep_checked_motif=1 + print_check_msg "$dep_checked_webkitgtk6" "no\n" + dep_checked_webkitgtk6=1 return 0 } dependency_error_libxml2() @@ -673,6 +561,57 @@ dependency_error_libxml2() dep_checked_libxml2=1 return 0 } +dependency_error_webkit2gtk4() +{ + print_check_msg "$dep_checked_webkit2gtk4" "checking for webkit2gtk4... " + # dependency webkit2gtk4 + while true + do + if [ -z "$PKG_CONFIG" ]; then + break + fi + if test_pkg_config "webkit2gtk-4.1" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags webkit2gtk-4.1`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs webkit2gtk-4.1`" + else + break + fi + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_WEBVIEW" + print_check_msg "$dep_checked_webkit2gtk4" "yes\n" + dep_checked_webkit2gtk4=1 + return 1 + done + + # dependency webkit2gtk4 + while true + do + if [ -z "$PKG_CONFIG" ]; then + break + fi + if test_pkg_config "webkit2gtk-4.0" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags webkit2gtk-4.0`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs webkit2gtk-4.0`" + else + break + fi + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_WEBVIEW" + print_check_msg "$dep_checked_webkit2gtk4" "yes\n" + dep_checked_webkit2gtk4=1 + return 1 + done + + # dependency webkit2gtk4 + while true + do + print_check_msg "$dep_checked_webkit2gtk4" "yes\n" + dep_checked_webkit2gtk4=1 + return 1 + done + + print_check_msg "$dep_checked_webkit2gtk4" "no\n" + dep_checked_webkit2gtk4=1 + return 0 +} dependency_error_cocoa() { print_check_msg "$dep_checked_cocoa" "checking for cocoa... " @@ -712,6 +651,151 @@ dependency_error_winui() dep_checked_winui=1 return 0 } +dependency_error_gtk2legacy() +{ + print_check_msg "$dep_checked_gtk2legacy" "checking for gtk2legacy... " + # dependency gtk2legacy + while true + do + if [ -z "$PKG_CONFIG" ]; then + break + fi + if test_pkg_config "gtk+-2.0" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`" + else + break + fi + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK2 -DUI_GTK2LEGACY" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" + print_check_msg "$dep_checked_gtk2legacy" "yes\n" + dep_checked_gtk2legacy=1 + return 1 + done + + print_check_msg "$dep_checked_gtk2legacy" "no\n" + dep_checked_gtk2legacy=1 + return 0 +} +dependency_error_openssl() +{ + print_check_msg "$dep_checked_openssl" "checking for openssl... " + # dependency openssl platform="windows" + while true + do + if notisplatform "windows"; then + break + fi + TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" + print_check_msg "$dep_checked_openssl" "yes\n" + dep_checked_openssl=1 + return 1 + done + + # dependency openssl platform="macos" + while true + do + if notisplatform "macos"; then + break + fi + TEMP_LDFLAGS="$TEMP_LDFLAGS -framework CoreFoundation" + print_check_msg "$dep_checked_openssl" "yes\n" + dep_checked_openssl=1 + return 1 + done + + # dependency openssl platform="bsd" + while true + do + if notisplatform "bsd"; then + break + fi + if isplatform "macos" || istoolchain "macos"; then + break + fi + TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" + print_check_msg "$dep_checked_openssl" "yes\n" + dep_checked_openssl=1 + return 1 + done + + # dependency openssl + while true + do + if [ -z "$PKG_CONFIG" ]; then + break + fi + if test_pkg_config "openssl" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`" + else + break + fi + print_check_msg "$dep_checked_openssl" "yes\n" + dep_checked_openssl=1 + return 1 + done + + print_check_msg "$dep_checked_openssl" "no\n" + dep_checked_openssl=1 + return 0 +} +dependency_error_libadwaita() +{ + print_check_msg "$dep_checked_libadwaita" "checking for libadwaita... " + # dependency libadwaita + while true + do + if [ -z "$PKG_CONFIG" ]; then + break + fi + if test_pkg_config "libadwaita-1" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libadwaita-1`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libadwaita-1`" + else + break + fi + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK4 -DUI_LIBADWAITA" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" + print_check_msg "$dep_checked_libadwaita" "yes\n" + dep_checked_libadwaita=1 + return 1 + done + + print_check_msg "$dep_checked_libadwaita" "no\n" + dep_checked_libadwaita=1 + return 0 +} +dependency_error_motif() +{ + print_check_msg "$dep_checked_motif" "checking for motif... " + # dependency motif platform="bsd" + while true + do + if notisplatform "bsd"; then + break + fi + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF -I/usr/local/include/X11" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread" + print_check_msg "$dep_checked_motif" "yes\n" + dep_checked_motif=1 + return 1 + done + + # dependency motif + while true + do + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread" + print_check_msg "$dep_checked_motif" "yes\n" + dep_checked_motif=1 + return 1 + done + + print_check_msg "$dep_checked_motif" "no\n" + dep_checked_motif=1 + return 0 +} # start collecting dependency information echo > "$TEMP_DIR/flags.mk" @@ -808,6 +892,9 @@ checkopt_toolkit_libadwaita() if dependency_error_libadwaita ; then VERR=1 fi + if dependency_error_webkitgtk6 ; then + VERR=1 + fi if [ $VERR -ne 0 ]; then return 1 fi @@ -823,6 +910,9 @@ checkopt_toolkit_gtk4() if dependency_error_gtk4 ; then VERR=1 fi + if dependency_error_webkitgtk6 ; then + VERR=1 + fi if [ $VERR -ne 0 ]; then return 1 fi @@ -838,6 +928,9 @@ checkopt_toolkit_gtk3() if dependency_error_gtk3 ; then VERR=1 fi + if dependency_error_webkit2gtk4 ; then + VERR=1 + fi if [ $VERR -ne 0 ]; then return 1 fi diff --git a/libidav/config.c b/libidav/config.c index 7b0abbc..9c295bb 100644 --- a/libidav/config.c +++ b/libidav/config.c @@ -1002,7 +1002,7 @@ const char* dav_config_keytype_str(DavCfgKeyType type) { int dav_config_register_keys(DavConfig *config, DavContext *ctx, dav_loadkeyfile_func loadkey) { for(DavCfgKey *key=config->keys;key;key=key->next) { - char *file = cx_strdup_m(key->file.value).ptr; + char *file = cx_strdup_a(cxDefaultAllocator, key->file.value).ptr; cxmutstr keycontent = loadkey(file); free(file); @@ -1013,7 +1013,7 @@ int dav_config_register_keys(DavConfig *config, DavContext *ctx, dav_loadkeyfile } DavKey *davkey = calloc(1, sizeof(DavKey)); - davkey->name = cx_strdup_m(key->name.value).ptr; + davkey->name = cx_strdup_a(cxDefaultAllocator, key->name.value).ptr; davkey->type = dav_config_keytype(key->type); davkey->data = keycontent.ptr; davkey->length = keycontent.length; diff --git a/libidav/davqlexec.c b/libidav/davqlexec.c index 4af5816..83cf720 100644 --- a/libidav/davqlexec.c +++ b/libidav/davqlexec.c @@ -302,9 +302,9 @@ static CxBuffer* fieldlist2propfindrequest(DavSession *sn, const CxAllocator *a, } } - i = cxMapIteratorValues(properties); + CxMapIterator mi = cxMapIteratorValues(properties); CxList *list = cxLinkedListCreateSimple(CX_STORE_POINTERS); - cx_foreach(DavProperty*, value, i) { + cx_foreach(DavProperty*, value, mi) { cxListAdd(list, value); } @@ -464,7 +464,7 @@ static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, * execute a davql select statement */ DavResult dav_exec_select(DavSession *sn, DavQLStatement *st, va_list ap) { - CxMempool *mp = cxBasicMempoolCreate(128); + CxMempool *mp = cxMempoolCreateSimple(128); DavResult result; result.result = NULL; result.status = 1; diff --git a/libidav/methods.c b/libidav/methods.c index a4fe63d..7c425db 100644 --- a/libidav/methods.c +++ b/libidav/methods.c @@ -200,7 +200,7 @@ CxBuffer* create_propfind_request(DavSession *sn, CxList *properties, char *root // write root element and namespaces cx_bprintf(buf, "encoffset = p->encoffset; newp->isdecrypted = p->isdecrypted; - CxIterator i = cxMapIterator(p->ids); + CxMapIterator i = cxMapIterator(p->ids); cx_foreach(CxMapEntry *, e, i) { PwdEntry *entry = e->value; pwdstore_put(newp, entry->id, entry->user, entry->password); @@ -489,8 +489,8 @@ int pwdstore_store(PwdStore *p, const char *file) { write_index_entry(index, e); } - i = cxMapIteratorValues(p->ids); - cx_foreach(PwdEntry*, value, i) { + CxMapIterator mi = cxMapIteratorValues(p->ids); + cx_foreach(PwdEntry*, value, mi) { if(!value->id || !value->user || !value->password) { continue; } diff --git a/libidav/resource.c b/libidav/resource.c index 7808bc3..91efa90 100644 --- a/libidav/resource.c +++ b/libidav/resource.c @@ -126,7 +126,7 @@ DavResource* dav_resource_new_full(DavSession *sn, const char *parent_path, cons void resource_free_properties(DavSession *sn, CxMap *properties) { if(!properties) return; - CxIterator i = cxMapIteratorValues(properties); + CxMapIterator i = cxMapIteratorValues(properties); cx_foreach(DavProperty*, property, i) { // TODO: free everything dav_session_free(sn, property); @@ -741,7 +741,7 @@ DavPropName* dav_get_property_names(DavResource *res, size_t *count) { sizeof(DavPropName)); - CxIterator i = cxMapIteratorValues(data->properties); + CxMapIterator i = cxMapIteratorValues(data->properties); cx_foreach(DavProperty*, value, i) { DavPropName *name = &names[i.index]; name->ns = value->ns->name; @@ -1515,7 +1515,7 @@ DavXmlNode* create_crypto_prop(DavSession *sn, CxMap *properties) { cxBufferPutString(content, "\n"); cxBufferPutString(content, "\n"); - CxIterator i = cxMapIteratorValues(properties); + CxMapIterator i = cxMapIteratorValues(properties); cx_foreach(DavProperty*, prop, i) { DavXmlNode pnode; pnode.type = DAV_XML_ELEMENT; diff --git a/libidav/session.c b/libidav/session.c index 13ec76d..e7b983f 100644 --- a/libidav/session.c +++ b/libidav/session.c @@ -49,7 +49,7 @@ DavSession* dav_session_new(DavContext *context, char *base_url) { } DavSession *sn = malloc(sizeof(DavSession)); memset(sn, 0, sizeof(DavSession)); - sn->mp = cxBasicMempoolCreate(DAV_SESSION_MEMPOOL_SIZE); + sn->mp = cxMempoolCreateSimple(DAV_SESSION_MEMPOOL_SIZE); sn->pathcache = cxHashMapCreate(sn->mp->allocator, CX_STORE_POINTERS, DAV_PATH_CACHE_SIZE); sn->key = NULL; sn->errorstr = NULL; @@ -118,7 +118,7 @@ DavSession* dav_session_clone(DavSession *sn) { DavSession *newsn = malloc(sizeof(DavSession)); memset(newsn, 0, sizeof(DavSession)); - newsn->mp = cxBasicMempoolCreate(DAV_SESSION_MEMPOOL_SIZE); + newsn->mp = cxMempoolCreateSimple(DAV_SESSION_MEMPOOL_SIZE); newsn->pathcache = cxHashMapCreate(newsn->mp->allocator, CX_STORE_POINTERS, DAV_PATH_CACHE_SIZE); newsn->key = sn->key; newsn->errorstr = NULL; diff --git a/libidav/utils.c b/libidav/utils.c index d1f3776..9b195e3 100644 --- a/libidav/utils.c +++ b/libidav/utils.c @@ -385,7 +385,9 @@ static size_t util_header_callback(char *buffer, size_t size, value.ptr++; value.length--; cxmutstr key_cp = cx_strdup(cx_strtrim(key)); - cx_strlower(key_cp); + for(int i=0;inamespaces) { - CxIterator i = cxMapIteratorValues(ctx->namespaces); + CxMapIterator i = cxMapIteratorValues(ctx->namespaces); cx_foreach(DavNamespace*, ns, i) { if(!ns) continue; if(ns->prefix) { @@ -129,7 +129,7 @@ void dav_context_destroy(DavContext *ctx) { // TODO: implement } if(ctx->keys) { - CxIterator i = cxMapIteratorValues(ctx->keys); + CxMapIterator i = cxMapIteratorValues(ctx->keys); cx_foreach(DavKey*, key, i) { if(!key) continue; if(key->name) { diff --git a/make/project.xml b/make/project.xml index 606f29d..24ca844 100644 --- a/make/project.xml +++ b/make/project.xml @@ -61,7 +61,7 @@ -lpthread - gtk+-3.0 + gtk3 -DUI_GTK3 -lpthread @@ -80,6 +80,25 @@ -DUI_WINUI + + webkitgtk-6.0 + -DUI_WEBVIEW + + + + + + webkit2gtk-4.1 + -DUI_WEBVIEW + + + webkit2gtk-4.0 + -DUI_WEBVIEW + + + + +