Wed, 02 Jan 2008 12:04:27 +0000
Modified patch from Gabriel (Sylar?) Schulof to deprecate PIDGIN_DIALOG. Closes #4535. (PS: I am aware of --author).
| 5205 | 1 | /** |
|
6927
528988ef2781
[gaim-migrate @ 7474]
Christian Hammond <chipx86@chipx86.com>
parents:
5982
diff
changeset
|
2 | * @file gtkplugin.c GTK+ Plugins support |
|
16254
eeb2bba4dc94
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents:
16123
diff
changeset
|
3 | * @ingroup pidgin |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* pidgin |
| 5205 | 7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
8 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
|
6927
528988ef2781
[gaim-migrate @ 7474]
Christian Hammond <chipx86@chipx86.com>
parents:
5982
diff
changeset
|
11 | * |
| 5205 | 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19733
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 5205 | 25 | */ |
| 11740 | 26 | #include "internal.h" |
| 15577 | 27 | #include "pidgin.h" |
| 5205 | 28 | #include "gtkplugin.h" |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
29 | #include "gtkpluginpref.h" |
|
13436
b80f8990bc67
[gaim-migrate @ 15810]
Richard Laager <rlaager@pidgin.im>
parents:
13435
diff
changeset
|
30 | #include "gtkutils.h" |
|
5981
c91ece01ad12
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
31 | #include "debug.h" |
|
c91ece01ad12
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
32 | #include "prefs.h" |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
33 | #include "request.h" |
|
22065
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
34 | #include "pidgintooltip.h" |
|
5981
c91ece01ad12
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
35 | |
| 5205 | 36 | #include <string.h> |
| 37 | ||
|
15880
d275b025481c
More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents:
15692
diff
changeset
|
38 | #define PIDGIN_RESPONSE_CONFIGURE 98121 |
|
12246
7af1ef3b1cc4
[gaim-migrate @ 14548]
Mark Doliner <markdoliner@pidgin.im>
parents:
12240
diff
changeset
|
39 | |
| 15884 | 40 | static void plugin_toggled_stage_two(PurplePlugin *plug, GtkTreeModel *model, |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
41 | GtkTreeIter *iter, gboolean unload); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
42 | |
|
12343
0ede7c5a9465
[gaim-migrate @ 14647]
Mark Doliner <markdoliner@pidgin.im>
parents:
12290
diff
changeset
|
43 | static GtkWidget *expander = NULL; |
| 11740 | 44 | static GtkWidget *plugin_dialog = NULL; |
| 45 | static GtkWidget *plugin_details = NULL; | |
| 46 | static GtkWidget *pref_button = NULL; | |
| 11781 | 47 | static GHashTable *plugin_pref_dialogs = NULL; |
| 11747 | 48 | |
| 5205 | 49 | GtkWidget * |
| 15884 | 50 | pidgin_plugin_get_config_frame(PurplePlugin *plugin) |
| 5205 | 51 | { |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
52 | GtkWidget *config = NULL; |
| 5205 | 53 | |
| 54 | g_return_val_if_fail(plugin != NULL, NULL); | |
| 55 | ||
|
15692
ecda27df58b9
Some more pidgininfication
Daniel Atallah <datallah@pidgin.im>
parents:
15577
diff
changeset
|
56 | if (PIDGIN_IS_PIDGIN_PLUGIN(plugin) && plugin->info->ui_info |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
57 | && PIDGIN_PLUGIN_UI_INFO(plugin)->get_config_frame) |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
58 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
59 | PidginPluginUiInfo *ui_info; |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
60 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
61 | ui_info = PIDGIN_PLUGIN_UI_INFO(plugin); |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
62 | |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
63 | config = ui_info->get_config_frame(plugin); |
| 5205 | 64 | |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
65 | if (plugin->info->prefs_info |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
66 | && plugin->info->prefs_info->get_plugin_pref_frame) |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
67 | { |
| 15884 | 68 | purple_debug_warning("gtkplugin", |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
69 | "Plugin %s contains both, ui_info and " |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
70 | "prefs_info preferences; prefs_info will be " |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
71 | "ignored.", plugin->info->name); |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
72 | } |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
73 | } |
| 5205 | 74 | |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
75 | if (config == NULL && plugin->info->prefs_info |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
76 | && plugin->info->prefs_info->get_plugin_pref_frame) |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
77 | { |
| 15884 | 78 | PurplePluginPrefFrame *frame; |
| 5205 | 79 | |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
80 | frame = plugin->info->prefs_info->get_plugin_pref_frame(plugin); |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
81 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
82 | config = pidgin_plugin_pref_create_frame(frame); |
| 12870 | 83 | |
| 12889 | 84 | /* XXX According to bug #1407047 this broke saving pluging preferences, I'll look at fixing it correctly later. |
| 15884 | 85 | purple_plugin_pref_frame_destroy(frame); |
| 12889 | 86 | */ |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
87 | } |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
88 | |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
89 | return config; |
| 5205 | 90 | } |
|
5981
c91ece01ad12
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
91 | |
|
c91ece01ad12
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
92 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
93 | pidgin_plugins_save(void) |
|
5981
c91ece01ad12
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
94 | { |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
95 | purple_plugins_save_loaded(PIDGIN_PREFS_ROOT "/plugins/loaded"); |
|
5981
c91ece01ad12
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
96 | } |
| 11740 | 97 | |
| 98 | static void | |
| 99 | update_plugin_list(void *data) | |
| 100 | { | |
| 101 | GtkListStore *ls = GTK_LIST_STORE(data); | |
| 102 | GtkTreeIter iter; | |
| 103 | GList *probes; | |
| 15884 | 104 | PurplePlugin *plug; |
| 11740 | 105 | |
| 106 | gtk_list_store_clear(ls); | |
| 15884 | 107 | purple_plugins_probe(G_MODULE_SUFFIX); |
| 11740 | 108 | |
| 15884 | 109 | for (probes = purple_plugins_get_all(); |
| 11740 | 110 | probes != NULL; |
| 111 | probes = probes->next) | |
| 112 | { | |
|
12702
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
113 | char *name; |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
114 | char *version; |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
115 | char *summary; |
| 11740 | 116 | char *desc; |
| 117 | plug = probes->data; | |
| 118 | ||
| 15884 | 119 | if (plug->info->type == PURPLE_PLUGIN_LOADER) { |
|
15336
a2454071e986
[gaim-migrate @ 18064]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15177
diff
changeset
|
120 | GList *cur; |
| 15884 | 121 | for (cur = PURPLE_PLUGIN_LOADER_INFO(plug)->exts; cur != NULL; |
|
15336
a2454071e986
[gaim-migrate @ 18064]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15177
diff
changeset
|
122 | cur = cur->next) |
| 15884 | 123 | purple_plugins_probe(cur->data); |
|
15336
a2454071e986
[gaim-migrate @ 18064]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15177
diff
changeset
|
124 | continue; |
| 15884 | 125 | } else if (plug->info->type != PURPLE_PLUGIN_STANDARD || |
| 126 | (plug->info->flags & PURPLE_PLUGIN_FLAG_INVISIBLE)) { | |
| 11740 | 127 | continue; |
| 128 | } | |
| 129 | ||
| 130 | gtk_list_store_append (ls, &iter); | |
|
12702
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
131 | |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
132 | name = g_markup_escape_text(plug->info->name ? _(plug->info->name) : g_basename(plug->path), -1); |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
133 | version = g_markup_escape_text(plug->info->version, -1); |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
134 | summary = g_markup_escape_text(_(plug->info->summary), -1); |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
135 | |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
136 | desc = g_strdup_printf("<b>%s</b> %s\n%s", name, |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
137 | version, |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
138 | summary); |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
139 | g_free(name); |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
140 | g_free(version); |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
141 | g_free(summary); |
|
fbd3bef47358
[gaim-migrate @ 15045]
Richard Laager <rlaager@pidgin.im>
parents:
12695
diff
changeset
|
142 | |
| 11740 | 143 | gtk_list_store_set(ls, &iter, |
| 15884 | 144 | 0, purple_plugin_is_loaded(plug), |
| 11740 | 145 | 1, desc, |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
146 | 2, plug, |
| 15884 | 147 | 3, purple_plugin_is_unloadable(plug), |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
148 | -1); |
| 11740 | 149 | g_free(desc); |
| 150 | } | |
| 151 | } | |
| 152 | ||
| 15884 | 153 | static void plugin_loading_common(PurplePlugin *plugin, GtkTreeView *view, gboolean loaded) |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
154 | { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
155 | GtkTreeIter iter; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
156 | GtkTreeModel *model = gtk_tree_view_get_model(view); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
157 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
158 | if (gtk_tree_model_get_iter_first(model, &iter)) { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
159 | do { |
| 15884 | 160 | PurplePlugin *plug; |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
161 | GtkTreeSelection *sel; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
162 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
163 | gtk_tree_model_get(model, &iter, 2, &plug, -1); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
164 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
165 | if (plug != plugin) |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
166 | continue; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
167 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
168 | gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, loaded, -1); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
169 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
170 | /* If the loaded/unloaded plugin is the selected row, |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
171 | * update the pref_button. */ |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
172 | sel = gtk_tree_view_get_selection(view); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
173 | if (gtk_tree_selection_get_selected(sel, &model, &iter)) |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
174 | { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
175 | gtk_tree_model_get(model, &iter, 2, &plug, -1); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
176 | if (plug == plugin) |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
177 | { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
178 | gtk_widget_set_sensitive(pref_button, |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
179 | loaded |
|
15692
ecda27df58b9
Some more pidgininfication
Daniel Atallah <datallah@pidgin.im>
parents:
15577
diff
changeset
|
180 | && ((PIDGIN_IS_PIDGIN_PLUGIN(plug) && plug->info->ui_info |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
181 | && PIDGIN_PLUGIN_UI_INFO(plug)->get_config_frame) |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
182 | || (plug->info->prefs_info |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
183 | && plug->info->prefs_info->get_plugin_pref_frame))); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
184 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
185 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
186 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
187 | break; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
188 | } while (gtk_tree_model_iter_next(model, &iter)); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
189 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
190 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
191 | |
| 15884 | 192 | static void plugin_load_cb(PurplePlugin *plugin, gpointer data) |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
193 | { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
194 | GtkTreeView *view = (GtkTreeView *)data; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
195 | plugin_loading_common(plugin, view, TRUE); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
196 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
197 | |
| 15884 | 198 | static void plugin_unload_cb(PurplePlugin *plugin, gpointer data) |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
199 | { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
200 | GtkTreeView *view = (GtkTreeView *)data; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
201 | plugin_loading_common(plugin, view, FALSE); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
202 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
203 | |
| 15884 | 204 | static void pref_dialog_response_cb(GtkWidget *d, int response, PurplePlugin *plug) |
| 11781 | 205 | { |
| 206 | switch (response) { | |
| 207 | case GTK_RESPONSE_CLOSE: | |
| 208 | case GTK_RESPONSE_DELETE_EVENT: | |
| 209 | g_hash_table_remove(plugin_pref_dialogs, plug); | |
| 210 | if (g_hash_table_size(plugin_pref_dialogs) == 0) { | |
| 211 | g_hash_table_destroy(plugin_pref_dialogs); | |
| 212 | plugin_pref_dialogs = NULL; | |
| 213 | } | |
| 214 | gtk_widget_destroy(d); | |
| 215 | break; | |
| 216 | } | |
| 217 | } | |
| 218 | ||
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
219 | static void plugin_unload_confirm_cb(gpointer *data) |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
220 | { |
| 15884 | 221 | PurplePlugin *plugin = (PurplePlugin *)data[0]; |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
222 | GtkTreeModel *model = (GtkTreeModel *)data[1]; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
223 | GtkTreeIter *iter = (GtkTreeIter *)data[2]; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
224 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
225 | plugin_toggled_stage_two(plugin, model, iter, TRUE); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
226 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
227 | g_free(data); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
228 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
229 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
230 | static void plugin_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer data) |
| 11740 | 231 | { |
| 232 | GtkTreeModel *model = (GtkTreeModel *)data; | |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
233 | GtkTreeIter *iter = g_new(GtkTreeIter, 1); |
| 11740 | 234 | GtkTreePath *path = gtk_tree_path_new_from_string(pth); |
| 15884 | 235 | PurplePlugin *plug; |
| 11781 | 236 | GtkWidget *dialog = NULL; |
| 11740 | 237 | |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
238 | gtk_tree_model_get_iter(model, iter, path); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
239 | gtk_tree_path_free(path); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
240 | gtk_tree_model_get(model, iter, 2, &plug, -1); |
| 11740 | 241 | |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
242 | /* Apparently, GTK+ won't honor the sensitive flag on cell renderers for booleans. */ |
| 15884 | 243 | if (purple_plugin_is_unloadable(plug)) |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
244 | { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
245 | g_free(iter); |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
246 | return; |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
247 | } |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
248 | |
| 15884 | 249 | if (!purple_plugin_is_loaded(plug)) |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
250 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
251 | pidgin_set_cursor(plugin_dialog, GDK_WATCH); |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
252 | |
| 15884 | 253 | purple_plugin_load(plug); |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
254 | plugin_toggled_stage_two(plug, model, iter, FALSE); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
255 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
256 | pidgin_clear_cursor(plugin_dialog); |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
257 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
258 | else |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
259 | { |
| 11781 | 260 | if (plugin_pref_dialogs != NULL && |
| 261 | (dialog = g_hash_table_lookup(plugin_pref_dialogs, plug))) | |
| 262 | pref_dialog_response_cb(dialog, GTK_RESPONSE_DELETE_EVENT, plug); | |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
263 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
264 | if (plug->dependent_plugins != NULL) |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
265 | { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
266 | GString *tmp = g_string_new(_("The following plugins will be unloaded.")); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
267 | GList *l; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
268 | gpointer *cb_data; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
269 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
270 | for (l = plug->dependent_plugins ; l != NULL ; l = l->next) |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
271 | { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
272 | const char *dep_name = (const char *)l->data; |
| 15884 | 273 | PurplePlugin *dep_plugin = purple_plugins_find_with_id(dep_name); |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
274 | g_return_if_fail(dep_plugin != NULL); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
275 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
276 | g_string_append_printf(tmp, "\n\t%s\n", _(dep_plugin->info->name)); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
277 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
278 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
279 | cb_data = g_new(gpointer, 3); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
280 | cb_data[0] = plug; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
281 | cb_data[1] = model; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
282 | cb_data[2] = iter; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
283 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
284 | purple_request_action(plugin_dialog, NULL, |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
285 | _("Multiple plugins will be unloaded."), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16254
diff
changeset
|
286 | tmp->str, 0, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
287 | NULL, NULL, NULL, |
|
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
288 | cb_data, 2, |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
289 | _("Unload Plugins"), G_CALLBACK(plugin_unload_confirm_cb), |
|
13378
973e8b2b2c88
[gaim-migrate @ 15750]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12927
diff
changeset
|
290 | _("Cancel"), g_free); |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
291 | g_string_free(tmp, TRUE); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
292 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
293 | else |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
294 | plugin_toggled_stage_two(plug, model, iter, TRUE); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
295 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
296 | } |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
297 | |
| 15884 | 298 | static void plugin_toggled_stage_two(PurplePlugin *plug, GtkTreeModel *model, GtkTreeIter *iter, gboolean unload) |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
299 | { |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
300 | gchar *name = NULL; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
301 | gchar *description = NULL; |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
302 | |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
303 | if (unload) |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
304 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
305 | pidgin_set_cursor(plugin_dialog, GDK_WATCH); |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
306 | |
|
20872
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
307 | if (!purple_plugin_unload(plug)) |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
308 | { |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
309 | const char *primary = _("Could not unload plugin"); |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
310 | const char *reload = _("The plugin could not be unloaded now, but will be disabled at the next startup."); |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
311 | |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
312 | if (!plug->error) |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
313 | { |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
314 | purple_notify_warning(NULL, NULL, primary, reload); |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
315 | } |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
316 | else |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
317 | { |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
318 | char *tmp = g_strdup_printf("%s\n\n%s", reload, plug->error); |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
319 | purple_notify_warning(NULL, NULL, primary, tmp); |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
320 | g_free(tmp); |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
321 | } |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
322 | |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
323 | purple_plugin_disable(plug); |
|
fc317689cfef
Use the new purple_plugin_disable() function and purple_plugin_unload()'s
Richard Laager <rlaager@pidgin.im>
parents:
20147
diff
changeset
|
324 | } |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
325 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
326 | pidgin_clear_cursor(plugin_dialog); |
| 11781 | 327 | } |
| 11740 | 328 | |
| 11781 | 329 | gtk_widget_set_sensitive(pref_button, |
| 15884 | 330 | purple_plugin_is_loaded(plug) |
|
15692
ecda27df58b9
Some more pidgininfication
Daniel Atallah <datallah@pidgin.im>
parents:
15577
diff
changeset
|
331 | && ((PIDGIN_IS_PIDGIN_PLUGIN(plug) && plug->info->ui_info |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
332 | && PIDGIN_PLUGIN_UI_INFO(plug)->get_config_frame) |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
333 | || (plug->info->prefs_info |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
334 | && plug->info->prefs_info->get_plugin_pref_frame))); |
| 11740 | 335 | |
| 336 | name = g_markup_escape_text(_(plug->info->name), -1); | |
| 337 | description = g_markup_escape_text(_(plug->info->description), -1); | |
| 11781 | 338 | |
| 11740 | 339 | if (plug->error != NULL) { |
| 340 | gchar *error = g_markup_escape_text(plug->error, -1); | |
| 341 | gchar *desc; | |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
342 | gchar *text = g_strdup_printf( |
| 11740 | 343 | "<span size=\"larger\">%s %s</span>\n\n" |
| 344 | "<span weight=\"bold\" color=\"red\">%s</span>\n\n" | |
| 345 | "%s", | |
| 346 | name, plug->info->version, error, description); | |
| 347 | desc = g_strdup_printf("<b>%s</b> %s\n<span weight=\"bold\" color=\"red\"%s</span>", | |
| 348 | plug->info->name, plug->info->version, error); | |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
349 | gtk_list_store_set(GTK_LIST_STORE (model), iter, |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
350 | 1, desc, |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
351 | -1); |
| 11740 | 352 | g_free(desc); |
| 353 | g_free(error); | |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
354 | gtk_label_set_markup(GTK_LABEL(plugin_details), text); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
355 | g_free(text); |
| 11740 | 356 | } |
| 357 | g_free(name); | |
| 358 | g_free(description); | |
| 359 | ||
| 360 | ||
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
361 | gtk_list_store_set(GTK_LIST_STORE (model), iter, |
| 15884 | 362 | 0, purple_plugin_is_loaded(plug), |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
363 | -1); |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
364 | g_free(iter); |
| 11740 | 365 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
366 | pidgin_plugins_save(); |
| 11740 | 367 | } |
| 368 | ||
| 11877 | 369 | static gboolean ensure_plugin_visible(void *data) |
| 370 | { | |
| 371 | GtkTreeSelection *sel = GTK_TREE_SELECTION(data); | |
|
12246
7af1ef3b1cc4
[gaim-migrate @ 14548]
Mark Doliner <markdoliner@pidgin.im>
parents:
12240
diff
changeset
|
372 | GtkTreeView *tv = gtk_tree_selection_get_tree_view(sel); |
| 11877 | 373 | GtkTreeModel *model = gtk_tree_view_get_model(tv); |
| 374 | GtkTreePath *path; | |
| 375 | GtkTreeIter iter; | |
| 376 | if (!gtk_tree_selection_get_selected (sel, &model, &iter)) | |
| 377 | return FALSE; | |
| 378 | path = gtk_tree_model_get_path(model, &iter); | |
| 379 | gtk_tree_view_scroll_to_cell(gtk_tree_selection_get_tree_view(sel), path, NULL, FALSE, 0, 0); | |
| 380 | gtk_tree_path_free(path); | |
| 381 | return FALSE; | |
| 382 | } | |
| 383 | ||
| 11740 | 384 | static void prefs_plugin_sel (GtkTreeSelection *sel, GtkTreeModel *model) |
| 385 | { | |
| 11741 | 386 | gchar *buf, *pname, *pdesc, *pauth, *pweb; |
| 11740 | 387 | GtkTreeIter iter; |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12343
diff
changeset
|
388 | GValue val; |
| 15884 | 389 | PurplePlugin *plug; |
| 11740 | 390 | |
|
11833
119ea75db24b
[gaim-migrate @ 14124]
Mark Doliner <markdoliner@pidgin.im>
parents:
11817
diff
changeset
|
391 | if (!gtk_tree_selection_get_selected (sel, &model, &iter)) |
|
119ea75db24b
[gaim-migrate @ 14124]
Mark Doliner <markdoliner@pidgin.im>
parents:
11817
diff
changeset
|
392 | { |
|
119ea75db24b
[gaim-migrate @ 14124]
Mark Doliner <markdoliner@pidgin.im>
parents:
11817
diff
changeset
|
393 | /* Clear the old plugin details */ |
|
119ea75db24b
[gaim-migrate @ 14124]
Mark Doliner <markdoliner@pidgin.im>
parents:
11817
diff
changeset
|
394 | gtk_label_set_markup(GTK_LABEL(plugin_details), ""); |
|
119ea75db24b
[gaim-migrate @ 14124]
Mark Doliner <markdoliner@pidgin.im>
parents:
11817
diff
changeset
|
395 | gtk_widget_set_sensitive(pref_button, FALSE); |
|
12343
0ede7c5a9465
[gaim-migrate @ 14647]
Mark Doliner <markdoliner@pidgin.im>
parents:
12290
diff
changeset
|
396 | |
|
0ede7c5a9465
[gaim-migrate @ 14647]
Mark Doliner <markdoliner@pidgin.im>
parents:
12290
diff
changeset
|
397 | /* Collapse and disable the expander widget */ |
|
0ede7c5a9465
[gaim-migrate @ 14647]
Mark Doliner <markdoliner@pidgin.im>
parents:
12290
diff
changeset
|
398 | gtk_expander_set_expanded(GTK_EXPANDER(expander), FALSE); |
|
0ede7c5a9465
[gaim-migrate @ 14647]
Mark Doliner <markdoliner@pidgin.im>
parents:
12290
diff
changeset
|
399 | gtk_widget_set_sensitive(expander, FALSE); |
|
0ede7c5a9465
[gaim-migrate @ 14647]
Mark Doliner <markdoliner@pidgin.im>
parents:
12290
diff
changeset
|
400 | |
| 11740 | 401 | return; |
|
11833
119ea75db24b
[gaim-migrate @ 14124]
Mark Doliner <markdoliner@pidgin.im>
parents:
11817
diff
changeset
|
402 | } |
|
119ea75db24b
[gaim-migrate @ 14124]
Mark Doliner <markdoliner@pidgin.im>
parents:
11817
diff
changeset
|
403 | |
|
12343
0ede7c5a9465
[gaim-migrate @ 14647]
Mark Doliner <markdoliner@pidgin.im>
parents:
12290
diff
changeset
|
404 | gtk_widget_set_sensitive(expander, TRUE); |
|
0ede7c5a9465
[gaim-migrate @ 14647]
Mark Doliner <markdoliner@pidgin.im>
parents:
12290
diff
changeset
|
405 | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12343
diff
changeset
|
406 | val.g_type = 0; |
| 11740 | 407 | gtk_tree_model_get_value (model, &iter, 2, &val); |
| 408 | plug = g_value_get_pointer(&val); | |
| 409 | ||
| 410 | pname = g_markup_escape_text(_(plug->info->name), -1); | |
| 411 | pdesc = (plug->info->description) ? | |
| 412 | g_markup_escape_text(_(plug->info->description), -1) : NULL; | |
| 413 | pauth = (plug->info->author) ? | |
| 414 | g_markup_escape_text(_(plug->info->author), -1) : NULL; | |
| 415 | pweb = (plug->info->homepage) ? | |
| 416 | g_markup_escape_text(_(plug->info->homepage), -1) : NULL; | |
| 417 | buf = g_strdup_printf( | |
|
11771
7e16b808a6ee
[gaim-migrate @ 14062]
Richard Laager <rlaager@pidgin.im>
parents:
11770
diff
changeset
|
418 | _("%s%s" |
| 11740 | 419 | "<span weight=\"bold\">Written by:</span>\t%s\n" |
|
12705
7780ec726bdb
[gaim-migrate @ 15048]
Richard Laager <rlaager@pidgin.im>
parents:
12702
diff
changeset
|
420 | "<span weight=\"bold\">Website:</span>\t\t%s\n" |
|
7780ec726bdb
[gaim-migrate @ 15048]
Richard Laager <rlaager@pidgin.im>
parents:
12702
diff
changeset
|
421 | "<span weight=\"bold\">Filename:</span>\t\t%s"), |
|
11771
7e16b808a6ee
[gaim-migrate @ 14062]
Richard Laager <rlaager@pidgin.im>
parents:
11770
diff
changeset
|
422 | pdesc ? pdesc : "", pdesc ? "\n\n" : "", |
| 11740 | 423 | pauth ? pauth : "", pweb ? pweb : "", plug->path); |
| 424 | ||
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
425 | if (plug->error != NULL) |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
426 | { |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
427 | char *tmp = g_strdup_printf( |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
428 | _("%s\n" |
|
12705
7780ec726bdb
[gaim-migrate @ 15048]
Richard Laager <rlaager@pidgin.im>
parents:
12702
diff
changeset
|
429 | "<span foreground=\"#ff0000\" weight=\"bold\">" |
|
7780ec726bdb
[gaim-migrate @ 15048]
Richard Laager <rlaager@pidgin.im>
parents:
12702
diff
changeset
|
430 | "Error: %s\n" |
|
7780ec726bdb
[gaim-migrate @ 15048]
Richard Laager <rlaager@pidgin.im>
parents:
12702
diff
changeset
|
431 | "Check the plugin website for an update." |
|
7780ec726bdb
[gaim-migrate @ 15048]
Richard Laager <rlaager@pidgin.im>
parents:
12702
diff
changeset
|
432 | "</span>"), |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
433 | buf, plug->error); |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
434 | g_free(buf); |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
435 | buf = tmp; |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
436 | } |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
437 | |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
438 | gtk_widget_set_sensitive(pref_button, |
| 15884 | 439 | purple_plugin_is_loaded(plug) |
|
15692
ecda27df58b9
Some more pidgininfication
Daniel Atallah <datallah@pidgin.im>
parents:
15577
diff
changeset
|
440 | && ((PIDGIN_IS_PIDGIN_PLUGIN(plug) && plug->info->ui_info |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
441 | && PIDGIN_PLUGIN_UI_INFO(plug)->get_config_frame) |
|
11817
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
442 | || (plug->info->prefs_info |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
443 | && plug->info->prefs_info->get_plugin_pref_frame))); |
|
b8622a510778
[gaim-migrate @ 14108]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11813
diff
changeset
|
444 | |
| 11740 | 445 | gtk_label_set_markup(GTK_LABEL(plugin_details), buf); |
| 11877 | 446 | |
| 447 | /* Make sure the selected plugin is still visible */ | |
| 448 | g_idle_add(ensure_plugin_visible, sel); | |
| 449 | ||
| 450 | ||
| 11740 | 451 | g_value_unset(&val); |
| 452 | g_free(buf); | |
| 453 | g_free(pname); | |
| 454 | g_free(pdesc); | |
| 455 | g_free(pauth); | |
| 456 | g_free(pweb); | |
| 457 | } | |
| 458 | ||
| 11741 | 459 | static void plugin_dialog_response_cb(GtkWidget *d, int response, GtkTreeSelection *sel) |
| 11740 | 460 | { |
| 15884 | 461 | PurplePlugin *plug; |
| 11740 | 462 | GtkWidget *dialog, *box; |
| 463 | GtkTreeModel *model; | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12343
diff
changeset
|
464 | GValue val; |
| 11740 | 465 | GtkTreeIter iter; |
| 466 | ||
| 467 | switch (response) { | |
| 468 | case GTK_RESPONSE_CLOSE: | |
| 469 | case GTK_RESPONSE_DELETE_EVENT: | |
| 15884 | 470 | purple_request_close_with_handle(plugin_dialog); |
| 471 | purple_signals_disconnect_by_handle(plugin_dialog); | |
| 11740 | 472 | gtk_widget_destroy(d); |
|
11888
525706b75438
[gaim-migrate @ 14179]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11886
diff
changeset
|
473 | if (plugin_pref_dialogs != NULL) { |
|
525706b75438
[gaim-migrate @ 14179]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11886
diff
changeset
|
474 | g_hash_table_destroy(plugin_pref_dialogs); |
|
525706b75438
[gaim-migrate @ 14179]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11886
diff
changeset
|
475 | plugin_pref_dialogs = NULL; |
|
525706b75438
[gaim-migrate @ 14179]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11886
diff
changeset
|
476 | } |
| 11740 | 477 | plugin_dialog = NULL; |
| 478 | break; | |
|
15880
d275b025481c
More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents:
15692
diff
changeset
|
479 | case PIDGIN_RESPONSE_CONFIGURE: |
| 11740 | 480 | if (! gtk_tree_selection_get_selected (sel, &model, &iter)) |
| 481 | return; | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12343
diff
changeset
|
482 | val.g_type = 0; |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12343
diff
changeset
|
483 | gtk_tree_model_get_value(model, &iter, 2, &val); |
| 11740 | 484 | plug = g_value_get_pointer(&val); |
| 485 | if (plug == NULL) | |
| 486 | break; | |
| 11781 | 487 | if (plugin_pref_dialogs != NULL && |
| 488 | g_hash_table_lookup(plugin_pref_dialogs, plug)) | |
| 11770 | 489 | break; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
490 | box = pidgin_plugin_get_config_frame(plug); |
| 11740 | 491 | if (box == NULL) |
| 492 | break; | |
| 493 | ||
| 15882 | 494 | dialog = gtk_dialog_new_with_buttons(PIDGIN_ALERT_TITLE, GTK_WINDOW(d), |
| 11744 | 495 | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT, |
| 11740 | 496 | GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, |
| 497 | NULL); | |
| 11781 | 498 | if (plugin_pref_dialogs == NULL) |
| 499 | plugin_pref_dialogs = g_hash_table_new(NULL, NULL); | |
| 500 | ||
| 501 | g_hash_table_insert(plugin_pref_dialogs, plug, dialog); | |
| 502 | ||
| 11770 | 503 | g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(pref_dialog_response_cb), plug); |
| 11740 | 504 | gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), box); |
| 11747 | 505 | gtk_window_set_role(GTK_WINDOW(dialog), "plugin_config"); |
| 15884 | 506 | gtk_window_set_title(GTK_WINDOW(dialog), _(purple_plugin_get_name(plug))); |
| 11740 | 507 | gtk_widget_show_all(dialog); |
| 11770 | 508 | g_value_unset(&val); |
| 11740 | 509 | break; |
| 510 | } | |
| 511 | } | |
| 512 | ||
|
12162
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
513 | static void |
|
13718
f29249a2856c
[gaim-migrate @ 16125]
Richard Laager <rlaager@pidgin.im>
parents:
13436
diff
changeset
|
514 | show_plugin_prefs_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, GtkWidget *dialog) |
|
12162
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
515 | { |
|
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
516 | GtkTreeSelection *sel; |
|
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
517 | GtkTreeIter iter; |
| 15884 | 518 | PurplePlugin *plugin; |
|
12162
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
519 | GtkTreeModel *model; |
|
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
520 | |
|
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
521 | sel = gtk_tree_view_get_selection(view); |
|
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
522 | |
|
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
523 | if (!gtk_tree_selection_get_selected(sel, &model, &iter)) |
|
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
524 | return; |
|
12246
7af1ef3b1cc4
[gaim-migrate @ 14548]
Mark Doliner <markdoliner@pidgin.im>
parents:
12240
diff
changeset
|
525 | |
|
12162
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
526 | gtk_tree_model_get(model, &iter, 2, &plugin, -1); |
|
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
527 | |
| 15884 | 528 | if (!purple_plugin_is_loaded(plugin)) |
|
12174
3b0b53e84591
[gaim-migrate @ 14476]
Richard Laager <rlaager@pidgin.im>
parents:
12162
diff
changeset
|
529 | return; |
|
3b0b53e84591
[gaim-migrate @ 14476]
Richard Laager <rlaager@pidgin.im>
parents:
12162
diff
changeset
|
530 | |
|
12162
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
531 | /* Now show the pref-dialog for the plugin */ |
|
15880
d275b025481c
More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents:
15692
diff
changeset
|
532 | plugin_dialog_response_cb(dialog, PIDGIN_RESPONSE_CONFIGURE, sel); |
|
12162
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
533 | } |
|
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
534 | |
|
22065
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
535 | static gboolean |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
536 | pidgin_plugins_paint_tooltip(GtkWidget *tipwindow, gpointer data) |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
537 | { |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
538 | PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin"); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
539 | gtk_paint_layout(tipwindow->style, tipwindow->window, GTK_STATE_NORMAL, FALSE, |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
540 | NULL, tipwindow, "tooltip", |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
541 | 6, 6, layout); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
542 | return TRUE; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
543 | } |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
544 | |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
545 | static gboolean |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
546 | pidgin_plugins_create_tooltip(GtkWidget *tipwindow, GtkTreePath *path, |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
547 | gpointer data, int *w, int *h) |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
548 | { |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
549 | GtkTreeIter iter; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
550 | GtkTreeView *treeview = GTK_TREE_VIEW(data); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
551 | PurplePlugin *plugin = NULL; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
552 | GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
553 | PangoLayout *layout; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
554 | int width, height; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
555 | char *markup, *name, *desc, *author; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
556 | |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
557 | if (!gtk_tree_model_get_iter(model, &iter, path)) |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
558 | return FALSE; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
559 | |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
560 | gtk_tree_model_get(model, &iter, 2, &plugin, -1); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
561 | |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
562 | markup = g_strdup_printf("<span size='x-large' weight='bold'>%s</span>\n<b>Description:</b> %s\n<b>Author:</b> %s", |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
563 | name = g_markup_escape_text(purple_plugin_get_name(plugin), -1), |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
564 | desc = g_markup_escape_text(purple_plugin_get_description(plugin), -1), |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
565 | author = g_markup_escape_text(purple_plugin_get_author(plugin), -1)); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
566 | |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
567 | layout = gtk_widget_create_pango_layout(tipwindow, NULL); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
568 | pango_layout_set_markup(layout, markup, -1); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
569 | pango_layout_set_wrap(layout, PANGO_WRAP_WORD); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
570 | pango_layout_set_width(layout, 600000); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
571 | pango_layout_get_size(layout, &width, &height); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
572 | g_object_set_data_full(G_OBJECT(tipwindow), "tooltip-plugin", layout, g_object_unref); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
573 | |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
574 | if (w) |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
575 | *w = PANGO_PIXELS(width) + 12; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
576 | if (h) |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
577 | *h = PANGO_PIXELS(height) + 12; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
578 | |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
579 | g_free(markup); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
580 | g_free(name); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
581 | g_free(desc); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
582 | g_free(author); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
583 | |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
584 | return TRUE; |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
585 | } |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
586 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
587 | void pidgin_plugin_dialog_show() |
| 11740 | 588 | { |
| 11741 | 589 | GtkWidget *sw; |
| 11740 | 590 | GtkWidget *event_view; |
| 591 | GtkListStore *ls; | |
| 592 | GtkCellRenderer *rend, *rendt; | |
| 593 | GtkTreeViewColumn *col; | |
| 594 | GtkTreeSelection *sel; | |
| 595 | ||
| 596 | if (plugin_dialog != NULL) { | |
| 597 | gtk_window_present(GTK_WINDOW(plugin_dialog)); | |
| 598 | return; | |
| 599 | } | |
| 600 | ||
| 601 | plugin_dialog = gtk_dialog_new_with_buttons(_("Plugins"), | |
| 602 | NULL, | |
| 603 | GTK_DIALOG_NO_SEPARATOR, | |
| 604 | NULL); | |
|
12246
7af1ef3b1cc4
[gaim-migrate @ 14548]
Mark Doliner <markdoliner@pidgin.im>
parents:
12240
diff
changeset
|
605 | pref_button = gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), |
|
15880
d275b025481c
More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents:
15692
diff
changeset
|
606 | _("Configure Pl_ugin"), PIDGIN_RESPONSE_CONFIGURE); |
|
12246
7af1ef3b1cc4
[gaim-migrate @ 14548]
Mark Doliner <markdoliner@pidgin.im>
parents:
12240
diff
changeset
|
607 | gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), |
|
7af1ef3b1cc4
[gaim-migrate @ 14548]
Mark Doliner <markdoliner@pidgin.im>
parents:
12240
diff
changeset
|
608 | GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); |
| 11813 | 609 | gtk_widget_set_sensitive(pref_button, FALSE); |
| 11747 | 610 | gtk_window_set_role(GTK_WINDOW(plugin_dialog), "plugins"); |
| 11740 | 611 | |
| 612 | sw = gtk_scrolled_window_new(NULL,NULL); | |
| 13775 | 613 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 11740 | 614 | gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
| 615 | ||
| 616 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), sw, TRUE, TRUE, 0); | |
| 617 | ||
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
618 | ls = gtk_list_store_new(4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN); |
| 11740 | 619 | gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), |
| 620 | 1, GTK_SORT_ASCENDING); | |
| 621 | ||
| 622 | update_plugin_list(ls); | |
| 11813 | 623 | |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
624 | event_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); |
| 11740 | 625 | |
| 14359 | 626 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(event_view), TRUE); |
| 627 | ||
|
12162
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
628 | g_signal_connect(G_OBJECT(event_view), "row-activated", |
|
13718
f29249a2856c
[gaim-migrate @ 16125]
Richard Laager <rlaager@pidgin.im>
parents:
13436
diff
changeset
|
629 | G_CALLBACK(show_plugin_prefs_cb), plugin_dialog); |
|
12162
449845a545ab
[gaim-migrate @ 14463]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12066
diff
changeset
|
630 | |
| 15884 | 631 | purple_signal_connect(purple_plugins_get_handle(), "plugin-load", plugin_dialog, |
| 632 | PURPLE_CALLBACK(plugin_load_cb), event_view); | |
| 633 | purple_signal_connect(purple_plugins_get_handle(), "plugin-unload", plugin_dialog, | |
| 634 | PURPLE_CALLBACK(plugin_unload_cb), event_view); | |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
635 | |
| 11740 | 636 | rend = gtk_cell_renderer_toggle_new(); |
| 637 | sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view)); | |
| 638 | ||
| 639 | col = gtk_tree_view_column_new_with_attributes (_("Enabled"), | |
| 640 | rend, | |
| 641 | "active", 0, | |
| 642 | NULL); | |
| 643 | gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); | |
|
11794
6c39942d27a9
[gaim-migrate @ 14085]
Gary Kramlich <grim@reaperworld.com>
parents:
11783
diff
changeset
|
644 | gtk_tree_view_column_set_sort_column_id(col, 0); |
|
12927
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
645 | g_signal_connect(G_OBJECT(rend), "toggled", |
|
f3e4ef8958a3
[gaim-migrate @ 15280]
Richard Laager <rlaager@pidgin.im>
parents:
12889
diff
changeset
|
646 | G_CALLBACK(plugin_toggled), ls); |
|
12246
7af1ef3b1cc4
[gaim-migrate @ 14548]
Mark Doliner <markdoliner@pidgin.im>
parents:
12240
diff
changeset
|
647 | |
| 11740 | 648 | rendt = gtk_cell_renderer_text_new(); |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
649 | g_object_set(rendt, |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
650 | "foreground", "#c0c0c0", |
|
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
651 | NULL); |
| 11740 | 652 | col = gtk_tree_view_column_new_with_attributes (_("Name"), |
| 653 | rendt, | |
| 654 | "markup", 1, | |
|
12695
0c93a42b7ee2
[gaim-migrate @ 15038]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
655 | "foreground-set", 3, |
| 11740 | 656 | NULL); |
| 657 | #if GTK_CHECK_VERSION(2,6,0) | |
| 658 | gtk_tree_view_column_set_expand (col, TRUE); | |
| 659 | g_object_set(rendt, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
| 660 | #endif | |
| 661 | gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); | |
|
11794
6c39942d27a9
[gaim-migrate @ 14085]
Gary Kramlich <grim@reaperworld.com>
parents:
11783
diff
changeset
|
662 | gtk_tree_view_column_set_sort_column_id(col, 1); |
| 11740 | 663 | g_object_unref(G_OBJECT(ls)); |
| 664 | gtk_container_add(GTK_CONTAINER(sw), event_view); | |
|
15177
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14359
diff
changeset
|
665 | gtk_tree_view_set_search_column(GTK_TREE_VIEW(event_view), 1); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14359
diff
changeset
|
666 | gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(event_view), |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
667 | pidgin_tree_view_search_equal_func, NULL, NULL); |
|
12246
7af1ef3b1cc4
[gaim-migrate @ 14548]
Mark Doliner <markdoliner@pidgin.im>
parents:
12240
diff
changeset
|
668 | |
|
22065
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
669 | pidgin_tooltip_setup_for_treeview(event_view, event_view, |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
670 | pidgin_plugins_create_tooltip, |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
671 | pidgin_plugins_paint_tooltip); |
|
4bfdea9613d1
Add tooltips to the plugin window. I did it mostly to test the new tooltip
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21352
diff
changeset
|
672 | |
| 11740 | 673 | expander = gtk_expander_new(_("<b>Plugin Details</b>")); |
| 674 | gtk_expander_set_use_markup(GTK_EXPANDER(expander), TRUE); | |
| 675 | plugin_details = gtk_label_new(NULL); | |
| 676 | gtk_label_set_line_wrap(GTK_LABEL(plugin_details), TRUE); | |
| 677 | gtk_container_add(GTK_CONTAINER(expander), plugin_details); | |
|
12343
0ede7c5a9465
[gaim-migrate @ 14647]
Mark Doliner <markdoliner@pidgin.im>
parents:
12290
diff
changeset
|
678 | gtk_widget_set_sensitive(expander, FALSE); |
| 11740 | 679 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), expander, FALSE, FALSE, 0); |
| 680 | ||
| 681 | g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (prefs_plugin_sel), NULL); | |
| 682 | g_signal_connect(G_OBJECT(plugin_dialog), "response", G_CALLBACK(plugin_dialog_response_cb), sel); | |
| 683 | gtk_window_set_default_size(GTK_WINDOW(plugin_dialog), 430, 430); | |
| 684 | gtk_widget_show_all(plugin_dialog); | |
| 685 | } |