Mercurial > pidgin.yaz
comparison src/plugins.c @ 3374:3cd2fbddf95a
[gaim-migrate @ 3393]
I had terrible days today and yesterday--a really terrible weekend.
No cool stuff from me--the prefs away message page works a bit better.
Ari and Chip both sent some patches to make things work a bit better in
GTK 2, and Etan rewrote the notify plugin so it's really cool now!
Thanks, guys!
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Mon, 05 Aug 2002 07:33:09 +0000 |
| parents | 0486d3d00d0e |
| children | 7a3f16a375a5 |
comparison
equal
deleted
inserted
replaced
| 3373:0e79bf1d79ea | 3374:3cd2fbddf95a |
|---|---|
| 85 static const gchar *plugin_makelistname(GModule *); | 85 static const gchar *plugin_makelistname(GModule *); |
| 86 | 86 |
| 87 static void destroy_plugins(GtkWidget *, gpointer); | 87 static void destroy_plugins(GtkWidget *, gpointer); |
| 88 static void load_file(GtkWidget *, gpointer); | 88 static void load_file(GtkWidget *, gpointer); |
| 89 static void load_which_plugin(GtkWidget *, gpointer); | 89 static void load_which_plugin(GtkWidget *, gpointer); |
| 90 static void list_clicked(GtkWidget *, struct gaim_plugin *); | |
| 91 void update_show_plugins(); | 90 void update_show_plugins(); |
| 92 static void hide_plugins(GtkWidget *, gpointer); | 91 static void hide_plugins(GtkWidget *, gpointer); |
| 92 static void clear_plugin_display(); | |
| 93 #if GTK_CHECK_VERSION(1,3,0) | |
| 94 static struct gaim_plugin *get_selected_plugin(GtkWidget *); | |
| 95 static void select_plugin(GtkWidget *w, struct gaim_plugin *p); | |
| 96 static void list_clicked(GtkWidget *, gpointer); | |
| 97 #else | |
| 98 static void list_clicked(GtkWidget *, struct gaim_plugin *); | |
| 99 #endif | |
| 93 | 100 |
| 94 /* ------------------ Code Below ---------------------------- */ | 101 /* ------------------ Code Below ---------------------------- */ |
| 95 | 102 |
| 96 static void destroy_plugins(GtkWidget *w, gpointer data) | 103 static void destroy_plugins(GtkWidget *w, gpointer data) |
| 97 { | 104 { |
| 136 } | 143 } |
| 137 | 144 |
| 138 static void load_which_plugin(GtkWidget *w, gpointer data) | 145 static void load_which_plugin(GtkWidget *w, gpointer data) |
| 139 { | 146 { |
| 140 char *file; | 147 char *file; |
| 141 | 148 struct gaim_plugin *p; |
| 142 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(plugin_dialog)); | 149 |
| 150 file = (char *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(plugin_dialog)); | |
| 143 if (file_is_dir(file, plugin_dialog)) { | 151 if (file_is_dir(file, plugin_dialog)) { |
| 144 return; | 152 return; |
| 145 } | 153 } |
| 146 | 154 |
| 147 if (file) | 155 if (file) |
| 148 load_plugin(file); | 156 p = load_plugin(file); |
| 157 else | |
| 158 p = NULL; | |
| 149 | 159 |
| 150 if (plugin_dialog) | 160 if (plugin_dialog) |
| 151 gtk_widget_destroy(plugin_dialog); | 161 gtk_widget_destroy(plugin_dialog); |
| 152 plugin_dialog = NULL; | 162 plugin_dialog = NULL; |
| 153 | 163 |
| 154 update_show_plugins(); | 164 update_show_plugins(); |
| 165 /* Select newly loaded plugin */ | |
| 166 if(p == NULL) | |
| 167 return; | |
| 168 #if GTK_CHECK_VERSION(1,3,0) | |
| 169 select_plugin(pluglist, p); | |
| 170 #else | |
| 171 gtk_list_select_item(GTK_LIST(pluglist), g_list_index(plugins, p)); | |
| 172 #endif | |
| 155 } | 173 } |
| 156 | 174 |
| 157 void show_plugins(GtkWidget *w, gpointer data) | 175 void show_plugins(GtkWidget *w, gpointer data) |
| 158 { | 176 { |
| 159 /* most of this code was shamelessly stolen from Glade */ | 177 /* most of this code was shamelessly stolen from Glade */ |
| 165 GtkWidget *frame; | 183 GtkWidget *frame; |
| 166 GtkWidget *scrolledwindow; | 184 GtkWidget *scrolledwindow; |
| 167 GtkWidget *label; | 185 GtkWidget *label; |
| 168 GtkWidget *add; | 186 GtkWidget *add; |
| 169 GtkWidget *close; | 187 GtkWidget *close; |
| 170 | 188 #if GTK_CHECK_VERSION(1,3,0) |
| 189 /* stuff needed for GtkTreeView *pluglist */ | |
| 190 GtkListStore *store; | |
| 191 GtkCellRenderer *renderer; | |
| 192 GtkTreeViewColumn *column; | |
| 193 GtkTreeSelection *selection; | |
| 194 /* needed for GtkTextView *plugtext */ | |
| 195 GtkTextBuffer *buffer; | |
| 196 #endif | |
| 197 | |
| 171 if (plugwindow) | 198 if (plugwindow) |
| 172 return; | 199 return; |
| 173 | 200 |
| 174 GAIM_DIALOG(plugwindow); | 201 GAIM_DIALOG(plugwindow); |
| 175 gtk_window_set_wmclass(GTK_WINDOW(plugwindow), "plugins", "Gaim"); | 202 gtk_window_set_wmclass(GTK_WINDOW(plugwindow), "plugins", "Gaim"); |
| 176 gtk_widget_realize(plugwindow); | 203 gtk_widget_realize(plugwindow); |
| 177 aol_icon(plugwindow->window); | 204 aol_icon(plugwindow->window); |
| 178 gtk_window_set_title(GTK_WINDOW(plugwindow), _("Gaim - Plugins")); | 205 gtk_window_set_title(GTK_WINDOW(plugwindow), _("Gaim - Plugins")); |
| 206 #if !GTK_CHECK_VERSION(1,3,0) | |
| 179 gtk_widget_set_usize(plugwindow, 515, 300); | 207 gtk_widget_set_usize(plugwindow, 515, 300); |
| 208 #endif | |
| 180 gtk_signal_connect(GTK_OBJECT(plugwindow), "destroy", GTK_SIGNAL_FUNC(hide_plugins), NULL); | 209 gtk_signal_connect(GTK_OBJECT(plugwindow), "destroy", GTK_SIGNAL_FUNC(hide_plugins), NULL); |
| 181 | 210 |
| 182 mainvbox = gtk_vbox_new(FALSE, 0); | 211 mainvbox = gtk_vbox_new(FALSE, 0); |
| 183 gtk_container_add(GTK_CONTAINER(plugwindow), mainvbox); | 212 gtk_container_add(GTK_CONTAINER(plugwindow), mainvbox); |
| 184 gtk_widget_show(mainvbox); | 213 gtk_widget_show(mainvbox); |
| 189 gtk_widget_show(tophbox); | 218 gtk_widget_show(tophbox); |
| 190 | 219 |
| 191 /* Left side: frame with list of plugin file names */ | 220 /* Left side: frame with list of plugin file names */ |
| 192 frame = gtk_frame_new(_("Loaded Plugins")); | 221 frame = gtk_frame_new(_("Loaded Plugins")); |
| 193 gtk_box_pack_start(GTK_BOX(tophbox), frame, FALSE, FALSE, 0); | 222 gtk_box_pack_start(GTK_BOX(tophbox), frame, FALSE, FALSE, 0); |
| 223 #if !GTK_CHECK_VERSION(1,3,0) | |
| 194 gtk_widget_set_usize(frame, 140, -1); | 224 gtk_widget_set_usize(frame, 140, -1); |
| 225 #endif | |
| 195 gtk_container_set_border_width(GTK_CONTAINER(frame), 6); | 226 gtk_container_set_border_width(GTK_CONTAINER(frame), 6); |
| 196 gtk_frame_set_label_align(GTK_FRAME(frame), 0.05, 0.5); | 227 gtk_frame_set_label_align(GTK_FRAME(frame), 0.05, 0.5); |
| 197 gtk_widget_show(frame); | 228 gtk_widget_show(frame); |
| 198 | 229 |
| 199 scrolledwindow = gtk_scrolled_window_new(NULL, NULL); | 230 scrolledwindow = gtk_scrolled_window_new(NULL, NULL); |
| 200 gtk_container_add(GTK_CONTAINER(frame), scrolledwindow); | 231 gtk_container_add(GTK_CONTAINER(frame), scrolledwindow); |
| 201 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), | 232 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), |
| 202 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | 233 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 203 gtk_widget_show(scrolledwindow); | 234 gtk_widget_show(scrolledwindow); |
| 204 | 235 #if GTK_CHECK_VERSION(1,3,0) |
| 236 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), | |
| 237 GTK_SHADOW_IN); | |
| 238 | |
| 239 /* Create & show plugin list */ | |
| 240 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); | |
| 241 pluglist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
| 242 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pluglist), FALSE); | |
| 243 renderer = gtk_cell_renderer_text_new(); | |
| 244 column = gtk_tree_view_column_new_with_attributes("text", | |
| 245 renderer, "text", 0, NULL); | |
| 246 gtk_tree_view_append_column(GTK_TREE_VIEW(pluglist), column); | |
| 247 gtk_container_add(GTK_CONTAINER(scrolledwindow), pluglist); | |
| 248 | |
| 249 g_object_unref(G_OBJECT(store)); | |
| 250 | |
| 251 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pluglist)); | |
| 252 g_signal_connect(G_OBJECT(selection), "changed", | |
| 253 G_CALLBACK(list_clicked), | |
| 254 NULL); | |
| 255 #else | |
| 205 pluglist = gtk_list_new(); | 256 pluglist = gtk_list_new(); |
| 206 gtk_list_set_selection_mode(GTK_LIST(pluglist), GTK_SELECTION_BROWSE); | 257 gtk_list_set_selection_mode(GTK_LIST(pluglist), GTK_SELECTION_BROWSE); |
| 207 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwindow), pluglist); | 258 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwindow), |
| 259 pluglist); | |
| 260 #endif /* GTK_CHECK_VERSION */ | |
| 261 | |
| 208 gtk_widget_show(pluglist); | 262 gtk_widget_show(pluglist); |
| 209 | 263 |
| 210 /* Right side: frame with description and the filepath of plugin */ | 264 /* Right side: frame with description and the filepath of plugin */ |
| 211 frame = gtk_frame_new(_("Description")); | 265 frame = gtk_frame_new(_("Selected Plugin")); |
| 212 gtk_box_pack_start(GTK_BOX(tophbox), frame, TRUE, TRUE, 0); | 266 gtk_box_pack_start(GTK_BOX(tophbox), frame, TRUE, TRUE, 0); |
| 213 gtk_container_set_border_width(GTK_CONTAINER(frame), 6); | 267 gtk_container_set_border_width(GTK_CONTAINER(frame), 6); |
| 214 gtk_frame_set_label_align(GTK_FRAME(frame), 0.05, 0.5); | 268 gtk_frame_set_label_align(GTK_FRAME(frame), 0.05, 0.5); |
| 215 gtk_widget_show(frame); | 269 gtk_widget_show(frame); |
| 216 | 270 |
| 221 scrolledwindow = gtk_scrolled_window_new(NULL, NULL); | 275 scrolledwindow = gtk_scrolled_window_new(NULL, NULL); |
| 222 gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0); | 276 gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0); |
| 223 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), | 277 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), |
| 224 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | 278 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 225 gtk_widget_show(scrolledwindow); | 279 gtk_widget_show(scrolledwindow); |
| 226 | 280 #if GTK_CHECK_VERSION(1,3,0) |
| 281 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), | |
| 282 GTK_SHADOW_IN); | |
| 283 | |
| 284 /* Create & show the plugin description widget */ | |
| 285 plugtext = gtk_text_view_new(); | |
| 286 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(plugtext), GTK_WRAP_WORD); | |
| 287 gtk_text_view_set_editable(GTK_TEXT_VIEW(plugtext), FALSE); | |
| 288 gtk_container_add(GTK_CONTAINER(scrolledwindow), plugtext); | |
| 289 gtk_widget_set_size_request(GTK_WIDGET(plugtext), -1, 200); | |
| 290 | |
| 291 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugtext)); | |
| 292 gtk_text_buffer_create_tag(buffer, "bold", "weight", | |
| 293 PANGO_WEIGHT_BOLD, NULL); | |
| 294 #else | |
| 227 plugtext = gtk_text_new(NULL, NULL); | 295 plugtext = gtk_text_new(NULL, NULL); |
| 228 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwindow), plugtext); | 296 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwindow), |
| 297 plugtext); | |
| 229 gtk_text_set_word_wrap(GTK_TEXT(plugtext), TRUE); | 298 gtk_text_set_word_wrap(GTK_TEXT(plugtext), TRUE); |
| 230 gtk_text_set_editable(GTK_TEXT(plugtext), FALSE); | 299 gtk_text_set_editable(GTK_TEXT(plugtext), FALSE); |
| 300 #endif | |
| 231 gtk_widget_show(plugtext); | 301 gtk_widget_show(plugtext); |
| 232 | 302 |
| 233 hbox = gtk_hbox_new(FALSE, 5); | 303 hbox = gtk_hbox_new(FALSE, 5); |
| 234 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 304 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 235 gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); | 305 gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); |
| 243 gtk_box_pack_start(GTK_BOX(hbox), plugentry, TRUE, TRUE, 0); | 313 gtk_box_pack_start(GTK_BOX(hbox), plugentry, TRUE, TRUE, 0); |
| 244 gtk_entry_set_editable(GTK_ENTRY(plugentry), FALSE); | 314 gtk_entry_set_editable(GTK_ENTRY(plugentry), FALSE); |
| 245 gtk_widget_show(plugentry); | 315 gtk_widget_show(plugentry); |
| 246 | 316 |
| 247 /* Build the bottom button bar */ | 317 /* Build the bottom button bar */ |
| 248 bothbox = gtk_hbox_new(TRUE, 10); | 318 bothbox = gtk_hbox_new(TRUE, 3); |
| 249 gtk_box_pack_start(GTK_BOX(mainvbox), bothbox, FALSE, FALSE, 0); | 319 gtk_box_pack_start(GTK_BOX(mainvbox), bothbox, FALSE, FALSE, 0); |
| 250 gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); | 320 gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); |
| 251 gtk_widget_show(bothbox); | 321 gtk_widget_show(bothbox); |
| 252 | 322 |
| 253 if (!tooltips) | 323 if (!tooltips) |
| 254 tooltips = gtk_tooltips_new(); | 324 tooltips = gtk_tooltips_new(); |
| 255 | 325 |
| 256 add = picture_button(plugwindow, _("Load"), gnome_add_xpm); | 326 add = picture_button(plugwindow, _("Load"), gnome_add_xpm); |
| 257 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(load_file), NULL); | 327 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(load_file), NULL); |
| 258 gtk_box_pack_start(GTK_BOX(bothbox), add, TRUE, TRUE, 0); | 328 gtk_box_pack_start_defaults(GTK_BOX(bothbox), add); |
| 259 gtk_tooltips_set_tip(tooltips, add, _("Load a plugin from a file"), ""); | 329 gtk_tooltips_set_tip(tooltips, add, _("Load a plugin from a file"), ""); |
| 260 | 330 |
| 261 config = picture_button(plugwindow, _("Configure"), gnome_preferences_xpm); | 331 config = picture_button(plugwindow, _("Configure"), gnome_preferences_xpm); |
| 262 gtk_widget_set_sensitive(config, FALSE); | 332 gtk_widget_set_sensitive(config, FALSE); |
| 263 gtk_box_pack_start(GTK_BOX(bothbox), config, TRUE, TRUE, 0); | 333 gtk_box_pack_start_defaults(GTK_BOX(bothbox), config); |
| 264 gtk_tooltips_set_tip(tooltips, config, _("Configure settings of the selected plugin"), ""); | 334 gtk_tooltips_set_tip(tooltips, config, _("Configure settings of the selected plugin"), ""); |
| 265 | 335 |
| 266 reload = picture_button(plugwindow, _("Reload"), refresh_xpm); | 336 reload = picture_button(plugwindow, _("Reload"), refresh_xpm); |
| 267 gtk_widget_set_sensitive(reload, FALSE); | 337 gtk_widget_set_sensitive(reload, FALSE); |
| 268 gtk_signal_connect(GTK_OBJECT(reload), "clicked", GTK_SIGNAL_FUNC(plugin_reload_cb), NULL); | 338 gtk_signal_connect(GTK_OBJECT(reload), "clicked", GTK_SIGNAL_FUNC(plugin_reload_cb), NULL); |
| 269 gtk_box_pack_start(GTK_BOX(bothbox), reload, TRUE, TRUE, 0); | 339 gtk_box_pack_start_defaults(GTK_BOX(bothbox), reload); |
| 270 gtk_tooltips_set_tip(tooltips, reload, _("Reload the selected plugin"), ""); | 340 gtk_tooltips_set_tip(tooltips, reload, _("Reload the selected plugin"), ""); |
| 271 | 341 |
| 272 unload = picture_button(plugwindow, _("Unload"), gnome_remove_xpm); | 342 unload = picture_button(plugwindow, _("Unload"), gnome_remove_xpm); |
| 273 gtk_signal_connect(GTK_OBJECT(unload), "clicked", GTK_SIGNAL_FUNC(unload_plugin_cb), pluglist); | 343 gtk_signal_connect(GTK_OBJECT(unload), "clicked", GTK_SIGNAL_FUNC(unload_plugin_cb), pluglist); |
| 274 gtk_box_pack_start(GTK_BOX(bothbox), unload, TRUE, TRUE, 0); | 344 gtk_box_pack_start_defaults(GTK_BOX(bothbox), unload); |
| 275 gtk_tooltips_set_tip(tooltips, unload, _("Unload the selected plugin"), ""); | 345 gtk_tooltips_set_tip(tooltips, unload, _("Unload the selected plugin"), ""); |
| 276 | 346 |
| 277 close = picture_button(plugwindow, _("Close"), cancel_xpm); | 347 close = picture_button(plugwindow, _("Close"), cancel_xpm); |
| 278 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(hide_plugins), NULL); | 348 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(hide_plugins), NULL); |
| 279 gtk_box_pack_start(GTK_BOX(bothbox), close, TRUE, TRUE, 0); | 349 gtk_box_pack_start_defaults(GTK_BOX(bothbox), close); |
| 280 gtk_tooltips_set_tip(tooltips, close, _("Close this window"), ""); | 350 gtk_tooltips_set_tip(tooltips, close, _("Close this window"), ""); |
| 281 | 351 |
| 282 update_show_plugins(); | 352 update_show_plugins(); |
| 283 gtk_widget_show(plugwindow); | 353 gtk_widget_show(plugwindow); |
| 284 } | 354 } |
| 285 | 355 |
| 286 void update_show_plugins() | 356 void update_show_plugins() |
| 287 { | 357 { |
| 288 GList *plugs = plugins; | 358 GList *plugs = plugins; |
| 289 struct gaim_plugin *p; | 359 struct gaim_plugin *p; |
| 360 #if GTK_CHECK_VERSION(1,3,0) | |
| 361 int pnum = 0; | |
| 362 GtkListStore *store; | |
| 363 GtkTreeIter iter; | |
| 364 #else | |
| 290 GtkWidget *label; | 365 GtkWidget *label; |
| 291 GtkWidget *list_item; | 366 GtkWidget *list_item; |
| 292 GtkWidget *hbox; | 367 GtkWidget *hbox; |
| 293 | 368 #endif |
| 369 | |
| 294 if (plugwindow == NULL) | 370 if (plugwindow == NULL) |
| 295 return; | 371 return; |
| 296 | 372 |
| 373 #if GTK_CHECK_VERSION(1,3,0) | |
| 374 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(pluglist))); | |
| 375 gtk_list_store_clear(store); | |
| 376 #else | |
| 297 gtk_list_clear_items(GTK_LIST(pluglist), 0, -1); | 377 gtk_list_clear_items(GTK_LIST(pluglist), 0, -1); |
| 378 #endif | |
| 298 while (plugs) { | 379 while (plugs) { |
| 299 p = (struct gaim_plugin *)plugs->data; | 380 p = (struct gaim_plugin *)plugs->data; |
| 381 #if GTK_CHECK_VERSION(1,3,0) | |
| 382 gtk_list_store_append(store, &iter); | |
| 383 gtk_list_store_set(store, &iter, 0, plugin_makelistname(p->handle), -1); | |
| 384 gtk_list_store_set(store, &iter, 1, pnum++, -1); | |
| 385 #else | |
| 300 label = gtk_label_new(plugin_makelistname(p->handle)); | 386 label = gtk_label_new(plugin_makelistname(p->handle)); |
| 301 hbox = gtk_hbox_new(FALSE, 0); /* for left justification */ | 387 hbox = gtk_hbox_new(FALSE, 0); /* for left justification */ |
| 302 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 388 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| 303 | 389 |
| 304 list_item = gtk_list_item_new(); | 390 list_item = gtk_list_item_new(); |
| 305 gtk_container_add(GTK_CONTAINER(list_item), hbox); | 391 gtk_container_add(GTK_CONTAINER(list_item), hbox); |
| 306 gtk_signal_connect(GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(list_clicked), p); | 392 gtk_signal_connect(GTK_OBJECT(list_item), "select", |
| 393 GTK_SIGNAL_FUNC(list_clicked), p); | |
| 307 gtk_object_set_user_data(GTK_OBJECT(list_item), p); | 394 gtk_object_set_user_data(GTK_OBJECT(list_item), p); |
| 308 | 395 |
| 309 gtk_widget_show(hbox); | 396 gtk_widget_show(hbox); |
| 310 gtk_widget_show(label); | 397 gtk_widget_show(label); |
| 311 gtk_container_add(GTK_CONTAINER(pluglist), list_item); | 398 gtk_container_add(GTK_CONTAINER(pluglist), list_item); |
| 312 gtk_widget_show(list_item); | 399 gtk_widget_show(list_item); |
| 313 | 400 #endif |
| 314 plugs = g_list_next(plugs); | 401 plugs = g_list_next(plugs); |
| 315 } | 402 } |
| 316 | 403 |
| 317 /* Clear the display if nothing's selected */ | 404 clear_plugin_display(); |
| 318 if (GTK_LIST(pluglist)->selection == NULL) { | |
| 319 guint text_len = gtk_text_get_length(GTK_TEXT(plugtext)); | |
| 320 gtk_text_set_point(GTK_TEXT(plugtext), 0); | |
| 321 gtk_text_forward_delete(GTK_TEXT(plugtext), text_len); | |
| 322 gtk_entry_set_text(GTK_ENTRY(plugentry), ""); | |
| 323 | |
| 324 gtk_widget_set_sensitive(config, FALSE); | |
| 325 gtk_widget_set_sensitive(reload, FALSE); | |
| 326 gtk_widget_set_sensitive(unload, FALSE); | |
| 327 } | |
| 328 } | 405 } |
| 329 | 406 |
| 330 static void unload_plugin_cb(GtkWidget *w, gpointer data) | 407 static void unload_plugin_cb(GtkWidget *w, gpointer data) |
| 331 { | 408 { |
| 409 struct gaim_plugin *p; | |
| 410 #if GTK_CHECK_VERSION(1,3,0) | |
| 411 p = get_selected_plugin(pluglist); | |
| 412 if(p == NULL) | |
| 413 return; | |
| 414 #else | |
| 332 GList *i; | 415 GList *i; |
| 333 struct gaim_plugin *p; | 416 |
| 334 | |
| 335 i = GTK_LIST(pluglist)->selection; | 417 i = GTK_LIST(pluglist)->selection; |
| 336 | 418 |
| 337 if (i == NULL) | 419 if (i == NULL) |
| 338 return; | 420 return; |
| 339 | 421 |
| 340 p = gtk_object_get_user_data(GTK_OBJECT(i->data)); | 422 p = gtk_object_get_user_data(GTK_OBJECT(i->data)); |
| 341 | 423 #endif |
| 342 unload_plugin(p); | 424 unload_plugin(p); |
| 343 update_show_plugins(); | 425 update_show_plugins(); |
| 344 } | 426 } |
| 345 | 427 |
| 346 static void plugin_reload_cb(GtkWidget *w, gpointer data) | 428 static void plugin_reload_cb(GtkWidget *w, gpointer data) |
| 347 { | 429 { |
| 430 struct gaim_plugin *p; | |
| 431 #if GTK_CHECK_VERSION(1,3,0) | |
| 432 p = get_selected_plugin(pluglist); | |
| 433 if(p == NULL) | |
| 434 return; | |
| 435 p = reload_plugin(p); | |
| 436 #else | |
| 348 GList *i; | 437 GList *i; |
| 349 struct gaim_plugin *p; | |
| 350 | 438 |
| 351 i = GTK_LIST(pluglist)->selection; | 439 i = GTK_LIST(pluglist)->selection; |
| 352 if (i == NULL) | 440 if (i == NULL) |
| 353 return; | 441 return; |
| 354 | 442 |
| 355 /* Just pass off plugin to the actual function */ | 443 /* Just pass off plugin to the actual function */ |
| 356 p = reload_plugin(gtk_object_get_user_data(GTK_OBJECT(i->data))); | 444 p = reload_plugin(gtk_object_get_user_data(GTK_OBJECT(i->data))); |
| 357 | 445 #endif |
| 358 update_show_plugins(); | 446 update_show_plugins(); |
| 359 | 447 |
| 360 /* Try and reselect the plugin in list */ | 448 /* Try and reselect the plugin in list */ |
| 361 if (!pluglist) | 449 if (!pluglist) |
| 362 return; | 450 return; |
| 451 #if GTK_CHECK_VERSION(1,3,0) | |
| 452 select_plugin(pluglist, p); | |
| 453 #else | |
| 363 gtk_list_select_item(GTK_LIST(pluglist), g_list_index(plugins, p)); | 454 gtk_list_select_item(GTK_LIST(pluglist), g_list_index(plugins, p)); |
| 364 } | 455 #endif |
| 365 | 456 } |
| 457 | |
| 458 | |
| 459 #if GTK_CHECK_VERSION(1,3,0) | |
| 460 static void list_clicked(GtkWidget *w, gpointer data) | |
| 461 #else | |
| 366 static void list_clicked(GtkWidget *w, struct gaim_plugin *p) | 462 static void list_clicked(GtkWidget *w, struct gaim_plugin *p) |
| 367 { | 463 #endif |
| 464 { | |
| 465 void (*gaim_plugin_config)(); | |
| 466 #if GTK_CHECK_VERSION(1,3,0) | |
| 467 struct gaim_plugin *p; | |
| 468 GtkTextBuffer *buffer; | |
| 469 GtkTextIter iter; | |
| 470 #else | |
| 368 gchar *temp; | 471 gchar *temp; |
| 369 guint text_len; | 472 guint text_len; |
| 370 void (*gaim_plugin_config)(); | 473 #endif |
| 371 | 474 |
| 372 if (confighandle != 0) | 475 if (confighandle != 0) { |
| 373 gtk_signal_disconnect(GTK_OBJECT(config), confighandle); | 476 gtk_signal_disconnect(GTK_OBJECT(config), confighandle); |
| 374 | 477 confighandle = 0; |
| 478 } | |
| 479 | |
| 480 #if GTK_CHECK_VERSION(1,3,0) | |
| 481 p = get_selected_plugin(pluglist); | |
| 482 if(p == NULL) { /* No selected plugin */ | |
| 483 clear_plugin_display(); | |
| 484 return; | |
| 485 } | |
| 486 | |
| 487 /* Set text and filepath widgets */ | |
| 488 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugtext)); | |
| 489 gtk_text_buffer_set_text(buffer, "", -1); | |
| 490 gtk_text_buffer_get_start_iter(buffer, &iter); | |
| 491 | |
| 492 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "Name:", -1, | |
| 493 "bold", NULL); | |
| 494 gtk_text_buffer_insert(buffer, &iter, " ", -1); | |
| 495 gtk_text_buffer_insert(buffer, &iter, (p->name != NULL) ? p->name : "", -1); | |
| 496 gtk_text_buffer_insert(buffer, &iter, "\n\n", -1); | |
| 497 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "Description:", -1, | |
| 498 "bold", NULL); | |
| 499 gtk_text_buffer_insert(buffer, &iter, "\n", -1); | |
| 500 gtk_text_buffer_insert(buffer, &iter, | |
| 501 (p->description != NULL) ? p->description : "", -1); | |
| 502 | |
| 503 gtk_entry_set_text(GTK_ENTRY(plugentry), g_module_name(p->handle)); | |
| 504 #else | |
| 375 text_len = gtk_text_get_length(GTK_TEXT(plugtext)); | 505 text_len = gtk_text_get_length(GTK_TEXT(plugtext)); |
| 376 gtk_text_set_point(GTK_TEXT(plugtext), 0); | 506 gtk_text_set_point(GTK_TEXT(plugtext), 0); |
| 377 gtk_text_forward_delete(GTK_TEXT(plugtext), text_len); | 507 gtk_text_forward_delete(GTK_TEXT(plugtext), text_len); |
| 378 | 508 |
| 379 temp = g_strdup_printf("Name: %s\n\nDescription:\n%s", | 509 temp = g_strdup_printf("Name: %s\n\nDescription:\n%s", |
| 380 (p->name != NULL) ? p->name : "", | 510 (p->name != NULL) ? p->name : "", |
| 381 (p->description != NULL) ? p->description : ""); | 511 (p->description != NULL) ? p->description : ""); |
| 382 gtk_text_insert(GTK_TEXT(plugtext), NULL, NULL, NULL, temp, -1); | 512 gtk_text_insert(GTK_TEXT(plugtext), NULL, NULL, NULL, temp, -1); |
| 383 g_free(temp); | 513 g_free(temp); |
| 384 gtk_entry_set_text(GTK_ENTRY(plugentry), g_module_name(p->handle)); | 514 gtk_entry_set_text(GTK_ENTRY(plugentry), g_module_name(p->handle)); |
| 385 | 515 #endif |
| 386 /* Find out if this plug-in has a configuration function */ | 516 /* Find out if this plug-in has a configuration function */ |
| 387 if (g_module_symbol(p->handle, "gaim_plugin_config", (gpointer *)&gaim_plugin_config)) { | 517 if (g_module_symbol(p->handle, "gaim_plugin_config", (gpointer *)&gaim_plugin_config)) { |
| 388 confighandle = gtk_signal_connect(GTK_OBJECT(config), "clicked", | 518 confighandle = gtk_signal_connect(GTK_OBJECT(config), "clicked", |
| 389 GTK_SIGNAL_FUNC(gaim_plugin_config), NULL); | 519 GTK_SIGNAL_FUNC(gaim_plugin_config), NULL); |
| 390 gtk_widget_set_sensitive(config, TRUE); | 520 gtk_widget_set_sensitive(config, TRUE); |
| 407 } | 537 } |
| 408 | 538 |
| 409 static const gchar *plugin_makelistname(GModule *module) | 539 static const gchar *plugin_makelistname(GModule *module) |
| 410 { | 540 { |
| 411 static gchar filename[PATHSIZE]; | 541 static gchar filename[PATHSIZE]; |
| 412 gchar *filepath = g_module_name(module); | 542 gchar *filepath = (char *)g_module_name(module); |
| 413 char *cp; | 543 char *cp; |
| 414 | 544 |
| 415 if (filepath == NULL || strlen(filepath) == 0) | 545 if (filepath == NULL || strlen(filepath) == 0) |
| 416 return NULL; | 546 return NULL; |
| 417 | 547 |
| 427 filename[strlen(filename) - 3] = '\0'; | 557 filename[strlen(filename) - 3] = '\0'; |
| 428 | 558 |
| 429 return filename; | 559 return filename; |
| 430 } | 560 } |
| 431 | 561 |
| 432 #endif | 562 #if GTK_CHECK_VERSION(1,3,0) |
| 563 static struct gaim_plugin *get_selected_plugin(GtkWidget *w) { | |
| 564 /* Given the pluglist widget, this will return a pointer to the plugin | |
| 565 * currently selected in the list, and NULL if none is selected. */ | |
| 566 gint index; | |
| 567 GList *plugs = plugins; | |
| 568 GtkTreeSelection *sel; | |
| 569 GtkTreeIter iter; | |
| 570 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(w)); | |
| 571 | |
| 572 /* Get list index of selected plugin */ | |
| 573 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(w)); | |
| 574 if(!gtk_tree_selection_get_selected(sel, &model, &iter)) | |
| 575 return NULL; | |
| 576 gtk_tree_model_get(model, &iter, 1, &index, -1); | |
| 577 | |
| 578 /* Get plugin entry from index */ | |
| 579 plugs = g_list_nth(plugins, index); | |
| 580 if(plugs == NULL) | |
| 581 return NULL; | |
| 582 else | |
| 583 return (struct gaim_plugin *)plugs->data; | |
| 584 } | |
| 585 | |
| 586 static void select_plugin(GtkWidget *w, struct gaim_plugin *p) { | |
| 587 /* Given the pluglist widget and a plugin, this will try to select | |
| 588 * entry in the list which corresponds with the plugin. */ | |
| 589 GtkTreeSelection *sel; | |
| 590 GtkTreeIter iter; | |
| 591 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(w)); | |
| 592 gchar temp[10]; | |
| 593 | |
| 594 if(g_list_index(plugins, p) == -1) | |
| 595 return; | |
| 596 | |
| 597 snprintf(temp, 10, "%d", g_list_index(plugins, p)); | |
| 598 gtk_tree_model_get_iter_from_string(model, | |
| 599 &iter, temp); | |
| 600 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(w)); | |
| 601 gtk_tree_selection_select_iter(sel, &iter); | |
| 602 } | |
| 603 #endif /* GTK_CHECK_VERSION */ | |
| 604 | |
| 605 static void clear_plugin_display() { | |
| 606 #if GTK_CHECK_VERSION(1,3,0) | |
| 607 GtkTreeSelection *selection; | |
| 608 GtkTextBuffer *buffer; | |
| 609 | |
| 610 /* Clear the plugin display if nothing's selected */ | |
| 611 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pluglist)); | |
| 612 if(gtk_tree_selection_get_selected(selection, NULL, NULL) == FALSE) { | |
| 613 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugtext)); | |
| 614 gtk_text_buffer_set_text(buffer, "", -1); | |
| 615 gtk_entry_set_text(GTK_ENTRY(plugentry), ""); | |
| 616 | |
| 617 gtk_widget_set_sensitive(config, FALSE); | |
| 618 gtk_widget_set_sensitive(reload, FALSE); | |
| 619 gtk_widget_set_sensitive(unload, FALSE); | |
| 620 } | |
| 621 #else | |
| 622 /* Clear the display if nothing's selected */ | |
| 623 if (GTK_LIST(pluglist)->selection == NULL) { | |
| 624 guint text_len = gtk_text_get_length(GTK_TEXT(plugtext)); | |
| 625 gtk_text_set_point(GTK_TEXT(plugtext), 0); | |
| 626 gtk_text_forward_delete(GTK_TEXT(plugtext), text_len); | |
| 627 gtk_entry_set_text(GTK_ENTRY(plugentry), ""); | |
| 628 | |
| 629 gtk_widget_set_sensitive(config, FALSE); | |
| 630 gtk_widget_set_sensitive(reload, FALSE); | |
| 631 gtk_widget_set_sensitive(unload, FALSE); | |
| 632 } | |
| 633 #endif | |
| 634 } | |
| 635 | |
| 636 #endif |
