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 #include <glib.h> 20 21 #include "sui/sui.h" 22 23 #include "i18n.h" 24 #include "utils.h" 25 #include "log.h" 26 sui_application_config_new(void)27SuiApplicationConfig *sui_application_config_new(void){ 28 return g_malloc0(sizeof(SuiApplicationConfig)); 29 } 30 sui_application_config_check(SuiApplicationConfig * cfg)31SrnRet sui_application_config_check(SuiApplicationConfig *cfg){ 32 const char *fmt = _("Missing field in SuiApplicationConfig: %1$s"); 33 34 if (str_is_empty(cfg->theme)){ 35 return RET_ERR(fmt, "theme"); 36 } 37 38 return SRN_OK; 39 } 40 sui_application_config_free(SuiApplicationConfig * cfg)41void sui_application_config_free(SuiApplicationConfig *cfg){ 42 str_assign(&cfg->theme, NULL); 43 g_free(cfg); 44 } 45 sui_application_options_new(void)46SuiApplicationOptions *sui_application_options_new(void){ 47 return g_malloc0(sizeof(SuiApplicationOptions)); 48 } 49 sui_application_options_free(SuiApplicationOptions * opts)50void sui_application_options_free(SuiApplicationOptions *opts){ 51 g_free(opts); 52 } 53 sui_window_config_new()54SuiWindowConfig *sui_window_config_new(){ 55 SuiWindowConfig *cfg; 56 57 cfg = g_malloc0(sizeof(SuiWindowConfig)); 58 59 return cfg; 60 } 61 sui_window_config_check(SuiWindowConfig * cfg)62SrnRet sui_window_config_check(SuiWindowConfig *cfg){ 63 g_return_val_if_fail(cfg, SRN_ERR); 64 65 return SRN_OK; 66 } 67 sui_window_config_free(SuiWindowConfig * cfg)68void sui_window_config_free(SuiWindowConfig *cfg){ 69 g_return_if_fail(cfg); 70 71 g_free(cfg); 72 } 73 sui_buffer_config_new()74SuiBufferConfig* sui_buffer_config_new(){ 75 SuiBufferConfig *cfg; 76 77 cfg = g_malloc0(sizeof(SuiBufferConfig)); 78 79 return cfg; 80 } 81 sui_buffer_config_check(SuiBufferConfig * cfg)82SrnRet sui_buffer_config_check(SuiBufferConfig *cfg){ 83 if (!cfg){ 84 return RET_ERR(_("Invalid SuiBufferConfig instance")); 85 } 86 return SRN_OK; 87 } 88 sui_buffer_config_free(SuiBufferConfig * cfg)89void sui_buffer_config_free(SuiBufferConfig *cfg){ 90 g_return_if_fail(cfg); 91 92 g_free(cfg->nick_completion_suffix); 93 g_free(cfg); 94 } 95