comparison pidgin/gtkdebug.c @ 15823:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 84b0f9b23ede
children 66dff3dfdea6
comparison
equal deleted inserted replaced
15822:84b0f9b23ede 15823:32c366eeeb99
1 /** 1 /**
2 * @file gtkdebug.c GTK+ Debug API 2 * @file gtkdebug.c GTK+ Debug API
3 * @ingroup gtkui 3 * @ingroup gtkui
4 * 4 *
5 * gaim 5 * purple
6 * 6 *
7 * Gaim is the legal property of its developers, whose names are too numerous 7 * Purple 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 8 * to list here. Please refer to the COPYRIGHT file distributed with this
9 * source distribution. 9 * source distribution.
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 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 12 * it under the terms of the GNU General Public License as published by
85 #endif /* HAVE_REGEX_H */ 85 #endif /* HAVE_REGEX_H */
86 86
87 static gint 87 static gint
88 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused) 88 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused)
89 { 89 {
90 gaim_prefs_disconnect_by_handle(pidgin_debug_get_handle()); 90 purple_prefs_disconnect_by_handle(pidgin_debug_get_handle());
91 91
92 #ifdef HAVE_REGEX_H 92 #ifdef HAVE_REGEX_H
93 if(debug_win->timer != 0) { 93 if(debug_win->timer != 0) {
94 const gchar *text; 94 const gchar *text;
95 95
96 g_source_remove(debug_win->timer); 96 g_source_remove(debug_win->timer);
97 97
98 text = gtk_entry_get_text(GTK_ENTRY(debug_win->expression)); 98 text = gtk_entry_get_text(GTK_ENTRY(debug_win->expression));
99 gaim_prefs_set_string("/gaim/gtk/debug/regex", text); 99 purple_prefs_set_string("/purple/gtk/debug/regex", text);
100 } 100 }
101 101
102 regfree(&debug_win->regex); 102 regfree(&debug_win->regex);
103 #endif 103 #endif
104 104
105 /* If the "Save Log" dialog is open then close it */ 105 /* If the "Save Log" dialog is open then close it */
106 gaim_request_close_with_handle(debug_win); 106 purple_request_close_with_handle(debug_win);
107 107
108 g_free(debug_win); 108 g_free(debug_win);
109 debug_win = NULL; 109 debug_win = NULL;
110 110
111 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", FALSE); 111 purple_prefs_set_bool("/purple/gtk/debug/enabled", FALSE);
112 112
113 return FALSE; 113 return FALSE;
114 } 114 }
115 115
116 static gboolean 116 static gboolean
117 configure_cb(GtkWidget *w, GdkEventConfigure *event, DebugWindow *win) 117 configure_cb(GtkWidget *w, GdkEventConfigure *event, DebugWindow *win)
118 { 118 {
119 if (GTK_WIDGET_VISIBLE(w)) { 119 if (GTK_WIDGET_VISIBLE(w)) {
120 gaim_prefs_set_int("/gaim/gtk/debug/width", event->width); 120 purple_prefs_set_int("/purple/gtk/debug/width", event->width);
121 gaim_prefs_set_int("/gaim/gtk/debug/height", event->height); 121 purple_prefs_set_int("/purple/gtk/debug/height", event->height);
122 } 122 }
123 123
124 return FALSE; 124 return FALSE;
125 } 125 }
126 126
213 DebugWindow *win = (DebugWindow *)user_data; 213 DebugWindow *win = (DebugWindow *)user_data;
214 FILE *fp; 214 FILE *fp;
215 char *tmp; 215 char *tmp;
216 216
217 if ((fp = g_fopen(filename, "w+")) == NULL) { 217 if ((fp = g_fopen(filename, "w+")) == NULL) {
218 gaim_notify_error(win, NULL, _("Unable to open file."), NULL); 218 purple_notify_error(win, NULL, _("Unable to open file."), NULL);
219 return; 219 return;
220 } 220 }
221 221
222 tmp = gtk_imhtml_get_text(GTK_IMHTML(win->text), NULL, NULL); 222 tmp = gtk_imhtml_get_text(GTK_IMHTML(win->text), NULL, NULL);
223 fprintf(fp, "Pidgin Debug Log : %s\n", gaim_date_format_full(NULL)); 223 fprintf(fp, "Pidgin Debug Log : %s\n", purple_date_format_full(NULL));
224 fprintf(fp, "%s", tmp); 224 fprintf(fp, "%s", tmp);
225 g_free(tmp); 225 g_free(tmp);
226 226
227 fclose(fp); 227 fclose(fp);
228 } 228 }
229 229
230 static void 230 static void
231 save_cb(GtkWidget *w, DebugWindow *win) 231 save_cb(GtkWidget *w, DebugWindow *win)
232 { 232 {
233 gaim_request_file(win, _("Save Debug Log"), "gaim-debug.log", TRUE, 233 purple_request_file(win, _("Save Debug Log"), "purple-debug.log", TRUE,
234 G_CALLBACK(save_writefile_cb), NULL, win); 234 G_CALLBACK(save_writefile_cb), NULL, win);
235 } 235 }
236 236
237 static void 237 static void
238 clear_cb(GtkWidget *w, DebugWindow *win) 238 clear_cb(GtkWidget *w, DebugWindow *win)
262 static void 262 static void
263 timestamps_cb(GtkWidget *w, DebugWindow *win) 263 timestamps_cb(GtkWidget *w, DebugWindow *win)
264 { 264 {
265 win->timestamps = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); 265 win->timestamps = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
266 266
267 gaim_prefs_set_bool("/core/debug/timestamps", win->timestamps); 267 purple_prefs_set_bool("/core/debug/timestamps", win->timestamps);
268 } 268 }
269 269
270 static void 270 static void
271 timestamps_pref_cb(const char *name, GaimPrefType type, 271 timestamps_pref_cb(const char *name, PurplePrefType type,
272 gconstpointer value, gpointer data) 272 gconstpointer value, gpointer data)
273 { 273 {
274 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), GPOINTER_TO_INT(value)); 274 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), GPOINTER_TO_INT(value));
275 } 275 }
276 276
318 inverted = (win->invert) ? REG_NOMATCH : 0; 318 inverted = (win->invert) ? REG_NOMATCH : 0;
319 319
320 /* I don't like having to do this, but we need it for highlighting. Plus 320 /* I don't like having to do this, but we need it for highlighting. Plus
321 * it makes the ^ and $ operators work :) 321 * it makes the ^ and $ operators work :)
322 */ 322 */
323 plaintext = gaim_markup_strip_html(text); 323 plaintext = purple_markup_strip_html(text);
324 324
325 /* we do a first pass to see if it matches at all. If it does we append 325 /* we do a first pass to see if it matches at all. If it does we append
326 * it, and work out the offsets to highlight. 326 * it, and work out the offsets to highlight.
327 */ 327 */
328 if(regexec(&win->regex, plaintext, n_matches, matches, 0) == inverted) { 328 if(regexec(&win->regex, plaintext, n_matches, matches, 0) == inverted) {
378 regex_filter_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter, 378 regex_filter_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter,
379 gpointer data) 379 gpointer data)
380 { 380 {
381 DebugWindow *win = (DebugWindow *)data; 381 DebugWindow *win = (DebugWindow *)data;
382 gchar *text; 382 gchar *text;
383 GaimDebugLevel level; 383 PurpleDebugLevel level;
384 384
385 gtk_tree_model_get(m, iter, 0, &text, 1, &level, -1); 385 gtk_tree_model_get(m, iter, 0, &text, 1, &level, -1);
386 386
387 if (level >= gaim_prefs_get_int("/gaim/gtk/debug/filterlevel")) 387 if (level >= purple_prefs_get_int("/purple/gtk/debug/filterlevel"))
388 regex_match(win, text); 388 regex_match(win, text);
389 389
390 g_free(text); 390 g_free(text);
391 391
392 return FALSE; 392 return FALSE;
407 regex_show_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter, 407 regex_show_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter,
408 gpointer data) 408 gpointer data)
409 { 409 {
410 DebugWindow *win = (DebugWindow *)data; 410 DebugWindow *win = (DebugWindow *)data;
411 gchar *text; 411 gchar *text;
412 GaimDebugLevel level; 412 PurpleDebugLevel level;
413 413
414 gtk_tree_model_get(m, iter, 0, &text, 1, &level, -1); 414 gtk_tree_model_get(m, iter, 0, &text, 1, &level, -1);
415 if (level >= gaim_prefs_get_int("/gaim/gtk/debug/filterlevel")) 415 if (level >= purple_prefs_get_int("/purple/gtk/debug/filterlevel"))
416 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0); 416 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0);
417 g_free(text); 417 g_free(text);
418 418
419 return FALSE; 419 return FALSE;
420 } 420 }
460 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) 460 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter)))
461 regex_filter_all(win); 461 regex_filter_all(win);
462 } 462 }
463 463
464 static void 464 static void
465 regex_pref_filter_cb(const gchar *name, GaimPrefType type, 465 regex_pref_filter_cb(const gchar *name, PurplePrefType type,
466 gconstpointer val, gpointer data) 466 gconstpointer val, gpointer data)
467 { 467 {
468 DebugWindow *win = (DebugWindow *)data; 468 DebugWindow *win = (DebugWindow *)data;
469 gboolean active = GPOINTER_TO_INT(val), current; 469 gboolean active = GPOINTER_TO_INT(val), current;
470 470
475 if(active != current) 475 if(active != current)
476 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), active); 476 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), active);
477 } 477 }
478 478
479 static void 479 static void
480 regex_pref_expression_cb(const gchar *name, GaimPrefType type, 480 regex_pref_expression_cb(const gchar *name, PurplePrefType type,
481 gconstpointer val, gpointer data) 481 gconstpointer val, gpointer data)
482 { 482 {
483 DebugWindow *win = (DebugWindow *)data; 483 DebugWindow *win = (DebugWindow *)data;
484 const gchar *exp = (const gchar *)val; 484 const gchar *exp = (const gchar *)val;
485 485
486 gtk_entry_set_text(GTK_ENTRY(win->expression), exp); 486 gtk_entry_set_text(GTK_ENTRY(win->expression), exp);
487 } 487 }
488 488
489 static void 489 static void
490 regex_pref_invert_cb(const gchar *name, GaimPrefType type, 490 regex_pref_invert_cb(const gchar *name, PurplePrefType type,
491 gconstpointer val, gpointer data) 491 gconstpointer val, gpointer data)
492 { 492 {
493 DebugWindow *win = (DebugWindow *)data; 493 DebugWindow *win = (DebugWindow *)data;
494 gboolean active = GPOINTER_TO_INT(val); 494 gboolean active = GPOINTER_TO_INT(val);
495 495
498 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) 498 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter)))
499 regex_filter_all(win); 499 regex_filter_all(win);
500 } 500 }
501 501
502 static void 502 static void
503 regex_pref_highlight_cb(const gchar *name, GaimPrefType type, 503 regex_pref_highlight_cb(const gchar *name, PurplePrefType type,
504 gconstpointer val, gpointer data) 504 gconstpointer val, gpointer data)
505 { 505 {
506 DebugWindow *win = (DebugWindow *)data; 506 DebugWindow *win = (DebugWindow *)data;
507 gboolean active = GPOINTER_TO_INT(val); 507 gboolean active = GPOINTER_TO_INT(val);
508 508
515 static void 515 static void
516 regex_row_changed_cb(GtkTreeModel *model, GtkTreePath *path, 516 regex_row_changed_cb(GtkTreeModel *model, GtkTreePath *path,
517 GtkTreeIter *iter, DebugWindow *win) 517 GtkTreeIter *iter, DebugWindow *win)
518 { 518 {
519 gchar *text; 519 gchar *text;
520 GaimDebugLevel level; 520 PurpleDebugLevel level;
521 521
522 if(!win || !win->window) 522 if(!win || !win->window)
523 return; 523 return;
524 524
525 /* If the debug window is paused, we just return since it's in the store. 525 /* If the debug window is paused, we just return since it's in the store.
531 if(win->paused) 531 if(win->paused)
532 return; 532 return;
533 533
534 gtk_tree_model_get(model, iter, 0, &text, 1, &level, -1); 534 gtk_tree_model_get(model, iter, 0, &text, 1, &level, -1);
535 535
536 if (level >= gaim_prefs_get_int("/gaim/gtk/debug/filterlevel")) { 536 if (level >= purple_prefs_get_int("/purple/gtk/debug/filterlevel")) {
537 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { 537 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) {
538 regex_match(win, text); 538 regex_match(win, text);
539 } else { 539 } else {
540 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0); 540 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0);
541 } 541 }
547 static gboolean 547 static gboolean
548 regex_timer_cb(DebugWindow *win) { 548 regex_timer_cb(DebugWindow *win) {
549 const gchar *text; 549 const gchar *text;
550 550
551 text = gtk_entry_get_text(GTK_ENTRY(win->expression)); 551 text = gtk_entry_get_text(GTK_ENTRY(win->expression));
552 gaim_prefs_set_string("/gaim/gtk/debug/regex", text); 552 purple_prefs_set_string("/purple/gtk/debug/regex", text);
553 553
554 win->timer = 0; 554 win->timer = 0;
555 555
556 return FALSE; 556 return FALSE;
557 } 557 }
562 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), 562 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter),
563 FALSE); 563 FALSE);
564 } 564 }
565 565
566 if(win->timer == 0) 566 if(win->timer == 0)
567 win->timer = gaim_timeout_add(5000, (GSourceFunc)regex_timer_cb, win); 567 win->timer = purple_timeout_add(5000, (GSourceFunc)regex_timer_cb, win);
568 568
569 regex_compile(win); 569 regex_compile(win);
570 } 570 }
571 571
572 static void 572 static void
583 regex_menu_cb(GtkWidget *item, const gchar *pref) { 583 regex_menu_cb(GtkWidget *item, const gchar *pref) {
584 gboolean active; 584 gboolean active;
585 585
586 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)); 586 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item));
587 587
588 gaim_prefs_set_bool(pref, active); 588 purple_prefs_set_bool(pref, active);
589 } 589 }
590 590
591 static void 591 static void
592 regex_popup_cb(GtkEntry *entry, GtkWidget *menu, DebugWindow *win) { 592 regex_popup_cb(GtkEntry *entry, GtkWidget *menu, DebugWindow *win) {
593 pidgin_separator(menu); 593 pidgin_separator(menu);
594 pidgin_new_check_item(menu, _("Invert"), 594 pidgin_new_check_item(menu, _("Invert"),
595 G_CALLBACK(regex_menu_cb), 595 G_CALLBACK(regex_menu_cb),
596 "/gaim/gtk/debug/invert", win->invert); 596 "/purple/gtk/debug/invert", win->invert);
597 pidgin_new_check_item(menu, _("Highlight matches"), 597 pidgin_new_check_item(menu, _("Highlight matches"),
598 G_CALLBACK(regex_menu_cb), 598 G_CALLBACK(regex_menu_cb),
599 "/gaim/gtk/debug/highlight", win->highlight); 599 "/purple/gtk/debug/highlight", win->highlight);
600 } 600 }
601 601
602 static void 602 static void
603 regex_filter_toggled_cb(GtkToggleButton *button, DebugWindow *win) { 603 regex_filter_toggled_cb(GtkToggleButton *button, DebugWindow *win) {
604 gboolean active; 604 gboolean active;
605 605
606 active = gtk_toggle_button_get_active(button); 606 active = gtk_toggle_button_get_active(button);
607 607
608 gaim_prefs_set_bool("/gaim/gtk/debug/filter", active); 608 purple_prefs_set_bool("/purple/gtk/debug/filter", active);
609 609
610 if(!GTK_IS_IMHTML(win->text)) 610 if(!GTK_IS_IMHTML(win->text))
611 return; 611 return;
612 612
613 if(active) 613 if(active)
615 else 615 else
616 regex_show_all(win); 616 regex_show_all(win);
617 } 617 }
618 618
619 static void 619 static void
620 filter_level_pref_changed(const char *name, GaimPrefType type, gconstpointer value, gpointer data) 620 filter_level_pref_changed(const char *name, PurplePrefType type, gconstpointer value, gpointer data)
621 { 621 {
622 DebugWindow *win = data; 622 DebugWindow *win = data;
623 623
624 if (GPOINTER_TO_INT(value) != gtk_combo_box_get_active(GTK_COMBO_BOX(win->filterlevel))) 624 if (GPOINTER_TO_INT(value) != gtk_combo_box_get_active(GTK_COMBO_BOX(win->filterlevel)))
625 gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel), GPOINTER_TO_INT(value)); 625 gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel), GPOINTER_TO_INT(value));
631 #endif /* HAVE_REGEX_H */ 631 #endif /* HAVE_REGEX_H */
632 632
633 static void 633 static void
634 filter_level_changed_cb(GtkWidget *combo, gpointer null) 634 filter_level_changed_cb(GtkWidget *combo, gpointer null)
635 { 635 {
636 gaim_prefs_set_int("/gaim/gtk/debug/filterlevel", 636 purple_prefs_set_int("/purple/gtk/debug/filterlevel",
637 gtk_combo_box_get_active(GTK_COMBO_BOX(combo))); 637 gtk_combo_box_get_active(GTK_COMBO_BOX(combo)));
638 } 638 }
639 639
640 static void 640 static void
641 toolbar_style_pref_changed_cb(const char *name, GaimPrefType type, gconstpointer value, gpointer data) 641 toolbar_style_pref_changed_cb(const char *name, PurplePrefType type, gconstpointer value, gpointer data)
642 { 642 {
643 gtk_toolbar_set_style(GTK_TOOLBAR(data), GPOINTER_TO_INT(value)); 643 gtk_toolbar_set_style(GTK_TOOLBAR(data), GPOINTER_TO_INT(value));
644 } 644 }
645 645
646 static void 646 static void
647 toolbar_icon_pref_changed(GtkWidget *item, GtkWidget *toolbar) 647 toolbar_icon_pref_changed(GtkWidget *item, GtkWidget *toolbar)
648 { 648 {
649 int style = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), "user_data")); 649 int style = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), "user_data"));
650 gaim_prefs_set_int("/gaim/gtk/debug/style", style); 650 purple_prefs_set_int("/purple/gtk/debug/style", style);
651 } 651 }
652 652
653 static gboolean 653 static gboolean
654 toolbar_context(GtkWidget *toolbar, GdkEventButton *event, gpointer null) 654 toolbar_context(GtkWidget *toolbar, GdkEventButton *event, gpointer null)
655 { 655 {
669 669
670 for (i = 0; i < 3; i++) { 670 for (i = 0; i < 3; i++) {
671 item = gtk_check_menu_item_new_with_mnemonic(text[i]); 671 item = gtk_check_menu_item_new_with_mnemonic(text[i]);
672 g_object_set_data(G_OBJECT(item), "user_data", GINT_TO_POINTER(value[i])); 672 g_object_set_data(G_OBJECT(item), "user_data", GINT_TO_POINTER(value[i]));
673 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(toolbar_icon_pref_changed), toolbar); 673 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(toolbar_icon_pref_changed), toolbar);
674 if (value[i] == gaim_prefs_get_int("/gaim/gtk/debug/style")) 674 if (value[i] == purple_prefs_get_int("/purple/gtk/debug/style"))
675 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); 675 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
676 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); 676 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
677 } 677 }
678 678
679 gtk_widget_show_all(menu); 679 gtk_widget_show_all(menu);
694 gint width, height; 694 gint width, height;
695 void *handle; 695 void *handle;
696 696
697 win = g_new0(DebugWindow, 1); 697 win = g_new0(DebugWindow, 1);
698 698
699 width = gaim_prefs_get_int("/gaim/gtk/debug/width"); 699 width = purple_prefs_get_int("/purple/gtk/debug/width");
700 height = gaim_prefs_get_int("/gaim/gtk/debug/height"); 700 height = purple_prefs_get_int("/purple/gtk/debug/height");
701 701
702 PIDGIN_DIALOG(win->window); 702 PIDGIN_DIALOG(win->window);
703 gaim_debug_info("gtkdebug", "Setting dimensions to %d, %d\n", 703 purple_debug_info("gtkdebug", "Setting dimensions to %d, %d\n",
704 width, height); 704 width, height);
705 705
706 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height); 706 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height);
707 gtk_window_set_role(GTK_WINDOW(win->window), "debug"); 707 gtk_window_set_role(GTK_WINDOW(win->window), "debug");
708 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window")); 708 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window"));
730 730
731 /* Setup the vbox */ 731 /* Setup the vbox */
732 vbox = gtk_vbox_new(FALSE, 0); 732 vbox = gtk_vbox_new(FALSE, 0);
733 gtk_container_add(GTK_CONTAINER(win->window), vbox); 733 gtk_container_add(GTK_CONTAINER(win->window), vbox);
734 734
735 if (gaim_prefs_get_bool("/gaim/gtk/debug/toolbar")) { 735 if (purple_prefs_get_bool("/purple/gtk/debug/toolbar")) {
736 /* Setup our top button bar thingie. */ 736 /* Setup our top button bar thingie. */
737 toolbar = gtk_toolbar_new(); 737 toolbar = gtk_toolbar_new();
738 gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE); 738 gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE);
739 #if GTK_CHECK_VERSION(2,4,0) 739 #if GTK_CHECK_VERSION(2,4,0)
740 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE); 740 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
741 #endif 741 #endif
742 g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(toolbar_context), win); 742 g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(toolbar_context), win);
743 743
744 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), 744 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),
745 gaim_prefs_get_int("/gaim/gtk/debug/style")); 745 purple_prefs_get_int("/purple/gtk/debug/style"));
746 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/style", 746 purple_prefs_connect_callback(handle, "/purple/gtk/debug/style",
747 toolbar_style_pref_changed_cb, toolbar); 747 toolbar_style_pref_changed_cb, toolbar);
748 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), 748 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),
749 GTK_ICON_SIZE_SMALL_TOOLBAR); 749 GTK_ICON_SIZE_SMALL_TOOLBAR);
750 750
751 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); 751 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
784 _("Timestamps"), NULL, NULL, 784 _("Timestamps"), NULL, NULL,
785 G_CALLBACK(timestamps_cb), 785 G_CALLBACK(timestamps_cb),
786 win); 786 win);
787 787
788 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), 788 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
789 gaim_prefs_get_bool("/core/debug/timestamps")); 789 purple_prefs_get_bool("/core/debug/timestamps"));
790 790
791 gaim_prefs_connect_callback(handle, "/core/debug/timestamps", 791 purple_prefs_connect_callback(handle, "/core/debug/timestamps",
792 timestamps_pref_cb, button); 792 timestamps_pref_cb, button);
793 793
794 #ifdef HAVE_REGEX_H 794 #ifdef HAVE_REGEX_H
795 /* regex stuff */ 795 /* regex stuff */
796 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 796 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
802 NULL, _("Filter"), _("Filter"), 802 NULL, _("Filter"), _("Filter"),
803 NULL, NULL, 803 NULL, NULL,
804 G_CALLBACK(regex_filter_toggled_cb), 804 G_CALLBACK(regex_filter_toggled_cb),
805 win); 805 win);
806 /* we purposely disable the toggle button here in case 806 /* we purposely disable the toggle button here in case
807 * /gaim/gtk/debug/expression has an empty string. If it does not have 807 * /purple/gtk/debug/expression has an empty string. If it does not have
808 * an empty string, the change signal will get called and make the 808 * an empty string, the change signal will get called and make the
809 * toggle button sensitive. 809 * toggle button sensitive.
810 */ 810 */
811 gtk_widget_set_sensitive(win->filter, FALSE); 811 gtk_widget_set_sensitive(win->filter, FALSE);
812 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), 812 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter),
813 gaim_prefs_get_bool("/gaim/gtk/debug/filter")); 813 purple_prefs_get_bool("/purple/gtk/debug/filter"));
814 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/filter", 814 purple_prefs_connect_callback(handle, "/purple/gtk/debug/filter",
815 regex_pref_filter_cb, win); 815 regex_pref_filter_cb, win);
816 816
817 /* regex entry */ 817 /* regex entry */
818 win->expression = gtk_entry_new(); 818 win->expression = gtk_entry_new();
819 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 819 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
824 * to colorize a stored expression. 824 * to colorize a stored expression.
825 */ 825 */
826 g_signal_connect(G_OBJECT(win->expression), "changed", 826 g_signal_connect(G_OBJECT(win->expression), "changed",
827 G_CALLBACK(regex_changed_cb), win); 827 G_CALLBACK(regex_changed_cb), win);
828 gtk_entry_set_text(GTK_ENTRY(win->expression), 828 gtk_entry_set_text(GTK_ENTRY(win->expression),
829 gaim_prefs_get_string("/gaim/gtk/debug/regex")); 829 purple_prefs_get_string("/purple/gtk/debug/regex"));
830 g_signal_connect(G_OBJECT(win->expression), "populate-popup", 830 g_signal_connect(G_OBJECT(win->expression), "populate-popup",
831 G_CALLBACK(regex_popup_cb), win); 831 G_CALLBACK(regex_popup_cb), win);
832 g_signal_connect(G_OBJECT(win->expression), "key-release-event", 832 g_signal_connect(G_OBJECT(win->expression), "key-release-event",
833 G_CALLBACK(regex_key_release_cb), win); 833 G_CALLBACK(regex_key_release_cb), win);
834 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/regex", 834 purple_prefs_connect_callback(handle, "/purple/gtk/debug/regex",
835 regex_pref_expression_cb, win); 835 regex_pref_expression_cb, win);
836 836
837 /* connect the rest of our pref callbacks */ 837 /* connect the rest of our pref callbacks */
838 win->invert = gaim_prefs_get_bool("/gaim/gtk/debug/invert"); 838 win->invert = purple_prefs_get_bool("/purple/gtk/debug/invert");
839 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/invert", 839 purple_prefs_connect_callback(handle, "/purple/gtk/debug/invert",
840 regex_pref_invert_cb, win); 840 regex_pref_invert_cb, win);
841 841
842 win->highlight = gaim_prefs_get_bool("/gaim/gtk/debug/highlight"); 842 win->highlight = purple_prefs_get_bool("/purple/gtk/debug/highlight");
843 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/highlight", 843 purple_prefs_connect_callback(handle, "/purple/gtk/debug/highlight",
844 regex_pref_highlight_cb, win); 844 regex_pref_highlight_cb, win);
845 845
846 #endif /* HAVE_REGEX_H */ 846 #endif /* HAVE_REGEX_H */
847 847
848 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 848 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
862 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info")); 862 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info"));
863 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Warning")); 863 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Warning"));
864 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Error ")); 864 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Error "));
865 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Fatal Error")); 865 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Fatal Error"));
866 gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel), 866 gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel),
867 gaim_prefs_get_int("/gaim/gtk/debug/filterlevel")); 867 purple_prefs_get_int("/purple/gtk/debug/filterlevel"));
868 #ifdef HAVE_REGEX_H 868 #ifdef HAVE_REGEX_H
869 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/filterlevel", 869 purple_prefs_connect_callback(handle, "/purple/gtk/debug/filterlevel",
870 filter_level_pref_changed, win); 870 filter_level_pref_changed, win);
871 #endif 871 #endif
872 g_signal_connect(G_OBJECT(win->filterlevel), "changed", 872 g_signal_connect(G_OBJECT(win->filterlevel), "changed",
873 G_CALLBACK(filter_level_changed_cb), NULL); 873 G_CALLBACK(filter_level_changed_cb), NULL);
874 } 874 }
892 892
893 return win; 893 return win;
894 } 894 }
895 895
896 static void 896 static void
897 debug_enabled_cb(const char *name, GaimPrefType type, 897 debug_enabled_cb(const char *name, PurplePrefType type,
898 gconstpointer value, gpointer data) 898 gconstpointer value, gpointer data)
899 { 899 {
900 if (value) 900 if (value)
901 pidgin_debug_window_show(); 901 pidgin_debug_window_show();
902 else 902 else
905 905
906 static void 906 static void
907 pidgin_glib_log_handler(const gchar *domain, GLogLevelFlags flags, 907 pidgin_glib_log_handler(const gchar *domain, GLogLevelFlags flags,
908 const gchar *msg, gpointer user_data) 908 const gchar *msg, gpointer user_data)
909 { 909 {
910 GaimDebugLevel level; 910 PurpleDebugLevel level;
911 char *new_msg = NULL; 911 char *new_msg = NULL;
912 char *new_domain = NULL; 912 char *new_domain = NULL;
913 913
914 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) 914 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR)
915 level = GAIM_DEBUG_ERROR; 915 level = PURPLE_DEBUG_ERROR;
916 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) 916 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL)
917 level = GAIM_DEBUG_FATAL; 917 level = PURPLE_DEBUG_FATAL;
918 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) 918 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING)
919 level = GAIM_DEBUG_WARNING; 919 level = PURPLE_DEBUG_WARNING;
920 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) 920 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE)
921 level = GAIM_DEBUG_INFO; 921 level = PURPLE_DEBUG_INFO;
922 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) 922 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO)
923 level = GAIM_DEBUG_INFO; 923 level = PURPLE_DEBUG_INFO;
924 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) 924 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG)
925 level = GAIM_DEBUG_MISC; 925 level = PURPLE_DEBUG_MISC;
926 else 926 else
927 { 927 {
928 gaim_debug_warning("gtkdebug", 928 purple_debug_warning("gtkdebug",
929 "Unknown glib logging level in %d\n", flags); 929 "Unknown glib logging level in %d\n", flags);
930 930
931 level = GAIM_DEBUG_MISC; /* This will never happen. */ 931 level = PURPLE_DEBUG_MISC; /* This will never happen. */
932 } 932 }
933 933
934 if (msg != NULL) 934 if (msg != NULL)
935 new_msg = gaim_utf8_try_convert(msg); 935 new_msg = purple_utf8_try_convert(msg);
936 936
937 if (domain != NULL) 937 if (domain != NULL)
938 new_domain = gaim_utf8_try_convert(domain); 938 new_domain = purple_utf8_try_convert(domain);
939 939
940 if (new_msg != NULL) 940 if (new_msg != NULL)
941 { 941 {
942 gaim_debug(level, (new_domain != NULL ? new_domain : "g_log"), 942 purple_debug(level, (new_domain != NULL ? new_domain : "g_log"),
943 "%s\n", new_msg); 943 "%s\n", new_msg);
944 944
945 g_free(new_msg); 945 g_free(new_msg);
946 } 946 }
947 947
964 * set after they are loaded, since prefs sets the enabled 964 * set after they are loaded, since prefs sets the enabled
965 * preference here and that loads the window, which calls the 965 * preference here and that loads the window, which calls the
966 * configure event, which overrides the width and height! :P 966 * configure event, which overrides the width and height! :P
967 */ 967 */
968 968
969 gaim_prefs_add_none("/gaim/gtk/debug"); 969 purple_prefs_add_none("/purple/gtk/debug");
970 970
971 /* Controls printing to the debug window */ 971 /* Controls printing to the debug window */
972 gaim_prefs_add_bool("/gaim/gtk/debug/enabled", FALSE); 972 purple_prefs_add_bool("/purple/gtk/debug/enabled", FALSE);
973 gaim_prefs_add_int("/gaim/gtk/debug/filterlevel", GAIM_DEBUG_ALL); 973 purple_prefs_add_int("/purple/gtk/debug/filterlevel", PURPLE_DEBUG_ALL);
974 gaim_prefs_add_int("/gaim/gtk/debug/style", GTK_TOOLBAR_BOTH_HORIZ); 974 purple_prefs_add_int("/purple/gtk/debug/style", GTK_TOOLBAR_BOTH_HORIZ);
975 975
976 gaim_prefs_add_bool("/gaim/gtk/debug/toolbar", TRUE); 976 purple_prefs_add_bool("/purple/gtk/debug/toolbar", TRUE);
977 gaim_prefs_add_int("/gaim/gtk/debug/width", 450); 977 purple_prefs_add_int("/purple/gtk/debug/width", 450);
978 gaim_prefs_add_int("/gaim/gtk/debug/height", 250); 978 purple_prefs_add_int("/purple/gtk/debug/height", 250);
979 979
980 #ifdef HAVE_REGEX_H 980 #ifdef HAVE_REGEX_H
981 gaim_prefs_add_string("/gaim/gtk/debug/regex", ""); 981 purple_prefs_add_string("/purple/gtk/debug/regex", "");
982 gaim_prefs_add_bool("/gaim/gtk/debug/filter", FALSE); 982 purple_prefs_add_bool("/purple/gtk/debug/filter", FALSE);
983 gaim_prefs_add_bool("/gaim/gtk/debug/invert", FALSE); 983 purple_prefs_add_bool("/purple/gtk/debug/invert", FALSE);
984 gaim_prefs_add_bool("/gaim/gtk/debug/case_insensitive", FALSE); 984 purple_prefs_add_bool("/purple/gtk/debug/case_insensitive", FALSE);
985 gaim_prefs_add_bool("/gaim/gtk/debug/highlight", FALSE); 985 purple_prefs_add_bool("/purple/gtk/debug/highlight", FALSE);
986 #endif /* HAVE_REGEX_H */ 986 #endif /* HAVE_REGEX_H */
987 987
988 gaim_prefs_connect_callback(NULL, "/gaim/gtk/debug/enabled", 988 purple_prefs_connect_callback(NULL, "/purple/gtk/debug/enabled",
989 debug_enabled_cb, NULL); 989 debug_enabled_cb, NULL);
990 990
991 #define REGISTER_G_LOG_HANDLER(name) \ 991 #define REGISTER_G_LOG_HANDLER(name) \
992 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ 992 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \
993 | G_LOG_FLAG_RECURSION, \ 993 | G_LOG_FLAG_RECURSION, \
1002 REGISTER_G_LOG_HANDLER("GModule"); 1002 REGISTER_G_LOG_HANDLER("GModule");
1003 REGISTER_G_LOG_HANDLER("GLib-GObject"); 1003 REGISTER_G_LOG_HANDLER("GLib-GObject");
1004 REGISTER_G_LOG_HANDLER("GThread"); 1004 REGISTER_G_LOG_HANDLER("GThread");
1005 1005
1006 #ifdef _WIN32 1006 #ifdef _WIN32
1007 if (!gaim_debug_is_enabled()) 1007 if (!purple_debug_is_enabled())
1008 g_set_print_handler(pidgin_glib_dummy_print_handler); 1008 g_set_print_handler(pidgin_glib_dummy_print_handler);
1009 #endif 1009 #endif
1010 } 1010 }
1011 1011
1012 void 1012 void
1013 pidgin_debug_uninit(void) 1013 pidgin_debug_uninit(void)
1014 { 1014 {
1015 gaim_debug_set_ui_ops(NULL); 1015 purple_debug_set_ui_ops(NULL);
1016 } 1016 }
1017 1017
1018 void 1018 void
1019 pidgin_debug_window_show(void) 1019 pidgin_debug_window_show(void)
1020 { 1020 {
1021 if (debug_win == NULL) 1021 if (debug_win == NULL)
1022 debug_win = debug_window_new(); 1022 debug_win = debug_window_new();
1023 1023
1024 gtk_widget_show(debug_win->window); 1024 gtk_widget_show(debug_win->window);
1025 1025
1026 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", TRUE); 1026 purple_prefs_set_bool("/purple/gtk/debug/enabled", TRUE);
1027 } 1027 }
1028 1028
1029 void 1029 void
1030 pidgin_debug_window_hide(void) 1030 pidgin_debug_window_hide(void)
1031 { 1031 {
1034 debug_window_destroy(NULL, NULL, NULL); 1034 debug_window_destroy(NULL, NULL, NULL);
1035 } 1035 }
1036 } 1036 }
1037 1037
1038 static void 1038 static void
1039 pidgin_debug_print(GaimDebugLevel level, const char *category, 1039 pidgin_debug_print(PurpleDebugLevel level, const char *category,
1040 const char *arg_s) 1040 const char *arg_s)
1041 { 1041 {
1042 #ifdef HAVE_REGEX_H 1042 #ifdef HAVE_REGEX_H
1043 GtkTreeIter iter; 1043 GtkTreeIter iter;
1044 #endif /* HAVE_REGEX_H */ 1044 #endif /* HAVE_REGEX_H */
1045 gboolean timestamps; 1045 gboolean timestamps;
1046 gchar *ts_s; 1046 gchar *ts_s;
1047 gchar *esc_s, *cat_s, *tmp, *s; 1047 gchar *esc_s, *cat_s, *tmp, *s;
1048 1048
1049 if (!gaim_prefs_get_bool("/gaim/gtk/debug/enabled") || 1049 if (!purple_prefs_get_bool("/purple/gtk/debug/enabled") ||
1050 (debug_win == NULL)) 1050 (debug_win == NULL))
1051 { 1051 {
1052 return; 1052 return;
1053 } 1053 }
1054 1054
1055 timestamps = gaim_prefs_get_bool("/core/debug/timestamps"); 1055 timestamps = purple_prefs_get_bool("/core/debug/timestamps");
1056 1056
1057 /* 1057 /*
1058 * For some reason we only print the timestamp if category is 1058 * For some reason we only print the timestamp if category is
1059 * not NULL. Why the hell do we do that? --Mark 1059 * not NULL. Why the hell do we do that? --Mark
1060 */ 1060 */
1061 if ((category != NULL) && (timestamps)) { 1061 if ((category != NULL) && (timestamps)) {
1062 const char *mdate; 1062 const char *mdate;
1063 1063
1064 time_t mtime = time(NULL); 1064 time_t mtime = time(NULL);
1065 mdate = gaim_utf8_strftime("%H:%M:%S", localtime(&mtime)); 1065 mdate = purple_utf8_strftime("%H:%M:%S", localtime(&mtime));
1066 ts_s = g_strdup_printf("(%s) ", mdate); 1066 ts_s = g_strdup_printf("(%s) ", mdate);
1067 } else { 1067 } else {
1068 ts_s = g_strdup(""); 1068 ts_s = g_strdup("");
1069 } 1069 }
1070 1070
1080 1080
1081 g_free(ts_s); 1081 g_free(ts_s);
1082 g_free(cat_s); 1082 g_free(cat_s);
1083 g_free(esc_s); 1083 g_free(esc_s);
1084 1084
1085 tmp = gaim_utf8_try_convert(s); 1085 tmp = purple_utf8_try_convert(s);
1086 g_free(s); 1086 g_free(s);
1087 s = tmp; 1087 s = tmp;
1088 1088
1089 if (level == GAIM_DEBUG_FATAL) { 1089 if (level == PURPLE_DEBUG_FATAL) {
1090 tmp = g_strdup_printf("<b>%s</b>", s); 1090 tmp = g_strdup_printf("<b>%s</b>", s);
1091 g_free(s); 1091 g_free(s);
1092 s = tmp; 1092 s = tmp;
1093 } 1093 }
1094 1094
1095 #ifdef HAVE_REGEX_H 1095 #ifdef HAVE_REGEX_H
1096 /* add the text to the list store */ 1096 /* add the text to the list store */
1097 gtk_list_store_append(debug_win->store, &iter); 1097 gtk_list_store_append(debug_win->store, &iter);
1098 gtk_list_store_set(debug_win->store, &iter, 0, s, 1, level, -1); 1098 gtk_list_store_set(debug_win->store, &iter, 0, s, 1, level, -1);
1099 #else /* HAVE_REGEX_H */ 1099 #else /* HAVE_REGEX_H */
1100 if(!debug_win->paused && level >= gaim_prefs_get_int("/gaim/gtk/debug/filterlevel")) 1100 if(!debug_win->paused && level >= purple_prefs_get_int("/purple/gtk/debug/filterlevel"))
1101 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, 0); 1101 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, 0);
1102 #endif /* !HAVE_REGEX_H */ 1102 #endif /* !HAVE_REGEX_H */
1103 1103
1104 g_free(s); 1104 g_free(s);
1105 } 1105 }
1106 1106
1107 static GaimDebugUiOps ops = 1107 static PurpleDebugUiOps ops =
1108 { 1108 {
1109 pidgin_debug_print, 1109 pidgin_debug_print,
1110 }; 1110 };
1111 1111
1112 GaimDebugUiOps * 1112 PurpleDebugUiOps *
1113 pidgin_debug_get_ui_ops(void) 1113 pidgin_debug_get_ui_ops(void)
1114 { 1114 {
1115 return &ops; 1115 return &ops;
1116 } 1116 }
1117 1117