Remmina - The GTK+ Remote Desktop Client  v1.4.25
Remmina is a remote desktop client written in GTK+, aiming to be useful for system administrators and travellers, who need to work with lots of remote computers in front of either large monitors or tiny netbooks. Remmina supports multiple network protocols in an integrated and consistent user interface. Currently RDP, VNC, NX, XDMCP and SSH are supported.
remmina_plugin_python_pref.c
Go to the documentation of this file.
1 /*
2  * Remmina - The GTK+ Remote Desktop Client
3  * Copyright (C) 2014-2021 Antenore Gatta, Giovanni Panozzo, Mathias Winterhalter (ToolsDevler)
4  *
5  * This program 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 2 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, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  * In addition, as a special exception, the copyright holders give
21  * permission to link the code of portions of this program with the
22  * OpenSSL library under certain conditions as described in each
23  * individual source file, and distribute linked combinations
24  * including the two.
25  * You must obey the GNU General Public License in all respects
26  * for all of the code used other than OpenSSL. * If you modify
27  * file(s) with this exception, you may extend this exception to your
28  * version of the file(s), but you are not obligated to do so. * If you
29  * do not wish to do so, delete this exception statement from your
30  * version. * If you delete this exception statement from all source
31  * files in the program, then also delete it here.
32  */
33 
35 // I N C L U D E S
37 
40 
42 // D E C L A R A T I O N S
44 
46 // A P I
48 
50 {
51  TRACE_CALL(__func__);
52 
53 }
54 
59 {
60  TRACE_CALL(__func__);
61 
62  PyPlugin* plugin = remmina_plugin_python_get_plugin(instance->name);
63 
64  PyObject* result = CallPythonMethod(plugin->instance, "get_pref_body", NULL, NULL);
65  if (result == Py_None || result == NULL)
66  {
67  return NULL;
68  }
69 
70  return get_pywidget(result);
71 }
72 
74 {
75  TRACE_CALL(__func__);
76 
77  PyObject* instance = plugin->instance;
78 
83  {
84  g_printerr("Unable to create pref plugin. Aborting!\n");
85  return NULL;
86  }
87 
89 
90  remmina_plugin->type = REMMINA_PLUGIN_TYPE_PREF;
91  remmina_plugin->domain = GETTEXT_PACKAGE;
92  remmina_plugin->name = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_NAME));
93  remmina_plugin->version = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_VERSION));
94  remmina_plugin->description = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_DESCRIPTION));
95  remmina_plugin->pref_label = PyUnicode_AsUTF8(PyObject_GetAttrString(instance, ATTR_PREF_LABEL));
97 
98  plugin->pref_plugin = remmina_plugin;
99  plugin->generic_plugin = (RemminaPlugin*)remmina_plugin;
100 
102 
103  return (RemminaPlugin*)remmina_plugin;
104 }
void remmina_plugin_python_pref_init(void)
Initializes the Python plugin specialisation for preferences plugins.
RemminaPluginType type
Definition: plugin.h:123
Maps an instance of a Python plugin to a Remmina one.
GtkWidget * remmina_plugin_python_pref_get_pref_body_wrapper(RemminaPrefPlugin *instance)
static RemminaProtocolPlugin remmina_plugin
Definition: exec_plugin.c:280
const gchar * domain
Definition: plugin.h:126
PyPlugin * remmina_plugin_python_get_plugin(const char *name)
Tries to find the Python plugin matching to the given instance of RemminaPlugin.
GtkWidget * get_pywidget(PyObject *obj)
Extracts a GtkWidget from a PyObject instance.
const char * ATTR_PREF_LABEL
const char * ATTR_DESCRIPTION
const gchar * description
Definition: plugin.h:125
RemminaPlugin * generic_plugin
const gchar * pref_label
Definition: plugin.h:129
RemminaPlugin * remmina_plugin_python_create_pref_plugin(PyPlugin *plugin)
Creates a new instance of the RemminaPluginPref, initializes its members and references the wrapper f...
void remmina_plugin_python_add_plugin(PyPlugin *plugin)
Registers the given plugin if no other plugin with the same name has been already registered...
gboolean remmina_plugin_python_check_attribute(PyObject *instance, const char *attr_name)
Checks if a given attribute exists.
const char * ATTR_NAME
GtkWidget *(* get_pref_body)(struct _RemminaPrefPlugin *instance)
Definition: plugin.h:130
const gchar * version
Definition: plugin.h:127
Contains functions and constants that are commonly used throughout the Python plugin implementation...
const gchar * name
Definition: plugin.h:124
void * remmina_plugin_python_malloc(int bytes)
Allocates memory and checks for errors before returning.
RemminaPrefPlugin * pref_plugin
Contains the specialisation of RemminaPluginFile plugins in Python.
const char * ATTR_VERSION