comparison plugins/spellchk.c @ 6485:70d5122bc3ff

[gaim-migrate @ 6999] Removed the old event system and replaced it with a much better signal system. There will most likely be some bugs in this, but it seems to be working for now. Plugins can now generate their own signals, and other plugins can find those plugins and connect to them. This could give plugins a form of IPC. It's also useful for other things. It's rather flexible, except for the damn marshalling, but there's no way around that that I or the glib people can see. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 18 Aug 2003 01:03:43 +0000
parents e9974608b319
children b0913ab92893
comparison
equal deleted inserted replaced
6484:5ced8e111473 6485:70d5122bc3ff
3 * or nearly directly from xchat, version 1.4.2 by Peter Zelezny and others. 3 * or nearly directly from xchat, version 1.4.2 by Peter Zelezny and others.
4 */ 4 */
5 #include "internal.h" 5 #include "internal.h"
6 6
7 #include "debug.h" 7 #include "debug.h"
8 #include "signals.h"
8 #include "util.h" 9 #include "util.h"
9 10
10 #include "gtkplugin.h" 11 #include "gtkplugin.h"
11 #include "gtkutils.h" 12 #include "gtkutils.h"
12 13
22 static int get_word(char *, int); 23 static int get_word(char *, int);
23 static char *have_word(char *, int); 24 static char *have_word(char *, int);
24 static void substitute(char **, int, int, const char *); 25 static void substitute(char **, int, int, const char *);
25 static GtkListStore *model; 26 static GtkListStore *model;
26 27
27 static void substitute_words(GaimConnection *gc, char *who, char **message, void *m) { 28 static void
29 substitute_words(GaimAccount *account, GaimConversation *conv,
30 char **message, void *data)
31 {
28 int i, l; 32 int i, l;
29 int word; 33 int word;
30 char *tmp; 34 char *tmp;
31 35
32 if (message == NULL || *message == NULL) 36 if (message == NULL || *message == NULL)
256 GtkTreeIter *iter, gpointer data) 260 GtkTreeIter *iter, gpointer data)
257 { 261 {
258 GSList **list = (GSList **)data; 262 GSList **list = (GSList **)data;
259 *list = g_slist_append(*list, gtk_tree_path_copy(path) ); 263 *list = g_slist_append(*list, gtk_tree_path_copy(path) );
260 } 264 }
261 265
262 266
263 static void remove_row(void *data1, gpointer data2) 267 static void remove_row(void *data1, gpointer data2)
264 { 268 {
265 GtkTreePath *path = (GtkTreePath*)data1; 269 GtkTreePath *path = (GtkTreePath*)data1;
266 GtkTreeIter iter; 270 GtkTreeIter iter;
326 "Error writing to %s: %m\n", tempfilename); 330 "Error writing to %s: %m\n", tempfilename);
327 unlink(tempfilename); 331 unlink(tempfilename);
328 g_free(name); 332 g_free(name);
329 return; 333 return;
330 } 334 }
331 rename(tempfilename, name); 335 rename(tempfilename, name);
332 g_free(name); 336 g_free(name);
333 } 337 }
334 338
335 static void 339 static void
336 check_if_something_is_selected(GtkTreeModel *model, 340 check_if_something_is_selected(GtkTreeModel *model,
366 */ 370 */
367 371
368 static gboolean 372 static gboolean
369 plugin_load(GaimPlugin *plugin) 373 plugin_load(GaimPlugin *plugin)
370 { 374 {
375 void *conv_handle = gaim_conversations_get_handle();
376
371 load_conf(); 377 load_conf();
372 378
373 gaim_signal_connect(plugin, event_im_send, substitute_words, NULL); 379 gaim_signal_connect(conv_handle, "sending-im-msg",
374 gaim_signal_connect(plugin, event_chat_send, substitute_words, NULL); 380 plugin, GAIM_CALLBACK(substitute_words), NULL);
381 gaim_signal_connect(conv_handle, "sending-chat-msg",
382 plugin, GAIM_CALLBACK(substitute_words), NULL);
375 383
376 return TRUE; 384 return TRUE;
377 } 385 }
378 386
379 static GtkWidget * 387 static GtkWidget *
388 396
389 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 397 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
390 398
391 ret = gtk_vbox_new(FALSE, 18); 399 ret = gtk_vbox_new(FALSE, 18);
392 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); 400 gtk_container_set_border_width (GTK_CONTAINER (ret), 12);
393 401
394 vbox = gaim_gtk_make_frame(ret, _("Text Replacements")); 402 vbox = gaim_gtk_make_frame(ret, _("Text Replacements"));
395 gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); 403 gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
396 gtk_widget_set_size_request(vbox, 300, -1); 404 gtk_widget_set_size_request(vbox, 300, -1);
397 gtk_widget_show (vbox); 405 gtk_widget_show (vbox);
398 406
406 gtk_widget_show(win); 414 gtk_widget_show(win);
407 415
408 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); 416 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
409 /* gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); */ 417 /* gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); */
410 gtk_widget_set_size_request(tree, 260,200); 418 gtk_widget_set_size_request(tree, 260,200);
411 419
412 renderer = gtk_cell_renderer_text_new (); 420 renderer = gtk_cell_renderer_text_new ();
413 g_object_set (G_OBJECT (renderer), 421 g_object_set (G_OBJECT (renderer),
414 "editable", TRUE, 422 "editable", TRUE,
415 NULL); 423 NULL);
416 g_signal_connect(G_OBJECT(renderer), "edited", 424 g_signal_connect(G_OBJECT(renderer), "edited",
457 gtk_widget_set_size_request(vbox, 300, -1); 465 gtk_widget_set_size_request(vbox, 300, -1);
458 466
459 hbox = gtk_hbox_new(FALSE, 2); 467 hbox = gtk_hbox_new(FALSE, 2);
460 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 468 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
461 gtk_widget_show(hbox); 469 gtk_widget_show(hbox);
462 470
463 label = gtk_label_new_with_mnemonic(_("You _type:")); 471 label = gtk_label_new_with_mnemonic(_("You _type:"));
464 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 472 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
465 473
466 bad_entry = gtk_entry_new(); 474 bad_entry = gtk_entry_new();
467 gtk_entry_set_max_length(GTK_ENTRY(bad_entry), 40); 475 gtk_entry_set_max_length(GTK_ENTRY(bad_entry), 40);