Fri, 25 Apr 2003 06:47:33 +0000
[gaim-migrate @ 5573]
I had a damn good commit message, but it was eaten. Let's try it again.
Announcing, Gaim Plugin API version 2.0, or GPAPIV2.0 for short.
There are lots'a cool thingies here.
Okay now, this isn't as cool as the previous message, but:
1) There's now a single entry function for all plugin types. It returns a
detailed information structure on the plugin. This removes a lot of the
ugliness from old plugins. Oh yeah, libicq wasn't converted to this, so
if you use it, well, you shouldn't have used it anyway, but now you
can't! bwahahaha. Use AIM/ICQ.
2) There are now 3 types of plugins: Standard, Loader, and Protocol
plugins.
Standard plugins are, well, standard, compiled plugins.
Loader plugins load other plugins. For example, the perl support is now
a loader plugin. It loads perl scripts. In the future, we'll have
Ruby and Python loader plugins.
Protocol plugins are, well, protocol plugins... yeah...
3) Plugins have unique IDs, so they can be referred to or automatically
updated from a plugin database in the future. Neat, huh?
4) Plugins will have dependency support in the future, and can be hidden,
so if you have, say, a logging core plugin, it won't have to show up,
but then you load the GTK+ logging plugin and it'll auto-load the core
plugin. Core/UI split plugins!
5) There will eventually be custom plugin signals and RPC of some sort, for
the core/ui split plugins.
So, okay, back up .gaimrc.
I'd like to thank my parents for their support, javabsp for helping convert
a bunch of protocol plugins, and Etan for helping convert a bunch of
standard plugins.
Have fun. If you have any problems, please let me know, but you probably
won't have anything major happen. You will have to convert your plugins,
though, and I'm not guaranteeing that all perl scripts will still work.
I'll end up changing the perl script API eventually, so I know they won't
down the road. Don't worry, though. It'll be mass cool.
faceprint wants me to just commit the damn code already. So, here we go!!!
..
..
I need a massage. From a young, cute girl. Are there any young, cute girls
in the audience? IM me plz k thx.
| 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 | 13 | * Fixed apply to conversations, count now keeps count across applies |
| 14 | * Fixed(?) memory leak, and in the process fixed some stupidities | |
| 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
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
21 | #include "config.h" |
|
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
22 | |
| 191 | 23 | #include "gaim.h" |
| 3428 | 24 | #include <string.h> |
| 25 | #include <ctype.h> | |
| 26 | #include <stdlib.h> | |
| 191 | 27 | #include <gtk/gtk.h> |
| 3385 | 28 | #include <X11/Xlib.h> |
| 3374 | 29 | #include <X11/Xutil.h> |
| 3392 | 30 | #include <X11/Xatom.h> |
| 3374 | 31 | #include <gdk/gdkx.h> |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
32 | #include "gtkplugin.h" |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
33 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
34 | #define NOTIFY_PLUGIN_ID "gtk-notify" |
| 3374 | 35 | |
| 3710 | 36 | guint type = 1; |
| 5021 | 37 | #define TYPE_IM 0x00000001 |
| 38 | #define TYPE_CHAT 0x00000002 | |
| 3710 | 39 | |
| 3392 | 40 | guint choice = 1; |
| 41 | #define NOTIFY_FOCUS 0x00000001 | |
| 42 | #define NOTIFY_TYPE 0x00000002 | |
| 5021 | 43 | #define NOTIFY_IN_FOCUS 0x00000004 |
| 44 | #define NOTIFY_CLICK 0x00000008 | |
| 3374 | 45 | |
| 3392 | 46 | guint method = 1; |
| 47 | #define METHOD_STRING 0x00000001 | |
| 48 | #define METHOD_QUOTE 0x00000002 | |
| 49 | #define METHOD_URGENT 0x00000004 | |
| 50 | #define METHOD_COUNT 0x00000008 | |
| 191 | 51 | |
| 52 | void *handle; | |
| 3565 | 53 | GtkWidget *Entry; |
| 4203 | 54 | gchar *title_string; |
| 55 | int Number = 0; | |
| 191 | 56 | |
| 3374 | 57 | /* predefine some functions, less warnings */ |
| 58 | void options(GtkWidget *widget, gpointer data); | |
| 4047 | 59 | /* this returns an int so that typing events don't get stopped here */ |
| 4203 | 60 | int un_star(GtkWidget *widget, gpointer data); |
| 3428 | 61 | int counter (char *buf, int *length); |
| 4035 | 62 | /*string functions */ |
| 63 | void string_add(GtkWidget *widget); | |
| 64 | gboolean string_remove(GtkWidget *widget); | |
| 65 | /* count functions */ | |
| 4203 | 66 | void count_add(GtkWidget *widget, int number); |
| 4035 | 67 | gboolean count_remove(GtkWidget *widget); |
| 68 | /* quote functions */ | |
| 69 | void quote_add(GtkWidget *widget); | |
| 70 | gboolean quote_remove(GtkWidget *widget); | |
| 71 | /* urgent functions */ | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
72 | void urgent_add(struct gaim_conversation *c); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
73 | gboolean urgent_remove(struct gaim_conversation *c); |
| 3710 | 74 | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
75 | int notify(struct gaim_conversation *cnv) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
76 | struct gaim_gtk_window *gtkwin; |
| 3710 | 77 | Window focus_return; |
| 4035 | 78 | int revert_to_return; |
| 191 | 79 | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
80 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(cnv)); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
81 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
82 | XGetInputFocus(GDK_WINDOW_XDISPLAY(gtkwin->window->window), &focus_return, &revert_to_return); |
| 3374 | 83 | |
| 4203 | 84 | if ((choice & NOTIFY_IN_FOCUS) || |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
85 | focus_return != GDK_WINDOW_XWINDOW(gtkwin->window->window)) { |
| 4035 | 86 | if (method & METHOD_STRING) |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
87 | string_add(gtkwin->window); |
| 4035 | 88 | if (method & METHOD_COUNT) |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
89 | count_add(gtkwin->window, 0); |
| 4035 | 90 | if (method & METHOD_QUOTE) |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
91 | quote_add(gtkwin->window); |
| 4035 | 92 | if (method & METHOD_URGENT) |
| 93 | urgent_add(cnv); | |
| 3374 | 94 | } |
| 95 | return 0; | |
| 96 | } | |
| 97 | ||
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
98 | guint unnotify(struct gaim_conversation *c, gboolean clean) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
99 | struct gaim_gtk_window *gtkwin; |
| 4035 | 100 | guint option = 0; |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
101 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
102 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
| 5021 | 103 | |
| 4043 | 104 | /* The top level ifs check whether we are either cleaning all methods, |
| 105 | * or whether we have that method is currently selected. | |
| 106 | * If we do then they are cleaned | |
| 107 | * | |
| 108 | * The second level ifs check if we removed something, | |
| 109 | * and if that method is currently selected. | |
| 110 | * If we did and it is then set option so that it can be re-added */ | |
| 4035 | 111 | if (clean || (method & METHOD_QUOTE)) |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
112 | if (quote_remove(gtkwin->window) && (method & METHOD_QUOTE)) |
| 4035 | 113 | option ^= METHOD_QUOTE; |
| 5021 | 114 | |
| 4035 | 115 | if (clean || (method & METHOD_COUNT)) |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
116 | if (count_remove(gtkwin->window) && (method & METHOD_COUNT)) |
| 4035 | 117 | option ^= METHOD_COUNT; |
| 4203 | 118 | |
| 4035 | 119 | if (clean || (method & METHOD_STRING)) |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
120 | if (string_remove(gtkwin->window) && (method & METHOD_STRING)) |
| 4035 | 121 | option ^= METHOD_STRING; |
| 4203 | 122 | |
| 4035 | 123 | if (clean || (method & METHOD_URGENT)) |
| 4043 | 124 | if (urgent_remove(c) && (method & METHOD_URGENT)) |
| 4035 | 125 | option ^= METHOD_URGENT; |
| 4203 | 126 | |
| 4035 | 127 | return option; |
| 3374 | 128 | } |
| 129 | ||
| 3710 | 130 | void chat_recv_im(struct gaim_connection *gc, int id, char **who, char **text) { |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
131 | struct gaim_conversation *c = gaim_find_chat(gc, id); |
| 3710 | 132 | |
| 133 | if (c && (type & TYPE_CHAT)) | |
| 134 | notify(c); | |
| 135 | return; | |
| 136 | } | |
| 137 | ||
| 138 | void chat_sent_im(struct gaim_connection *gc, int id, char **text) { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
139 | struct gaim_conversation *c = gaim_find_chat(gc, id); |
| 3710 | 140 | |
| 141 | if (c && (type & TYPE_CHAT)) | |
| 4035 | 142 | unnotify(c, FALSE); |
| 3710 | 143 | return; |
| 144 | } | |
| 145 | ||
| 146 | int im_recv_im(struct gaim_connection *gc, char **who, char **what, void *m) { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
147 | struct gaim_conversation *c = gaim_find_conversation(*who); |
| 3710 | 148 | |
| 149 | if (c && (type & TYPE_IM)) | |
| 150 | notify(c); | |
| 151 | return 0; | |
| 152 | } | |
| 153 | ||
| 154 | int im_sent_im(struct gaim_connection *gc, char *who, char **what, void *m) { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
155 | struct gaim_conversation *c = gaim_find_conversation(who); |
| 3374 | 156 | |
| 3710 | 157 | if (c && (type & TYPE_IM)) |
| 4035 | 158 | unnotify(c, FALSE); |
| 3710 | 159 | return 0; |
| 160 | } | |
| 3392 | 161 | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
162 | int attach_signals(struct gaim_conversation *c) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
163 | struct gaim_gtk_conversation *gtkconv; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
164 | struct gaim_gtk_window *gtkwin; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
165 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
166 | gtkconv = GAIM_GTK_CONVERSATION(c); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
167 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
168 | |
| 3392 | 169 | if (choice & NOTIFY_FOCUS) { |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
170 | g_signal_connect(G_OBJECT(gtkwin->window), "focus-in-event", G_CALLBACK(un_star), NULL); |
| 3374 | 171 | } |
| 3710 | 172 | |
| 173 | if (choice & NOTIFY_CLICK) { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
174 | g_signal_connect(G_OBJECT(gtkwin->window), "button_press_event", G_CALLBACK(un_star), NULL); |
| 4035 | 175 | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
176 | g_signal_connect_swapped(G_OBJECT(gtkconv->imhtml), "button_press_event", G_CALLBACK(un_star), G_OBJECT(gtkwin->window)); |
| 4035 | 177 | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
178 | g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "button_press_event", G_CALLBACK(un_star), G_OBJECT(gtkwin->window)); |
| 3374 | 179 | } |
| 180 | ||
| 3392 | 181 | if (choice & NOTIFY_TYPE) { |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
182 | g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key-press-event", G_CALLBACK(un_star), G_OBJECT(gtkwin->window)); |
| 191 | 183 | } |
| 4035 | 184 | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
185 | g_object_set_data(G_OBJECT(gtkwin->window), "user_data", c); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
186 | g_object_set_data(G_OBJECT(gtkwin->window), "notify_data", GUINT_TO_POINTER(choice)); |
| 3428 | 187 | return 0; |
| 191 | 188 | } |
| 189 | ||
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
190 | void detach_signals(struct gaim_conversation *c) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
191 | struct gaim_gtk_conversation *gtkconv; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
192 | struct gaim_gtk_window *gtkwin; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
193 | guint options; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
194 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
195 | gtkconv = GAIM_GTK_CONVERSATION(c); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
196 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
197 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
198 | options = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(gtkwin->window), "notify_data")); |
| 4203 | 199 | |
| 200 | if (options & NOTIFY_FOCUS) { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
201 | g_signal_handlers_disconnect_by_func(G_OBJECT(gtkwin->window), un_star, NULL); |
| 4203 | 202 | } |
| 203 | if (options & NOTIFY_CLICK) { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
204 | g_signal_handlers_disconnect_by_func(G_OBJECT(gtkwin->window), un_star, NULL); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
205 | g_signal_handlers_disconnect_by_func(G_OBJECT(gtkconv->imhtml), un_star, gtkwin->window); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
206 | g_signal_handlers_disconnect_by_func(G_OBJECT(gtkconv->entry), un_star, gtkwin->window); |
| 4203 | 207 | } |
| 208 | ||
| 209 | if (options & NOTIFY_TYPE) { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
210 | g_signal_handlers_disconnect_by_func(G_OBJECT(gtkconv->entry), un_star, gtkwin->window); |
| 4203 | 211 | } |
| 212 | } | |
| 213 | ||
| 3710 | 214 | void new_conv(char *who) { |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
215 | struct gaim_conversation *c = gaim_find_conversation(who); |
| 3710 | 216 | |
| 4035 | 217 | if (c && (type & TYPE_IM)) |
| 3710 | 218 | attach_signals(c); |
| 219 | } | |
| 220 | ||
| 221 | void chat_join(struct gaim_connection *gc, int id, char *room) { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
222 | struct gaim_conversation *c = gaim_find_chat(gc, id); |
| 3710 | 223 | |
| 4043 | 224 | if (c && (type & TYPE_CHAT)) |
| 3710 | 225 | attach_signals(c); |
| 226 | } | |
| 227 | ||
| 4203 | 228 | int un_star(GtkWidget *widget, gpointer data) { |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
229 | struct gaim_conversation *c = g_object_get_data(G_OBJECT(widget), "user_data"); |
| 3374 | 230 | |
| 231 | if (method & METHOD_QUOTE) | |
| 232 | quote_remove(widget); | |
| 3392 | 233 | if (method & METHOD_COUNT) |
| 234 | count_remove(widget); | |
| 3374 | 235 | if (method & METHOD_STRING) |
| 236 | string_remove(widget); | |
| 4043 | 237 | if (c && method & METHOD_URGENT) |
| 3374 | 238 | urgent_remove(c); |
| 4047 | 239 | return 0; |
| 3374 | 240 | } |
| 241 | ||
| 5021 | 242 | /* This function returns the number in [ ]'s or 0 |
| 243 | and sets *length to the number of digits in that number */ | |
| 3392 | 244 | int counter (char *buf, int *length) { |
| 245 | char temp[256]; | |
| 5021 | 246 | int i = 0; |
| 247 | int j = 0; | |
| 3392 | 248 | *length = 0; |
| 249 | ||
| 5021 | 250 | /* Don't assume buf[0]=='[' */ |
| 251 | while( buf[i++] != '[' && i<sizeof(buf)); | |
| 252 | ||
| 3392 | 253 | while (isdigit(buf[i]) && i<sizeof(buf)) { |
| 5021 | 254 | temp[j++] = buf[i++]; |
| 3392 | 255 | (*length)++; |
| 256 | } | |
| 5021 | 257 | temp[j] = '\0'; |
| 4035 | 258 | |
| 3392 | 259 | if (buf[i] != ']') { |
| 260 | *length = 0; | |
| 261 | return (0); | |
| 262 | } | |
| 263 | ||
| 264 | return (atoi(temp)); | |
| 265 | } | |
| 266 | ||
| 4035 | 267 | void string_add(GtkWidget *widget) { |
| 268 | char buf[256]; | |
| 269 | GtkWindow *win = GTK_WINDOW(widget); | |
| 270 | ||
| 271 | strncpy(buf, win->title, sizeof(buf)); | |
| 272 | if (!strstr(buf, title_string)) { | |
| 273 | g_snprintf(buf, sizeof(buf), "%s%s", title_string, win->title); | |
| 274 | gtk_window_set_title(win, buf); | |
| 275 | } | |
| 276 | } | |
| 277 | ||
| 278 | gboolean string_remove(GtkWidget *widget) { | |
| 191 | 279 | char buf[256]; |
| 3374 | 280 | GtkWindow *win = GTK_WINDOW(widget); |
| 281 | ||
| 3392 | 282 | strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 283 | if (strstr(buf, title_string)) { |
| 284 | g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]); | |
| 285 | gtk_window_set_title(win, buf); | |
| 4035 | 286 | return TRUE; |
| 3374 | 287 | } |
| 4035 | 288 | return FALSE; |
| 3374 | 289 | } |
| 290 | ||
| 4203 | 291 | void count_add(GtkWidget *widget, int number) { |
| 4035 | 292 | char buf[256]; |
| 293 | int c, length; | |
| 294 | GtkWindow *win = GTK_WINDOW(widget); | |
| 295 | ||
| 296 | strncpy(buf, win->title, sizeof(buf)); | |
| 297 | c = counter(buf, &length); | |
| 5021 | 298 | |
| 4203 | 299 | if (number) { |
| 5021 | 300 | /* This might cause problems in the future. |
| 301 | I'm pretty sure if count_add is called after quote_add | |
| 302 | and number!=0, then this will have problems dealing with | |
| 303 | the quotation marks. */ | |
| 4203 | 304 | g_snprintf(buf, sizeof(buf), "[%d] %s", number, win->title); |
| 305 | } else if (!c) { | |
| 4035 | 306 | g_snprintf(buf, sizeof(buf), "[1] %s", win->title); |
| 5021 | 307 | } else if (buf[0] == '[' || buf[1] == '[' ) { |
| 308 | /* This has to be so complicated in order to account for METHOD_QUOTE */ | |
| 309 | g_snprintf(buf, sizeof(buf), "[%d] %s", c+1, &win->title[ ((method & METHOD_QUOTE) ? 4 : 3)+length ]); | |
| 310 | if( buf[ strlen(buf)-1 ] == '"' ) | |
| 311 | buf[ strlen(buf)-1 ] = '\0'; | |
| 4035 | 312 | } |
| 313 | gtk_window_set_title(win, buf); | |
| 314 | } | |
| 315 | ||
| 316 | gboolean count_remove(GtkWidget *widget) { | |
| 3392 | 317 | char buf[256]; |
| 318 | GtkWindow *win = GTK_WINDOW(widget); | |
| 319 | int length; | |
| 320 | ||
| 321 | strncpy(buf, win->title, sizeof(buf)); | |
| 4793 | 322 | if (buf[0] == '[') { |
| 4203 | 323 | Number = counter(buf, &length); |
| 3392 | 324 | g_snprintf(buf, sizeof(buf), "%s", &win->title[3+length]); |
| 325 | gtk_window_set_title(win, buf); | |
| 4035 | 326 | return TRUE; |
| 3392 | 327 | } |
| 4035 | 328 | return FALSE; |
| 3392 | 329 | } |
| 330 | ||
| 4035 | 331 | void quote_add(GtkWidget *widget) { |
| 332 | char buf[256]; | |
| 333 | GtkWindow *win = GTK_WINDOW(widget); | |
| 334 | ||
| 335 | strncpy(buf, win->title, sizeof(buf)); | |
| 4793 | 336 | if (buf[0] != '\"') { |
| 4035 | 337 | g_snprintf(buf, sizeof(buf), "\"%s\"", win->title); |
| 338 | gtk_window_set_title(win, buf); | |
| 339 | } | |
| 340 | } | |
| 341 | ||
| 342 | gboolean quote_remove(GtkWidget *widget) { | |
| 3374 | 343 | char buf[256]; |
| 344 | GtkWindow *win = GTK_WINDOW(widget); | |
| 191 | 345 | |
| 3392 | 346 | strncpy(buf, win->title, sizeof(buf)); |
| 4793 | 347 | if (buf[0] == '\"') { |
| 3374 | 348 | g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]); |
| 191 | 349 | gtk_window_set_title(win, buf); |
| 4035 | 350 | return TRUE; |
| 191 | 351 | } |
| 4035 | 352 | return FALSE; |
| 3374 | 353 | } |
| 354 | ||
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
355 | void urgent_add(struct gaim_conversation *c) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
356 | struct gaim_gtk_window *gtkwin; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
357 | XWMHints *hints; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
358 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
359 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
360 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
361 | hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window)); |
| 4035 | 362 | hints->flags |= XUrgencyHint; |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
363 | XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); |
| 4218 | 364 | XFree(hints); |
| 4035 | 365 | } |
| 366 | ||
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
367 | gboolean urgent_remove(struct gaim_conversation *c) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
368 | struct gaim_gtk_conversation *gtkconv; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
369 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
370 | gtkconv = GAIM_GTK_CONVERSATION(c); |
| 4203 | 371 | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
372 | if ((gaim_conversation_get_type(c) == GAIM_CONV_CHAT && |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
373 | (chat_options & OPT_CHAT_ONE_WINDOW)) || |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
374 | (gaim_conversation_get_type(c) != GAIM_CONV_CHAT && |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
375 | (im_options & OPT_IM_ONE_WINDOW))) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
376 | if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
377 | struct gaim_conversation *c = (struct gaim_conversation *)gaim_get_chats()->data; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
378 | struct gaim_gtk_window *gtkwin; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
379 | GdkWindow *win; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
380 | XWMHints *hints; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
381 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
382 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
383 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
384 | win = gtkwin->window->window; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
385 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
386 | hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); |
| 4203 | 387 | if (hints->flags & XUrgencyHint) { |
| 388 | hints->flags &= ~XUrgencyHint; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
389 | XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); |
| 4218 | 390 | XFree(hints); |
| 4203 | 391 | return TRUE; |
| 392 | } | |
| 4218 | 393 | XFree(hints); |
| 4203 | 394 | return FALSE; |
| 395 | } else { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
396 | struct gaim_conversation *c; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
397 | struct gaim_gtk_window *gtkwin; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
398 | GdkWindow *win; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
399 | XWMHints *hints; |
| 3374 | 400 | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
401 | c = (struct gaim_conversation *)gaim_get_ims()->data; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
402 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
403 | win = gtkwin->window->window; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
404 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
405 | hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); |
| 4203 | 406 | if (hints->flags & XUrgencyHint) { |
| 407 | hints->flags &= ~XUrgencyHint; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
408 | XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); |
| 4218 | 409 | XFree(hints); |
| 4203 | 410 | return TRUE; |
| 411 | } | |
| 4218 | 412 | XFree(hints); |
| 4203 | 413 | return FALSE; |
| 414 | } | |
| 415 | } else { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
416 | struct gaim_gtk_window *gtkwin; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
417 | XWMHints *hints; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
418 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
419 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
420 | hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window)); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
421 | |
| 4203 | 422 | if (hints->flags & XUrgencyHint) { |
| 423 | hints->flags &= ~XUrgencyHint; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
424 | XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); |
| 4218 | 425 | XFree(hints); |
| 4203 | 426 | return TRUE; |
| 427 | } | |
| 4218 | 428 | XFree(hints); |
| 4203 | 429 | return FALSE; |
| 4035 | 430 | } |
| 3374 | 431 | } |
| 432 | ||
| 433 | void save_notify_prefs() { | |
| 3392 | 434 | gchar buf[1000]; |
| 3374 | 435 | FILE *fp; |
| 436 | ||
| 437 | snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME")); | |
| 438 | if (!(fp = fopen(buf, "w"))) { | |
| 3561 | 439 | do_error_dialog(_("Unable to write to config file"), _("Notify plugin"), GAIM_ERROR); |
| 3374 | 440 | return; |
| 441 | } | |
| 442 | ||
| 3710 | 443 | fprintf(fp, "%d=TYPE\n", type); |
| 3392 | 444 | fprintf(fp, "%d=CHOICE\n", choice); |
| 445 | fprintf(fp, "%d=METHOD\n", method); | |
| 446 | fprintf(fp, "%s=STRING\n", title_string); | |
| 3374 | 447 | fclose(fp); |
| 448 | } | |
| 449 | ||
| 450 | void load_notify_prefs() { | |
| 451 | gchar buf[1000]; | |
| 452 | gchar **parsed; | |
| 453 | FILE *fp; | |
| 454 | ||
| 455 | g_snprintf(buf, sizeof(buf), "%s/.gaim/.notify", getenv("HOME")); | |
| 456 | if (!(fp = fopen(buf, "r"))) | |
| 457 | return; | |
| 458 | ||
| 459 | while (fgets(buf, 1000, fp) != NULL) { | |
| 460 | parsed = g_strsplit(g_strchomp(buf), "=", 2); | |
| 461 | if (parsed[0] && parsed[1]) { | |
| 3710 | 462 | if (!strcmp(parsed[1], "TYPE")) |
| 463 | type = atoi(parsed[0]); | |
| 3392 | 464 | if (!strcmp(parsed[1], "CHOICE")) |
| 465 | choice = atoi(parsed[0]); | |
| 466 | if (!strcmp(parsed[1], "METHOD")) | |
| 467 | method = atoi(parsed[0]); | |
| 4203 | 468 | if (!strcmp(parsed[1], "STRING")) { |
| 469 | if (title_string != NULL) | |
| 470 | g_free(title_string); | |
| 471 | title_string = g_strdup(parsed[0]); | |
| 472 | } | |
| 3374 | 473 | } |
| 3392 | 474 | g_strfreev(parsed); |
| 3374 | 475 | } |
| 476 | fclose(fp); | |
| 477 | return; | |
| 478 | } | |
| 479 | ||
| 480 | void options(GtkWidget *widget, gpointer data) { | |
| 4035 | 481 | gint option = GPOINTER_TO_INT(data); |
| 3374 | 482 | |
| 483 | if (option == 0) | |
| 3392 | 484 | choice ^= NOTIFY_FOCUS; |
| 3374 | 485 | else if (option == 1) |
| 3710 | 486 | choice ^= NOTIFY_CLICK; |
| 487 | else if (option == 2) | |
| 3392 | 488 | choice ^= NOTIFY_TYPE; |
| 3710 | 489 | else if (option == 3) { |
| 3374 | 490 | method ^= METHOD_STRING; |
| 491 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) | |
| 492 | gtk_widget_set_sensitive(Entry, TRUE); | |
| 493 | else | |
| 494 | gtk_widget_set_sensitive(Entry, FALSE); | |
| 495 | } | |
| 3710 | 496 | else if (option == 4) |
| 3374 | 497 | method ^= METHOD_QUOTE; |
| 3710 | 498 | else if (option == 5) |
| 3374 | 499 | method ^= METHOD_URGENT; |
| 3710 | 500 | else if (option == 6) |
| 3392 | 501 | choice ^= NOTIFY_IN_FOCUS; |
| 3710 | 502 | else if (option == 7) |
| 3392 | 503 | method ^= METHOD_COUNT; |
| 3710 | 504 | else if (option == 8) |
| 505 | type ^= TYPE_IM; | |
| 506 | else if (option == 9) | |
| 507 | type ^= TYPE_CHAT; | |
| 4203 | 508 | else if (option == 10) { |
| 509 | /* I made an option for this as at least a way to have it save correctly | |
| 510 | * I'd much rather there were better ways, and I don't want to save this | |
| 511 | * no matter which pref is changed, that's too much of a hack */ | |
| 512 | if (title_string != NULL) { | |
| 513 | g_free(title_string); | |
| 514 | title_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(Entry))); | |
| 515 | } | |
| 516 | } | |
| 3710 | 517 | |
| 518 | save_notify_prefs(); | |
| 3374 | 519 | } |
| 520 | ||
| 4035 | 521 | void apply_options(GtkWidget *widget, gpointer data) { |
|
4376
88f8faf7cb61
[gaim-migrate @ 4642]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
522 | GList *cnv = gaim_get_conversations(); |
| 4035 | 523 | |
| 524 | while (cnv) { | |
| 525 | guint notification; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
526 | struct gaim_conversation *c = (struct gaim_conversation *) cnv->data; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
527 | struct gaim_gtk_conversation *gtkconv; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
528 | struct gaim_gtk_window *gtkwin; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
529 | guint options = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(c->window), "notify_data")); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
530 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
531 | gtkconv = GAIM_GTK_CONVERSATION(c); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
532 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
533 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
534 | if (options & NOTIFY_FOCUS) |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
535 | g_signal_handlers_disconnect_by_func(G_OBJECT(gtkwin->window), un_star, NULL); |
| 4035 | 536 | |
| 4203 | 537 | /* remove old notification signals */ |
| 538 | detach_signals(c); | |
| 4035 | 539 | |
| 540 | /* clean off all notification markings */ | |
| 541 | notification = unnotify(c, TRUE); | |
| 4203 | 542 | |
| 4035 | 543 | /* re-add appropriate notification methods cleaned above */ |
| 4043 | 544 | if (notification & METHOD_STRING) /* re-add string */ |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
545 | string_add(gtkwin->window); |
| 4035 | 546 | if (notification & METHOD_QUOTE) /* re-add quote */ |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
547 | quote_add(gtkwin->window); |
| 4035 | 548 | if (notification & METHOD_COUNT) /* re-add count */ |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
549 | count_add(gtkwin->window, Number); |
| 4035 | 550 | if (notification & METHOD_URGENT) /* re-add urgent */ |
| 551 | urgent_add(c); | |
| 4203 | 552 | |
| 4035 | 553 | /* attach new unnotification signals */ |
| 554 | attach_signals(c); | |
| 555 | ||
| 556 | cnv = cnv->next; | |
| 557 | } | |
| 558 | } | |
| 559 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
560 | static GtkWidget * |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
561 | get_config_frame(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
562 | { |
| 3565 | 563 | GtkWidget *ret; |
| 564 | GtkWidget *vbox, *hbox; | |
| 4035 | 565 | GtkWidget *toggle, *button; |
| 3565 | 566 | ret = gtk_vbox_new(FALSE, 18); |
| 567 | gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | |
| 3392 | 568 | |
| 3710 | 569 | vbox = make_frame(ret, _("Notify For")); |
| 570 | toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); | |
| 571 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 572 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), type & TYPE_IM); | |
| 4203 | 573 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(8)); |
| 3710 | 574 | |
| 575 | toggle = gtk_check_button_new_with_mnemonic(_("_Chat windows")); | |
| 576 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 577 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), type & TYPE_CHAT); | |
| 4203 | 578 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(9)); |
| 3710 | 579 | |
| 580 | /*--------------*/ | |
| 3565 | 581 | vbox = make_frame(ret, _("Notification Methods")); |
| 582 | hbox = gtk_hbox_new(FALSE, 18); | |
| 583 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
| 4203 | 584 | toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title (hit enter to save):")); |
| 3565 | 585 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_STRING); |
| 4035 | 586 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(3)); |
| 3565 | 587 | gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
| 4203 | 588 | Entry = gtk_entry_new(); |
| 589 | gtk_entry_set_max_length(GTK_ENTRY(Entry), 10); | |
| 3565 | 590 | gtk_widget_set_sensitive(GTK_WIDGET(Entry), method & METHOD_STRING); |
| 591 | gtk_box_pack_start(GTK_BOX(hbox), Entry, FALSE, FALSE, 0); | |
| 3392 | 592 | gtk_entry_set_text(GTK_ENTRY(Entry), title_string); |
| 4203 | 593 | g_signal_connect(G_OBJECT(Entry), "activate", G_CALLBACK(options), GINT_TO_POINTER(10)); |
| 3374 | 594 | |
| 3710 | 595 | toggle = gtk_check_button_new_with_mnemonic(_("_Quote window title")); |
| 3565 | 596 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 597 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_QUOTE); | |
| 4035 | 598 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(4)); |
| 3374 | 599 | |
| 3565 | 600 | toggle = gtk_check_button_new_with_mnemonic(_("Set Window Manager \"_URGENT\" Hint")); |
| 601 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 602 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_URGENT); | |
| 4035 | 603 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(5)); |
| 604 | ||
| 3710 | 605 | toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); |
| 3565 | 606 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_COUNT); |
| 607 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 4035 | 608 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(7)); |
| 3710 | 609 | |
| 610 | toggle = gtk_check_button_new_with_mnemonic(_("_Notify even if conversation is in focus")); | |
| 611 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_IN_FOCUS); | |
| 612 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 4035 | 613 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(6)); |
| 3392 | 614 | |
| 3565 | 615 | /*--------------*/ |
| 616 | vbox = make_frame(ret, _("Notification Removal")); | |
| 3710 | 617 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window gains _focus")); |
| 3565 | 618 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 619 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_FOCUS); | |
| 4035 | 620 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(0)); |
| 3374 | 621 | |
| 3710 | 622 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); |
| 623 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 624 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_CLICK); | |
| 4035 | 625 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(1)); |
| 3710 | 626 | |
| 3565 | 627 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); |
| 628 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 629 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_TYPE); | |
| 4035 | 630 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(2)); |
| 631 | ||
| 632 | button = gtk_button_new_with_mnemonic(_("Appl_y")); | |
| 633 | gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 5); | |
| 634 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(apply_options), NULL); | |
| 3565 | 635 | |
| 636 | gtk_widget_show_all(ret); | |
| 637 | return ret; | |
| 3374 | 638 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
639 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
640 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
641 | plugin_load(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
642 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
643 | title_string = g_strdup("(*) "); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
644 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
645 | load_notify_prefs(); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
646 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
647 | gaim_signal_connect(plugin, event_im_recv, im_recv_im, NULL); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
648 | gaim_signal_connect(plugin, event_chat_recv, chat_recv_im, NULL); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
649 | gaim_signal_connect(plugin, event_im_send, im_sent_im, NULL); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
650 | gaim_signal_connect(plugin, event_chat_send, chat_sent_im, NULL); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
651 | gaim_signal_connect(plugin, event_new_conversation, new_conv, NULL); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
652 | gaim_signal_connect(plugin, event_chat_join, chat_join, NULL); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
653 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
654 | return TRUE; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
655 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
656 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
657 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
658 | plugin_unload(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
659 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
660 | GList *c = gaim_get_conversations(); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
661 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
662 | while (c) { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
663 | struct gaim_conversation *cnv = (struct gaim_conversation *)c->data; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
664 | struct gaim_gtk_window *gtkwin; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
665 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
666 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(cnv)); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
667 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
668 | detach_signals(cnv); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
669 | un_star(gtkwin->window, NULL); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
670 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
671 | c = c->next; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
672 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
673 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
674 | /* this might be a hack I'm not sure, I don't think so but... */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
675 | g_free(title_string); |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
676 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
677 | return TRUE; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
678 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
679 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
680 | static GaimGtkPluginUiInfo ui_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
681 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
682 | get_config_frame |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
683 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
684 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
685 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
686 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
687 | 2, /**< api_version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
688 | GAIM_PLUGIN_STANDARD, /**< type */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
689 | GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
690 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
691 | NULL, /**< dependencies */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
692 | GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
693 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
694 | NOTIFY_PLUGIN_ID, /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
695 | N_("Message Notification"), /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
696 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
697 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
698 | N_("Provides a variety of ways of notifying you of unread messages."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
699 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
700 | N_("Provides a variety of ways of notifying you of unread messages."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
701 | "Etan Reisner <deryni@eden.rutgers.edu>", /**< author */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
702 | WEBSITE, /**< homepage */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
703 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
704 | plugin_load, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
705 | plugin_unload, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
706 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
707 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
708 | &ui_info, /**< ui_info */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
709 | NULL /**< extra_info */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
710 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
711 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
712 | static void |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
713 | __init_plugin(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
714 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
715 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
716 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
717 | GAIM_INIT_PLUGIN(notify, __init_plugin, info); |