Mercurial > pidgin.yaz
annotate src/away.c @ 1106:5bc8fdacd2cb
[gaim-migrate @ 1116]
lots of changes.
buddy.c: just in general tried to get things to work better. moving things in the edit list window and signing off should be handled better in the main buddy list window (watch out for flashes).
gaim.h: removed toc-specific things and moved them to toc.c and rvous.c as needed.
gtkhtml.c: possible fix for AOL 6.0 problems (I wasn't able to reproduce the problem before or after the fix, but i fixed what i think might have been causing the problem).
multi.c: moved LOGIN_STEPS from gaim.h here and actually use it now
oscar.c: moved an oscar-specific struct definition from gaim.h here and also handle problems better
perl.c: fix for stupid problem
rvous.c: first pass at attempt to be able to remove toc.c and rvous.c (though this will never happen; gaim will support toc as long as aol does) without cruft. gaim is now only dependent on toc.c and rvous.c for toc_build_config and parse_toc_buddy_list, which gaim needs to save and read its buddy list.
toc.c: rewrote the signin process so that the read()'s won't block. it's not actually a non-blocking read; it's just that it won't ever get to the read until there's data to be read (thanks to the gdk_input watcher). this means the cancel button should work after it's connected, but it's still not a non-blocking connect.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 20 Nov 2000 07:24:18 +0000 |
parents | 77b6bc7288d3 |
children | c73736fa0b7c |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
23 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
24 #endif |
1 | 25 #ifdef USE_APPLET |
26 #include <gnome.h> | |
27 #include <applet-widget.h> | |
28 #include "gnome_applet_mgr.h" | |
29 #endif /* USE_APPLET */ | |
30 #include <string.h> | |
31 #include <stdio.h> | |
32 #include <stdlib.h> | |
33 #include <time.h> | |
34 | |
35 #include <gtk/gtk.h> | |
36 #include "gaim.h" | |
621 | 37 #include "pixmaps/join.xpm" |
1 | 38 |
133
e277d5f0c1dd
[gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
39 GtkWidget *imaway=NULL; |
1 | 40 |
652
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
41 GtkWidget *awaymenu = NULL; |
1 | 42 struct away_message *awaymessage = NULL; |
43 | |
44 static void destroy_im_away() | |
45 { | |
46 if (imaway) | |
47 gtk_widget_destroy(imaway); | |
48 imaway=NULL; | |
49 } | |
50 | |
51 void do_im_back(GtkWidget *w, GtkWidget *x) | |
52 { | |
53 #ifdef USE_APPLET | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
652
diff
changeset
|
54 applet_widget_unregister_callback(APPLET_WIDGET(applet),"away"); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
652
diff
changeset
|
55 set_user_state(online); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
652
diff
changeset
|
56 insert_applet_away(); |
1 | 57 #endif /* USE_APPLET */ |
58 if (imaway) { | |
59 gtk_widget_destroy(imaway); | |
60 imaway=NULL; | |
61 } | |
62 | |
63 serv_set_away(NULL); | |
64 awaymessage = NULL; | |
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
960
diff
changeset
|
65 plugin_event(event_back, 0, 0, 0, 0); |
1 | 66 } |
67 | |
1044 | 68 |
69 /* | |
70 * rcg10312000 This could be more robust, but it works for my current | |
71 * goal: to remove those annoying <BR> tags. :) | |
72 */ | |
73 static void strncpy_nohtml(gchar *dest, const gchar *src, size_t destsize) | |
74 { | |
75 gchar *ptr; | |
76 g_snprintf(dest, destsize, "%s", src); | |
77 | |
78 while (1) { | |
79 ptr = strstr(dest, "<BR>"); | |
80 if (ptr == NULL) /* done? */ | |
81 return; | |
82 | |
83 /* replace <BR> with a newline. */ | |
84 *ptr = '\n'; | |
85 memmove(ptr + 1, ptr + 4, strlen(ptr + 4) + 1); | |
86 } | |
87 } | |
88 | |
89 | |
1 | 90 void do_away_message(GtkWidget *w, struct away_message *a) |
91 { | |
92 GtkWidget *back; | |
136
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
133
diff
changeset
|
93 GtkWidget *awaytext; |
1 | 94 GtkWidget *vscrollbar; |
95 GtkWidget *bbox; | |
96 GtkWidget *vbox; | |
97 GtkWidget *topbox; | |
98 char *buf2; | |
99 char buf[BUF_LONG]; | |
100 GList *cnv = conversations; | |
101 struct conversation *c; | |
102 | |
652
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
103 if (!blist) |
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
104 return; |
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
105 |
18 | 106 #ifdef USE_APPLET |
107 remove_applet_away(); | |
108 applet_widget_register_callback(APPLET_WIDGET(applet), | |
109 "away", | |
110 _("Back"), | |
111 (AppletCallbackFunc) do_im_back, | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
652
diff
changeset
|
112 NULL); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
652
diff
changeset
|
113 set_user_state(away); |
18 | 114 #endif |
115 | |
1 | 116 if (!imaway) { |
117 imaway = gtk_window_new(GTK_WINDOW_DIALOG); | |
905 | 118 gtk_window_set_wmclass(GTK_WINDOW(imaway), "imaway", "Gaim"); |
1 | 119 gtk_widget_realize(imaway); |
120 aol_icon(imaway->window); | |
621 | 121 back = picture_button(imaway, _("I'm Back!"), join_xpm); |
1 | 122 bbox = gtk_hbox_new(TRUE, 10); |
123 topbox = gtk_hbox_new(FALSE, 5); | |
124 vbox = gtk_vbox_new(FALSE, 5); | |
125 | |
126 awaytext = gtk_text_new(NULL, NULL); | |
1044 | 127 |
128 /* rcg10312000 Convert basic HTML (<BR>, etc) to plain text. | |
1 | 129 g_snprintf(buf, sizeof(buf), "%s", a->message); |
1044 | 130 */ |
131 strncpy_nohtml(buf, a->message, sizeof (buf)); | |
132 | |
133 vscrollbar = gtk_vscrollbar_new(GTK_TEXT(awaytext)->vadj); | |
1 | 134 gtk_widget_show(vscrollbar); |
135 gtk_widget_set_usize(awaytext, 225, 75); | |
136 gtk_text_set_word_wrap(GTK_TEXT(awaytext), TRUE); | |
137 gtk_widget_show(awaytext); | |
138 gtk_text_freeze(GTK_TEXT(awaytext)); | |
139 gtk_text_insert(GTK_TEXT(awaytext), NULL, NULL, NULL, buf, -1); | |
140 gtk_widget_show(awaytext); | |
141 | |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
142 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
143 gtk_button_set_relief(GTK_BUTTON(back), GTK_RELIEF_NONE); |
1 | 144 |
145 /* Put the buttons in the box */ | |
146 gtk_box_pack_start(GTK_BOX(bbox), back, TRUE, TRUE, 10); | |
147 | |
148 gtk_box_pack_start(GTK_BOX(topbox), awaytext, FALSE, FALSE, 5); | |
149 | |
150 /* And the boxes in the box */ | |
151 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
152 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
153 | |
154 /* Handle closes right */ | |
155 gtk_signal_connect(GTK_OBJECT(imaway), "destroy", | |
939 | 156 GTK_SIGNAL_FUNC(do_im_back), imaway); |
1 | 157 gtk_signal_connect(GTK_OBJECT(back), "clicked", |
158 GTK_SIGNAL_FUNC(do_im_back), imaway); | |
159 | |
160 /* Finish up */ | |
161 gtk_widget_show(back); | |
162 gtk_widget_show(topbox); | |
163 gtk_widget_show(bbox); | |
164 gtk_widget_show(vbox); | |
165 if (strlen(a->name)) | |
166 gtk_window_set_title(GTK_WINDOW(imaway), a->name); | |
167 else | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
168 gtk_window_set_title(GTK_WINDOW(imaway), _("Gaim - Away!")); |
1 | 169 gtk_window_set_focus(GTK_WINDOW(imaway), back); |
170 gtk_container_add(GTK_CONTAINER(imaway), vbox); | |
171 awaymessage = a; | |
172 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
173 } else { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
174 destroy_im_away(); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
175 do_away_message(w, a); |
652
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
176 return; |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
177 } |
1 | 178 |
179 /* New away message... Clear out the old sent_aways */ | |
180 while(cnv) { | |
181 c = (struct conversation *)cnv->data; | |
182 c->sent_away = 0; | |
183 cnv = cnv->next; | |
184 } | |
185 | |
186 | |
79 | 187 buf2 = g_malloc(strlen(awaymessage->message)*4 + 1); |
188 strcpy(buf2, awaymessage->message); | |
1 | 189 serv_set_away(buf2); |
79 | 190 g_free(buf2); |
1 | 191 gtk_widget_show(imaway); |
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
960
diff
changeset
|
192 plugin_event(event_away, 0, 0, 0, 0); |
1 | 193 } |
194 | |
195 void rem_away_mess(GtkWidget *w, struct away_message *a) | |
196 { | |
18 | 197 #ifdef USE_APPLET |
198 char *awayname; | |
79 | 199 awayname = g_malloc(sizeof (*awayname) * (6 + strlen(a->name))); |
18 | 200 awayname[0] = '\0'; |
201 strcat(awayname, "away/"); | |
202 strcat(awayname, a->name); | |
203 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname); | |
204 #endif | |
940 | 205 away_messages = g_slist_remove(away_messages, a); |
1 | 206 g_free(a); |
207 do_away_menu(); | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
136
diff
changeset
|
208 save_prefs(); |
1 | 209 } |
210 | |
211 | |
212 void do_away_menu() | |
213 { | |
214 GtkWidget *menuitem; | |
215 static GtkWidget *remmenu; | |
216 GtkWidget *remitem; | |
217 GtkWidget *label; | |
218 GtkWidget *sep; | |
219 GList *l; | |
220 GtkWidget *list_item; | |
940 | 221 GSList *awy = away_messages; |
1 | 222 struct away_message *a; |
223 | |
18 | 224 #ifdef USE_APPLET |
225 remove_applet_away(); | |
226 if (imaway) | |
227 applet_widget_register_callback(APPLET_WIDGET(applet), | |
228 "away", | |
229 _("Back"), | |
230 (AppletCallbackFunc)do_im_back, | |
231 NULL); | |
232 else | |
233 insert_applet_away(); | |
234 #endif | |
1 | 235 |
652
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
236 if (prefs_away_list != NULL) { |
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
237 gtk_list_clear_items(GTK_LIST(prefs_away_list), 0, -1); |
1 | 238 while(awy) { |
239 a = (struct away_message *)awy->data; | |
240 label = gtk_label_new(a->name); | |
241 list_item = gtk_list_item_new(); | |
242 gtk_container_add(GTK_CONTAINER(list_item), label); | |
243 gtk_signal_connect(GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(away_list_clicked), a); | |
821 | 244 /* gtk_signal_connect(GTK_OBJECT(list_item), "deselect", GTK_SIGNAL_FUNC(away_list_unclicked), a);*/ |
1 | 245 gtk_object_set_user_data(GTK_OBJECT(list_item), a); |
246 | |
247 gtk_widget_show(label); | |
652
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
248 gtk_container_add(GTK_CONTAINER(prefs_away_list), list_item); |
1 | 249 gtk_widget_show(list_item); |
250 | |
940 | 251 awy = g_slist_next(awy); |
1 | 252 } |
253 if (away_messages != NULL) | |
652
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
254 gtk_list_select_item(GTK_LIST(prefs_away_list), 0); |
1 | 255 } |
256 | |
652
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
257 if (!awaymenu) return; |
1 | 258 l = gtk_container_children(GTK_CONTAINER(awaymenu)); |
259 | |
260 while(l) { | |
261 gtk_widget_destroy(GTK_WIDGET(l->data)); | |
262 l = l->next; | |
263 } | |
264 | |
265 | |
266 remmenu = gtk_menu_new(); | |
267 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
268 menuitem = gtk_menu_item_new_with_label(_("New Away Message")); |
1 | 269 gtk_menu_append(GTK_MENU(awaymenu), menuitem); |
270 gtk_widget_show(menuitem); | |
271 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(create_away_mess), NULL); | |
272 | |
22 | 273 awy = away_messages; |
1 | 274 while(awy) { |
275 a = (struct away_message *)awy->data; | |
276 | |
277 remitem = gtk_menu_item_new_with_label(a->name); | |
278 gtk_menu_append(GTK_MENU(remmenu), remitem); | |
279 gtk_widget_show(remitem); | |
280 gtk_signal_connect(GTK_OBJECT(remitem), "activate", GTK_SIGNAL_FUNC(rem_away_mess), a); | |
281 | |
940 | 282 awy = g_slist_next(awy); |
1 | 283 |
284 } | |
285 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
286 menuitem = gtk_menu_item_new_with_label(_("Remove Away Message")); |
1 | 287 gtk_menu_append(GTK_MENU(awaymenu), menuitem); |
288 gtk_widget_show(menuitem); | |
289 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), remmenu); | |
290 gtk_widget_show(remmenu); | |
291 | |
292 sep = gtk_hseparator_new(); | |
293 menuitem = gtk_menu_item_new(); | |
294 gtk_menu_append(GTK_MENU(awaymenu), menuitem); | |
295 gtk_container_add(GTK_CONTAINER(menuitem), sep); | |
296 gtk_widget_set_sensitive(menuitem, FALSE); | |
297 gtk_widget_show(menuitem); | |
298 gtk_widget_show(sep); | |
299 | |
300 awy = away_messages; | |
301 | |
302 while(awy) { | |
303 a = (struct away_message *)awy->data; | |
304 | |
305 menuitem = gtk_menu_item_new_with_label(a->name); | |
306 gtk_menu_append(GTK_MENU(awaymenu), menuitem); | |
307 gtk_widget_show(menuitem); | |
308 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(do_away_message), a); | |
309 | |
940 | 310 awy = g_slist_next(awy); |
1 | 311 |
312 } | |
313 | |
314 } | |
315 | |
316 | |
317 | |
318 | |
319 | |
320 |