1 /* 2 * Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org> 3 * 4 * This file is part of Zrythm 5 * 6 * Zrythm is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * Zrythm is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with Zrythm. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 20 /** 21 * \file 22 * 23 * Text expander widget. 24 */ 25 26 #ifndef __GUI_WIDGETS_TEXT_EXPANDER_H__ 27 #define __GUI_WIDGETS_TEXT_EXPANDER_H__ 28 29 #include "gui/widgets/expander_box.h" 30 #include "utils/types.h" 31 32 #include <gtk/gtk.h> 33 34 #pragma GCC diagnostic push 35 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 36 #include <gtksourceview/gtksource.h> 37 #pragma GCC diagnostic pop 38 39 #define TEXT_EXPANDER_WIDGET_TYPE \ 40 (text_expander_widget_get_type ()) 41 G_DECLARE_FINAL_TYPE ( 42 TextExpanderWidget, 43 text_expander_widget, 44 Z, TEXT_EXPANDER_WIDGET, 45 ExpanderBoxWidget); 46 47 /** 48 * @addtogroup widgets 49 * 50 * @{ 51 */ 52 53 /** 54 * A TwoColExpanderBoxWidget for showing the ports 55 * in the InspectorWidget. 56 */ 57 typedef struct _TextExpanderWidget 58 { 59 ExpanderBoxWidget parent_instance; 60 61 /** Getter for the string. */ 62 GenericStringGetter getter; 63 64 /** Setter for the string. */ 65 GenericStringSetter setter; 66 67 /** Object to call get/set on. */ 68 void * obj; 69 70 /** Scrolled window for the editor inside. */ 71 GtkScrolledWindow * scroll; 72 GtkViewport * viewport; 73 74 /** Editor. */ 75 GtkSourceView * editor; 76 77 /** Editor buffer. */ 78 GtkSourceBuffer * buffer; 79 80 GtkLabel * label; 81 82 GtkMenuButton * edit_btn; 83 84 GtkPopover * popover; 85 86 bool has_focus; 87 } TextExpanderWidget; 88 89 /** 90 * Refreshes the text. 91 */ 92 void 93 text_expander_widget_refresh ( 94 TextExpanderWidget * self); 95 96 /** 97 * Sets up the TextExpanderWidget. 98 */ 99 void 100 text_expander_widget_setup ( 101 TextExpanderWidget * self, 102 bool wrap_text, 103 GenericStringGetter getter, 104 GenericStringSetter setter, 105 void * obj); 106 107 /** 108 * @} 109 */ 110 111 #endif 112