application/menu.c

changeset 3
c04433993fbb
parent 2
ea89bbb0c4c8
child 4
d8e8f34e65ee
equal deleted inserted replaced
2:ea89bbb0c4c8 3:c04433993fbb
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "menu.h" 29 #include "menu.h"
30 #include "window.h"
30 31
31 #include <stdio.h> 32 #include <stdio.h>
32 #include <stdlib.h> 33 #include <stdlib.h>
33 34
34 #pragma clang diagnostic ignored "-Wdeprecated-declarations" 35 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
35 36
36 static UiInteger *tb_sidebar; 37 static UiInteger *tb_sidebar;
37 static UiInteger *tb_browser; 38 static UiInteger *tb_singleview;
38 static UiInteger *tb_editor; 39 static UiInteger *tb_dualview;
39 40
40 static void create_main_menu(void) { 41 static void create_main_menu(void) {
41 ui_menu("File"); 42 ui_menu("File");
42 ui_menuitem_st(UI_STOCK_OPEN, NULL, NULL); 43 ui_menuitem_st(UI_STOCK_OPEN, NULL, NULL);
43 44
48 } 49 }
49 50
50 static void create_main_toolbar(void) { 51 static void create_main_toolbar(void) {
51 UiContext *ctx = ui_global_context(); 52 UiContext *ctx = ui_global_context();
52 tb_sidebar = ui_int_new(ctx, NULL); 53 tb_sidebar = ui_int_new(ctx, NULL);
53 tb_browser = ui_int_new(ctx, NULL); 54 tb_singleview = ui_int_new(ctx, NULL);
54 tb_editor = ui_int_new(ctx, NULL); 55 tb_dualview = ui_int_new(ctx, NULL);
56 tb_sidebar->observers = ui_add_observer(tb_sidebar->observers, action_show_sidebar, NULL);
57 tb_singleview->observers = ui_add_observer(tb_singleview->observers, action_singleview, NULL);
58 tb_dualview->observers = ui_add_observer(tb_dualview->observers, action_dualview, NULL);
55 59
56 ui_toolitem_toggle("show-sidebar", "Sidebar", NULL, tb_sidebar); 60 ui_toolitem_toggle("show-sidebar", "Sidebar", NULL, tb_sidebar);
57 ui_toolitem_toggle("show-browser", "Browser", NULL, tb_browser); 61 ui_toolitem_toggle("singleview", "S", NULL, tb_singleview);
58 ui_toolitem_toggle("show-editor", "Editor", NULL, tb_editor); 62 ui_toolitem_toggle("dualview", "D", NULL, tb_dualview);
63
59 tb_sidebar->value = 1; 64 tb_sidebar->value = 1;
60 tb_browser->value = 1; 65 tb_singleview->value = 0;
61 tb_editor->value = 1; 66 tb_dualview->value = 1;
62 67
63 ui_toolbar_add_default("show-sidebar"); 68 ui_toolbar_add_default("show-sidebar");
64 ui_toolbar_add_default("show-browser"); 69 ui_toolbar_add_default("@separator");
65 ui_toolbar_add_default("show-editor"); 70 ui_toolbar_add_default("singleview");
71 ui_toolbar_add_default("dualview");
72 ui_toolbar_add_default("@separator");
66 } 73 }
67 74
68 void menu_init(void) { 75 void menu_init(void) {
69 create_main_menu(); 76 create_main_menu();
70 create_main_toolbar(); 77 create_main_toolbar();
71 } 78 }
72 79
73 void action_show_sidebar(UiEvent *event, void *udata) { 80 void action_show_sidebar(UiEvent *event, void *udata) {
81 WindowData *w = event->window;
82 ui_set_visible(w->sidebar, event->intval);
83 }
84
85 static void change_view(WindowData *w, int dual) {
86 if(dual) {
87 ui_set_visible(w->browser, TRUE);
88 ui_set_visible(w->editor, TRUE);
89 } else {
90 UiBool e, b;
91 if(w->editorIsOpen) {
92 e = TRUE;
93 b = FALSE;
94 } else {
95 e = FALSE;
96 b = TRUE;
97 }
98 ui_set_visible(w->browser, b);
99 ui_set_visible(w->editor, e);
100 }
101 }
102
103 void action_dualview(UiEvent *event, void *udata) {
104 int s = event->intval == 1 ? 0 : 1;
105 tb_singleview->set(tb_singleview, s);
106 change_view(event->window, event->intval);
107 }
108
109 void action_singleview(UiEvent *event, void *udata) {
110 int s = event->intval == 1 ? 0 : 1;
111 tb_dualview->set(tb_dualview, s);
112 change_view(event->window, s);
113 }
114
115
116
117
118 void action_test1(UiEvent *event, void *udata) {
74 119
75 } 120 }
76 121
77 void action_show_browser(UiEvent *event, void *udata) { 122 void action_test2(UiEvent *event, void *udata) {
78 123
79 } 124 }
80
81 void action_show_editor(UiEvent *event, void *udata) {
82
83 }

mercurial