Mercurial > pidgin
annotate plugins/notify.c @ 4359:5fb47ec9bfe4
[gaim-migrate @ 4625]
Wow, okay, where to begin with this one ;)
I rewrote the whole conversation backend. It is now core/UI split. Here's
how it works..
Every conversation is represented by a gaim_conversation structure. This
branches out into gaim_im and gaim_chat structures. Every conversation
lives in (well, normally, but it doesn't have to) a gaim_window structure.
This is a _CORE_ representation of a window. There can be multiple
gaim_window structures around.
The gaim_window and gaim_conversation structures have UI-specific operation
structures associated with them. At the moment, the only UI is GTK+, and
this will be for some time. Don't start thinking you can write a QT UI now.
It's just not going to happen.
Everything that is done on a conversation is done through the core API.
This API does core processing and then calls the UI operations for the
rendering and anything else.
Now, what does this give the user?
- Multiple windows.
- Multiple tabs per window.
- Draggable tabs.
- Send As menu is moved to the menubar.
- Menubar for chats.
- Some very cool stuff in the future, like replacing, say, IRC chat windows
with an X-Chat interface, or whatever.
- Later on, customizable window/conversation positioning.
For developers:
- Fully documented API
- Core/UI split
- Variable checking and mostly sane handling of incorrect variables.
- Logical structure to conversations, both core and UI.
- Some very cool stuff in the future, like replacing, say, IRC chat windows
with an X-Chat interface, or whatever.
- Later on, customizable window/conversation positioning.
- Oh yeah, and the beginning of a stock icon system.
Now, there are things that aren't there yet. You will see tabs even if you
have them turned off. This will be fixed in time. Also, the preferences
will change to work with the new structure. I'm starting school in 2 days,
so it may not be done immediately, but hopefully in the next week.
Enjoy!
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 20 Jan 2003 09:10:23 +0000 |
parents | fac89c0d55c2 |
children | 2c985a9e994c |
rev | line source |
---|---|
3392 | 1 /* Rewritten by Etan Reisner <deryni@eden.rutgers.edu> |
3374 | 2 * |
3 * Added config dialog | |
4 * Added control over notification method | |
5 * Added control over when to release notification | |
4035 | 6 * |
7 * Added option to get notification for chats also | |
8 * Cleaned up code | |
9 * Added option to notify on click as it's own option | |
10 * rather then as what happens when on focus isn't clicked | |
11 * Added apply button to change the denotification methods for | |
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 | 16 * |
17 * Thanks to Carles Pina i Estany <carles@pinux.info> | |
18 * for count of new messages option | |
19 */ | |
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 | 23 #ifndef GAIM_PLUGINS |
24 #define GAIM_PLUGINS | |
25 #endif | |
3374 | 26 |
191 | 27 #include "gaim.h" |
3428 | 28 #include <string.h> |
29 #include <ctype.h> | |
30 #include <stdlib.h> | |
191 | 31 #include <gtk/gtk.h> |
3385 | 32 #include <X11/Xlib.h> |
3374 | 33 #include <X11/Xutil.h> |
3392 | 34 #include <X11/Xatom.h> |
3374 | 35 #include <gdk/gdkx.h> |
36 | |
3710 | 37 guint type = 1; |
38 #define TYPE_IM 0x00000001 | |
39 #define TYPE_CHAT 0x00000002 | |
40 | |
3392 | 41 guint choice = 1; |
42 #define NOTIFY_FOCUS 0x00000001 | |
43 #define NOTIFY_TYPE 0x00000002 | |
44 #define NOTIFY_IN_FOCUS 0x00000004 | |
3710 | 45 #define NOTIFY_CLICK 0x00000008 |
3374 | 46 |
3392 | 47 guint method = 1; |
48 #define METHOD_STRING 0x00000001 | |
49 #define METHOD_QUOTE 0x00000002 | |
50 #define METHOD_URGENT 0x00000004 | |
51 #define METHOD_COUNT 0x00000008 | |
191 | 52 |
53 void *handle; | |
3565 | 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 | 57 |
3374 | 58 /* predefine some functions, less warnings */ |
59 void options(GtkWidget *widget, gpointer data); | |
4047 | 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 | 62 int counter (char *buf, int *length); |
4035 | 63 /*string functions */ |
64 void string_add(GtkWidget *widget); | |
65 gboolean string_remove(GtkWidget *widget); | |
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 | 68 gboolean count_remove(GtkWidget *widget); |
69 /* quote functions */ | |
70 void quote_add(GtkWidget *widget); | |
71 gboolean quote_remove(GtkWidget *widget); | |
72 /* urgent functions */ | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
73 void urgent_add(struct gaim_conversation *c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
74 gboolean urgent_remove(struct gaim_conversation *c); |
3710 | 75 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
76 int notify(struct gaim_conversation *cnv) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
77 struct gaim_gtk_window *gtkwin; |
3710 | 78 Window focus_return; |
4035 | 79 int revert_to_return; |
191 | 80 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
81 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(cnv)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
82 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
83 XGetInputFocus(GDK_WINDOW_XDISPLAY(gtkwin->window->window), &focus_return, &revert_to_return); |
3374 | 84 |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
85 if ((choice & NOTIFY_IN_FOCUS) || |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
86 focus_return != GDK_WINDOW_XWINDOW(gtkwin->window->window)) { |
4035 | 87 if (method & METHOD_STRING) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
88 string_add(gtkwin->window); |
4035 | 89 if (method & METHOD_COUNT) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
90 count_add(gtkwin->window, 0); |
4035 | 91 if (method & METHOD_QUOTE) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
92 quote_add(gtkwin->window); |
4035 | 93 if (method & METHOD_URGENT) |
94 urgent_add(cnv); | |
3374 | 95 } |
96 return 0; | |
97 } | |
98 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
99 guint unnotify(struct gaim_conversation *c, gboolean clean) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
100 struct gaim_gtk_window *gtkwin; |
4035 | 101 guint option = 0; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
102 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
103 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
104 |
4043 | 105 /* The top level ifs check whether we are either cleaning all methods, |
106 * or whether we have that method is currently selected. | |
107 * If we do then they are cleaned | |
108 * | |
109 * The second level ifs check if we removed something, | |
110 * and if that method is currently selected. | |
111 * If we did and it is then set option so that it can be re-added */ | |
4035 | 112 if (clean || (method & METHOD_QUOTE)) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
113 if (quote_remove(gtkwin->window) && (method & METHOD_QUOTE)) |
4035 | 114 option ^= METHOD_QUOTE; |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
115 |
4035 | 116 if (clean || (method & METHOD_COUNT)) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
117 if (count_remove(gtkwin->window) && (method & METHOD_COUNT)) |
4035 | 118 option ^= METHOD_COUNT; |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
119 |
4035 | 120 if (clean || (method & METHOD_STRING)) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
121 if (string_remove(gtkwin->window) && (method & METHOD_STRING)) |
4035 | 122 option ^= METHOD_STRING; |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
123 |
4035 | 124 if (clean || (method & METHOD_URGENT)) |
4043 | 125 if (urgent_remove(c) && (method & METHOD_URGENT)) |
4035 | 126 option ^= METHOD_URGENT; |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
127 |
4035 | 128 return option; |
3374 | 129 } |
130 | |
3710 | 131 void chat_recv_im(struct gaim_connection *gc, int id, char **who, char **text) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
132 struct gaim_conversation *c = gaim_find_chat(gc, id); |
3710 | 133 |
134 if (c && (type & TYPE_CHAT)) | |
135 notify(c); | |
136 return; | |
137 } | |
138 | |
139 void chat_sent_im(struct gaim_connection *gc, int id, char **text) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
140 struct gaim_conversation *c = gaim_find_chat(gc, id); |
3710 | 141 |
142 if (c && (type & TYPE_CHAT)) | |
4035 | 143 unnotify(c, FALSE); |
3710 | 144 return; |
145 } | |
146 | |
147 int im_recv_im(struct gaim_connection *gc, char **who, char **what, void *m) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
148 struct gaim_conversation *c = gaim_find_conversation(*who); |
3710 | 149 |
150 if (c && (type & TYPE_IM)) | |
151 notify(c); | |
152 return 0; | |
153 } | |
154 | |
155 int im_sent_im(struct gaim_connection *gc, char *who, char **what, void *m) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
156 struct gaim_conversation *c = gaim_find_conversation(who); |
3374 | 157 |
3710 | 158 if (c && (type & TYPE_IM)) |
4035 | 159 unnotify(c, FALSE); |
3710 | 160 return 0; |
161 } | |
3392 | 162 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
163 int attach_signals(struct gaim_conversation *c) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
164 struct gaim_gtk_conversation *gtkconv; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
165 struct gaim_gtk_window *gtkwin; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
166 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
167 gtkconv = GAIM_GTK_CONVERSATION(c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
168 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
169 |
3392 | 170 if (choice & NOTIFY_FOCUS) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
171 g_signal_connect(G_OBJECT(gtkwin->window), "focus-in-event", G_CALLBACK(un_star), NULL); |
3374 | 172 } |
3710 | 173 |
174 if (choice & NOTIFY_CLICK) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
175 g_signal_connect(G_OBJECT(gtkwin->window), "button_press_event", G_CALLBACK(un_star), NULL); |
4035 | 176 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
177 g_signal_connect_swapped(G_OBJECT(gtkconv->imhtml), "button_press_event", G_CALLBACK(un_star), G_OBJECT(gtkwin->window)); |
4035 | 178 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
179 g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "button_press_event", G_CALLBACK(un_star), G_OBJECT(gtkwin->window)); |
3374 | 180 } |
181 | |
3392 | 182 if (choice & NOTIFY_TYPE) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
183 g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key-press-event", G_CALLBACK(un_star), G_OBJECT(gtkwin->window)); |
191 | 184 } |
4035 | 185 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
186 g_object_set_data(G_OBJECT(gtkwin->window), "user_data", c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
187 g_object_set_data(G_OBJECT(gtkwin->window), "notify_data", GUINT_TO_POINTER(choice)); |
3428 | 188 return 0; |
191 | 189 } |
190 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
191 void detach_signals(struct gaim_conversation *c) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
192 struct gaim_gtk_conversation *gtkconv; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
193 struct gaim_gtk_window *gtkwin; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
194 guint options; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
195 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
196 gtkconv = GAIM_GTK_CONVERSATION(c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
197 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
198 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
199 options = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(gtkwin->window), "notify_data")); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
200 |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
201 if (options & NOTIFY_FOCUS) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
202 g_signal_handlers_disconnect_by_func(G_OBJECT(gtkwin->window), un_star, NULL); |
4203
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 if (options & NOTIFY_CLICK) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
205 g_signal_handlers_disconnect_by_func(G_OBJECT(gtkwin->window), un_star, NULL); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
206 g_signal_handlers_disconnect_by_func(G_OBJECT(gtkconv->imhtml), un_star, gtkwin->window); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
207 g_signal_handlers_disconnect_by_func(G_OBJECT(gtkconv->entry), un_star, gtkwin->window); |
4203
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 |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
210 if (options & NOTIFY_TYPE) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
211 g_signal_handlers_disconnect_by_func(G_OBJECT(gtkconv->entry), un_star, gtkwin->window); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
212 } |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
213 } |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
214 |
3710 | 215 void new_conv(char *who) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
216 struct gaim_conversation *c = gaim_find_conversation(who); |
3710 | 217 |
4035 | 218 if (c && (type & TYPE_IM)) |
3710 | 219 attach_signals(c); |
220 } | |
221 | |
222 void chat_join(struct gaim_connection *gc, int id, char *room) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
223 struct gaim_conversation *c = gaim_find_chat(gc, id); |
3710 | 224 |
4043 | 225 if (c && (type & TYPE_CHAT)) |
3710 | 226 attach_signals(c); |
227 } | |
228 | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
229 int un_star(GtkWidget *widget, gpointer data) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
230 struct gaim_conversation *c = g_object_get_data(G_OBJECT(widget), "user_data"); |
3374 | 231 |
232 if (method & METHOD_QUOTE) | |
233 quote_remove(widget); | |
3392 | 234 if (method & METHOD_COUNT) |
235 count_remove(widget); | |
3374 | 236 if (method & METHOD_STRING) |
237 string_remove(widget); | |
4043 | 238 if (c && method & METHOD_URGENT) |
3374 | 239 urgent_remove(c); |
4047 | 240 return 0; |
3374 | 241 } |
242 | |
3392 | 243 /* This function returns the number in [ ]'s or 0 */ |
244 int counter (char *buf, int *length) { | |
245 char temp[256]; | |
246 int i = 1; | |
247 *length = 0; | |
248 | |
249 while (isdigit(buf[i]) && i<sizeof(buf)) { | |
250 temp[i-1] = buf[i]; | |
251 (*length)++; | |
252 i++; | |
253 } | |
254 temp[i] = '\0'; | |
4035 | 255 |
3392 | 256 if (buf[i] != ']') { |
257 *length = 0; | |
258 return (0); | |
259 } | |
260 | |
261 return (atoi(temp)); | |
262 } | |
263 | |
4035 | 264 void string_add(GtkWidget *widget) { |
265 char buf[256]; | |
266 GtkWindow *win = GTK_WINDOW(widget); | |
267 | |
268 strncpy(buf, win->title, sizeof(buf)); | |
269 if (!strstr(buf, title_string)) { | |
270 g_snprintf(buf, sizeof(buf), "%s%s", title_string, win->title); | |
271 gtk_window_set_title(win, buf); | |
272 } | |
273 } | |
274 | |
275 gboolean string_remove(GtkWidget *widget) { | |
191 | 276 char buf[256]; |
3374 | 277 GtkWindow *win = GTK_WINDOW(widget); |
278 | |
3392 | 279 strncpy(buf, win->title, sizeof(buf)); |
3374 | 280 if (strstr(buf, title_string)) { |
281 g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]); | |
282 gtk_window_set_title(win, buf); | |
4035 | 283 return TRUE; |
3374 | 284 } |
4035 | 285 return FALSE; |
3374 | 286 } |
287 | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
288 void count_add(GtkWidget *widget, int number) { |
4035 | 289 char buf[256]; |
290 int c, length; | |
291 GtkWindow *win = GTK_WINDOW(widget); | |
292 | |
293 strncpy(buf, win->title, sizeof(buf)); | |
294 c = counter(buf, &length); | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
295 if (number) { |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
296 g_snprintf(buf, sizeof(buf), "[%d] %s", number, win->title); |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
297 } else if (!c) { |
4035 | 298 g_snprintf(buf, sizeof(buf), "[1] %s", win->title); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
299 } else if (!g_strncasecmp(buf, "[", 1)) { |
4035 | 300 g_snprintf(buf, sizeof(buf), "[%d] %s", c+1, &win->title[3+length]); |
301 } | |
302 gtk_window_set_title(win, buf); | |
303 } | |
304 | |
305 gboolean count_remove(GtkWidget *widget) { | |
3392 | 306 char buf[256]; |
307 GtkWindow *win = GTK_WINDOW(widget); | |
308 int length; | |
309 | |
310 strncpy(buf, win->title, sizeof(buf)); | |
311 if (!g_strncasecmp(buf, "[", 1)) { | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
312 Number = counter(buf, &length); |
3392 | 313 g_snprintf(buf, sizeof(buf), "%s", &win->title[3+length]); |
314 gtk_window_set_title(win, buf); | |
4035 | 315 return TRUE; |
3392 | 316 } |
4035 | 317 return FALSE; |
3392 | 318 } |
319 | |
4035 | 320 void quote_add(GtkWidget *widget) { |
321 char buf[256]; | |
322 GtkWindow *win = GTK_WINDOW(widget); | |
323 | |
324 strncpy(buf, win->title, sizeof(buf)); | |
325 if (g_strncasecmp(buf, "\"", 1)) { | |
326 g_snprintf(buf, sizeof(buf), "\"%s\"", win->title); | |
327 gtk_window_set_title(win, buf); | |
328 } | |
329 } | |
330 | |
331 gboolean quote_remove(GtkWidget *widget) { | |
3374 | 332 char buf[256]; |
333 GtkWindow *win = GTK_WINDOW(widget); | |
191 | 334 |
3392 | 335 strncpy(buf, win->title, sizeof(buf)); |
3374 | 336 if (!g_strncasecmp(buf, "\"", 1)) { |
337 g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]); | |
191 | 338 gtk_window_set_title(win, buf); |
4035 | 339 return TRUE; |
191 | 340 } |
4035 | 341 return FALSE; |
3374 | 342 } |
343 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
344 void urgent_add(struct gaim_conversation *c) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
345 struct gaim_gtk_window *gtkwin; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
346 XWMHints *hints; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
347 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
348 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
349 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
350 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window)); |
4035 | 351 hints->flags |= XUrgencyHint; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
352 XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); |
4218 | 353 XFree(hints); |
4035 | 354 } |
355 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
356 gboolean urgent_remove(struct gaim_conversation *c) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
357 struct gaim_gtk_conversation *gtkconv; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
358 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
359 gtkconv = GAIM_GTK_CONVERSATION(c); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
360 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
361 if ((gaim_conversation_get_type(c) == GAIM_CONV_CHAT && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
362 (chat_options & OPT_CHAT_ONE_WINDOW)) || |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
363 (gaim_conversation_get_type(c) != GAIM_CONV_CHAT && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
364 (im_options & OPT_IM_ONE_WINDOW))) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
365 if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
366 struct gaim_conversation *c = (struct gaim_conversation *)gaim_get_chats()->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
367 struct gaim_gtk_window *gtkwin; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
368 GdkWindow *win; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
369 XWMHints *hints; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
370 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
371 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
372 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
373 win = gtkwin->window->window; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
374 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
375 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
376 if (hints->flags & XUrgencyHint) { |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
377 hints->flags &= ~XUrgencyHint; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
378 XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); |
4218 | 379 XFree(hints); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
380 return TRUE; |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
381 } |
4218 | 382 XFree(hints); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
383 return FALSE; |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
384 } else { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
385 struct gaim_conversation *c; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
386 struct gaim_gtk_window *gtkwin; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
387 GdkWindow *win; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
388 XWMHints *hints; |
3374 | 389 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
390 c = (struct gaim_conversation *)gaim_get_ims()->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
391 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
392 win = gtkwin->window->window; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
393 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
394 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
395 if (hints->flags & XUrgencyHint) { |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
396 hints->flags &= ~XUrgencyHint; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
397 XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); |
4218 | 398 XFree(hints); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
399 return TRUE; |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
400 } |
4218 | 401 XFree(hints); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
402 return FALSE; |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
403 } |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
404 } else { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
405 struct gaim_gtk_window *gtkwin; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
406 XWMHints *hints; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
407 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
408 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
409 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
410 |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
411 if (hints->flags & XUrgencyHint) { |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
412 hints->flags &= ~XUrgencyHint; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
413 XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); |
4218 | 414 XFree(hints); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
415 return TRUE; |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
416 } |
4218 | 417 XFree(hints); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
418 return FALSE; |
4035 | 419 } |
3374 | 420 } |
421 | |
422 void save_notify_prefs() { | |
3392 | 423 gchar buf[1000]; |
3374 | 424 FILE *fp; |
425 | |
426 snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME")); | |
427 if (!(fp = fopen(buf, "w"))) { | |
3561 | 428 do_error_dialog(_("Unable to write to config file"), _("Notify plugin"), GAIM_ERROR); |
3374 | 429 return; |
430 } | |
431 | |
3710 | 432 fprintf(fp, "%d=TYPE\n", type); |
3392 | 433 fprintf(fp, "%d=CHOICE\n", choice); |
434 fprintf(fp, "%d=METHOD\n", method); | |
435 fprintf(fp, "%s=STRING\n", title_string); | |
3374 | 436 fclose(fp); |
437 } | |
438 | |
439 void load_notify_prefs() { | |
440 gchar buf[1000]; | |
441 gchar **parsed; | |
442 FILE *fp; | |
443 | |
444 g_snprintf(buf, sizeof(buf), "%s/.gaim/.notify", getenv("HOME")); | |
445 if (!(fp = fopen(buf, "r"))) | |
446 return; | |
447 | |
448 while (fgets(buf, 1000, fp) != NULL) { | |
449 parsed = g_strsplit(g_strchomp(buf), "=", 2); | |
450 if (parsed[0] && parsed[1]) { | |
3710 | 451 if (!strcmp(parsed[1], "TYPE")) |
452 type = atoi(parsed[0]); | |
3392 | 453 if (!strcmp(parsed[1], "CHOICE")) |
454 choice = atoi(parsed[0]); | |
455 if (!strcmp(parsed[1], "METHOD")) | |
456 method = atoi(parsed[0]); | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
457 if (!strcmp(parsed[1], "STRING")) { |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
458 if (title_string != NULL) |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
459 g_free(title_string); |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
460 title_string = g_strdup(parsed[0]); |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
461 } |
3374 | 462 } |
3392 | 463 g_strfreev(parsed); |
3374 | 464 } |
465 fclose(fp); | |
466 return; | |
467 } | |
468 | |
469 void options(GtkWidget *widget, gpointer data) { | |
4035 | 470 gint option = GPOINTER_TO_INT(data); |
3374 | 471 |
472 if (option == 0) | |
3392 | 473 choice ^= NOTIFY_FOCUS; |
3374 | 474 else if (option == 1) |
3710 | 475 choice ^= NOTIFY_CLICK; |
476 else if (option == 2) | |
3392 | 477 choice ^= NOTIFY_TYPE; |
3710 | 478 else if (option == 3) { |
3374 | 479 method ^= METHOD_STRING; |
480 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) | |
481 gtk_widget_set_sensitive(Entry, TRUE); | |
482 else | |
483 gtk_widget_set_sensitive(Entry, FALSE); | |
484 } | |
3710 | 485 else if (option == 4) |
3374 | 486 method ^= METHOD_QUOTE; |
3710 | 487 else if (option == 5) |
3374 | 488 method ^= METHOD_URGENT; |
3710 | 489 else if (option == 6) |
3392 | 490 choice ^= NOTIFY_IN_FOCUS; |
3710 | 491 else if (option == 7) |
3392 | 492 method ^= METHOD_COUNT; |
3710 | 493 else if (option == 8) |
494 type ^= TYPE_IM; | |
495 else if (option == 9) | |
496 type ^= TYPE_CHAT; | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
497 else if (option == 10) { |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
498 /* 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
|
499 * 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
|
500 * 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
|
501 if (title_string != NULL) { |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
502 g_free(title_string); |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
503 title_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(Entry))); |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
504 } |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
505 } |
3710 | 506 |
507 save_notify_prefs(); | |
3374 | 508 } |
509 | |
4035 | 510 void apply_options(GtkWidget *widget, gpointer data) { |
511 GList *cnv = conversations; | |
512 | |
513 while (cnv) { | |
514 guint notification; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
515 struct gaim_conversation *c = (struct gaim_conversation *) cnv->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
516 struct gaim_gtk_conversation *gtkconv; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
517 struct gaim_gtk_window *gtkwin; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
518 guint options = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(c->window), "notify_data")); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
519 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
520 gtkconv = GAIM_GTK_CONVERSATION(c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
521 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
522 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
523 if (options & NOTIFY_FOCUS) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
524 g_signal_handlers_disconnect_by_func(G_OBJECT(gtkwin->window), un_star, NULL); |
4035 | 525 |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
526 /* remove old notification signals */ |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
527 detach_signals(c); |
4035 | 528 |
529 /* clean off all notification markings */ | |
530 notification = unnotify(c, TRUE); | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
531 |
4035 | 532 /* re-add appropriate notification methods cleaned above */ |
4043 | 533 if (notification & METHOD_STRING) /* re-add string */ |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
534 string_add(gtkwin->window); |
4035 | 535 if (notification & METHOD_QUOTE) /* re-add quote */ |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
536 quote_add(gtkwin->window); |
4035 | 537 if (notification & METHOD_COUNT) /* re-add count */ |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
538 count_add(gtkwin->window, Number); |
4035 | 539 if (notification & METHOD_URGENT) /* re-add urgent */ |
540 urgent_add(c); | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
541 |
4035 | 542 /* attach new unnotification signals */ |
543 attach_signals(c); | |
544 | |
545 cnv = cnv->next; | |
546 } | |
547 } | |
548 | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
549 char *gaim_plugin_init(GModule *hndl) { |
191 | 550 handle = hndl; |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
551 title_string = g_strdup("(*) "); |
191 | 552 |
3374 | 553 load_notify_prefs(); |
554 | |
3710 | 555 gaim_signal_connect(handle, event_im_recv, im_recv_im, NULL); |
556 gaim_signal_connect(handle, event_chat_recv, chat_recv_im, NULL); | |
557 gaim_signal_connect(handle, event_im_send, im_sent_im, NULL); | |
558 gaim_signal_connect(handle, event_chat_send, chat_sent_im, NULL); | |
3374 | 559 gaim_signal_connect(handle, event_new_conversation, new_conv, NULL); |
3710 | 560 gaim_signal_connect(handle, event_chat_join, chat_join, NULL); |
1052
25f121faa75e
[gaim-migrate @ 1062]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
561 return NULL; |
191 | 562 } |
563 | |
3392 | 564 void gaim_plugin_remove() { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
565 GList *c = gaim_get_ims(); |
3392 | 566 |
567 while (c) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
568 struct gaim_conversation *cnv = (struct gaim_conversation *)c->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
569 struct gaim_gtk_window *gtkwin; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
570 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
571 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(cnv)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
572 |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
573 detach_signals(cnv); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
574 un_star(gtkwin->window, NULL); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
575 |
3710 | 576 c = c->next; |
3392 | 577 } |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
578 |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
579 /* 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
|
580 g_free(title_string); |
3392 | 581 } |
582 | |
3551 | 583 struct gaim_plugin_description desc; |
584 struct gaim_plugin_description *gaim_plugin_desc() { | |
585 desc.api_version = PLUGIN_API_VERSION; | |
586 desc.name = g_strdup("Message Notification"); | |
587 desc.version = g_strdup(VERSION); | |
588 desc.description = g_strdup("Provides a variety of ways of notifying you of unread messages."); | |
589 desc.authors = g_strdup("Etan Reisner <deryni@eden.rutgers.edu>"); | |
590 desc.url = g_strdup(WEBSITE); | |
591 return &desc; | |
592 } | |
593 | |
191 | 594 char *name() { |
595 return "Visual Notification"; | |
596 } | |
597 | |
598 char *description() { | |
599 return "Puts an asterisk in the title bar of all conversations" | |
600 " where you have not responded to a message yet."; | |
601 } | |
3374 | 602 |
3565 | 603 GtkWidget *gaim_plugin_config_gtk() { |
604 GtkWidget *ret; | |
605 GtkWidget *vbox, *hbox; | |
4035 | 606 GtkWidget *toggle, *button; |
3565 | 607 ret = gtk_vbox_new(FALSE, 18); |
608 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | |
3392 | 609 |
3710 | 610 vbox = make_frame(ret, _("Notify For")); |
611 toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); | |
612 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
613 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
|
614 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(8)); |
3710 | 615 |
616 toggle = gtk_check_button_new_with_mnemonic(_("_Chat windows")); | |
617 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
618 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
|
619 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(9)); |
3710 | 620 |
621 /*--------------*/ | |
3565 | 622 vbox = make_frame(ret, _("Notification Methods")); |
623 hbox = gtk_hbox_new(FALSE, 18); | |
624 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
|
625 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title (hit enter to save):")); |
3565 | 626 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_STRING); |
4035 | 627 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(3)); |
3565 | 628 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
|
629 Entry = gtk_entry_new(); |
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
630 gtk_entry_set_max_length(GTK_ENTRY(Entry), 10); |
3565 | 631 gtk_widget_set_sensitive(GTK_WIDGET(Entry), method & METHOD_STRING); |
632 gtk_box_pack_start(GTK_BOX(hbox), Entry, FALSE, FALSE, 0); | |
3392 | 633 gtk_entry_set_text(GTK_ENTRY(Entry), title_string); |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
634 g_signal_connect(G_OBJECT(Entry), "activate", G_CALLBACK(options), GINT_TO_POINTER(10)); |
3374 | 635 |
3710 | 636 toggle = gtk_check_button_new_with_mnemonic(_("_Quote window title")); |
3565 | 637 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
638 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_QUOTE); | |
4035 | 639 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(4)); |
3374 | 640 |
3565 | 641 toggle = gtk_check_button_new_with_mnemonic(_("Set Window Manager \"_URGENT\" Hint")); |
642 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
643 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_URGENT); | |
4035 | 644 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(5)); |
645 | |
3710 | 646 toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); |
3565 | 647 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_COUNT); |
648 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
4035 | 649 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(7)); |
3710 | 650 |
651 toggle = gtk_check_button_new_with_mnemonic(_("_Notify even if conversation is in focus")); | |
652 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_IN_FOCUS); | |
653 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
4035 | 654 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(6)); |
3392 | 655 |
3565 | 656 /*--------------*/ |
657 vbox = make_frame(ret, _("Notification Removal")); | |
3710 | 658 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window gains _focus")); |
3565 | 659 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
660 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_FOCUS); | |
4035 | 661 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(0)); |
3374 | 662 |
3710 | 663 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); |
664 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
665 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_CLICK); | |
4035 | 666 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(1)); |
3710 | 667 |
3565 | 668 toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); |
669 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
670 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_TYPE); | |
4035 | 671 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(2)); |
672 | |
673 button = gtk_button_new_with_mnemonic(_("Appl_y")); | |
674 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 5); | |
675 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(apply_options), NULL); | |
3565 | 676 |
677 gtk_widget_show_all(ret); | |
678 return ret; | |
3374 | 679 } |