Mercurial > pidgin.yaz
annotate src/gtkplugin.c @ 11912:8eb1f4b9210c
[gaim-migrate @ 14203]
I'm bored of testing this now, I'll just fix any problems I find as I come
across them.
howl/bonjour is now split out into its own rpm, as is mono (which I guess
may or may not make the final cut). I cleaned up some perl foo, but may
have broken it in the process.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Mon, 31 Oct 2005 01:41:45 +0000 |
parents | 7d2d926704aa |
children | ee8312c764b1 |
rev | line source |
---|---|
5205 | 1 /** |
6927
ee51189dfe76
[gaim-migrate @ 7474]
Christian Hammond <chipx86@chipx86.com>
parents:
5982
diff
changeset
|
2 * @file gtkplugin.c GTK+ Plugins support |
ee51189dfe76
[gaim-migrate @ 7474]
Christian Hammond <chipx86@chipx86.com>
parents:
5982
diff
changeset
|
3 * @ingroup gtkui |
5205 | 4 * |
5 * gaim | |
6 * | |
8046 | 7 * Gaim 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 | |
9 * source distribution. | |
6927
ee51189dfe76
[gaim-migrate @ 7474]
Christian Hammond <chipx86@chipx86.com>
parents:
5982
diff
changeset
|
10 * |
5205 | 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 | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
11740 | 25 #include "internal.h" |
9791 | 26 #include "gtkgaim.h" |
5205 | 27 #include "gtkplugin.h" |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
28 #include "gtkpluginpref.h" |
5981
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
29 #include "debug.h" |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
30 #include "prefs.h" |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
31 |
5205 | 32 #include <string.h> |
33 | |
11740 | 34 static GtkWidget *plugin_dialog = NULL; |
35 static GtkWidget *plugin_details = NULL; | |
36 static GtkWidget *pref_button = NULL; | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
37 static GHashTable *plugin_pref_dialogs = NULL; |
11747
b8bf638cc4aa
[gaim-migrate @ 14038]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11744
diff
changeset
|
38 |
5205 | 39 GtkWidget * |
40 gaim_gtk_plugin_get_config_frame(GaimPlugin *plugin) | |
41 { | |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
42 GtkWidget *config = NULL; |
5205 | 43 |
44 g_return_val_if_fail(plugin != NULL, NULL); | |
45 | |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
46 if (GAIM_IS_GTK_PLUGIN(plugin) && plugin->info->ui_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
47 && GAIM_GTK_PLUGIN_UI_INFO(plugin)->get_config_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
48 { |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
49 GaimGtkPluginUiInfo *ui_info; |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
50 |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
51 ui_info = GAIM_GTK_PLUGIN_UI_INFO(plugin); |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
52 |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
53 config = ui_info->get_config_frame(plugin); |
5205 | 54 |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
55 if (plugin->info->prefs_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
56 && plugin->info->prefs_info->get_plugin_pref_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
57 { |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
58 gaim_debug_warning("gtkplugin", |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
59 "Plugin %s contains both, ui_info and " |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
60 "prefs_info preferences; prefs_info will be " |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
61 "ignored.", plugin->info->name); |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
62 } |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
63 } |
5205 | 64 |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
65 if (config == NULL && plugin->info->prefs_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
66 && plugin->info->prefs_info->get_plugin_pref_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
67 { |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
68 GaimPluginPrefFrame *frame; |
5205 | 69 |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
70 frame = plugin->info->prefs_info->get_plugin_pref_frame(plugin); |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
71 |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
72 config = gaim_gtk_plugin_pref_create_frame(frame); |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
73 } |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
74 |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
75 return config; |
5205 | 76 } |
5981
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
77 |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
78 void |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
79 gaim_gtk_plugins_save(void) |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
80 { |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
81 GList *pl; |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
82 GList *files = NULL; |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
83 GaimPlugin *p; |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
84 |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
85 for (pl = gaim_plugins_get_loaded(); pl != NULL; pl = pl->next) { |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
86 p = pl->data; |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
87 |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
88 if (p->info->type != GAIM_PLUGIN_PROTOCOL && |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
89 p->info->type != GAIM_PLUGIN_LOADER) { |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
90 |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
91 files = g_list_append(files, p->path); |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
92 } |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
93 } |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
94 |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
95 gaim_prefs_set_string_list("/gaim/gtk/plugins/loaded", files); |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
96 g_list_free(files); |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
97 } |
11740 | 98 |
99 static void | |
100 update_plugin_list(void *data) | |
101 { | |
102 GtkListStore *ls = GTK_LIST_STORE(data); | |
103 GtkTreeIter iter; | |
104 GList *probes; | |
105 GaimPlugin *plug; | |
106 | |
107 gtk_list_store_clear(ls); | |
108 gaim_plugins_probe(GAIM_PLUGIN_EXT); | |
109 | |
110 for (probes = gaim_plugins_get_all(); | |
111 probes != NULL; | |
112 probes = probes->next) | |
113 { | |
114 char *desc; | |
115 plug = probes->data; | |
116 | |
117 if (plug->info->type != GAIM_PLUGIN_STANDARD || | |
118 (plug->info->flags & GAIM_PLUGIN_FLAG_INVISIBLE)) | |
119 { | |
120 continue; | |
121 } | |
122 | |
123 gtk_list_store_append (ls, &iter); | |
124 desc = g_strdup_printf("<b>%s</b> %s\n%s", plug->info->name ? _(plug->info->name) : g_basename(plug->path), | |
125 plug->info->version, | |
126 plug->info->summary); | |
127 gtk_list_store_set(ls, &iter, | |
128 0, gaim_plugin_is_loaded(plug), | |
129 1, desc, | |
130 2, plug, -1); | |
131 g_free(desc); | |
132 } | |
133 } | |
134 | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
135 static void pref_dialog_response_cb(GtkWidget *d, int response, GaimPlugin *plug) |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
136 { |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
137 switch (response) { |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
138 case GTK_RESPONSE_CLOSE: |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
139 case GTK_RESPONSE_DELETE_EVENT: |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
140 g_hash_table_remove(plugin_pref_dialogs, plug); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
141 if (g_hash_table_size(plugin_pref_dialogs) == 0) { |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
142 g_hash_table_destroy(plugin_pref_dialogs); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
143 plugin_pref_dialogs = NULL; |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
144 } |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
145 gtk_widget_destroy(d); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
146 break; |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
147 } |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
148 } |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
149 |
11740 | 150 static void plugin_load (GtkCellRendererToggle *cell, gchar *pth, gpointer data) |
151 { | |
152 GtkTreeModel *model = (GtkTreeModel *)data; | |
153 GtkTreeIter iter; | |
154 GtkTreePath *path = gtk_tree_path_new_from_string(pth); | |
155 GaimPlugin *plug; | |
156 gchar buf[1024]; | |
157 gchar *name = NULL, *description = NULL; | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
158 GtkWidget *dialog = NULL; |
11740 | 159 |
160 GdkCursor *wait = gdk_cursor_new (GDK_WATCH); | |
11742 | 161 gdk_window_set_cursor(plugin_dialog->window, wait); |
11740 | 162 gdk_cursor_unref(wait); |
163 | |
164 gtk_tree_model_get_iter (model, &iter, path); | |
165 gtk_tree_model_get (model, &iter, 2, &plug, -1); | |
166 | |
167 if (!gaim_plugin_is_loaded(plug)) | |
168 gaim_plugin_load(plug); | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
169 else { |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
170 if (plugin_pref_dialogs != NULL && |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
171 (dialog = g_hash_table_lookup(plugin_pref_dialogs, plug))) |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
172 pref_dialog_response_cb(dialog, GTK_RESPONSE_DELETE_EVENT, plug); |
11740 | 173 gaim_plugin_unload(plug); |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
174 } |
11740 | 175 |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
176 gtk_widget_set_sensitive(pref_button, |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
177 gaim_plugin_is_loaded(plug) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
178 && ((GAIM_IS_GTK_PLUGIN(plug) && plug->info->ui_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
179 && GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
180 || (plug->info->prefs_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
181 && plug->info->prefs_info->get_plugin_pref_frame))); |
11740 | 182 |
11742 | 183 gdk_window_set_cursor(plugin_dialog->window, NULL); |
11740 | 184 |
185 name = g_markup_escape_text(_(plug->info->name), -1); | |
186 description = g_markup_escape_text(_(plug->info->description), -1); | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
187 |
11740 | 188 if (plug->error != NULL) { |
189 gchar *error = g_markup_escape_text(plug->error, -1); | |
190 gchar *desc; | |
191 g_snprintf(buf, sizeof(buf), | |
192 "<span size=\"larger\">%s %s</span>\n\n" | |
193 "<span weight=\"bold\" color=\"red\">%s</span>\n\n" | |
194 "%s", | |
195 name, plug->info->version, error, description); | |
196 desc = g_strdup_printf("<b>%s</b> %s\n<span weight=\"bold\" color=\"red\"%s</span>", | |
197 plug->info->name, plug->info->version, error); | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
198 gtk_list_store_set (GTK_LIST_STORE (model), &iter, |
11740 | 199 1, desc, |
200 -1); | |
201 g_free(desc); | |
202 g_free(error); | |
11843 | 203 gtk_label_set_markup(GTK_LABEL(plugin_details), buf); |
11740 | 204 } |
205 g_free(name); | |
206 g_free(description); | |
207 | |
208 | |
209 gtk_list_store_set (GTK_LIST_STORE (model), &iter, | |
210 0, gaim_plugin_is_loaded(plug), | |
211 -1); | |
212 | |
213 gtk_tree_path_free(path); | |
214 gaim_gtk_plugins_save(); | |
215 } | |
216 | |
11877 | 217 static gboolean ensure_plugin_visible(void *data) |
218 { | |
219 GtkTreeSelection *sel = GTK_TREE_SELECTION(data); | |
220 GtkTreeView *tv = gtk_tree_selection_get_tree_view(sel); | |
221 GtkTreeModel *model = gtk_tree_view_get_model(tv); | |
222 GtkTreePath *path; | |
223 GtkTreeIter iter; | |
224 if (!gtk_tree_selection_get_selected (sel, &model, &iter)) | |
225 return FALSE; | |
226 path = gtk_tree_model_get_path(model, &iter); | |
227 gtk_tree_view_scroll_to_cell(gtk_tree_selection_get_tree_view(sel), path, NULL, FALSE, 0, 0); | |
228 gtk_tree_path_free(path); | |
229 return FALSE; | |
230 } | |
231 | |
11740 | 232 static void prefs_plugin_sel (GtkTreeSelection *sel, GtkTreeModel *model) |
233 { | |
11741 | 234 gchar *buf, *pname, *pdesc, *pauth, *pweb; |
11740 | 235 GtkTreeIter iter; |
236 GValue val = { 0, }; | |
237 GaimPlugin *plug; | |
238 | |
11833 | 239 if (!gtk_tree_selection_get_selected (sel, &model, &iter)) |
240 { | |
241 /* Clear the old plugin details */ | |
242 gtk_label_set_markup(GTK_LABEL(plugin_details), ""); | |
243 gtk_widget_set_sensitive(pref_button, FALSE); | |
11740 | 244 return; |
11833 | 245 } |
246 | |
11740 | 247 gtk_tree_model_get_value (model, &iter, 2, &val); |
248 plug = g_value_get_pointer(&val); | |
249 | |
250 pname = g_markup_escape_text(_(plug->info->name), -1); | |
251 pdesc = (plug->info->description) ? | |
252 g_markup_escape_text(_(plug->info->description), -1) : NULL; | |
253 pauth = (plug->info->author) ? | |
254 g_markup_escape_text(_(plug->info->author), -1) : NULL; | |
255 pweb = (plug->info->homepage) ? | |
256 g_markup_escape_text(_(plug->info->homepage), -1) : NULL; | |
257 buf = g_strdup_printf( | |
11771
08b1dd8aa11c
[gaim-migrate @ 14062]
Richard Laager <rlaager@wiktel.com>
parents:
11770
diff
changeset
|
258 _("%s%s" |
11740 | 259 "<span weight=\"bold\">Written by:</span>\t%s\n" |
11777
1253620ea5f2
[gaim-migrate @ 14068]
Richard Laager <rlaager@wiktel.com>
parents:
11775
diff
changeset
|
260 "<span weight=\"bold\">Web site:</span>\t\t%s\n" |
11740 | 261 "<span weight=\"bold\">File name:</span>\t%s"), |
11771
08b1dd8aa11c
[gaim-migrate @ 14062]
Richard Laager <rlaager@wiktel.com>
parents:
11770
diff
changeset
|
262 pdesc ? pdesc : "", pdesc ? "\n\n" : "", |
11740 | 263 pauth ? pauth : "", pweb ? pweb : "", plug->path); |
264 | |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
265 gtk_widget_set_sensitive(pref_button, |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
266 gaim_plugin_is_loaded(plug) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
267 && ((GAIM_IS_GTK_PLUGIN(plug) && plug->info->ui_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
268 && GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
269 || (plug->info->prefs_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
270 && plug->info->prefs_info->get_plugin_pref_frame))); |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
271 |
11740 | 272 gtk_label_set_markup(GTK_LABEL(plugin_details), buf); |
11877 | 273 |
274 /* Make sure the selected plugin is still visible */ | |
275 g_idle_add(ensure_plugin_visible, sel); | |
276 | |
277 | |
11740 | 278 g_value_unset(&val); |
279 g_free(buf); | |
280 g_free(pname); | |
281 g_free(pdesc); | |
282 g_free(pauth); | |
283 g_free(pweb); | |
284 } | |
285 | |
11741 | 286 static void plugin_dialog_response_cb(GtkWidget *d, int response, GtkTreeSelection *sel) |
11740 | 287 { |
288 GaimPlugin *plug; | |
289 GtkWidget *dialog, *box; | |
290 GtkTreeModel *model; | |
11743 | 291 GValue val = { 0, }; |
11740 | 292 GtkTreeIter iter; |
293 | |
294 switch (response) { | |
295 case GTK_RESPONSE_CLOSE: | |
296 case GTK_RESPONSE_DELETE_EVENT: | |
297 gtk_widget_destroy(d); | |
11888 | 298 if (plugin_pref_dialogs != NULL) { |
299 g_hash_table_destroy(plugin_pref_dialogs); | |
300 plugin_pref_dialogs = NULL; | |
301 } | |
11740 | 302 plugin_dialog = NULL; |
303 break; | |
304 case 98121: | |
305 if (! gtk_tree_selection_get_selected (sel, &model, &iter)) | |
306 return; | |
307 gtk_tree_model_get_value (model, &iter, 2, &val); | |
308 plug = g_value_get_pointer(&val); | |
309 if (plug == NULL) | |
310 break; | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
311 if (plugin_pref_dialogs != NULL && |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
312 g_hash_table_lookup(plugin_pref_dialogs, plug)) |
11770 | 313 break; |
11740 | 314 box = gaim_gtk_plugin_get_config_frame(plug); |
315 if (box == NULL) | |
316 break; | |
317 | |
11741 | 318 dialog = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, GTK_WINDOW(d), |
11744 | 319 GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT, |
11740 | 320 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, |
321 NULL); | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
322 if (plugin_pref_dialogs == NULL) |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
323 plugin_pref_dialogs = g_hash_table_new(NULL, NULL); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
324 |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
325 g_hash_table_insert(plugin_pref_dialogs, plug, dialog); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
326 |
11770 | 327 g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(pref_dialog_response_cb), plug); |
11740 | 328 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), box); |
11747
b8bf638cc4aa
[gaim-migrate @ 14038]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11744
diff
changeset
|
329 gtk_window_set_role(GTK_WINDOW(dialog), "plugin_config"); |
11775
400b802cd62b
[gaim-migrate @ 14066]
Gary Kramlich <grim@reaperworld.com>
parents:
11771
diff
changeset
|
330 gtk_window_set_title(GTK_WINDOW(dialog), gaim_plugin_get_name(plug)); |
11740 | 331 gtk_widget_show_all(dialog); |
11770 | 332 g_value_unset(&val); |
11740 | 333 break; |
334 } | |
335 } | |
336 | |
337 void gaim_gtk_plugin_dialog_show() | |
338 { | |
11741 | 339 GtkWidget *sw; |
11740 | 340 GtkWidget *event_view; |
341 GtkListStore *ls; | |
342 GtkCellRenderer *rend, *rendt; | |
343 GtkTreeViewColumn *col; | |
344 GtkTreeSelection *sel; | |
345 GtkWidget *expander; | |
346 | |
347 if (plugin_dialog != NULL) { | |
348 gtk_window_present(GTK_WINDOW(plugin_dialog)); | |
349 return; | |
350 } | |
351 | |
352 plugin_dialog = gtk_dialog_new_with_buttons(_("Plugins"), | |
353 NULL, | |
354 GTK_DIALOG_NO_SEPARATOR, | |
355 NULL); | |
356 pref_button = gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), GTK_STOCK_PREFERENCES, 98121); | |
357 gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); | |
11813
1f7f4f850db5
[gaim-migrate @ 14104]
Gary Kramlich <grim@reaperworld.com>
parents:
11794
diff
changeset
|
358 gtk_widget_set_sensitive(pref_button, FALSE); |
11747
b8bf638cc4aa
[gaim-migrate @ 14038]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11744
diff
changeset
|
359 gtk_window_set_role(GTK_WINDOW(plugin_dialog), "plugins"); |
11740 | 360 |
361 sw = gtk_scrolled_window_new(NULL,NULL); | |
362 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
363 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); | |
364 | |
365 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), sw, TRUE, TRUE, 0); | |
366 | |
367 ls = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER); | |
368 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), | |
369 1, GTK_SORT_ASCENDING); | |
370 | |
371 update_plugin_list(ls); | |
11813
1f7f4f850db5
[gaim-migrate @ 14104]
Gary Kramlich <grim@reaperworld.com>
parents:
11794
diff
changeset
|
372 |
11740 | 373 event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(ls)); |
374 | |
375 rend = gtk_cell_renderer_toggle_new(); | |
376 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view)); | |
377 | |
378 col = gtk_tree_view_column_new_with_attributes (_("Enabled"), | |
379 rend, | |
380 "active", 0, | |
381 NULL); | |
382 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); | |
11794
f5105a2b8bf6
[gaim-migrate @ 14085]
Gary Kramlich <grim@reaperworld.com>
parents:
11783
diff
changeset
|
383 gtk_tree_view_column_set_sort_column_id(col, 0); |
11740 | 384 g_signal_connect (G_OBJECT(rend), "toggled", |
385 G_CALLBACK(plugin_load), ls); | |
386 | |
387 rendt = gtk_cell_renderer_text_new(); | |
388 col = gtk_tree_view_column_new_with_attributes (_("Name"), | |
389 rendt, | |
390 "markup", 1, | |
391 NULL); | |
392 #if GTK_CHECK_VERSION(2,6,0) | |
393 gtk_tree_view_column_set_expand (col, TRUE); | |
394 g_object_set(rendt, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
395 #endif | |
396 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); | |
11794
f5105a2b8bf6
[gaim-migrate @ 14085]
Gary Kramlich <grim@reaperworld.com>
parents:
11783
diff
changeset
|
397 gtk_tree_view_column_set_sort_column_id(col, 1); |
11740 | 398 g_object_unref(G_OBJECT(ls)); |
399 gtk_container_add(GTK_CONTAINER(sw), event_view); | |
400 | |
401 expander = gtk_expander_new(_("<b>Plugin Details</b>")); | |
402 gtk_expander_set_use_markup(GTK_EXPANDER(expander), TRUE); | |
403 plugin_details = gtk_label_new(NULL); | |
404 gtk_label_set_line_wrap(GTK_LABEL(plugin_details), TRUE); | |
405 gtk_container_add(GTK_CONTAINER(expander), plugin_details); | |
406 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), expander, FALSE, FALSE, 0); | |
407 | |
408 g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (prefs_plugin_sel), NULL); | |
409 g_signal_connect(G_OBJECT(plugin_dialog), "response", G_CALLBACK(plugin_dialog_response_cb), sel); | |
410 gtk_window_set_default_size(GTK_WINDOW(plugin_dialog), 430, 430); | |
411 gtk_widget_show_all(plugin_dialog); | |
412 } |