1 /* Copyright (C) 2016-2017 Shengyu Zhang <i@silverrainz.me> 2 * 3 * This file is part of Srain. 4 * 5 * Srain is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef __SUI_COMPLETION_H 20 #define __SUI_COMPLETION_H 21 22 #include <gtk/gtk.h> 23 24 #define SUI_TYPE_COMPLETION (sui_completion_get_type()) 25 #define SUI_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SUI_TYPE_COMPLETION, SuiCompletion)) 26 #define SUI_IS_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SUI_TYPE_COMPLETION)) 27 28 enum { 29 SUI_COMPLETION_COLUMN_PREFIX = 0, // Prefix column of completion result 30 SUI_COMPLETION_COLUMN_SUFFIX, // Suffix column of completion result 31 SUI_COMPLETION_N_COLUMNS, 32 }; 33 34 /** 35 * @brief SuiCompletionFunc returns a list of completion result according the 36 * context 37 * 38 * @param context Content of SuiCompletion's text buffer 39 * @param user_data User defined data 40 * 41 * @return Completion result, which is a multi-column list. See 42 * SUI_COMPLETION_COL_RESULT and SUI_TYPE_COMPLETION 43 */ 44 typedef GtkTreeModel* (SuiCompletionFunc) (const char *context, void *user_data); 45 46 typedef struct _SuiCompletion SuiCompletion; 47 typedef struct _SuiCompletionClass SuiCompletionClass; 48 49 GType sui_completion_get_type(void); 50 SuiCompletion *sui_completion_new(GtkTextBuffer *buffer); 51 void sui_completion_complete(SuiCompletion *self, SuiCompletionFunc *func, void *user_data); 52 53 void sui_completion_set_text_buffer(SuiCompletion *self, GtkTextBuffer *text_buffer); 54 GtkTextBuffer* sui_completion_get_text_buffer(SuiCompletion *self); 55 56 #endif /* __SUI_COMPLETION_H */ 57