/soc/2013/ankitkv/gobjectification: 8cf6f1734398: Refactored gtk...

Ankit Vani a at nevitus.org
Thu Aug 1 17:43:06 EDT 2013


Changeset: 8cf6f1734398fde138c0b1a6b05ec7a2a2adf3da
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-02 03:12 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/8cf6f1734398

Description:

Refactored gtkdialogs to use the new API

diffstat:

 pidgin/gtkdialogs.c |  48 ++++++++++++++++++++++++++++++------------------
 1 files changed, 30 insertions(+), 18 deletions(-)

diffs (117 lines):

diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -565,6 +565,7 @@ void pidgin_dialogs_buildinfo(void)
 	GString *str;
 	char *tmp;
 	static GtkWidget *buildinfo = NULL;
+	GPluginPlugin *plugin;
 
 	if (buildinfo != NULL) {
 		gtk_window_present(GTK_WINDOW(buildinfo));
@@ -686,18 +687,23 @@ void pidgin_dialogs_buildinfo(void)
 	g_string_append(str, "<dt>Network Security Services (NSS):</dt><dd>Disabled</dd>");
 #endif
 
-	if (purple_plugins_find_with_id("core-perl") != NULL)
+	plugin = gplugin_plugin_manager_find_plugin("core-perl");
+	if (plugin != NULL) {
 		g_string_append(str, "<dt>Perl:</dt><dd>Enabled</dd>");
-	else
+		g_object_unref(plugin);
+	} else {
 		g_string_append(str, "<dt>Perl:</dt><dd>Disabled</dd>");
+	}
 
-	if (purple_plugins_find_with_id("core-tcl") != NULL) {
+	plugin = gplugin_plugin_manager_find_plugin("core-tcl");
+	if (plugin != NULL) {
 		g_string_append(str, "<dt>Tcl:</dt><dd>Enabled</dd>");
 #ifdef HAVE_TK
 		g_string_append(str, "<dt>Tk:</dt><dd>Enabled</dd>");
 #else
 		g_string_append(str, "<dt>Tk:</dt><dd>Disabled</dd>");
 #endif
+		g_object_unref(plugin);
 	} else {
 		g_string_append(str, "<dt>Tcl:</dt><dd>Disabled</dd>");
 		g_string_append(str, "<dt>Tk:</dt><dd>Disabled</dd>");
@@ -828,28 +834,32 @@ void pidgin_dialogs_translators(void)
 void pidgin_dialogs_plugins_info(void)
 {
 	GString *str;
-	GList *l = NULL;
-	PurplePlugin *plugin = NULL;
+	GList *plugins, *l = NULL;
+	GPluginPlugin *plugin = NULL;
+	GPluginPluginInfo *info;
 	char *title = g_strdup_printf(_("%s Plugin Information"), PIDGIN_NAME);
 	char *pname = NULL, *pauthor = NULL;
 	const char *pver, *pwebsite, *pid;
-	gboolean ploaded, punloadable;
+	gboolean ploaded, ploadable;
 	static GtkWidget *plugins_info = NULL;
 
 	str = g_string_sized_new(4096);
 
 	g_string_append_printf(str, "<h2>%s</h2><dl>", _("Plugin Information"));
 
-	for(l = purple_plugins_get_all(); l; l = l->next) {
-		plugin = (PurplePlugin *)l->data;
+	plugins = purple_plugins_find_all();
 
-		pname = g_markup_escape_text(purple_plugin_get_name(plugin), -1);
-		if ((pauthor = (char *)purple_plugin_get_author(plugin)) != NULL)
+	for(l = plugins; l; l = l->next) {
+		plugin = GPLUGIN_PLUGIN(l->data);
+		info = gplugin_plugin_get_info(plugin);
+
+		pname = g_markup_escape_text(gplugin_plugin_info_get_name(info), -1);
+		if ((pauthor = (char *)gplugin_plugin_info_get_author(info)) != NULL)
 			pauthor = g_markup_escape_text(pauthor, -1);
-		pver = purple_plugin_get_version(plugin);
-		pwebsite = purple_plugin_get_homepage(plugin);
-		pid = purple_plugin_get_id(plugin);
-		punloadable = purple_plugin_is_unloadable(plugin);
+		pver = gplugin_plugin_info_get_version(info);
+		pwebsite = gplugin_plugin_info_get_website(info);
+		pid = gplugin_plugin_info_get_id(info);
+		ploadable = purple_plugin_info_is_loadable(PURPLE_PLUGIN_INFO(info));
 		ploaded = purple_plugin_is_loaded(plugin);
 
 		g_string_append_printf(str,
@@ -863,12 +873,14 @@ void pidgin_dialogs_plugins_info(void)
 				"</dd><br/>",
 				pname, pauthor ? pauthor : "(null)",
 				pver, pwebsite, pid,
-				punloadable ? "<span style=\"color: #FF0000;\"><b>No</b></span>" : "Yes",
+				ploadable ? "Yes" : "<span style=\"color: #FF0000;\"><b>No</b></span>",
 				ploaded ? "Yes" : "No");
 
 		g_free(pname);
 		g_free(pauthor);
+		g_object_unref(info);
 	}
+	purple_plugins_free_found_list(plugins);
 
 	g_string_append(str, "</dl>");
 
@@ -896,15 +908,15 @@ pidgin_dialogs_im_name_validator(PurpleR
 {
 	PurpleRequestFields *fields = _fields;
 	PurpleAccount *account;
-	PurplePlugin *prpl;
+	PurplePluginProtocolInfo *prpl_info;
 	const char *username;
 	gboolean valid;
 
 	account = purple_request_fields_get_account(fields, "account");
-	prpl = purple_find_protocol_info(purple_account_get_protocol_id(account));
+	prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(account));
 	username = purple_request_fields_get_string(fields, "screenname");
 
-	valid = purple_validate(prpl, username);
+	valid = purple_validate(prpl_info, username);
 
 	if (errmsg && !valid)
 		*errmsg = g_strdup(_("Invalid username"));



More information about the Commits mailing list