1 #if defined(HAVE_CONFIG_H) && !defined(GEANYPY_WINDOWS)
2 # include "config.h"
3 #endif
4
5 #include "geanypy.h"
6
7
8 static void
MainWidgets_dealloc(MainWidgets * self)9 MainWidgets_dealloc(MainWidgets *self)
10 {
11 self->ob_type->tp_free((PyObject *) self);
12 }
13
14
15 static int
MainWidgets_init(MainWidgets * self)16 MainWidgets_init(MainWidgets *self)
17 {
18 self->main_widgets = geany_data->main_widgets;
19 return 0;
20 }
21
22
23 static PyObject *
MainWidgets_get_property(MainWidgets * self,const gchar * prop_name)24 MainWidgets_get_property(MainWidgets *self, const gchar *prop_name)
25 {
26 g_return_val_if_fail(self != NULL, NULL);
27 g_return_val_if_fail(prop_name != NULL, NULL);
28
29 if (!self->main_widgets)
30 {
31 PyErr_SetString(PyExc_RuntimeError,
32 "MainWidgets instance not initialized properly");
33 return NULL;
34 }
35
36 if (g_str_equal(prop_name, "editor_menu"))
37 return pygobject_new(G_OBJECT(self->main_widgets->editor_menu));
38 else if (g_str_equal(prop_name, "message_window_notebook"))
39 return pygobject_new(G_OBJECT(self->main_widgets->message_window_notebook));
40 else if (g_str_equal(prop_name, "notebook"))
41 return pygobject_new(G_OBJECT(self->main_widgets->notebook));
42 else if (g_str_equal(prop_name, "progressbar"))
43 return pygobject_new(G_OBJECT(self->main_widgets->progressbar));
44 else if (g_str_equal(prop_name, "project_menu"))
45 return pygobject_new(G_OBJECT(self->main_widgets->project_menu));
46 else if (g_str_equal(prop_name, "sidebar_notebook"))
47 return pygobject_new(G_OBJECT(self->main_widgets->sidebar_notebook));
48 else if (g_str_equal(prop_name, "toolbar"))
49 return pygobject_new(G_OBJECT(self->main_widgets->toolbar));
50 else if (g_str_equal(prop_name, "tools_menu"))
51 return pygobject_new(G_OBJECT(self->main_widgets->tools_menu));
52 else if (g_str_equal(prop_name, "window"))
53 return pygobject_new(G_OBJECT(self->main_widgets->window));
54
55 Py_RETURN_NONE;
56 }
57 GEANYPY_PROPS_READONLY(MainWidgets);
58
59
60 static PyGetSetDef MainWidgets_getseters[] = {
61 GEANYPY_GETSETDEF(MainWidgets, "editor_menu",
62 "Popup context menu on the editor widget."),
63 GEANYPY_GETSETDEF(MainWidgets, "message_window_notebook",
64 "Notebook in the bottom message window."),
65 GEANYPY_GETSETDEF(MainWidgets, "notebook",
66 "The central documents notebook."),
67 GEANYPY_GETSETDEF(MainWidgets, "progressbar",
68 "Progress bar in the bottom status bar."),
69 GEANYPY_GETSETDEF(MainWidgets, "project_menu",
70 "The Project menu in the main menu bar."),
71 GEANYPY_GETSETDEF(MainWidgets, "sidebar_notebook",
72 "The notebook in the sidebar."),
73 GEANYPY_GETSETDEF(MainWidgets, "toolbar",
74 "Main toolbar."),
75 GEANYPY_GETSETDEF(MainWidgets, "tools_menu",
76 "The Tools menu in the main menu bar (recommended for plugins)."),
77 GEANYPY_GETSETDEF(MainWidgets, "window",
78 "Main window."),
79 { NULL },
80 };
81
82
83 PyTypeObject MainWidgetsType = {
84 PyObject_HEAD_INIT(NULL)
85 0, /* ob_size */
86 "geany.ui_utils.MainWidgets", /* tp_name */
87 sizeof(MainWidgets), /* tp_basicsize */
88 0, /* tp_itemsize */
89 (destructor) MainWidgets_dealloc, /* tp_dealloc */
90 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* tp_print - tp_as_buffer */
91 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
92 "Wrapper around the GeanyMainWidgets structure.", /* tp_doc */
93 0, 0, 0, 0, 0, 0, 0, 0, /* tp_traverse - tp_members */
94 MainWidgets_getseters, /* tp_getset */
95 0, 0, 0, 0, 0, /* tp_base - tp_dictoffset */
96 (initproc) MainWidgets_init, /* tp_init */
97 0, 0, /* tp_alloc - tp_new */
98
99 };
100