/soc/2013/ankitkv/gobjectification: c726e758c59b: Refactored fin...
Ankit Vani
a at nevitus.org
Mon Sep 16 13:23:55 EDT 2013
Changeset: c726e758c59b337e8fbed6e692607b4d29d444a8
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-16 22:53 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/c726e758c59b
Description:
Refactored finch grouping plugin to use the new plugin API
diffstat:
finch/plugins/grouping.c | 109 ++++++++++++++++++----------------------------
1 files changed, 44 insertions(+), 65 deletions(-)
diffs (152 lines):
diff --git a/finch/plugins/grouping.c b/finch/plugins/grouping.c
--- a/finch/plugins/grouping.c
+++ b/finch/plugins/grouping.c
@@ -17,9 +17,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
-
-#define PURPLE_PLUGIN
-
#include "internal.h"
#include "purple.h"
@@ -45,32 +42,19 @@ static FinchBlistManager *default_manage
/**
* GObject code
*/
-static GType
-finch_grouping_node_get_type(void)
+static void
+finch_grouping_node_init(FinchGroupingNode *node)
{
- static GType type = 0;
+}
- if(type == 0) {
- static const GTypeInfo info = {
- sizeof(FinchGroupingNodeClass),
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- sizeof(FinchGroupingNode),
- 0,
- NULL,
- NULL,
- };
+static void
+finch_grouping_node_class_init(FinchGroupingNodeClass *klass)
+{
+}
- type = g_type_register_static(PURPLE_TYPE_BLIST_NODE,
- "FinchGroupingNode",
- &info, 0);
- }
-
- return type;
-}
+GType finch_grouping_node_get_type(void);
+PURPLE_DEFINE_TYPE(FinchGroupingNode, finch_grouping_node,
+ PURPLE_TYPE_BLIST_NODE);
/**
* Online/Offline
@@ -351,11 +335,38 @@ static FinchBlistManager nested_group =
.can_add_node = nested_group_can_add_node,
};
+static FinchPluginInfo *
+plugin_query(GError **error)
+{
+ const gchar * const authors[] = {
+ "Sadrul H Chowdhury <sadrul at users.sourceforge.net>",
+ NULL
+ };
+
+ return finch_plugin_info_new(
+ "id", "grouping",
+ "name", N_("Grouping"),
+ "version", VERSION,
+ "category", N_("User interface"),
+ "summary", N_("Provides alternate buddylist grouping options."),
+ "description", N_("Provides alternate buddylist grouping options."),
+ "authors", authors,
+ "website", PURPLE_WEBSITE,
+ "abi-version", PURPLE_ABI_VERSION,
+ NULL
+ );
+}
+
static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
{
+ finch_grouping_node_register_type(plugin);
+
default_manager = finch_blist_manager_find("default");
+ online = g_object_new(FINCH_TYPE_GROUPING_NODE, NULL);
+ offline = g_object_new(FINCH_TYPE_GROUPING_NODE, NULL);
+
finch_blist_install_manager(&on_offline);
finch_blist_install_manager(&meebo_group);
finch_blist_install_manager(&no_group);
@@ -364,49 +375,17 @@ plugin_load(PurplePlugin *plugin)
}
static gboolean
-plugin_unload(PurplePlugin *plugin)
+plugin_unload(PurplePlugin *plugin, GError **error)
{
finch_blist_uninstall_manager(&on_offline);
finch_blist_uninstall_manager(&meebo_group);
finch_blist_uninstall_manager(&no_group);
finch_blist_uninstall_manager(&nested_group);
+
+ g_object_unref(online);
+ g_object_unref(offline);
+
return TRUE;
}
-static PurplePluginInfo info =
-{
- PURPLE_PLUGIN_MAGIC,
- PURPLE_MAJOR_VERSION,
- PURPLE_MINOR_VERSION,
- PURPLE_PLUGIN_STANDARD,
- FINCH_PLUGIN_TYPE,
- 0,
- NULL,
- PURPLE_PRIORITY_DEFAULT,
- "grouping",
- N_("Grouping"),
- VERSION,
- N_("Provides alternate buddylist grouping options."),
- N_("Provides alternate buddylist grouping options."),
- "Sadrul H Chowdhury <sadrul at users.sourceforge.net>",
- PURPLE_WEBSITE,
- plugin_load,
- plugin_unload,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,NULL,NULL,NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
-{
- online = g_object_new(FINCH_TYPE_GROUPING_NODE, NULL);
- offline = g_object_new(FINCH_TYPE_GROUPING_NODE, NULL);
-}
-
-PURPLE_INIT_PLUGIN(grouping, init_plugin, info)
-
-
+PURPLE_PLUGIN_INIT(grouping, plugin_query, plugin_load, plugin_unload);
More information about the Commits
mailing list