Mercurial > pidgin.yaz
comparison finch/gntplugin.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 0e3a8505ebbe |
children | 66dff3dfdea6 |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
1 /** | 1 /** |
2 * @file gntplugin.c GNT Plugins API | 2 * @file gntplugin.c GNT Plugins API |
3 * @ingroup gntui | 3 * @ingroup gntui |
4 * | 4 * |
5 * gaim | 5 * purple |
6 * | 6 * |
7 * Gaim is the legal property of its developers, whose names are too numerous | 7 * Purple is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
9 * source distribution. | 9 * source distribution. |
10 * | 10 * |
11 * This program is free software; you can redistribute it and/or modify | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | 12 * it under the terms of the GNU General Public License as published by |
29 #include <gntline.h> | 29 #include <gntline.h> |
30 #include <gnttree.h> | 30 #include <gnttree.h> |
31 | 31 |
32 #include "notify.h" | 32 #include "notify.h" |
33 | 33 |
34 #include "gntgaim.h" | 34 #include "finch.h" |
35 #include "gntplugin.h" | 35 #include "gntplugin.h" |
36 | 36 |
37 static struct | 37 static struct |
38 { | 38 { |
39 GntWidget *tree; | 39 GntWidget *tree; |
43 } plugins; | 43 } plugins; |
44 | 44 |
45 static GHashTable *confwins; | 45 static GHashTable *confwins; |
46 | 46 |
47 static void | 47 static void |
48 decide_conf_button(GaimPlugin *plugin) | 48 decide_conf_button(PurplePlugin *plugin) |
49 { | 49 { |
50 if (gaim_plugin_is_loaded(plugin) && | 50 if (purple_plugin_is_loaded(plugin) && |
51 ((GAIM_IS_GNT_PLUGIN(plugin) && | 51 ((PURPLE_IS_GNT_PLUGIN(plugin) && |
52 GAIM_GNT_PLUGIN_UI_INFO(plugin) != NULL) || | 52 FINCH_PLUGIN_UI_INFO(plugin) != NULL) || |
53 (plugin->info->prefs_info && | 53 (plugin->info->prefs_info && |
54 plugin->info->prefs_info->get_plugin_pref_frame))) | 54 plugin->info->prefs_info->get_plugin_pref_frame))) |
55 gnt_widget_set_visible(plugins.conf, TRUE); | 55 gnt_widget_set_visible(plugins.conf, TRUE); |
56 else | 56 else |
57 gnt_widget_set_visible(plugins.conf, FALSE); | 57 gnt_widget_set_visible(plugins.conf, FALSE); |
59 gnt_box_readjust(GNT_BOX(plugins.window)); | 59 gnt_box_readjust(GNT_BOX(plugins.window)); |
60 gnt_widget_draw(plugins.window); | 60 gnt_widget_draw(plugins.window); |
61 } | 61 } |
62 | 62 |
63 static void | 63 static void |
64 plugin_toggled_cb(GntWidget *tree, GaimPlugin *plugin, gpointer null) | 64 plugin_toggled_cb(GntWidget *tree, PurplePlugin *plugin, gpointer null) |
65 { | 65 { |
66 if (gnt_tree_get_choice(GNT_TREE(tree), plugin)) | 66 if (gnt_tree_get_choice(GNT_TREE(tree), plugin)) |
67 { | 67 { |
68 if(!gaim_plugin_load(plugin)) | 68 if(!purple_plugin_load(plugin)) |
69 gaim_notify_error(NULL, "ERROR", "loading plugin failed", NULL); | 69 purple_notify_error(NULL, "ERROR", "loading plugin failed", NULL); |
70 } | 70 } |
71 else | 71 else |
72 { | 72 { |
73 GntWidget *win; | 73 GntWidget *win; |
74 | 74 |
75 if (!gaim_plugin_unload(plugin)) | 75 if (!purple_plugin_unload(plugin)) |
76 gaim_notify_error(NULL, "ERROR", "unloading plugin failed", NULL); | 76 purple_notify_error(NULL, "ERROR", "unloading plugin failed", NULL); |
77 | 77 |
78 if ((win = g_hash_table_lookup(confwins, plugin)) != NULL) | 78 if ((win = g_hash_table_lookup(confwins, plugin)) != NULL) |
79 { | 79 { |
80 gnt_widget_destroy(win); | 80 gnt_widget_destroy(win); |
81 } | 81 } |
86 | 86 |
87 /* Xerox */ | 87 /* Xerox */ |
88 void | 88 void |
89 finch_plugins_save_loaded(void) | 89 finch_plugins_save_loaded(void) |
90 { | 90 { |
91 gaim_plugins_save_loaded("/gaim/gnt/plugins/loaded"); | 91 purple_plugins_save_loaded("/purple/gnt/plugins/loaded"); |
92 } | 92 } |
93 | 93 |
94 static void | 94 static void |
95 selection_changed(GntWidget *widget, gpointer old, gpointer current, gpointer null) | 95 selection_changed(GntWidget *widget, gpointer old, gpointer current, gpointer null) |
96 { | 96 { |
97 GaimPlugin *plugin = current; | 97 PurplePlugin *plugin = current; |
98 char *text; | 98 char *text; |
99 | 99 |
100 /* XXX: Use formatting and stuff */ | 100 /* XXX: Use formatting and stuff */ |
101 gnt_text_view_clear(GNT_TEXT_VIEW(plugins.aboot)); | 101 gnt_text_view_clear(GNT_TEXT_VIEW(plugins.aboot)); |
102 text = g_strdup_printf(_("Name: %s\nVersion: %s\nDescription: %s\nAuthor: %s\nWebsite: %s\nFilename: %s\n"), | 102 text = g_strdup_printf(_("Name: %s\nVersion: %s\nDescription: %s\nAuthor: %s\nWebsite: %s\nFilename: %s\n"), |
116 plugins.tree = NULL; | 116 plugins.tree = NULL; |
117 plugins.aboot = NULL; | 117 plugins.aboot = NULL; |
118 } | 118 } |
119 | 119 |
120 static int | 120 static int |
121 plugin_compare(GaimPlugin *p1, GaimPlugin *p2) | 121 plugin_compare(PurplePlugin *p1, PurplePlugin *p2) |
122 { | 122 { |
123 char *s1 = g_utf8_strup(p1->info->name, -1); | 123 char *s1 = g_utf8_strup(p1->info->name, -1); |
124 char *s2 = g_utf8_strup(p2->info->name, -1); | 124 char *s2 = g_utf8_strup(p2->info->name, -1); |
125 int ret = g_utf8_collate(s1, s2); | 125 int ret = g_utf8_collate(s1, s2); |
126 g_free(s1); | 126 g_free(s1); |
141 } | 141 } |
142 | 142 |
143 static void | 143 static void |
144 configure_plugin_cb(GntWidget *button, gpointer null) | 144 configure_plugin_cb(GntWidget *button, gpointer null) |
145 { | 145 { |
146 GaimPlugin *plugin; | 146 PurplePlugin *plugin; |
147 FinchPluginFrame callback; | 147 FinchPluginFrame callback; |
148 | 148 |
149 g_return_if_fail(plugins.tree != NULL); | 149 g_return_if_fail(plugins.tree != NULL); |
150 | 150 |
151 plugin = gnt_tree_get_selection_data(GNT_TREE(plugins.tree)); | 151 plugin = gnt_tree_get_selection_data(GNT_TREE(plugins.tree)); |
152 if (!gaim_plugin_is_loaded(plugin)) | 152 if (!purple_plugin_is_loaded(plugin)) |
153 { | 153 { |
154 gaim_notify_error(plugin, _("Error"), | 154 purple_notify_error(plugin, _("Error"), |
155 _("Plugin need to be loaded before you can configure it."), NULL); | 155 _("Plugin need to be loaded before you can configure it."), NULL); |
156 return; | 156 return; |
157 } | 157 } |
158 | 158 |
159 if (confwins && g_hash_table_lookup(confwins, plugin)) | 159 if (confwins && g_hash_table_lookup(confwins, plugin)) |
160 return; | 160 return; |
161 | 161 |
162 if (GAIM_IS_GNT_PLUGIN(plugin) && | 162 if (PURPLE_IS_GNT_PLUGIN(plugin) && |
163 (callback = GAIM_GNT_PLUGIN_UI_INFO(plugin)) != NULL) | 163 (callback = FINCH_PLUGIN_UI_INFO(plugin)) != NULL) |
164 { | 164 { |
165 GntWidget *window = gnt_vbox_new(FALSE); | 165 GntWidget *window = gnt_vbox_new(FALSE); |
166 GntWidget *box, *button; | 166 GntWidget *box, *button; |
167 | 167 |
168 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | 168 gnt_box_set_toplevel(GNT_BOX(window), TRUE); |
188 g_hash_table_insert(confwins, plugin, window); | 188 g_hash_table_insert(confwins, plugin, window); |
189 } | 189 } |
190 else if (plugin->info->prefs_info && | 190 else if (plugin->info->prefs_info && |
191 plugin->info->prefs_info->get_plugin_pref_frame) | 191 plugin->info->prefs_info->get_plugin_pref_frame) |
192 { | 192 { |
193 gaim_notify_info(plugin, _("..."), | 193 purple_notify_info(plugin, _("..."), |
194 _("Still need to do something about this."), NULL); | 194 _("Still need to do something about this."), NULL); |
195 return; | 195 return; |
196 } | 196 } |
197 else | 197 else |
198 { | 198 { |
199 gaim_notify_info(plugin, _("Error"), | 199 purple_notify_info(plugin, _("Error"), |
200 _("No configuration options for this plugin."), NULL); | 200 _("No configuration options for this plugin."), NULL); |
201 return; | 201 return; |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
207 GntWidget *window, *tree, *box, *aboot, *button; | 207 GntWidget *window, *tree, *box, *aboot, *button; |
208 GList *iter; | 208 GList *iter; |
209 if (plugins.window) | 209 if (plugins.window) |
210 return; | 210 return; |
211 | 211 |
212 gaim_plugins_probe(G_MODULE_SUFFIX); | 212 purple_plugins_probe(G_MODULE_SUFFIX); |
213 | 213 |
214 plugins.window = window = gnt_vbox_new(FALSE); | 214 plugins.window = window = gnt_vbox_new(FALSE); |
215 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | 215 gnt_box_set_toplevel(GNT_BOX(window), TRUE); |
216 gnt_box_set_title(GNT_BOX(window), _("Plugins")); | 216 gnt_box_set_title(GNT_BOX(window), _("Plugins")); |
217 gnt_box_set_pad(GNT_BOX(window), 0); | 217 gnt_box_set_pad(GNT_BOX(window), 0); |
234 | 234 |
235 plugins.aboot = aboot = gnt_text_view_new(); | 235 plugins.aboot = aboot = gnt_text_view_new(); |
236 gnt_widget_set_size(aboot, 40, 20); | 236 gnt_widget_set_size(aboot, 40, 20); |
237 gnt_box_add_widget(GNT_BOX(box), aboot); | 237 gnt_box_add_widget(GNT_BOX(box), aboot); |
238 | 238 |
239 for (iter = gaim_plugins_get_all(); iter; iter = iter->next) | 239 for (iter = purple_plugins_get_all(); iter; iter = iter->next) |
240 { | 240 { |
241 GaimPlugin *plug = iter->data; | 241 PurplePlugin *plug = iter->data; |
242 | 242 |
243 if (plug->info->type != GAIM_PLUGIN_STANDARD || | 243 if (plug->info->type != PURPLE_PLUGIN_STANDARD || |
244 (plug->info->flags & GAIM_PLUGIN_FLAG_INVISIBLE) || | 244 (plug->info->flags & PURPLE_PLUGIN_FLAG_INVISIBLE) || |
245 plug->error) | 245 plug->error) |
246 continue; | 246 continue; |
247 | 247 |
248 gnt_tree_add_choice(GNT_TREE(tree), plug, | 248 gnt_tree_add_choice(GNT_TREE(tree), plug, |
249 gnt_tree_create_row(GNT_TREE(tree), plug->info->name), NULL, NULL); | 249 gnt_tree_create_row(GNT_TREE(tree), plug->info->name), NULL, NULL); |
250 gnt_tree_set_choice(GNT_TREE(tree), plug, gaim_plugin_is_loaded(plug)); | 250 gnt_tree_set_choice(GNT_TREE(tree), plug, purple_plugin_is_loaded(plug)); |
251 } | 251 } |
252 gnt_tree_set_col_width(GNT_TREE(tree), 0, 30); | 252 gnt_tree_set_col_width(GNT_TREE(tree), 0, 30); |
253 g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(plugin_toggled_cb), NULL); | 253 g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(plugin_toggled_cb), NULL); |
254 g_signal_connect(G_OBJECT(tree), "selection_changed", G_CALLBACK(selection_changed), NULL); | 254 g_signal_connect(G_OBJECT(tree), "selection_changed", G_CALLBACK(selection_changed), NULL); |
255 | 255 |