Mercurial > pidgin.yaz
annotate src/gtkplugin.c @ 12471:011efeb86b8d
[gaim-migrate @ 14781]
SF Patch #1368906 from charkins
"This patch adds a tooltip to the docklet icon. It is
based off of faceprint's code for the blist menutray.
Wingaim had some status strings it was displaying in
the tooltip, this patch removes those."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 12 Dec 2005 19:55:42 +0000 |
parents | a02f877637a6 |
children | e856f985a0b9 |
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 | |
12246 | 34 #define GAIM_RESPONSE_CONFIGURE 98121 |
35 | |
12343 | 36 static GtkWidget *expander = NULL; |
11740 | 37 static GtkWidget *plugin_dialog = NULL; |
38 static GtkWidget *plugin_details = NULL; | |
39 static GtkWidget *pref_button = NULL; | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
40 static GHashTable *plugin_pref_dialogs = NULL; |
11747
b8bf638cc4aa
[gaim-migrate @ 14038]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11744
diff
changeset
|
41 |
5205 | 42 GtkWidget * |
43 gaim_gtk_plugin_get_config_frame(GaimPlugin *plugin) | |
44 { | |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
45 GtkWidget *config = NULL; |
5205 | 46 |
47 g_return_val_if_fail(plugin != NULL, NULL); | |
48 | |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
49 if (GAIM_IS_GTK_PLUGIN(plugin) && plugin->info->ui_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
50 && GAIM_GTK_PLUGIN_UI_INFO(plugin)->get_config_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
51 { |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
52 GaimGtkPluginUiInfo *ui_info; |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
53 |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
54 ui_info = GAIM_GTK_PLUGIN_UI_INFO(plugin); |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
55 |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
56 config = ui_info->get_config_frame(plugin); |
5205 | 57 |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
58 if (plugin->info->prefs_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
59 && plugin->info->prefs_info->get_plugin_pref_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
60 { |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
61 gaim_debug_warning("gtkplugin", |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
62 "Plugin %s contains both, ui_info and " |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
63 "prefs_info preferences; prefs_info will be " |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
64 "ignored.", plugin->info->name); |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
65 } |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
66 } |
5205 | 67 |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
68 if (config == NULL && plugin->info->prefs_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
69 && plugin->info->prefs_info->get_plugin_pref_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
70 { |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
71 GaimPluginPrefFrame *frame; |
5205 | 72 |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
73 frame = plugin->info->prefs_info->get_plugin_pref_frame(plugin); |
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 config = gaim_gtk_plugin_pref_create_frame(frame); |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
76 } |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
77 |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
78 return config; |
5205 | 79 } |
5981
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 void |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
82 gaim_gtk_plugins_save(void) |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
83 { |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
84 GList *pl; |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
85 GList *files = NULL; |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
86 GaimPlugin *p; |
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 for (pl = gaim_plugins_get_loaded(); pl != NULL; pl = pl->next) { |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
89 p = pl->data; |
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 if (p->info->type != GAIM_PLUGIN_PROTOCOL && |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
92 p->info->type != GAIM_PLUGIN_LOADER) { |
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 files = g_list_append(files, p->path); |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
95 } |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
96 } |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
97 |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
98 gaim_prefs_set_string_list("/gaim/gtk/plugins/loaded", files); |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
99 g_list_free(files); |
81564bb4db68
[gaim-migrate @ 6429]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
100 } |
11740 | 101 |
102 static void | |
103 update_plugin_list(void *data) | |
104 { | |
105 GtkListStore *ls = GTK_LIST_STORE(data); | |
106 GtkTreeIter iter; | |
107 GList *probes; | |
108 GaimPlugin *plug; | |
109 | |
110 gtk_list_store_clear(ls); | |
12066 | 111 gaim_plugins_probe(G_MODULE_SUFFIX); |
11740 | 112 |
113 for (probes = gaim_plugins_get_all(); | |
114 probes != NULL; | |
115 probes = probes->next) | |
116 { | |
117 char *desc; | |
118 plug = probes->data; | |
119 | |
120 if (plug->info->type != GAIM_PLUGIN_STANDARD || | |
121 (plug->info->flags & GAIM_PLUGIN_FLAG_INVISIBLE)) | |
122 { | |
123 continue; | |
124 } | |
125 | |
126 gtk_list_store_append (ls, &iter); | |
127 desc = g_strdup_printf("<b>%s</b> %s\n%s", plug->info->name ? _(plug->info->name) : g_basename(plug->path), | |
128 plug->info->version, | |
12240 | 129 _(plug->info->summary)); |
11740 | 130 gtk_list_store_set(ls, &iter, |
131 0, gaim_plugin_is_loaded(plug), | |
132 1, desc, | |
133 2, plug, -1); | |
134 g_free(desc); | |
135 } | |
136 } | |
137 | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
138 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
|
139 { |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
140 switch (response) { |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
141 case GTK_RESPONSE_CLOSE: |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
142 case GTK_RESPONSE_DELETE_EVENT: |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
143 g_hash_table_remove(plugin_pref_dialogs, plug); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
144 if (g_hash_table_size(plugin_pref_dialogs) == 0) { |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
145 g_hash_table_destroy(plugin_pref_dialogs); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
146 plugin_pref_dialogs = NULL; |
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 gtk_widget_destroy(d); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
149 break; |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
150 } |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
151 } |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
152 |
11740 | 153 static void plugin_load (GtkCellRendererToggle *cell, gchar *pth, gpointer data) |
154 { | |
155 GtkTreeModel *model = (GtkTreeModel *)data; | |
156 GtkTreeIter iter; | |
157 GtkTreePath *path = gtk_tree_path_new_from_string(pth); | |
158 GaimPlugin *plug; | |
159 gchar buf[1024]; | |
160 gchar *name = NULL, *description = NULL; | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
161 GtkWidget *dialog = NULL; |
11740 | 162 |
163 GdkCursor *wait = gdk_cursor_new (GDK_WATCH); | |
11742 | 164 gdk_window_set_cursor(plugin_dialog->window, wait); |
11740 | 165 gdk_cursor_unref(wait); |
166 | |
167 gtk_tree_model_get_iter (model, &iter, path); | |
168 gtk_tree_model_get (model, &iter, 2, &plug, -1); | |
169 | |
170 if (!gaim_plugin_is_loaded(plug)) | |
171 gaim_plugin_load(plug); | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
172 else { |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
173 if (plugin_pref_dialogs != NULL && |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
174 (dialog = g_hash_table_lookup(plugin_pref_dialogs, plug))) |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
175 pref_dialog_response_cb(dialog, GTK_RESPONSE_DELETE_EVENT, plug); |
11740 | 176 gaim_plugin_unload(plug); |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
177 } |
11740 | 178 |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
179 gtk_widget_set_sensitive(pref_button, |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
180 gaim_plugin_is_loaded(plug) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
181 && ((GAIM_IS_GTK_PLUGIN(plug) && plug->info->ui_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
182 && GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
183 || (plug->info->prefs_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
184 && plug->info->prefs_info->get_plugin_pref_frame))); |
11740 | 185 |
11742 | 186 gdk_window_set_cursor(plugin_dialog->window, NULL); |
11740 | 187 |
188 name = g_markup_escape_text(_(plug->info->name), -1); | |
189 description = g_markup_escape_text(_(plug->info->description), -1); | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
190 |
11740 | 191 if (plug->error != NULL) { |
192 gchar *error = g_markup_escape_text(plug->error, -1); | |
193 gchar *desc; | |
194 g_snprintf(buf, sizeof(buf), | |
195 "<span size=\"larger\">%s %s</span>\n\n" | |
196 "<span weight=\"bold\" color=\"red\">%s</span>\n\n" | |
197 "%s", | |
198 name, plug->info->version, error, description); | |
199 desc = g_strdup_printf("<b>%s</b> %s\n<span weight=\"bold\" color=\"red\"%s</span>", | |
200 plug->info->name, plug->info->version, error); | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
201 gtk_list_store_set (GTK_LIST_STORE (model), &iter, |
11740 | 202 1, desc, |
203 -1); | |
204 g_free(desc); | |
205 g_free(error); | |
11843 | 206 gtk_label_set_markup(GTK_LABEL(plugin_details), buf); |
11740 | 207 } |
208 g_free(name); | |
209 g_free(description); | |
210 | |
211 | |
12246 | 212 gtk_list_store_set (GTK_LIST_STORE (model), &iter, |
213 0, gaim_plugin_is_loaded(plug), | |
11740 | 214 -1); |
215 | |
216 gtk_tree_path_free(path); | |
217 gaim_gtk_plugins_save(); | |
218 } | |
219 | |
11877 | 220 static gboolean ensure_plugin_visible(void *data) |
221 { | |
222 GtkTreeSelection *sel = GTK_TREE_SELECTION(data); | |
12246 | 223 GtkTreeView *tv = gtk_tree_selection_get_tree_view(sel); |
11877 | 224 GtkTreeModel *model = gtk_tree_view_get_model(tv); |
225 GtkTreePath *path; | |
226 GtkTreeIter iter; | |
227 if (!gtk_tree_selection_get_selected (sel, &model, &iter)) | |
228 return FALSE; | |
229 path = gtk_tree_model_get_path(model, &iter); | |
230 gtk_tree_view_scroll_to_cell(gtk_tree_selection_get_tree_view(sel), path, NULL, FALSE, 0, 0); | |
231 gtk_tree_path_free(path); | |
232 return FALSE; | |
233 } | |
234 | |
11740 | 235 static void prefs_plugin_sel (GtkTreeSelection *sel, GtkTreeModel *model) |
236 { | |
11741 | 237 gchar *buf, *pname, *pdesc, *pauth, *pweb; |
11740 | 238 GtkTreeIter iter; |
239 GValue val = { 0, }; | |
240 GaimPlugin *plug; | |
241 | |
11833 | 242 if (!gtk_tree_selection_get_selected (sel, &model, &iter)) |
243 { | |
244 /* Clear the old plugin details */ | |
245 gtk_label_set_markup(GTK_LABEL(plugin_details), ""); | |
246 gtk_widget_set_sensitive(pref_button, FALSE); | |
12343 | 247 |
248 /* Collapse and disable the expander widget */ | |
249 gtk_expander_set_expanded(GTK_EXPANDER(expander), FALSE); | |
250 gtk_widget_set_sensitive(expander, FALSE); | |
251 | |
11740 | 252 return; |
11833 | 253 } |
254 | |
12343 | 255 gtk_widget_set_sensitive(expander, TRUE); |
256 | |
11740 | 257 gtk_tree_model_get_value (model, &iter, 2, &val); |
258 plug = g_value_get_pointer(&val); | |
259 | |
260 pname = g_markup_escape_text(_(plug->info->name), -1); | |
261 pdesc = (plug->info->description) ? | |
262 g_markup_escape_text(_(plug->info->description), -1) : NULL; | |
263 pauth = (plug->info->author) ? | |
264 g_markup_escape_text(_(plug->info->author), -1) : NULL; | |
265 pweb = (plug->info->homepage) ? | |
266 g_markup_escape_text(_(plug->info->homepage), -1) : NULL; | |
267 buf = g_strdup_printf( | |
11771
08b1dd8aa11c
[gaim-migrate @ 14062]
Richard Laager <rlaager@wiktel.com>
parents:
11770
diff
changeset
|
268 _("%s%s" |
11740 | 269 "<span weight=\"bold\">Written by:</span>\t%s\n" |
11777
1253620ea5f2
[gaim-migrate @ 14068]
Richard Laager <rlaager@wiktel.com>
parents:
11775
diff
changeset
|
270 "<span weight=\"bold\">Web site:</span>\t\t%s\n" |
11740 | 271 "<span weight=\"bold\">File name:</span>\t%s"), |
11771
08b1dd8aa11c
[gaim-migrate @ 14062]
Richard Laager <rlaager@wiktel.com>
parents:
11770
diff
changeset
|
272 pdesc ? pdesc : "", pdesc ? "\n\n" : "", |
11740 | 273 pauth ? pauth : "", pweb ? pweb : "", plug->path); |
274 | |
11817
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
275 gtk_widget_set_sensitive(pref_button, |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
276 gaim_plugin_is_loaded(plug) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
277 && ((GAIM_IS_GTK_PLUGIN(plug) && plug->info->ui_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
278 && GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame) |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
279 || (plug->info->prefs_info |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
280 && plug->info->prefs_info->get_plugin_pref_frame))); |
1bb0efbd4394
[gaim-migrate @ 14108]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11813
diff
changeset
|
281 |
11740 | 282 gtk_label_set_markup(GTK_LABEL(plugin_details), buf); |
11877 | 283 |
284 /* Make sure the selected plugin is still visible */ | |
285 g_idle_add(ensure_plugin_visible, sel); | |
286 | |
287 | |
11740 | 288 g_value_unset(&val); |
289 g_free(buf); | |
290 g_free(pname); | |
291 g_free(pdesc); | |
292 g_free(pauth); | |
293 g_free(pweb); | |
294 } | |
295 | |
11741 | 296 static void plugin_dialog_response_cb(GtkWidget *d, int response, GtkTreeSelection *sel) |
11740 | 297 { |
298 GaimPlugin *plug; | |
299 GtkWidget *dialog, *box; | |
300 GtkTreeModel *model; | |
11743 | 301 GValue val = { 0, }; |
11740 | 302 GtkTreeIter iter; |
303 | |
304 switch (response) { | |
305 case GTK_RESPONSE_CLOSE: | |
306 case GTK_RESPONSE_DELETE_EVENT: | |
307 gtk_widget_destroy(d); | |
11888 | 308 if (plugin_pref_dialogs != NULL) { |
309 g_hash_table_destroy(plugin_pref_dialogs); | |
310 plugin_pref_dialogs = NULL; | |
311 } | |
11740 | 312 plugin_dialog = NULL; |
313 break; | |
12246 | 314 case GAIM_RESPONSE_CONFIGURE: |
11740 | 315 if (! gtk_tree_selection_get_selected (sel, &model, &iter)) |
316 return; | |
317 gtk_tree_model_get_value (model, &iter, 2, &val); | |
318 plug = g_value_get_pointer(&val); | |
319 if (plug == NULL) | |
320 break; | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
321 if (plugin_pref_dialogs != NULL && |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
322 g_hash_table_lookup(plugin_pref_dialogs, plug)) |
11770 | 323 break; |
11740 | 324 box = gaim_gtk_plugin_get_config_frame(plug); |
325 if (box == NULL) | |
326 break; | |
327 | |
11741 | 328 dialog = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, GTK_WINDOW(d), |
11744 | 329 GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT, |
11740 | 330 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, |
331 NULL); | |
11781
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
332 if (plugin_pref_dialogs == NULL) |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
333 plugin_pref_dialogs = g_hash_table_new(NULL, NULL); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
334 |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
335 g_hash_table_insert(plugin_pref_dialogs, plug, dialog); |
10317f1a2de2
[gaim-migrate @ 14072]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11777
diff
changeset
|
336 |
11770 | 337 g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(pref_dialog_response_cb), plug); |
11740 | 338 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), box); |
11747
b8bf638cc4aa
[gaim-migrate @ 14038]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11744
diff
changeset
|
339 gtk_window_set_role(GTK_WINDOW(dialog), "plugin_config"); |
12290 | 340 gtk_window_set_title(GTK_WINDOW(dialog), _(gaim_plugin_get_name(plug))); |
11740 | 341 gtk_widget_show_all(dialog); |
11770 | 342 g_value_unset(&val); |
11740 | 343 break; |
344 } | |
345 } | |
346 | |
12162
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
347 static void |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
348 show_plugin_prefs_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer null) |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
349 { |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
350 GtkTreeSelection *sel; |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
351 GtkTreeIter iter; |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
352 GaimPlugin *plugin; |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
353 GtkTreeModel *model; |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
354 |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
355 sel = gtk_tree_view_get_selection(view); |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
356 |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
357 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
358 return; |
12246 | 359 |
12162
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
360 gtk_tree_model_get(model, &iter, 2, &plugin, -1); |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
361 |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
362 if (!gaim_plugin_is_loaded(plugin)) |
12174
c7652a910308
[gaim-migrate @ 14476]
Richard Laager <rlaager@wiktel.com>
parents:
12162
diff
changeset
|
363 return; |
c7652a910308
[gaim-migrate @ 14476]
Richard Laager <rlaager@wiktel.com>
parents:
12162
diff
changeset
|
364 |
12162
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
365 /* Now show the pref-dialog for the plugin */ |
12246 | 366 plugin_dialog_response_cb(NULL, GAIM_RESPONSE_CONFIGURE, sel); |
12162
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
367 } |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
368 |
11740 | 369 void gaim_gtk_plugin_dialog_show() |
370 { | |
11741 | 371 GtkWidget *sw; |
11740 | 372 GtkWidget *event_view; |
373 GtkListStore *ls; | |
374 GtkCellRenderer *rend, *rendt; | |
375 GtkTreeViewColumn *col; | |
376 GtkTreeSelection *sel; | |
377 | |
378 if (plugin_dialog != NULL) { | |
379 gtk_window_present(GTK_WINDOW(plugin_dialog)); | |
380 return; | |
381 } | |
382 | |
383 plugin_dialog = gtk_dialog_new_with_buttons(_("Plugins"), | |
384 NULL, | |
385 GTK_DIALOG_NO_SEPARATOR, | |
386 NULL); | |
12246 | 387 pref_button = gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), |
12276
b3652193d359
[gaim-migrate @ 14580]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12246
diff
changeset
|
388 _("Configure Pl_ugin"), GAIM_RESPONSE_CONFIGURE); |
12246 | 389 gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), |
390 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); | |
11813
1f7f4f850db5
[gaim-migrate @ 14104]
Gary Kramlich <grim@reaperworld.com>
parents:
11794
diff
changeset
|
391 gtk_widget_set_sensitive(pref_button, FALSE); |
11747
b8bf638cc4aa
[gaim-migrate @ 14038]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11744
diff
changeset
|
392 gtk_window_set_role(GTK_WINDOW(plugin_dialog), "plugins"); |
11740 | 393 |
394 sw = gtk_scrolled_window_new(NULL,NULL); | |
395 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
396 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); | |
397 | |
398 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), sw, TRUE, TRUE, 0); | |
399 | |
400 ls = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER); | |
401 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), | |
402 1, GTK_SORT_ASCENDING); | |
403 | |
404 update_plugin_list(ls); | |
11813
1f7f4f850db5
[gaim-migrate @ 14104]
Gary Kramlich <grim@reaperworld.com>
parents:
11794
diff
changeset
|
405 |
11740 | 406 event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(ls)); |
407 | |
12162
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
408 g_signal_connect(G_OBJECT(event_view), "row-activated", |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
409 G_CALLBACK(show_plugin_prefs_cb), event_view); |
5e24b8e49522
[gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents:
12066
diff
changeset
|
410 |
11740 | 411 rend = gtk_cell_renderer_toggle_new(); |
412 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view)); | |
413 | |
414 col = gtk_tree_view_column_new_with_attributes (_("Enabled"), | |
415 rend, | |
416 "active", 0, | |
417 NULL); | |
418 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
|
419 gtk_tree_view_column_set_sort_column_id(col, 0); |
11740 | 420 g_signal_connect (G_OBJECT(rend), "toggled", |
421 G_CALLBACK(plugin_load), ls); | |
12246 | 422 |
11740 | 423 rendt = gtk_cell_renderer_text_new(); |
424 col = gtk_tree_view_column_new_with_attributes (_("Name"), | |
425 rendt, | |
426 "markup", 1, | |
427 NULL); | |
428 #if GTK_CHECK_VERSION(2,6,0) | |
429 gtk_tree_view_column_set_expand (col, TRUE); | |
430 g_object_set(rendt, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
431 #endif | |
432 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
|
433 gtk_tree_view_column_set_sort_column_id(col, 1); |
11740 | 434 g_object_unref(G_OBJECT(ls)); |
435 gtk_container_add(GTK_CONTAINER(sw), event_view); | |
12246 | 436 |
11740 | 437 expander = gtk_expander_new(_("<b>Plugin Details</b>")); |
438 gtk_expander_set_use_markup(GTK_EXPANDER(expander), TRUE); | |
439 plugin_details = gtk_label_new(NULL); | |
440 gtk_label_set_line_wrap(GTK_LABEL(plugin_details), TRUE); | |
441 gtk_container_add(GTK_CONTAINER(expander), plugin_details); | |
12343 | 442 gtk_widget_set_sensitive(expander, FALSE); |
11740 | 443 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), expander, FALSE, FALSE, 0); |
444 | |
445 g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (prefs_plugin_sel), NULL); | |
446 g_signal_connect(G_OBJECT(plugin_dialog), "response", G_CALLBACK(plugin_dialog_response_cb), sel); | |
447 gtk_window_set_default_size(GTK_WINDOW(plugin_dialog), 430, 430); | |
448 gtk_widget_show_all(plugin_dialog); | |
449 } |