annotate plugins/notify.c @ 4237:2b5fa2b2f4ae

[gaim-migrate @ 4483] This was a team effort. I did my part, he did his part, and somehow we managed to get it done. I'd like to thank my parents. And God. And my pet turtle, Fluffy. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 08 Jan 2003 01:56:03 +0000
parents fac89c0d55c2
children 5fb47ec9bfe4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
1 /* Rewritten by Etan Reisner <deryni@eden.rutgers.edu>
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
2 *
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
3 * Added config dialog
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
4 * Added control over notification method
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
5 * Added control over when to release notification
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
6 *
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
7 * Added option to get notification for chats also
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
8 * Cleaned up code
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
9 * Added option to notify on click as it's own option
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
10 * rather then as what happens when on focus isn't clicked
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
11 * Added apply button to change the denotification methods for
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
12 * open conversation windows
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
13 * Fixed apply to conversations, count now keeps count across applies
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
14 * Fixed(?) memory leak, and in the process fixed some stupidities
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
15 * Hit enter when done editing the title string entry box to save it
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
16 *
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
17 * Thanks to Carles Pina i Estany <carles@pinux.info>
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
18 * for count of new messages option
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
19 */
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
20
4202
59751fe608c5 [gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents: 4165
diff changeset
21 #include "config.h"
59751fe608c5 [gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents: 4165
diff changeset
22
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
23 #ifndef GAIM_PLUGINS
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
24 #define GAIM_PLUGINS
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
25 #endif
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
26
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include "gaim.h"
3428
0202b5e1af69 [gaim-migrate @ 3454]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
28 #include <string.h>
0202b5e1af69 [gaim-migrate @ 3454]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
29 #include <ctype.h>
0202b5e1af69 [gaim-migrate @ 3454]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
30 #include <stdlib.h>
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <gtk/gtk.h>
3385
7931eb8bba19 [gaim-migrate @ 3404]
Sean Egan <seanegan@gmail.com>
parents: 3374
diff changeset
32 #include <X11/Xlib.h>
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
33 #include <X11/Xutil.h>
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
34 #include <X11/Xatom.h>
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
35 #include <gdk/gdkx.h>
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
36
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
37 guint type = 1;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
38 #define TYPE_IM 0x00000001
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
39 #define TYPE_CHAT 0x00000002
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
40
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
41 guint choice = 1;
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
42 #define NOTIFY_FOCUS 0x00000001
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
43 #define NOTIFY_TYPE 0x00000002
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
44 #define NOTIFY_IN_FOCUS 0x00000004
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
45 #define NOTIFY_CLICK 0x00000008
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
46
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
47 guint method = 1;
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
48 #define METHOD_STRING 0x00000001
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
49 #define METHOD_QUOTE 0x00000002
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
50 #define METHOD_URGENT 0x00000004
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
51 #define METHOD_COUNT 0x00000008
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 void *handle;
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
54 GtkWidget *Entry;
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
55 gchar *title_string;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
56 int Number = 0;
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
58 /* predefine some functions, less warnings */
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
59 void options(GtkWidget *widget, gpointer data);
4047
0fccde7ed9b8 [gaim-migrate @ 4255]
Sean Egan <seanegan@gmail.com>
parents: 4043
diff changeset
60 /* this returns an int so that typing events don't get stopped here */
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
61 int un_star(GtkWidget *widget, gpointer data);
3428
0202b5e1af69 [gaim-migrate @ 3454]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
62 int counter (char *buf, int *length);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
63 /*string functions */
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
64 void string_add(GtkWidget *widget);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
65 gboolean string_remove(GtkWidget *widget);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
66 /* count functions */
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
67 void count_add(GtkWidget *widget, int number);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
68 gboolean count_remove(GtkWidget *widget);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
69 /* quote functions */
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
70 void quote_add(GtkWidget *widget);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
71 gboolean quote_remove(GtkWidget *widget);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
72 /* urgent functions */
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
73 void urgent_add(struct conversation *c);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
74 gboolean urgent_remove(struct conversation *c);
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
75
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
76 struct conversation *find_chat(struct gaim_connection *gc, int id) {
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
77 GList *cnv = chats;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
78 struct conversation *c;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
79
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
80 while (cnv) {
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
81 c = (struct conversation *) cnv->data;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
82
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
83 if (c && (c->gc == gc) && c->is_chat && (c->id == id))
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
84 return c;
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1000
diff changeset
85
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
86 cnv = cnv->next;
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1000
diff changeset
87 }
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
88 return NULL;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
89 }
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
91 int notify(struct conversation *cnv) {
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
92 Window focus_return;
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
93 int revert_to_return;
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
95 XGetInputFocus(GDK_WINDOW_XDISPLAY(cnv->window->window), &focus_return, &revert_to_return);
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
96
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
97 if ((choice & NOTIFY_IN_FOCUS) ||
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
98 focus_return != GDK_WINDOW_XWINDOW(cnv->window->window)) {
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
99 if (method & METHOD_STRING)
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
100 string_add(cnv->window);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
101 if (method & METHOD_COUNT)
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
102 count_add(cnv->window, 0);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
103 if (method & METHOD_QUOTE)
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
104 quote_add(cnv->window);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
105 if (method & METHOD_URGENT)
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
106 urgent_add(cnv);
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
107 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
108 return 0;
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
109 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
110
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
111 guint unnotify(struct conversation *c, gboolean clean) {
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
112 guint option = 0;
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
113 /* The top level ifs check whether we are either cleaning all methods,
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
114 * or whether we have that method is currently selected.
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
115 * If we do then they are cleaned
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
116 *
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
117 * The second level ifs check if we removed something,
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
118 * and if that method is currently selected.
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
119 * If we did and it is then set option so that it can be re-added */
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
120 if (clean || (method & METHOD_QUOTE))
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
121 if (quote_remove(c->window) && (method & METHOD_QUOTE))
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
122 option ^= METHOD_QUOTE;
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
123
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
124 if (clean || (method & METHOD_COUNT))
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
125 if (count_remove(c->window) && (method & METHOD_COUNT))
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
126 option ^= METHOD_COUNT;
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
127
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
128 if (clean || (method & METHOD_STRING))
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
129 if (string_remove(c->window) && (method & METHOD_STRING))
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
130 option ^= METHOD_STRING;
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
131
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
132 if (clean || (method & METHOD_URGENT))
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
133 if (urgent_remove(c) && (method & METHOD_URGENT))
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
134 option ^= METHOD_URGENT;
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
135
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
136 return option;
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
137 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
138
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
139 void chat_recv_im(struct gaim_connection *gc, int id, char **who, char **text) {
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
140 struct conversation *c = find_chat(gc, id);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
141
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
142 if (c && (type & TYPE_CHAT))
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
143 notify(c);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
144 return;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
145 }
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
146
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
147 void chat_sent_im(struct gaim_connection *gc, int id, char **text) {
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
148 struct conversation *c = find_chat(gc, id);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
149
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
150 if (c && (type & TYPE_CHAT))
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
151 unnotify(c, FALSE);
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
152 return;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
153 }
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
154
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
155 int im_recv_im(struct gaim_connection *gc, char **who, char **what, void *m) {
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
156 struct conversation *c = find_conversation(*who);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
157
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
158 if (c && (type & TYPE_IM))
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
159 notify(c);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
160 return 0;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
161 }
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
162
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
163 int im_sent_im(struct gaim_connection *gc, char *who, char **what, void *m) {
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
164 struct conversation *c = find_conversation(who);
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
165
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
166 if (c && (type & TYPE_IM))
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
167 unnotify(c, FALSE);
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
168 return 0;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
169 }
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
170
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
171 int attach_signals(struct conversation *c) {
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
172 if (choice & NOTIFY_FOCUS) {
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
173 g_signal_connect(G_OBJECT(c->window), "focus-in-event", G_CALLBACK(un_star), NULL);
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
174 }
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
175
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
176 if (choice & NOTIFY_CLICK) {
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
177 g_signal_connect(G_OBJECT(c->window), "button_press_event", G_CALLBACK(un_star), NULL);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
178
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
179 g_signal_connect_swapped(G_OBJECT(c->text), "button_press_event", G_CALLBACK(un_star), G_OBJECT(c->window));
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
180
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
181 g_signal_connect_swapped(G_OBJECT(c->entry), "button_press_event", G_CALLBACK(un_star), G_OBJECT(c->window));
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
182 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
183
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
184 if (choice & NOTIFY_TYPE) {
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
185 g_signal_connect_swapped(G_OBJECT(c->entry), "key-press-event", G_CALLBACK(un_star), G_OBJECT(c->window));
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 }
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
187
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
188 g_object_set_data(G_OBJECT(c->window), "user_data", c);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
189 g_object_set_data(G_OBJECT(c->window), "notify_data", GUINT_TO_POINTER(choice));
3428
0202b5e1af69 [gaim-migrate @ 3454]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
190 return 0;
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 }
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
193 void detach_signals(struct conversation *c) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
194 guint options = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(c->window), "notify_data"));
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
195
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
196 if (options & NOTIFY_FOCUS) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
197 g_signal_handlers_disconnect_by_func(G_OBJECT(c->window), un_star, NULL);
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
198 }
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
199 if (options & NOTIFY_CLICK) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
200 g_signal_handlers_disconnect_by_func(G_OBJECT(c->window), un_star, NULL);
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
201 g_signal_handlers_disconnect_by_func(G_OBJECT(c->text), un_star, c->window);
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
202 g_signal_handlers_disconnect_by_func(G_OBJECT(c->entry), un_star, c->window);
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
203 }
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
204
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
205 if (options & NOTIFY_TYPE) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
206 g_signal_handlers_disconnect_by_func(G_OBJECT(c->entry), un_star, c->window);
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
207 }
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
208 }
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
209
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
210 void new_conv(char *who) {
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
211 struct conversation *c = find_conversation(who);
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
212
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
213 if (c && (type & TYPE_IM))
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
214 attach_signals(c);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
215 return;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
216 }
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
217
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
218 void chat_join(struct gaim_connection *gc, int id, char *room) {
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
219 struct conversation *c = find_chat(gc, id);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
220
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
221 if (c && (type & TYPE_CHAT))
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
222 attach_signals(c);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
223 return;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
224 }
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
225
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
226 int un_star(GtkWidget *widget, gpointer data) {
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
227 struct conversation *c = g_object_get_data(G_OBJECT(widget), "user_data");
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
228
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
229 if (method & METHOD_QUOTE)
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
230 quote_remove(widget);
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
231 if (method & METHOD_COUNT)
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
232 count_remove(widget);
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
233 if (method & METHOD_STRING)
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
234 string_remove(widget);
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
235 if (c && method & METHOD_URGENT)
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
236 urgent_remove(c);
4047
0fccde7ed9b8 [gaim-migrate @ 4255]
Sean Egan <seanegan@gmail.com>
parents: 4043
diff changeset
237 return 0;
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
238 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
239
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
240 /* This function returns the number in [ ]'s or 0 */
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
241 int counter (char *buf, int *length) {
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
242 char temp[256];
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
243 int i = 1;
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
244 *length = 0;
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
245
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
246 while (isdigit(buf[i]) && i<sizeof(buf)) {
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
247 temp[i-1] = buf[i];
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
248 (*length)++;
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
249 i++;
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
250 }
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
251 temp[i] = '\0';
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
252
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
253 if (buf[i] != ']') {
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
254 *length = 0;
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
255 return (0);
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
256 }
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
257
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
258 return (atoi(temp));
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
259 }
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
260
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
261 void string_add(GtkWidget *widget) {
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
262 char buf[256];
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
263 GtkWindow *win = GTK_WINDOW(widget);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
264
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
265 strncpy(buf, win->title, sizeof(buf));
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
266 if (!strstr(buf, title_string)) {
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
267 g_snprintf(buf, sizeof(buf), "%s%s", title_string, win->title);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
268 gtk_window_set_title(win, buf);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
269 }
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
270 }
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
271
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
272 gboolean string_remove(GtkWidget *widget) {
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 char buf[256];
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
274 GtkWindow *win = GTK_WINDOW(widget);
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
275
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
276 strncpy(buf, win->title, sizeof(buf));
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
277 if (strstr(buf, title_string)) {
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
278 g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]);
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
279 gtk_window_set_title(win, buf);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
280 return TRUE;
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
281 }
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
282 return FALSE;
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
283 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
284
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
285 void count_add(GtkWidget *widget, int number) {
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
286 char buf[256];
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
287 int c, length;
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
288 GtkWindow *win = GTK_WINDOW(widget);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
289
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
290 strncpy(buf, win->title, sizeof(buf));
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
291 c = counter(buf, &length);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
292 if (number) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
293 g_snprintf(buf, sizeof(buf), "[%d] %s", number, win->title);
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
294 } else if (!c) {
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
295 g_snprintf(buf, sizeof(buf), "[1] %s", win->title);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
296 } else if (!g_strncasecmp(buf, "[", 1)) {
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
297 g_snprintf(buf, sizeof(buf), "[%d] %s", c+1, &win->title[3+length]);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
298 }
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
299 gtk_window_set_title(win, buf);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
300 }
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
301
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
302 gboolean count_remove(GtkWidget *widget) {
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
303 char buf[256];
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
304 GtkWindow *win = GTK_WINDOW(widget);
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
305 int length;
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
306
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
307 strncpy(buf, win->title, sizeof(buf));
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
308 if (!g_strncasecmp(buf, "[", 1)) {
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
309 Number = counter(buf, &length);
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
310 g_snprintf(buf, sizeof(buf), "%s", &win->title[3+length]);
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
311 gtk_window_set_title(win, buf);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
312 return TRUE;
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
313 }
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
314 return FALSE;
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
315 }
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
316
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
317 void quote_add(GtkWidget *widget) {
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
318 char buf[256];
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
319 GtkWindow *win = GTK_WINDOW(widget);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
320
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
321 strncpy(buf, win->title, sizeof(buf));
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
322 if (g_strncasecmp(buf, "\"", 1)) {
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
323 g_snprintf(buf, sizeof(buf), "\"%s\"", win->title);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
324 gtk_window_set_title(win, buf);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
325 }
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
326 }
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
327
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
328 gboolean quote_remove(GtkWidget *widget) {
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
329 char buf[256];
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
330 GtkWindow *win = GTK_WINDOW(widget);
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
332 strncpy(buf, win->title, sizeof(buf));
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
333 if (!g_strncasecmp(buf, "\"", 1)) {
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
334 g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]);
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 gtk_window_set_title(win, buf);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
336 return TRUE;
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 }
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
338 return FALSE;
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
339 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
340
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
341 void urgent_add(struct conversation *c) {
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
342 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window));
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
343 hints->flags |= XUrgencyHint;
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
344 XSetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window), hints);
4218
fac89c0d55c2 [gaim-migrate @ 4462]
Sean Egan <seanegan@gmail.com>
parents: 4203
diff changeset
345 XFree(hints);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
346 }
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
347
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
348 gboolean urgent_remove(struct conversation *c) {
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
349 if ((c->is_chat && (chat_options & OPT_CHAT_ONE_WINDOW)) || (!c->is_chat && (im_options & OPT_IM_ONE_WINDOW))) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
350 if (c->is_chat) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
351 struct conversation *c = (struct conversation *)chats->data;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
352 GdkWindow *win = c->window->window;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
353
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
354 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win));
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
355 if (hints->flags & XUrgencyHint) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
356 hints->flags &= ~XUrgencyHint;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
357 XSetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window), hints);
4218
fac89c0d55c2 [gaim-migrate @ 4462]
Sean Egan <seanegan@gmail.com>
parents: 4203
diff changeset
358 XFree(hints);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
359 return TRUE;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
360 }
4218
fac89c0d55c2 [gaim-migrate @ 4462]
Sean Egan <seanegan@gmail.com>
parents: 4203
diff changeset
361 XFree(hints);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
362 return FALSE;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
363 } else {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
364 struct conversation *c = (struct conversation *)conversations->data;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
365 GdkWindow *win = c->window->window;
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
366
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
367 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win));
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
368 if (hints->flags & XUrgencyHint) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
369 hints->flags &= ~XUrgencyHint;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
370 XSetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window), hints);
4218
fac89c0d55c2 [gaim-migrate @ 4462]
Sean Egan <seanegan@gmail.com>
parents: 4203
diff changeset
371 XFree(hints);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
372 return TRUE;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
373 }
4218
fac89c0d55c2 [gaim-migrate @ 4462]
Sean Egan <seanegan@gmail.com>
parents: 4203
diff changeset
374 XFree(hints);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
375 return FALSE;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
376 }
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
377 } else {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
378 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window));
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
379 if (hints->flags & XUrgencyHint) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
380 hints->flags &= ~XUrgencyHint;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
381 XSetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window), hints);
4218
fac89c0d55c2 [gaim-migrate @ 4462]
Sean Egan <seanegan@gmail.com>
parents: 4203
diff changeset
382 XFree(hints);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
383 return TRUE;
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
384 }
4218
fac89c0d55c2 [gaim-migrate @ 4462]
Sean Egan <seanegan@gmail.com>
parents: 4203
diff changeset
385 XFree(hints);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
386 return FALSE;
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
387 }
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
388 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
389
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
390 void save_notify_prefs() {
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
391 gchar buf[1000];
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
392 FILE *fp;
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
393
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
394 snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME"));
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
395 if (!(fp = fopen(buf, "w"))) {
3561
333551497ff8 [gaim-migrate @ 3655]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
396 do_error_dialog(_("Unable to write to config file"), _("Notify plugin"), GAIM_ERROR);
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
397 return;
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
398 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
399
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
400 fprintf(fp, "%d=TYPE\n", type);
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
401 fprintf(fp, "%d=CHOICE\n", choice);
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
402 fprintf(fp, "%d=METHOD\n", method);
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
403 fprintf(fp, "%s=STRING\n", title_string);
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
404 fclose(fp);
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
405 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
406
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
407 void load_notify_prefs() {
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
408 gchar buf[1000];
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
409 gchar **parsed;
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
410 FILE *fp;
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
411
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
412 g_snprintf(buf, sizeof(buf), "%s/.gaim/.notify", getenv("HOME"));
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
413 if (!(fp = fopen(buf, "r")))
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
414 return;
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
415
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
416 while (fgets(buf, 1000, fp) != NULL) {
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
417 parsed = g_strsplit(g_strchomp(buf), "=", 2);
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
418 if (parsed[0] && parsed[1]) {
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
419 if (!strcmp(parsed[1], "TYPE"))
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
420 type = atoi(parsed[0]);
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
421 if (!strcmp(parsed[1], "CHOICE"))
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
422 choice = atoi(parsed[0]);
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
423 if (!strcmp(parsed[1], "METHOD"))
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
424 method = atoi(parsed[0]);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
425 if (!strcmp(parsed[1], "STRING")) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
426 if (title_string != NULL)
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
427 g_free(title_string);
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
428 title_string = g_strdup(parsed[0]);
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
429 }
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
430 }
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
431 g_strfreev(parsed);
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
432 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
433 fclose(fp);
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
434 return;
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
435 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
436
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
437 void options(GtkWidget *widget, gpointer data) {
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
438 gint option = GPOINTER_TO_INT(data);
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
439
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
440 if (option == 0)
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
441 choice ^= NOTIFY_FOCUS;
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
442 else if (option == 1)
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
443 choice ^= NOTIFY_CLICK;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
444 else if (option == 2)
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
445 choice ^= NOTIFY_TYPE;
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
446 else if (option == 3) {
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
447 method ^= METHOD_STRING;
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
448 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
449 gtk_widget_set_sensitive(Entry, TRUE);
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
450 else
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
451 gtk_widget_set_sensitive(Entry, FALSE);
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
452 }
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
453 else if (option == 4)
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
454 method ^= METHOD_QUOTE;
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
455 else if (option == 5)
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
456 method ^= METHOD_URGENT;
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
457 else if (option == 6)
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
458 choice ^= NOTIFY_IN_FOCUS;
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
459 else if (option == 7)
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
460 method ^= METHOD_COUNT;
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
461 else if (option == 8)
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
462 type ^= TYPE_IM;
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
463 else if (option == 9)
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
464 type ^= TYPE_CHAT;
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
465 else if (option == 10) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
466 /* I made an option for this as at least a way to have it save correctly
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
467 * I'd much rather there were better ways, and I don't want to save this
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
468 * no matter which pref is changed, that's too much of a hack */
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
469 if (title_string != NULL) {
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
470 g_free(title_string);
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
471 title_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(Entry)));
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
472 }
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
473 }
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
474
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
475 save_notify_prefs();
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
476 }
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
477
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
478 void apply_options(GtkWidget *widget, gpointer data) {
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
479 GList *cnv = conversations;
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
480
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
481 while (cnv) {
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
482 guint notification;
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
483 struct conversation *c = (struct conversation *) cnv->data;
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
484
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
485 /* remove old notification signals */
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
486 detach_signals(c);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
487
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
488 /* clean off all notification markings */
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
489 notification = unnotify(c, TRUE);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
490
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
491 /* re-add appropriate notification methods cleaned above */
4043
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
492 if (notification & METHOD_STRING) /* re-add string */
e25edee01c33 [gaim-migrate @ 4251]
Luke Schierer <lschiere@pidgin.im>
parents: 4035
diff changeset
493 string_add(c->window);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
494 if (notification & METHOD_QUOTE) /* re-add quote */
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
495 quote_add(c->window);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
496 if (notification & METHOD_COUNT) /* re-add count */
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
497 count_add(c->window, Number);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
498 if (notification & METHOD_URGENT) /* re-add urgent */
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
499 urgent_add(c);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
500
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
501 /* attach new unnotification signals */
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
502 attach_signals(c);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
503
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
504 cnv = cnv->next;
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
505 }
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
506
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
507 return;
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
508 }
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
509
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1000
diff changeset
510 char *gaim_plugin_init(GModule *hndl) {
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511 handle = hndl;
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
512 title_string = g_strdup("(*) ");
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
514 load_notify_prefs();
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
515
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
516 gaim_signal_connect(handle, event_im_recv, im_recv_im, NULL);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
517 gaim_signal_connect(handle, event_chat_recv, chat_recv_im, NULL);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
518 gaim_signal_connect(handle, event_im_send, im_sent_im, NULL);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
519 gaim_signal_connect(handle, event_chat_send, chat_sent_im, NULL);
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
520 gaim_signal_connect(handle, event_new_conversation, new_conv, NULL);
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
521 gaim_signal_connect(handle, event_chat_join, chat_join, NULL);
1052
25f121faa75e [gaim-migrate @ 1062]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1047
diff changeset
522 return NULL;
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 }
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
525 void gaim_plugin_remove() {
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
526 GList *c = conversations;
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
527
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
528 while (c) {
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
529 struct conversation *cnv = (struct conversation *)c->data;
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
530
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
531 detach_signals(cnv);
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
532 un_star(cnv->window, NULL);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
533
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
534 c = c->next;
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
535 }
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
536
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
537 /* this might be a hack I'm not sure, I don't think so but... */
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
538 g_free(title_string);
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
539 }
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
540
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
541 struct gaim_plugin_description desc;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
542 struct gaim_plugin_description *gaim_plugin_desc() {
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
543 desc.api_version = PLUGIN_API_VERSION;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
544 desc.name = g_strdup("Message Notification");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
545 desc.version = g_strdup(VERSION);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
546 desc.description = g_strdup("Provides a variety of ways of notifying you of unread messages.");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
547 desc.authors = g_strdup("Etan Reisner &lt;deryni@eden.rutgers.edu>");
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
548 desc.url = g_strdup(WEBSITE);
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
549 return &desc;
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
550 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3511
diff changeset
551
191
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 char *name() {
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 return "Visual Notification";
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 }
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 char *description() {
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557 return "Puts an asterisk in the title bar of all conversations"
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 " where you have not responded to a message yet.";
948100a8cb23 [gaim-migrate @ 201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559 }
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
560
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
561 GtkWidget *gaim_plugin_config_gtk() {
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
562 GtkWidget *ret;
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
563 GtkWidget *vbox, *hbox;
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
564 GtkWidget *toggle, *button;
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
565 ret = gtk_vbox_new(FALSE, 18);
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
566 gtk_container_set_border_width (GTK_CONTAINER (ret), 12);
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
567
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
568 vbox = make_frame(ret, _("Notify For"));
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
569 toggle = gtk_check_button_new_with_mnemonic(_("_IM windows"));
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
570 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
571 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), type & TYPE_IM);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
572 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(8));
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
573
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
574 toggle = gtk_check_button_new_with_mnemonic(_("_Chat windows"));
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
575 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
576 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), type & TYPE_CHAT);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
577 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(9));
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
578
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
579 /*--------------*/
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
580 vbox = make_frame(ret, _("Notification Methods"));
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
581 hbox = gtk_hbox_new(FALSE, 18);
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
582 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
583 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title (hit enter to save):"));
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
584 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_STRING);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
585 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(3));
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
586 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
587 Entry = gtk_entry_new();
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
588 gtk_entry_set_max_length(GTK_ENTRY(Entry), 10);
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
589 gtk_widget_set_sensitive(GTK_WIDGET(Entry), method & METHOD_STRING);
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
590 gtk_box_pack_start(GTK_BOX(hbox), Entry, FALSE, FALSE, 0);
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
591 gtk_entry_set_text(GTK_ENTRY(Entry), title_string);
4203
ec6d0c5e5c23 [gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents: 4202
diff changeset
592 g_signal_connect(G_OBJECT(Entry), "activate", G_CALLBACK(options), GINT_TO_POINTER(10));
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
593
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
594 toggle = gtk_check_button_new_with_mnemonic(_("_Quote window title"));
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
595 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
596 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_QUOTE);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
597 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(4));
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
598
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
599 toggle = gtk_check_button_new_with_mnemonic(_("Set Window Manager \"_URGENT\" Hint"));
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
600 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
601 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_URGENT);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
602 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(5));
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
603
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
604 toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title"));
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
605 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_COUNT);
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
606 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
607 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(7));
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
608
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
609 toggle = gtk_check_button_new_with_mnemonic(_("_Notify even if conversation is in focus"));
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
610 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_IN_FOCUS);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
611 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
612 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(6));
3392
5a5df7968b6e [gaim-migrate @ 3411]
Sean Egan <seanegan@gmail.com>
parents: 3385
diff changeset
613
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
614 /*--------------*/
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
615 vbox = make_frame(ret, _("Notification Removal"));
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
616 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window gains _focus"));
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
617 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
618 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_FOCUS);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
619 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(0));
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
620
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
621 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click"));
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
622 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
623 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_CLICK);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
624 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(1));
3710
03ba413ca20b [gaim-migrate @ 3843]
Luke Schierer <lschiere@pidgin.im>
parents: 3565
diff changeset
625
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
626 toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window"));
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
627 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
628 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_TYPE);
4035
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
629 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(2));
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
630
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
631 button = gtk_button_new_with_mnemonic(_("Appl_y"));
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
632 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 5);
4cea75cf291d [gaim-migrate @ 4241]
Luke Schierer <lschiere@pidgin.im>
parents: 3710
diff changeset
633 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(apply_options), NULL);
3565
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
634
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
635 gtk_widget_show_all(ret);
154c4a9d9b6d [gaim-migrate @ 3660]
Sean Egan <seanegan@gmail.com>
parents: 3561
diff changeset
636 return ret;
3374
3cd2fbddf95a [gaim-migrate @ 3393]
Sean Egan <seanegan@gmail.com>
parents: 2313
diff changeset
637 }