Fri, 11 Dec 2020 18:32:54 +0100
add sqlite dependency
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2020 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 "menu.h" #include "window.h" #include <stdio.h> #include <stdlib.h> #pragma clang diagnostic ignored "-Wdeprecated-declarations" static UiInteger *tb_sidebar; static UiInteger *tb_singleview; static UiInteger *tb_dualview; static void create_main_menu(void) { ui_menu("File"); ui_menuitem_st(UI_STOCK_NEW, NULL, NULL); ui_menuitem_st(UI_STOCK_OPEN, NULL, NULL); ui_menu("Edit"); ui_menuitem_st(UI_STOCK_UNDO, NULL, NULL); ui_menuitem_st(UI_STOCK_REDO, NULL, NULL); } static void create_main_toolbar(void) { UiContext *ctx = ui_global_context(); tb_sidebar = ui_int_new(ctx, NULL); tb_singleview = ui_int_new(ctx, NULL); tb_dualview = ui_int_new(ctx, NULL); tb_sidebar->observers = ui_add_observer(tb_sidebar->observers, action_show_sidebar, NULL); tb_singleview->observers = ui_add_observer(tb_singleview->observers, action_singleview, NULL); tb_dualview->observers = ui_add_observer(tb_dualview->observers, action_dualview, NULL); ui_toolitem_toggle("show-sidebar", "Sidebar", NULL, tb_sidebar); ui_toolitem_toggle("singleview", "S", NULL, tb_singleview); ui_toolitem_toggle("dualview", "D", NULL, tb_dualview); ui_toolitem_st("new-note", UI_STOCK_NEW, NULL, NULL); tb_sidebar->value = 1; tb_singleview->value = 0; tb_dualview->value = 1; ui_toolbar_add_default("show-sidebar"); ui_toolbar_add_default("@separator"); ui_toolbar_add_default("singleview"); ui_toolbar_add_default("dualview"); ui_toolbar_add_default("@separator"); ui_toolbar_add_default("new-note"); } void menu_init(void) { create_main_menu(); create_main_toolbar(); } void action_show_sidebar(UiEvent *event, void *udata) { WindowData *w = event->window; ui_set_visible(w->sidebar, event->intval); } static void change_view(WindowData *w, int dual) { if(dual) { ui_set_visible(w->browser, TRUE); ui_set_visible(w->editor, TRUE); } else { UiBool e, b; if(w->editorIsOpen) { e = TRUE; b = FALSE; } else { e = FALSE; b = TRUE; } ui_set_visible(w->browser, b); ui_set_visible(w->editor, e); } } void action_dualview(UiEvent *event, void *udata) { int s = event->intval == 1 ? 0 : 1; tb_singleview->set(tb_singleview, s); change_view(event->window, event->intval); } void action_singleview(UiEvent *event, void *udata) { int s = event->intval == 1 ? 0 : 1; tb_dualview->set(tb_dualview, s); change_view(event->window, s); } void action_test1(UiEvent *event, void *udata) { } void action_test2(UiEvent *event, void *udata) { }