pidgin/pidgin

Parents 1af60f2ac6b6
Children 40f2888f85c1
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
--- a/pidgin/gtkplugin.c Mon Nov 11 22:20:27 2019 -0600
+++ b/pidgin/gtkplugin.c Tue Nov 12 01:34:57 2019 -0600
@@ -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 @@
} 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 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 @@
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 @@
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 @@
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 @@
}
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 @@
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");
--- a/pidgin/gtkplugin.h Mon Nov 11 22:20:27 2019 -0600
+++ b/pidgin/gtkplugin.h Tue Nov 12 01:34:57 2019 -0600
@@ -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.
--- a/pidgin/meson.build Mon Nov 11 22:20:27 2019 -0600
+++ b/pidgin/meson.build Tue Nov 12 01:34:57 2019 -0600
@@ -44,6 +44,7 @@
'pidginlog.c',
'pidginmenutray.c',
'pidginmessage.c',
+ 'pidginplugininfo.c',
'pidginpluginsdialog.c',
'pidgintalkatu.c',
'pidgintooltip.c',
@@ -97,6 +98,7 @@
'pidginlog.h',
'pidginmenutray.h',
'pidginmessage.h',
+ 'pidginplugininfo.h',
'pidginpluginsdialog.h',
'pidgintalkatu.h',
'pidgintooltip.h',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginplugininfo.c Tue Nov 12 01:34:57 2019 -0600
@@ -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);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginplugininfo.h Tue Nov 12 01:34:57 2019 -0600
@@ -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 */