/soc/2013/ankitkv/gobjectification: d2c0c68a9816: Merged soc.201...

Ankit Vani a at nevitus.org
Wed Oct 23 18:53:24 EDT 2013


Changeset: d2c0c68a981673306a7eef24710a3bc00b644406
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-24 04:21 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/d2c0c68a9816

Description:

Merged soc.2013.gobjectification branch.
Added ui_data to PurplePluginInfo, as well as purple_plugin_info_[gs]et_ui_data functions.

diffstat:

 libpurple/plugins.c                  |  16 ++++++++++++++++
 libpurple/plugins.h                  |  24 ++++++++++++++++++++++++
 libpurple/plugins/perl/perl.c        |   2 --
 libpurple/protocols/gg/pubdir-prpl.c |   4 ++--
 pidgin/gtkplugin.c                   |   9 +++++++++
 5 files changed, 51 insertions(+), 4 deletions(-)

diffs (126 lines):

diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -772,6 +772,22 @@ purple_plugin_info_get_error(const Purpl
 	return priv->error;
 }
 
+void
+purple_plugin_info_set_ui_data(PurplePluginInfo *info, gpointer ui_data)
+{
+	g_return_if_fail(PURPLE_IS_PLUGIN_INFO(info));
+
+	info->ui_data = ui_data;
+}
+
+gpointer
+purple_plugin_info_get_ui_data(const PurplePluginInfo *info)
+{
+	g_return_val_if_fail(PURPLE_IS_PLUGIN_INFO(info), NULL);
+
+	return info->ui_data;
+}
+
 /**************************************************************************
  * PluginAction API
  **************************************************************************/
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -117,6 +117,11 @@ struct _PurplePluginInfo {
 #else
 	GObject parent;
 #endif
+
+	/** The UI data associated with the plugin. This is a convenience
+	 *  field provided to the UIs -- it is not used by the libpurple core.
+	 */
+	gpointer ui_data;
 };
 
 /**
@@ -707,6 +712,25 @@ purple_plugin_info_get_flags(const Purpl
  */
 const gchar *purple_plugin_info_get_error(const PurplePluginInfo *info);
 
+/**
+ * Set the UI data associated with a plugin.
+ *
+ * @param info The plugin's info instance.
+ * @param ui_data A pointer to associate with this object.
+ */
+void purple_plugin_info_set_ui_data(PurplePluginInfo *info, gpointer ui_data);
+
+/**
+ * Returns the UI data associated with a plugin.
+ *
+ * @param info The plugin's info instance.
+ *
+ * @return The UI data associated with this plugin.  This is a
+ *         convenience field provided to the UIs--it is not
+ *         used by the libpurple core.
+ */
+gpointer purple_plugin_info_get_ui_data(const PurplePluginInfo *info);
+
 /*@}*/
 
 /**************************************************************************/
diff --git a/libpurple/plugins/perl/perl.c b/libpurple/plugins/perl/perl.c
--- a/libpurple/plugins/perl/perl.c
+++ b/libpurple/plugins/perl/perl.c
@@ -117,8 +117,6 @@ struct _PurplePerlInfoStrings
 static PurplePluginUiInfo ui_info =
 {
 	purple_perl_get_plugin_frame,
-	0,   /* page_num (Reserved) */
-	NULL, /* frame (Reserved)    */
 	/* Padding */
 	NULL,
 	NULL,
diff --git a/libpurple/protocols/gg/pubdir-prpl.c b/libpurple/protocols/gg/pubdir-prpl.c
--- a/libpurple/protocols/gg/pubdir-prpl.c
+++ b/libpurple/protocols/gg/pubdir-prpl.c
@@ -531,8 +531,8 @@ void ggp_pubdir_search(PurpleConnection 
 	purple_request_field_group_add_field(group, field);
 
 	field = purple_request_field_choice_new("gender", _("Gender"),
-		GINT_TO_POINTER(form->gender));
-	purple_request_field_choice_add(field, _("Male or female"), 0);
+		form ? GINT_TO_POINTER(form->gender) : NULL);
+	purple_request_field_choice_add(field, _("Male or female"), NULL);
 	purple_request_field_choice_add(field, _("Male"),
 		GINT_TO_POINTER(GGP_PUBDIR_GENDER_MALE));
 	purple_request_field_choice_add(field, _("Female"),
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -197,6 +197,8 @@ pidgin_plugin_get_config_frame(PurplePlu
 		frame = get_pref_frame(plugin);
 
 		config = pidgin_plugin_pref_create_frame(frame);
+
+		purple_plugin_info_set_ui_data(info, frame);
 	}
 
 	return config;
@@ -349,6 +351,8 @@ static void plugin_unload_cb(PurplePlugi
 
 static void pref_dialog_response_cb(GtkWidget *d, int response, PurplePlugin *plug)
 {
+	PurplePluginInfo *info = purple_plugin_get_info(plug);
+
 	switch (response) {
 	case GTK_RESPONSE_CLOSE:
 	case GTK_RESPONSE_DELETE_EVENT:
@@ -359,6 +363,11 @@ static void pref_dialog_response_cb(GtkW
 		}
 		gtk_widget_destroy(d);
 
+		if (purple_plugin_info_get_pref_frame_callback(info) && info->ui_data) {
+			purple_plugin_pref_frame_destroy(info->ui_data);
+			purple_plugin_info_set_ui_data(info, NULL);
+		}
+
 		break;
 	}
 }



More information about the Commits mailing list