UNIXworkcode

1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 * 4 * Copyright 2017 Olaf Wintermann. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef TOOLBAR_H 30 #define TOOLBAR_H 31 32 #include "../ui/toolbar.h" 33 #include "../common/toolbar.h" 34 #include <cx/map.h> 35 #include <cx/list.h> 36 37 #include "list.h" 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 #if UI_GTK2 || UI_GTK3 44 45 typedef struct UiToolItemI UiToolItemI; 46 typedef struct UiToolItem UiToolItem; 47 typedef struct UiStToolItem UiStToolItem; 48 typedef struct UiToggleToolItem UiToggleToolItem; 49 50 typedef struct UiToolbarComboBox UiToolbarComboBox; 51 typedef struct UiToolbarComboBoxNV UiToolbarComboBoxNV; 52 53 typedef void(*ui_toolbar_add_f)(GtkToolbar*, UiToolItemI*, UiObject*); 54 55 struct UiToolItemI { 56 ui_toolbar_add_f add_to; 57 }; 58 59 struct UiToolItem { 60 UiToolItemI item; 61 const char *label; 62 const char *image; 63 ui_callback callback; 64 void *userdata; 65 const char *varname; 66 CxList *groups; 67 int isimportant; 68 }; 69 70 struct UiStToolItem { 71 UiToolItemI item; 72 const char *stockid; 73 ui_callback callback; 74 void *userdata; 75 const char *varname; 76 CxList *groups; 77 int isimportant; 78 }; 79 80 struct UiToggleToolItem { 81 UiToolItemI item; 82 const char *label; 83 const char *image; 84 const char *stockid; 85 UiInteger *value; 86 const char *var; 87 CxList *groups; 88 int isimportant; 89 }; 90 91 struct UiToolbarComboBox { 92 UiToolItemI item; 93 UiVar *var; 94 ui_getvaluefunc getvalue; 95 ui_callback callback; 96 void *userdata; 97 }; 98 99 struct UiToolbarComboBoxNV { 100 UiToolItemI item; 101 char *listname; 102 ui_getvaluefunc getvalue; 103 ui_callback callback; 104 void *userdata; 105 }; 106 107 108 void ui_toolitem_vstgr( 109 char *name, 110 char *stockid, 111 int isimportant, 112 ui_callback f, 113 void *userdata, 114 va_list ap); 115 116 GtkWidget* ui_create_toolbar(UiObject *obj); 117 118 void ui_toolbar_add_items(UiObject *obj, GtkWidget *toolbar, CxMap *items, CxList *defaults); 119 120 void add_toolitem_widget(GtkToolbar *tb, UiToolbarItem *item, UiObject *obj); 121 void add_toolitem_toggle_widget(GtkToolbar *tb, UiToolbarToggleItem *item, UiObject *obj); 122 void add_toolitem_menu_widget(GtkToolbar *tb, UiToolbarMenuItem *item, UiObject *obj); 123 124 void ui_tool_button_toggled(GtkToggleToolButton *widget, UiVarEventData *event); 125 int64_t ui_tool_toggle_button_get(UiInteger *integer); 126 void ui_tool_toggle_button_set(UiInteger *integer, int64_t value); 127 128 GtkWidget* ui_create_headerbar(UiObject *obj); 129 130 void ui_toolbar_headerbar_add_items(UiObject *obj, GtkWidget *headerbar, CxMap *items, CxList *defaults); 131 132 void add_headerbar_item_widget(GtkHeaderBar *hb, UiToolbarItem *item, UiObject *obj); 133 void add_headerbar_item_toggle_widget(GtkHeaderBar *hb, UiToolbarToggleItem *item, UiObject *obj); 134 void add_headerbar_item_menu_widget(GtkHeaderBar *hb, UiToolbarMenuItem *item, UiObject *obj); 135 136 137 /* 138 void add_toolbar_combobox(GtkToolbar *tb, UiToolbarComboBox *cb, UiObject *obj); 139 void add_toolbar_combobox_nv(GtkToolbar *tb, UiToolbarComboBoxNV *cb, UiObject *obj); 140 void ui_combobox_change_event(GtkComboBox *widget, UiEventData *e); 141 void ui_combobox_update(UiEvent *event, void *combobox); 142 */ 143 144 #endif 145 146 #ifdef __cplusplus 147 } 148 #endif 149 150 #endif /* TOOLBAR_H */ 151 152