diff options
author | Gary Kramlich <grim@reaperworld.com> | 2019-11-12 01:34:57 -0600 |
---|---|---|
committer | Gary Kramlich <grim@reaperworld.com> | 2019-11-12 01:34:57 -0600 |
commit | f035bc192c21bd1c8884d5a4df085edeee886730 (patch) | |
tree | cac5bcb8067292b721151acb86a3cd395a982f83 | |
parent | 546fb54943bba625abc084243ff6400922d89786 (diff) | |
download | pidgin-f035bc192c21bd1c8884d5a4df085edeee886730.tar.gz |
Move PidginPluginInfo to it's own file and remove references to the broken gtk config frame code. This is going to be overhauled in an upcomming commit
-rw-r--r-- | pidgin/gtkplugin.c | 156 | ||||
-rw-r--r-- | pidgin/gtkplugin.h | 66 | ||||
-rw-r--r-- | pidgin/meson.build | 2 | ||||
-rw-r--r-- | pidgin/pidginplugininfo.c | 61 | ||||
-rw-r--r-- | pidgin/pidginplugininfo.h | 60 |
5 files changed, 135 insertions, 210 deletions
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c index e6a300889c..091b3080db 100644 --- a/pidgin/gtkplugin.c +++ b/pidgin/gtkplugin.c @@ -34,18 +34,6 @@ typedef struct { - PidginPluginConfigFrameCb config_frame_cb; -} PidginPluginInfoPrivate; - -enum -{ - PROP_0, - PROP_GTK_CONFIG_FRAME_CB, - PROP_LAST -}; - -typedef struct -{ enum { PIDGIN_PLUGIN_UI_DATA_TYPE_FRAME, @@ -64,9 +52,6 @@ typedef struct } u; } PidginPluginUiData; -G_DEFINE_TYPE_WITH_PRIVATE(PidginPluginInfo, pidgin_plugin_info, - PURPLE_TYPE_PLUGIN_INFO); - static void plugin_toggled_stage_two(PurplePlugin *plug, GtkTreeModel *model, GtkTreeIter *iter, GError *error, gboolean unload); @@ -83,91 +68,11 @@ static GtkLabel *plugin_filename = NULL; static GtkWidget *pref_button = NULL; -/* Set method for GObject properties */ -static void -pidgin_plugin_info_set_property(GObject *obj, guint param_id, const GValue *value, - GParamSpec *pspec) -{ - PidginPluginInfoPrivate *priv = - pidgin_plugin_info_get_instance_private( - PIDGIN_PLUGIN_INFO(obj)); - - switch (param_id) { - case PROP_GTK_CONFIG_FRAME_CB: - priv->config_frame_cb = g_value_get_pointer(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); - break; - } -} - -/* Get method for GObject properties */ -static void -pidgin_plugin_info_get_property(GObject *obj, guint param_id, GValue *value, - GParamSpec *pspec) -{ - PidginPluginInfoPrivate *priv = - pidgin_plugin_info_get_instance_private( - PIDGIN_PLUGIN_INFO(obj)); - - switch (param_id) { - case PROP_GTK_CONFIG_FRAME_CB: - g_value_set_pointer(value, priv->config_frame_cb); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); - break; - } -} - -/* Class initializer function */ -static void pidgin_plugin_info_class_init(PidginPluginInfoClass *klass) -{ - GObjectClass *obj_class = G_OBJECT_CLASS(klass); - - /* Setup properties */ - obj_class->get_property = pidgin_plugin_info_get_property; - obj_class->set_property = pidgin_plugin_info_set_property; - - g_object_class_install_property(obj_class, PROP_GTK_CONFIG_FRAME_CB, - g_param_spec_pointer("gtk-config-frame-cb", - "GTK configuration frame callback", - "Callback that returns a GTK configuration frame", - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); -} - -static void -pidgin_plugin_info_init(PidginPluginInfo *info) -{ -} - -PidginPluginInfo * -pidgin_plugin_info_new(const char *first_property, ...) -{ - GObject *info; - va_list var_args; - - /* at least ID is required */ - if (!first_property) - return NULL; - - va_start(var_args, first_property); - info = g_object_new_valist(PIDGIN_TYPE_PLUGIN_INFO, first_property, - var_args); - va_end(var_args); - - g_object_set(info, "ui-requirement", PIDGIN_UI, NULL); - - return PIDGIN_PLUGIN_INFO(info); -} - static gboolean pidgin_plugin_has_prefs(PurplePlugin *plugin) { PurplePluginInfo *info = purple_plugin_get_info(plugin); - PidginPluginInfoPrivate *priv = NULL; + PurplePluginPrefFrameCb config_frame_cb = NULL; gboolean ret; g_return_val_if_fail(plugin != NULL, FALSE); @@ -175,45 +80,13 @@ pidgin_plugin_has_prefs(PurplePlugin *plugin) if (!purple_plugin_is_loaded(plugin)) return FALSE; - if (PIDGIN_IS_PLUGIN_INFO(info)) - priv = pidgin_plugin_info_get_instance_private( - PIDGIN_PLUGIN_INFO(info)); - - ret = ((priv && priv->config_frame_cb) || + ret = (config_frame_cb || purple_plugin_info_get_pref_frame_cb(info) || purple_plugin_info_get_pref_request_cb(info)); return ret; } -static GtkWidget * -pidgin_plugin_get_config_frame(PurplePlugin *plugin, - PurplePluginPrefFrame **purple_pref_frame) -{ - GtkWidget *config = NULL; - PurplePluginInfo *info; - PurplePluginPrefFrameCb pref_frame_cb = NULL; - - g_return_val_if_fail(PURPLE_IS_PLUGIN(plugin), NULL); - - info = purple_plugin_get_info(plugin); - if(!PURPLE_IS_PLUGIN_INFO(info)) - return NULL; - - pref_frame_cb = purple_plugin_info_get_pref_frame_cb(info); - if(pref_frame_cb) { - PurplePluginPrefFrame *frame = pref_frame_cb(plugin); - - if(frame) { - config = pidgin_plugin_pref_create_frame(frame); - - *purple_pref_frame = frame; - } - } - - return config; -} - static void pref_dialog_close(PurplePlugin *plugin) { @@ -260,11 +133,9 @@ static void pidgin_plugin_open_config(PurplePlugin *plugin, GtkWindow *parent) { PurplePluginInfo *info; - PidginPluginInfoPrivate *priv = NULL; PidginPluginUiData *ui_data; PurplePluginPrefFrameCb pref_frame_cb; PurplePluginPrefRequestCb pref_request_cb; - PidginPluginConfigFrameCb get_pidgin_frame = NULL; gint prefs_count; g_return_if_fail(plugin != NULL); @@ -279,23 +150,21 @@ pidgin_plugin_open_config(PurplePlugin *plugin, GtkWindow *parent) if (purple_plugin_info_get_ui_data(info)) return; - if (PIDGIN_IS_PLUGIN_INFO(info)) - priv = pidgin_plugin_info_get_instance_private( - PIDGIN_PLUGIN_INFO(info)); - pref_frame_cb = purple_plugin_info_get_pref_frame_cb(info); pref_request_cb = purple_plugin_info_get_pref_request_cb(info); - if (priv) - get_pidgin_frame = priv->config_frame_cb; + ui_data = g_new0(PidginPluginUiData, 1); + purple_plugin_info_set_ui_data(info, ui_data); prefs_count = 0; - if (pref_frame_cb) + if (pref_frame_cb) { prefs_count++; + + ui_data->u.frame.pref_frame = pref_frame_cb(plugin); + } + if (pref_request_cb) prefs_count++; - if (get_pidgin_frame) - prefs_count++; if (prefs_count > 1) { purple_debug_warning("gtkplugin", @@ -306,13 +175,11 @@ pidgin_plugin_open_config(PurplePlugin *plugin, GtkWindow *parent) } g_return_if_fail(prefs_count > 0); - ui_data = g_new0(PidginPluginUiData, 1); - purple_plugin_info_set_ui_data(info, ui_data); /* Priority: pidgin frame > purple request > purple frame * Purple frame could be replaced with purple request some day. */ - if (pref_request_cb && !get_pidgin_frame) { + if (pref_request_cb) { ui_data->type = PIDGIN_PLUGIN_UI_DATA_TYPE_REQUEST; ui_data->u.request_handle = pref_request_cb(plugin); purple_request_add_close_notify(ui_data->u.request_handle, @@ -324,8 +191,7 @@ pidgin_plugin_open_config(PurplePlugin *plugin, GtkWindow *parent) ui_data->type = PIDGIN_PLUGIN_UI_DATA_TYPE_FRAME; - box = pidgin_plugin_get_config_frame(plugin, - &ui_data->u.frame.pref_frame); + box = pidgin_plugin_pref_create_frame(ui_data->u.frame.pref_frame); if (box == NULL) { purple_debug_error("gtkplugin", "Failed to display prefs frame"); diff --git a/pidgin/gtkplugin.h b/pidgin/gtkplugin.h index c71a8c3c6d..7ab4c45adc 100644 --- a/pidgin/gtkplugin.h +++ b/pidgin/gtkplugin.h @@ -31,75 +31,11 @@ #include "pidgin.h" #include "plugins.h" -#define PIDGIN_TYPE_PLUGIN_INFO (pidgin_plugin_info_get_type()) -#define PIDGIN_PLUGIN_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_PLUGIN_INFO, PidginPluginInfo)) -#define PIDGIN_PLUGIN_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PIDGIN_TYPE_PLUGIN_INFO, PidginPluginInfoClass)) -#define PIDGIN_IS_PLUGIN_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PIDGIN_TYPE_PLUGIN_INFO)) -#define PIDGIN_IS_PLUGIN_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PIDGIN_TYPE_PLUGIN_INFO)) -#define PIDGIN_PLUGIN_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PIDGIN_TYPE_PLUGIN_INFO, PidginPluginInfoClass)) - -typedef struct _PidginPluginInfo PidginPluginInfo; -typedef struct _PidginPluginInfoClass PidginPluginInfoClass; - -typedef GtkWidget *(*PidginPluginConfigFrameCb)(PurplePlugin *plugin); - -/** - * PidginPluginInfo: - * - * Extends #PurplePluginInfo to hold UI information for pidgin. - */ -struct _PidginPluginInfo { - PurplePluginInfo parent; -}; - -/** - * PidginPluginInfoClass: - * - * The base class for all #PidginPluginInfo's. - */ -struct _PidginPluginInfoClass { - PurplePluginInfoClass parent_class; - - /*< private >*/ - void (*_pidgin_reserved1)(void); - void (*_pidgin_reserved2)(void); - void (*_pidgin_reserved3)(void); - void (*_pidgin_reserved4)(void); -}; +#include "pidginplugininfo.h" G_BEGIN_DECLS /** - * pidgin_plugin_info_get_type: - * - * Returns: The #GType for the #PidginPluginInfo object. - */ -GType pidgin_plugin_info_get_type(void); - -/** - * pidgin_plugin_info_new: - * @first_property: The first property name - * @...: The value of the first property, followed optionally by more - * name/value pairs, followed by %NULL - * - * Creates a new #PidginPluginInfo instance to be returned from - * #plugin_query of a pidgin plugin, using the provided name/value - * pairs. - * - * See purple_plugin_info_new() for a list of available property names. - * Additionally, you can provide the property - * <literal>"gtk-config-frame-cb"</literal>, which should be a callback that - * returns a #GtkWidget for the plugin's configuration - * (see #PidginPluginConfigFrameCb). - * - * See purple_plugin_info_new(). - * - * Returns: A new #PidginPluginInfo instance. - */ -PidginPluginInfo *pidgin_plugin_info_new(const char *first_property, ...) - G_GNUC_NULL_TERMINATED; - -/** * pidgin_plugins_save: * * Saves all loaded plugins. diff --git a/pidgin/meson.build b/pidgin/meson.build index 61376bb42a..108430f629 100644 --- a/pidgin/meson.build +++ b/pidgin/meson.build @@ -44,6 +44,7 @@ libpidgin_SOURCES = [ 'pidginlog.c', 'pidginmenutray.c', 'pidginmessage.c', + 'pidginplugininfo.c', 'pidginpluginsdialog.c', 'pidgintalkatu.c', 'pidgintooltip.c', @@ -97,6 +98,7 @@ libpidgin_headers = [ 'pidginlog.h', 'pidginmenutray.h', 'pidginmessage.h', + 'pidginplugininfo.h', 'pidginpluginsdialog.h', 'pidgintalkatu.h', 'pidgintooltip.h', diff --git a/pidgin/pidginplugininfo.c b/pidgin/pidginplugininfo.c new file mode 100644 index 0000000000..5dff97d7b8 --- /dev/null +++ b/pidgin/pidginplugininfo.c @@ -0,0 +1,61 @@ +/* pidgin + * + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ +#include "pidginplugininfo.h" + +struct _PidginPluginInfo { + PurplePluginInfo parent; +}; + +/****************************************************************************** + * GObject Implementation + *****************************************************************************/ +G_DEFINE_TYPE(PidginPluginInfo, pidgin_plugin_info, PURPLE_TYPE_PLUGIN_INFO); + +static void +pidgin_plugin_info_init(PidginPluginInfo *info) { +} + +static void +pidgin_plugin_info_class_init(PidginPluginInfoClass *klass) { +} + +/****************************************************************************** + * API + *****************************************************************************/ +PidginPluginInfo * +pidgin_plugin_info_new(const char *first_property, ...) +{ + GObject *info; + va_list var_args; + + /* at least ID is required */ + if (!first_property) + return NULL; + + va_start(var_args, first_property); + info = g_object_new_valist(PIDGIN_TYPE_PLUGIN_INFO, first_property, + var_args); + va_end(var_args); + + g_object_set(info, "ui-requirement", PIDGIN_UI, NULL); + + return PIDGIN_PLUGIN_INFO(info); +} diff --git a/pidgin/pidginplugininfo.h b/pidgin/pidginplugininfo.h new file mode 100644 index 0000000000..af9b47b050 --- /dev/null +++ b/pidgin/pidginplugininfo.h @@ -0,0 +1,60 @@ +/* pidgin + * + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ +#ifndef PIDGIN_PLUGIN_INFO_H +#define PIDGIN_PLUGIN_INFO_H + +#include <gtk/gtk.h> + +#include <purple.h> + +#include "pidgin.h" + +G_BEGIN_DECLS + +#define PIDGIN_TYPE_PLUGIN_INFO (pidgin_plugin_info_get_type()) +G_DECLARE_FINAL_TYPE(PidginPluginInfo, pidgin_plugin_info, PIDGIN, PLUGIN_INFO, PurplePluginInfo) + +/** + * pidgin_plugin_info_new: + * @first_property: The first property name + * @...: The value of the first property, followed optionally by more + * name/value pairs, followed by %NULL + * + * Creates a new #PidginPluginInfo instance to be returned from + * #plugin_query of a pidgin plugin, using the provided name/value + * pairs. + * + * See purple_plugin_info_new() for a list of available property names. + * Additionally, you can provide the property + * <literal>"gtk-config-frame-cb"</literal>, which should be a callback that + * returns a #GtkWidget for the plugin's configuration + * (see #PidginPluginConfigFrameCb). + * + * See purple_plugin_info_new(). + * + * Returns: A new #PidginPluginInfo instance. + */ +PidginPluginInfo *pidgin_plugin_info_new(const char *first_property, ...) + G_GNUC_NULL_TERMINATED; + +G_END_DECLS + +#endif /* PIDGIN_PLUGIN_INFO_H */ |