/soc/2013/ankitkv/gobjectification: deee438dc431: Refactored mor...

Ankit Vani a at nevitus.org
Tue Sep 17 10:55:31 EDT 2013


Changeset: deee438dc431ce1c3eb6c7f183523c0beb6a0185
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-17 20:25 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/deee438dc431

Description:

Refactored more pidgin plugins to use the new plugin API

diffstat:

 pidgin/plugins/relnot.c      |   76 +++++++++-------------
 pidgin/plugins/sendbutton.c  |   70 ++++++++------------
 pidgin/plugins/spellchk.c    |  145 +++++++++++++++++-------------------------
 pidgin/plugins/themeedit.c   |   79 +++++++++-------------
 pidgin/plugins/webkit.c      |   70 ++++++++------------
 pidgin/plugins/xmppconsole.c |  132 +++++++++++++++++---------------------
 6 files changed, 238 insertions(+), 334 deletions(-)

diffs (truncated from 725 to 300 lines):

diff --git a/pidgin/plugins/relnot.c b/pidgin/plugins/relnot.c
--- a/pidgin/plugins/relnot.c
+++ b/pidgin/plugins/relnot.c
@@ -35,6 +35,7 @@
 #include "core.h"
 #include "debug.h"
 #include "gtkblist.h"
+#include "gtkplugin.h"
 #include "gtkutils.h"
 #include "http.h"
 #include "notify.h"
@@ -140,9 +141,35 @@ signed_on_cb(PurpleConnection *gc, void 
 /**************************************************************************
  * Plugin stuff
  **************************************************************************/
+static PidginPluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Nathan Walp <faceprint at faceprint.com>",
+		NULL
+	};
+
+	return pidgin_plugin_info_new(
+		"id",           "gtk-relnot",
+		"name",         N_("Release Notification"),
+		"version",      DISPLAY_VERSION,
+		"category",     N_("Notification"),
+		"summary",      N_("Checks periodically for new releases."),
+		"description",  N_("Checks periodically for new releases and notifies "
+		                   "the user with the ChangeLog."),
+		"authors",      authors,
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
+	purple_prefs_add_none("/plugins/gtk/relnot");
+	purple_prefs_add_int("/plugins/gtk/relnot/last_check", 0);
+
 	purple_signal_connect(purple_connections_get_handle(), "signed-on",
 						plugin, PURPLE_CALLBACK(signed_on_cb), NULL);
 
@@ -153,49 +180,10 @@ plugin_load(PurplePlugin *plugin)
 	return TRUE;
 }
 
-static PurplePluginInfo info =
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
 {
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_STANDARD,                             /**< type           */
-	NULL,                                             /**< ui_requirement */
-	0,                                                /**< flags          */
-	NULL,                                             /**< dependencies   */
-	PURPLE_PRIORITY_DEFAULT,                            /**< priority       */
-
-	"gtk-relnot",                                     /**< id             */
-	N_("Release Notification"),                       /**< name           */
-	DISPLAY_VERSION,                                  /**< version        */
-	                                                  /**  summary        */
-	N_("Checks periodically for new releases."),
-	                                                  /**  description    */
-	N_("Checks periodically for new releases and notifies the user "
-			"with the ChangeLog."),
-	"Nathan Walp <faceprint at faceprint.com>",          /**< author         */
-	PURPLE_WEBSITE,                                     /**< homepage       */
-
-	plugin_load,                                      /**< load           */
-	NULL,                                             /**< unload         */
-	NULL,                                             /**< destroy        */
-
-	NULL,                                             /**< ui_info        */
-	NULL,                                             /**< extra_info     */
-	NULL,
-	NULL,
-
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
-{
-	purple_prefs_add_none("/plugins/gtk/relnot");
-	purple_prefs_add_int("/plugins/gtk/relnot/last_check", 0);
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN(relnot, init_plugin, info)
+PURPLE_PLUGIN_INIT(relnot, plugin_query, plugin_load, plugin_unload);
diff --git a/pidgin/plugins/sendbutton.c b/pidgin/plugins/sendbutton.c
--- a/pidgin/plugins/sendbutton.c
+++ b/pidgin/plugins/sendbutton.c
@@ -114,8 +114,32 @@ conversation_displayed_cb(PidginConversa
 	}
 }
 
+static PidginPluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Etan Reisner <deryni at pidgin.im>",
+		NULL
+	};
+
+	return pidgin_plugin_info_new(
+		"id",           "gtksendbutton",
+		"name",         N_("Send Button"),
+		"version",      DISPLAY_VERSION,
+		"category",     N_("User interface"),
+		"summary",      N_("Conversation Window Send Button."),
+		"description",  N_("Adds a Send button to the entry area of the "
+		                   "conversation window. Intended for use when no "
+		                   "physical keyboard is present."),
+		"authors",      authors,
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 	GList *convs = purple_conversations_get_all();
 	void *gtk_conv_handle = pidgin_conversations_get_handle();
@@ -143,7 +167,7 @@ plugin_load(PurplePlugin *plugin)
 }
 
 static gboolean
