Remove some deprecation warnings from python-shell
[claws.git] / src / plugins / python / python_prefs.c
blobc4b1bd8a7993a0d9bf4f3ca40642c6ee31c5239b
1 /* Python plugin for Claws Mail
2 * Copyright (C) 2009-2018 Holger Berndt and The Claws Mail Team
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #include "claws-features.h"
21 #endif
23 #include <glib.h>
24 #include <glib/gi18n.h>
26 #include "common/version.h"
27 #include "defs.h"
28 #include "claws.h"
29 #include "plugin.h"
30 #include "file-utils.h"
31 #include "utils.h"
32 #include "prefs.h"
33 #include "prefs_common.h"
34 #include "prefs_gtk.h"
35 #include "python_prefs.h"
37 #define PREFS_BLOCK_NAME "Python"
39 PythonConfig python_config;
41 static PrefParam prefs[] = {
42 {"console_win_width", "-1", &python_config.console_win_width,
43 P_INT, NULL, NULL, NULL},
44 {"console_win_height", "-1", &python_config.console_win_height,
45 P_INT, NULL, NULL, NULL},
46 {0,0,0,0,0,0,0}
49 void python_prefs_init(void)
51 gchar *rcpath;
53 prefs_set_default(prefs);
54 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
55 prefs_read_config(prefs, PREFS_BLOCK_NAME, rcpath, NULL);
56 g_free(rcpath);
59 void python_prefs_done(void)
61 PrefFile *pref_file;
62 gchar *rc_file_path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
63 COMMON_RC, NULL);
64 pref_file = prefs_write_open(rc_file_path);
65 g_free(rc_file_path);
67 if (!(pref_file) || (prefs_set_block_label(pref_file, PREFS_BLOCK_NAME) < 0))
68 return;
70 if (prefs_write_param(prefs, pref_file->fp) < 0) {
71 g_warning("failed to write Python plugin configuration");
72 prefs_file_close_revert(pref_file);
73 return;
76 if (fprintf(pref_file->fp, "\n") < 0) {
77 FILE_OP_ERROR(rc_file_path, "fprintf");
78 prefs_file_close_revert(pref_file);
79 } else
80 prefs_file_close(pref_file);