comparison plugins/notify.c @ 10606:1a65fc2d7978

[gaim-migrate @ 12039] So I'd intended to take care of the stuff in the comments at the top before committing this, but the window raising stuff came up again so I'll just commit and deal with the rest later. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Wed, 16 Feb 2005 22:14:51 +0000
parents 45ad1d15fab3
children 9c4dca2deb99
comparison
equal deleted inserted replaced
10605:56d4460bb6bd 10606:1a65fc2d7978
20 * 20 *
21 * You should have received a copy of the GNU General Public License 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 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 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * 24 *
25 */
26
27 /* TODO conversations have an a_virgin member which seems to be used to detect
28 * when a conversation was created remotely as opposed to remotely, look at
29 * code for sounds on first message to see how it's used and use it to allow
30 * for notifying on first message I don't think this is going to work because
31 * the check for this in the source comes after all the conversation signals
32 * are fired. */
33
34 /* TODO
35 * 22:22:17 <seanegan> deryni: speaking of notify.c... you know what else
36 * might be a neat feature?
37 * 22:22:30 <seanegan> Changing the window icon.
38 * 22:23:25 <deryni> seanegan: To what?
39 * 22:23:42 <seanegan> deryni: I dunno. Flash it between the regular icon and
40 * blank or something.
41 * 22:23:53 <deryni> Also I think gaim might re-set that sort of frequently,
42 * but I'd have to look.
43 * 22:25:16 <seanegan> deryni: I keep my conversations in one workspace and am
44 * frequently in an another, and the icon flashing in the pager would be a
45 * neat visual clue.
25 */ 46 */
26 47
27 /* 48 /*
28 * From Etan, 2002: 49 * From Etan, 2002:
29 * -Added config dialog 50 * -Added config dialog
71 92
72 #include "internal.h" 93 #include "internal.h"
73 #include "gtkgaim.h" 94 #include "gtkgaim.h"
74 #include "gtkprefs.h" 95 #include "gtkprefs.h"
75 96
76 #include "debug.h"
77 #include "prefs.h" 97 #include "prefs.h"
78 #include "signals.h" 98 #include "signals.h"
79 #include "version.h" 99 #include "version.h"
80 100
81 #include "gtkplugin.h" 101 #include "gtkplugin.h"
101 static void notify_toggle_cb(GtkWidget *widget, gpointer data); 121 static void notify_toggle_cb(GtkWidget *widget, gpointer data);
102 static gboolean options_entry_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data); 122 static gboolean options_entry_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data);
103 static void apply_method(); 123 static void apply_method();
104 static void apply_notify(); 124 static void apply_notify();
105 125
126 /* string function */
127 static void handle_string(GaimConvWindow *gaimwin);
128
129 /* count function */
130 static void handle_count(GaimConvWindow *gaimwin);
131
132 /* urgent function */
133 static void handle_urgent(GaimConvWindow *gaimwin, gboolean add);
134
106 /* raise function */ 135 /* raise function */
107 static void handle_raise(GaimConvWindow *window); 136 static void handle_raise(GaimConvWindow *gaimwin);
108
109 /* string function */
110 static void handle_string(GaimConvWindow *window);
111
112 /* count function */
113 static void handle_count(GaimConvWindow *window);
114
115 /* urgent function */
116 static void handle_urgent(GaimConvWindow *window, gboolean add);
117 137
118 /****************************************/ 138 /****************************************/
119 /* Begin doing stuff below this line... */ 139 /* Begin doing stuff below this line... */
120 /****************************************/ 140 /****************************************/
121 static int 141 static int
466 gtk_window_get_title(window)); 486 gtk_window_get_title(window));
467 gtk_window_set_title(window, newtitle); 487 gtk_window_set_title(window, newtitle);
468 } 488 }
469 489
470 static void 490 static void
471 handle_raise(GaimConvWindow *gaimwin)
472 {
473 GtkWindow *window = GTK_WINDOW(GAIM_GTK_WINDOW(gaimwin)->window);
474 gtk_window_present(window);
475 }
476
477 static void
478 handle_count(GaimConvWindow *gaimwin) 491 handle_count(GaimConvWindow *gaimwin)
479 { 492 {
480 GtkWindow *window; 493 GtkWindow *window;
481 char newtitle[256]; 494 char newtitle[256];
482 495
483 g_return_if_fail(gaimwin != NULL); 496 g_return_if_fail(gaimwin != NULL);
484 497
485 window = GTK_WINDOW(GAIM_GTK_WINDOW(gaimwin)->window); 498 window = GTK_WINDOW(GAIM_GTK_WINDOW(gaimwin)->window);
486 g_return_if_fail(window != NULL); 499 g_return_if_fail(window != NULL);
487 500
488 g_snprintf(newtitle, sizeof(newtitle), "[%d] %s", count_messages(gaimwin), 501 g_snprintf(newtitle, sizeof(newtitle), "[%d] %s",
489 gtk_window_get_title(window)); 502 count_messages(gaimwin), gtk_window_get_title(window));
490 gtk_window_set_title(window, newtitle); 503 gtk_window_set_title(window, newtitle);
491 } 504 }
492 505
493 static void 506 static void
494 handle_urgent(GaimConvWindow *gaimwin, gboolean add) 507 handle_urgent(GaimConvWindow *gaimwin, gboolean add)
498 511
499 g_return_if_fail(gtkwin != NULL); 512 g_return_if_fail(gtkwin != NULL);
500 g_return_if_fail(gtkwin->window != NULL); 513 g_return_if_fail(gtkwin->window != NULL);
501 g_return_if_fail(gtkwin->window->window != NULL); 514 g_return_if_fail(gtkwin->window->window != NULL);
502 515
503 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window)); 516 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window),
517 GDK_WINDOW_XWINDOW(gtkwin->window->window));
504 if (add) 518 if (add)
505 hints->flags |= XUrgencyHint; 519 hints->flags |= XUrgencyHint;
506 else 520 else
507 hints->flags &= ~XUrgencyHint; 521 hints->flags &= ~XUrgencyHint;
508 XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), 522 XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window),
509 GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); 523 GDK_WINDOW_XWINDOW(gtkwin->window->window), hints);
510 XFree(hints); 524 XFree(hints);
511 } 525 }
512 526
513 static void 527 static void
528 handle_raise(GaimConvWindow *gaimwin)
529 {
530 gaim_conv_window_raise(gaimwin);
531 }
532
533 static void
514 type_toggle_cb(GtkWidget *widget, gpointer data) 534 type_toggle_cb(GtkWidget *widget, gpointer data)
515 { 535 {
516 gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); 536 gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
517 gchar pref[256]; 537 gchar pref[256];
518 538
642 662
643 /*---------- "Notification Methods" ----------*/ 663 /*---------- "Notification Methods" ----------*/
644 frame = gaim_gtk_make_frame(ret, _("Notification Methods")); 664 frame = gaim_gtk_make_frame(ret, _("Notification Methods"));
645 vbox = gtk_vbox_new(FALSE, 5); 665 vbox = gtk_vbox_new(FALSE, 5);
646 gtk_container_add(GTK_CONTAINER(frame), vbox); 666 gtk_container_add(GTK_CONTAINER(frame), vbox);
647
648 /* Raise method button */
649 gaim_gtk_prefs_checkbox("R_aise window", "/plugins/gtk/X11/notify/method_raise", vbox);
650 667
651 /* String method button */ 668 /* String method button */
652 hbox = gtk_hbox_new(FALSE, 18); 669 hbox = gtk_hbox_new(FALSE, 18);
653 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 670 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
654 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); 671 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:"));
682 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); 699 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
683 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), 700 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle),
684 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")); 701 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent"));
685 g_signal_connect(G_OBJECT(toggle), "toggled", 702 g_signal_connect(G_OBJECT(toggle), "toggled",
686 G_CALLBACK(method_toggle_cb), "method_urgent"); 703 G_CALLBACK(method_toggle_cb), "method_urgent");
704
705 /* Raise window method button */
706 toggle = gtk_check_button_new_with_mnemonic(_("R_aise conversation window"));
707 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
708 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle),
709 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_raise"));
710 g_signal_connect(G_OBJECT(toggle), "toggled",
711 G_CALLBACK(method_toggle_cb), "method_raise");
687 712
688 /*---------- "Notification Removals" ----------*/ 713 /*---------- "Notification Removals" ----------*/
689 frame = gaim_gtk_make_frame(ret, _("Notification Removal")); 714 frame = gaim_gtk_make_frame(ret, _("Notification Removal"));
690 vbox = gtk_vbox_new(FALSE, 5); 715 vbox = gtk_vbox_new(FALSE, 5);
691 gtk_container_add(GTK_CONTAINER(frame), vbox); 716 gtk_container_add(GTK_CONTAINER(frame), vbox);