1 #if defined(HAVE_CONFIG_H) && !defined(GEANYPY_WINDOWS)
2 # include "config.h"
3 #endif
4
5 #include "geanypy.h"
6
7
8 #define RET_BOOL(memb) \
9 { \
10 if (memb) \
11 Py_RETURN_TRUE; \
12 else \
13 Py_RETURN_FALSE; \
14 }
15
16
17 static void
InterfacePrefs_dealloc(InterfacePrefs * self)18 InterfacePrefs_dealloc(InterfacePrefs *self)
19 {
20 g_return_if_fail(self != NULL);
21 self->ob_type->tp_free((PyObject *) self);
22 }
23
24
25 static int
InterfacePrefs_init(InterfacePrefs * self)26 InterfacePrefs_init(InterfacePrefs *self)
27 {
28 g_return_val_if_fail(self != NULL, -1);
29 self->iface_prefs = geany_data->interface_prefs;
30 return 0;
31 }
32
33
34 static PyObject *
InterfacePrefs_get_property(InterfacePrefs * self,const gchar * prop_name)35 InterfacePrefs_get_property(InterfacePrefs *self, const gchar *prop_name)
36 {
37 g_return_val_if_fail(self != NULL, NULL);
38 g_return_val_if_fail(prop_name != NULL, NULL);
39
40 if (!self->iface_prefs)
41 {
42 PyErr_SetString(PyExc_RuntimeError,
43 "InterfacePrefs instance not initialized properly");
44 return NULL;
45 }
46
47 if (g_str_equal(prop_name, "compiler_tab_autoscroll"))
48 RET_BOOL(self->iface_prefs->compiler_tab_autoscroll)
49 else if (g_str_equal(prop_name, "editor_font"))
50 return PyString_FromString(self->iface_prefs->editor_font);
51 else if (g_str_equal(prop_name, "highlighting_invert_all"))
52 RET_BOOL(self->iface_prefs->highlighting_invert_all)
53 else if (g_str_equal(prop_name, "msgwin_compiler_visible"))
54 RET_BOOL(self->iface_prefs->msgwin_compiler_visible)
55 else if (g_str_equal(prop_name, "msgwin_font"))
56 return PyString_FromString(self->iface_prefs->msgwin_font);
57 else if (g_str_equal(prop_name, "msgwin_messages_visible"))
58 RET_BOOL(self->iface_prefs->msgwin_messages_visible)
59 else if (g_str_equal(prop_name, "msgwin_scribble_visible"))
60 RET_BOOL(self->iface_prefs->msgwin_scribble_visible)
61 else if (g_str_equal(prop_name, "msgwin_status_visible"))
62 RET_BOOL(self->iface_prefs->msgwin_status_visible)
63 else if (g_str_equal(prop_name, "notebook_double_click_hides_widgets"))
64 RET_BOOL(self->iface_prefs->notebook_double_click_hides_widgets)
65 else if (g_str_equal(prop_name, "show_notebook_tabs"))
66 RET_BOOL(self->iface_prefs->show_notebook_tabs)
67 else if (g_str_equal(prop_name, "show_symbol_list_expanders"))
68 RET_BOOL(self->iface_prefs->show_symbol_list_expanders)
69 else if (g_str_equal(prop_name, "sidebar_openfiles_visible"))
70 RET_BOOL(self->iface_prefs->sidebar_openfiles_visible)
71 else if (g_str_equal(prop_name, "sidebar_pos"))
72 return PyInt_FromLong((glong) self->iface_prefs->sidebar_pos);
73 else if (g_str_equal(prop_name, "sidebar_symbol_visible"))
74 RET_BOOL(self->iface_prefs->sidebar_symbol_visible)
75 else if (g_str_equal(prop_name, "statusbar_visible"))
76 RET_BOOL(self->iface_prefs->statusbar_visible)
77 else if (g_str_equal(prop_name, "tab_pos_editor"))
78 return PyInt_FromLong((glong) self->iface_prefs->tab_pos_editor);
79 else if (g_str_equal(prop_name, "tab_pos_msgwin"))
80 return PyInt_FromLong((glong) self->iface_prefs->tab_pos_msgwin);
81 else if (g_str_equal(prop_name, "tab_pos_sidebar"))
82 return PyInt_FromLong((glong) self->iface_prefs->tab_pos_sidebar);
83 else if (g_str_equal(prop_name, "tagbar_font"))
84 return PyString_FromString(self->iface_prefs->tagbar_font);
85 else if (g_str_equal(prop_name, "use_native_windows_dialogs"))
86 RET_BOOL(self->iface_prefs->use_native_windows_dialogs)
87
88 Py_RETURN_NONE;
89 }
90 GEANYPY_PROPS_READONLY(InterfacePrefs);
91
92
93 static PyGetSetDef InterfacePrefs_getseters[] = {
94 GEANYPY_GETSETDEF(InterfacePrefs, "compiler_tab_autoscroll",
95 "Wether compiler messages window is automatically scrolled to "
96 "show new messages."),
97 GEANYPY_GETSETDEF(InterfacePrefs, "editor_font",
98 "Font used in the editor window."),
99 GEANYPY_GETSETDEF(InterfacePrefs, "highlighting_invert_all",
100 "Whether highlighting colors are inverted."),
101 GEANYPY_GETSETDEF(InterfacePrefs, "msgwin_compiler_visible",
102 "Wether message window's compiler tab is visible."),
103 GEANYPY_GETSETDEF(InterfacePrefs, "msgwin_font",
104 "Font used in the message window."),
105 GEANYPY_GETSETDEF(InterfacePrefs, "msgwin_messages_visible",
106 "Whether message window's messages tab is visible."),
107 GEANYPY_GETSETDEF(InterfacePrefs, "msgwin_scribble_visible",
108 "Whether message window's scribble tab is visible."),
109 GEANYPY_GETSETDEF(InterfacePrefs, "msgwin_status_visible",
110 "Whether message window's status tab is visible."),
111 GEANYPY_GETSETDEF(InterfacePrefs, "notebook_double_click_hides_widgets",
112 "Whether a double-click on the notebook tabs hides all other windows."),
113 GEANYPY_GETSETDEF(InterfacePrefs, "show_notebook_tabs",
114 "Whether editor tabs are visible."),
115 GEANYPY_GETSETDEF(InterfacePrefs, "show_symbol_list_expanders",
116 "Whether to show expanders in the symbol list."),
117 GEANYPY_GETSETDEF(InterfacePrefs, "sidebar_openfiles_visible",
118 "Whether the open files list is visible."),
119 GEANYPY_GETSETDEF(InterfacePrefs, "sidebar_pos",
120 "Position of the sidebar (left or right)."),
121 GEANYPY_GETSETDEF(InterfacePrefs, "sidebar_symbol_visible",
122 "Whether the status bar is visible."),
123 GEANYPY_GETSETDEF(InterfacePrefs, "statusbar_visible",
124 "Whether the statusbar is visible."),
125 GEANYPY_GETSETDEF(InterfacePrefs, "tab_pos_editor",
126 "Position of the editor's tabs."),
127 GEANYPY_GETSETDEF(InterfacePrefs, "tab_pos_msgwin",
128 "Position of the message window tabs."),
129 GEANYPY_GETSETDEF(InterfacePrefs, "tab_pos_sidebar",
130 "Position of the sidebar's tabs."),
131 GEANYPY_GETSETDEF(InterfacePrefs, "tagbar_font",
132 "Symbol sidebar font."),
133 GEANYPY_GETSETDEF(InterfacePrefs, "use_native_windows_dialogs",
134 "Whether to use native Windows dialogs (only on Win32)."),
135 { NULL }
136 };
137
138
139 PyTypeObject InterfacePrefsType = {
140 PyObject_HEAD_INIT(NULL)
141 0, /* ob_size */
142 "geany.ui_utils.InterfacePrefs", /* tp_name */
143 sizeof(InterfacePrefs), /* tp_basicsize */
144 0, /* tp_itemsize */
145 (destructor) InterfacePrefs_dealloc, /* tp_dealloc */
146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* tp_print - tp_as_buffer */
147 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
148 "Wrapper around a GeanyInterfacePrefs structure.", /* tp_doc */
149 0, 0, 0, 0, 0, 0, 0, 0, /* tp_traverse - tp_members */
150 InterfacePrefs_getseters, /* tp_getset */
151 0, 0, 0, 0, 0, /* tp_base - tp_dictoffset */
152 (initproc) InterfacePrefs_init, /* tp_init */
153 0, 0, /* tp_alloc - tp_new */
154 };
155