-plugin_unload(PurplePlugin *plugin)
+plugin_unload(PurplePlugin *plugin, GError **error)
 {
 	GList *convs = purple_conversations_get_all();
 
@@ -161,44 +185,4 @@ plugin_unload(PurplePlugin *plugin)
 	return TRUE;
 }
 
-static PurplePluginInfo info =
-{
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,                           /**< major version */
-	PURPLE_MINOR_VERSION,                           /**< minor version */
-	PURPLE_PLUGIN_STANDARD,                         /**< type */
-	PIDGIN_PLUGIN_TYPE,                             /**< ui_requirement */
-	0,                                              /**< flags */
-	NULL,                                           /**< dependencies */
-	PURPLE_PRIORITY_DEFAULT,                        /**< priority */
-
-	"gtksendbutton",                                /**< id */
-	N_("Send Button"),                              /**< name */
-	DISPLAY_VERSION,                                /**< version */
-	N_("Conversation Window Send Button."),         /**< summary */
-	N_("Adds a Send button to the entry area of "
-	   "the conversation window. Intended for use "
-	   "when no physical keyboard is present."),    /**< description */
-	"Etan Reisner <deryni at pidgin.im>",              /**< author */
-	PURPLE_WEBSITE,                                 /**< homepage */
-	plugin_load,                                    /**< load */
-	plugin_unload,                                  /**< unload */
-	NULL,                                           /**< destroy */
-	NULL,                                           /**< ui_info */
-	NULL,                                           /**< extra_info */
-	NULL,                                           /**< prefs_info */
-	NULL,                                           /**< actions */
-
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
-{
-}
-
-PURPLE_INIT_PLUGIN(sendbutton, init_plugin, info)
+PURPLE_PLUGIN_INIT(sendbutton, plugin_query, plugin_load, plugin_unload);
diff --git a/pidgin/plugins/spellchk.c b/pidgin/plugins/spellchk.c
--- a/pidgin/plugins/spellchk.c
+++ b/pidgin/plugins/spellchk.c
@@ -2107,48 +2107,6 @@ static void on_entry_changed(GtkEditable
 		non_empty(gtk_entry_get_text(GTK_ENTRY(good_entry))));
 }
 
-/*
- *  EXPORTED FUNCTIONS
- */
-
-static gboolean
-plugin_load(PurplePlugin *plugin)
-{
-	void *conv_handle = purple_conversations_get_handle();
-	GList *convs;
-
-	load_conf();
-
-	/* Attach to existing conversations */
-	for (convs = purple_conversations_get_all(); convs != NULL; convs = convs->next)
-	{
-		spellchk_new_attach((PurpleConversation *)convs->data);
-	}
-
-	purple_signal_connect(conv_handle, "conversation-created",
-			    plugin, PURPLE_CALLBACK(spellchk_new_attach), NULL);
-
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin)
-{
-	GList *convs;
-
-	/* Detach from existing conversations */
-	for (convs = purple_conversations_get_all(); convs != NULL; convs = convs->next)
-	{
-		PidginConversation *gtkconv = PIDGIN_CONVERSATION((PurpleConversation *)convs->data);
-		spellchk *spell = g_object_get_data(G_OBJECT(gtkconv->entry), SPELLCHK_OBJECT_KEY);
-
-		g_signal_handlers_disconnect_by_func(gtkconv->entry, message_send_cb, spell);
-		g_object_set_data(G_OBJECT(gtkconv->entry), SPELLCHK_OBJECT_KEY, NULL);
-	}
-
-	return TRUE;
-}
-
 static void whole_words_button_toggled(GtkToggleButton *complete_toggle, GtkToggleButton *case_toggle)
 {
 	gboolean enabled = gtk_toggle_button_get_active(complete_toggle);
@@ -2316,59 +2274,76 @@ get_config_frame(PurplePlugin *plugin)
 	return ret;
 }
 
-static PidginPluginUiInfo ui_info =
+/*
+ *  EXPORTED FUNCTIONS
+ */
+
+static PidginPluginInfo *
+plugin_query(GError **error)
 {
-	get_config_frame,
-	0, /* page_num (Reserved) */
+	const gchar * const authors[] = {
+		"Eric Warmenhoven <eric at warmenhoven.org>",
+		NULL
+	};
 
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
+	return pidgin_plugin_info_new(
+		"id",                   SPELLCHECK_PLUGIN_ID,
+		"name",                 N_("Text replacement"),
+		"version",              DISPLAY_VERSION,
+		"category",             N_("Utility"),
+		"summary",              N_("Replaces text in outgoing messages according to user-defined rules."),
+		"description",          N_("Replaces text in outgoing messages according to user-defined rules."),
+		"authors",              authors,
+		"website",              PURPLE_WEBSITE,
+		"abi-version",          PURPLE_ABI_VERSION,
+		"pidgin-config-frame",  get_config_frame,
+		NULL
+	);
+}
 
-static PurplePluginInfo info =
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
 {
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_STANDARD,
-	PIDGIN_PLUGIN_TYPE,
-	0,
-	NULL,
-	PURPLE_PRIORITY_DEFAULT,
-	SPELLCHECK_PLUGIN_ID,
-	N_("Text replacement"),



More information about the Commits mailing list