Mercurial > pidgin
annotate src/conversation.c @ 230:83dd297aa363
[gaim-migrate @ 240]
Added a few patches from fflewddur to add default away messages, save prefs
after deleting an away message, and *duh* *duh* *duh* *duh* presenting.....
font face selection dialog! Thanks fflewddur.
I also added a pixmap for font face to eventually go on the conversation
windows, but I didn't implement it yet.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 10 May 2000 10:56:25 +0000 |
parents | ec0686b3b03f |
children | 985635758c33 |
rev | line source |
---|---|
66 | 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 | |
22 #include <string.h> | |
23 #include <sys/time.h> | |
24 #include <sys/types.h> | |
25 #include <sys/stat.h> | |
26 #include <unistd.h> | |
27 #include <stdio.h> | |
28 #include <stdlib.h> | |
210
ec0686b3b03f
[gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
209
diff
changeset
|
29 #include <ctype.h> |
66 | 30 #include <gtk/gtk.h> |
31 #include "gaim.h" | |
32 #include "gtkhtml.h" | |
33 #include <gdk/gdkkeysyms.h> | |
34 #include "pixmaps/underline.xpm" | |
35 #include "pixmaps/bold.xpm" | |
36 #include "pixmaps/italic.xpm" | |
37 #include "pixmaps/small.xpm" | |
38 #include "pixmaps/normal.xpm" | |
39 #include "pixmaps/big.xpm" | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
40 /* #include "pixmaps/fontface.xpm" */ |
66 | 41 #include "pixmaps/speaker.xpm" |
210
ec0686b3b03f
[gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
209
diff
changeset
|
42 /* #include "pixmaps/aimicon2.xpm" */ |
66 | 43 #include "pixmaps/wood.xpm" |
44 #include "pixmaps/palette.xpm" | |
45 #include "pixmaps/link.xpm" | |
46 #include "pixmaps/strike.xpm" | |
47 | |
48 int state_lock=0; | |
49 | |
50 GdkPixmap *dark_icon_pm = NULL; | |
51 GdkBitmap *dark_icon_bm = NULL; | |
52 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
53 char *fontface; |
66 | 54 |
55 void check_everything(GtkWidget *entry); | |
56 gboolean user_keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c); | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
57 void set_font_face(GtkWidget *widget, struct conversation *c); |
66 | 58 |
59 /*------------------------------------------------------------------------*/ | |
60 /* Helpers */ | |
61 /*------------------------------------------------------------------------*/ | |
62 | |
63 | |
64 void quiet_set(GtkWidget *tb, int state) | |
65 { | |
66 state_lock=1; | |
67 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(tb), state); | |
68 state_lock=0; | |
69 } | |
70 | |
71 | |
72 void set_state_lock(int i) | |
73 { | |
74 state_lock = i; | |
75 } | |
76 | |
77 struct conversation *new_conversation(char *name) | |
78 { | |
79 struct conversation *c; | |
80 | |
81 c = find_conversation(name); | |
82 | |
83 if (c != NULL) | |
84 return c; | |
85 | |
86 c = (struct conversation *)g_new0(struct conversation, 1); | |
87 g_snprintf(c->name, sizeof(c->name), "%s", name); | |
88 | |
89 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { | |
90 FILE *fd; | |
70 | 91 |
66 | 92 fd = open_log_file(c); |
93 if (!(general_options & OPT_GEN_STRIP_HTML)) | |
70 | 94 fprintf(fd, "<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n", full_date()); |
66 | 95 else |
70 | 96 fprintf(fd, " ---- New Conversation @ %s ----\n", full_date()); |
97 | |
66 | 98 fclose(fd); |
99 } | |
100 | |
101 show_conv(c); | |
102 conversations = g_list_append(conversations, c); | |
103 return c; | |
104 } | |
105 | |
106 | |
107 struct conversation *find_conversation(char *name) | |
108 { | |
109 char *cuser = g_malloc(64); | |
110 struct conversation *c; | |
111 GList *cnv = conversations; | |
112 | |
113 strcpy(cuser, normalize(name)); | |
114 | |
115 while(cnv) { | |
116 c = (struct conversation *)cnv->data; | |
117 if(!strcasecmp(cuser, normalize(c->name))) { | |
118 g_free(cuser); | |
119 return c; | |
120 } | |
121 cnv = cnv->next; | |
122 } | |
123 g_free(cuser); | |
124 return NULL; | |
125 } | |
126 | |
127 /* --------------------------------------------------- | |
128 * Function to remove a log file entry | |
129 * --------------------------------------------------- | |
130 */ | |
131 | |
132 void rm_log(struct log_conversation *a) | |
133 { | |
134 struct conversation *cnv = find_conversation(a->name); | |
135 char buf[128]; | |
136 | |
137 log_conversations = g_list_remove(log_conversations, a); | |
138 | |
139 save_prefs(); | |
140 | |
141 if (cnv) { | |
142 if (!(general_options & OPT_GEN_LOG_ALL)) | |
143 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, cnv->name); | |
144 else | |
145 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, cnv->name); | |
146 gtk_window_set_title(GTK_WINDOW(cnv->window), buf); | |
147 } | |
148 } | |
149 | |
150 struct log_conversation *find_log_info(char *name) | |
151 { | |
152 char *pname = g_malloc(64); | |
153 GList *lc = log_conversations; | |
154 struct log_conversation *l; | |
155 | |
156 | |
157 strcpy(pname, normalize(name)); | |
158 | |
159 while(lc) { | |
160 l = (struct log_conversation *)lc->data; | |
161 if (!strcasecmp(pname, normalize(l->name))) { | |
162 g_free(pname); | |
163 return l; | |
164 } | |
165 lc = lc->next; | |
166 } | |
167 g_free(pname); | |
168 return NULL; | |
169 } | |
170 | |
171 void delete_conversation(struct conversation *cnv) | |
172 { | |
173 conversations = g_list_remove(conversations, cnv); | |
174 g_free(cnv); | |
175 } | |
176 | |
177 void update_log_convs() | |
178 { | |
179 GList *cnv = conversations; | |
180 struct conversation *c; | |
181 | |
182 while(cnv) { | |
183 c = (struct conversation *)cnv->data; | |
184 | |
185 if (c->log_button) | |
186 gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE); | |
187 | |
188 cnv = cnv->next; | |
189 } | |
190 } | |
191 | |
192 void update_font_buttons() | |
193 { | |
194 GList *cnv = conversations; | |
195 struct conversation *c; | |
196 | |
197 while (cnv) { | |
198 c = (struct conversation *)cnv->data; | |
199 | |
200 if (c->bold) | |
201 gtk_widget_set_sensitive(c->bold, ((font_options & OPT_FONT_BOLD)) ? FALSE : TRUE); | |
202 | |
203 if (c->italic) | |
204 gtk_widget_set_sensitive(c->italic, ((font_options & OPT_FONT_ITALIC)) ? FALSE : TRUE); | |
205 | |
206 if (c->underline) | |
207 gtk_widget_set_sensitive(c->underline, ((font_options & OPT_FONT_UNDERLINE)) ? FALSE : TRUE); | |
208 | |
209 if (c->strike) | |
210 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); | |
211 | |
212 cnv = cnv->next; | |
213 } | |
214 } | |
215 | |
216 /* | |
217 void update_transparency() | |
218 { | |
219 GList *cnv = conversations; | |
220 struct conversation *c; | |
221 | |
222 This func should be uncalled! | |
223 | |
224 while(cnv) { | |
225 c = (struct conversation *)cnv->data; | |
226 | |
227 if (c->text) | |
228 gtk_html_set_transparent(GTK_HTML(c->text), | |
229 (transparent) ? TRUE : FALSE); | |
230 | |
231 cnv = cnv->next; | |
232 } | |
233 } | |
234 */ | |
235 | |
236 | |
237 /*------------------------------------------------------------------------*/ | |
238 /* Callbacks */ | |
239 /*------------------------------------------------------------------------*/ | |
240 | |
241 void toggle_loggle(GtkWidget *w, struct conversation *p) | |
242 { | |
243 if (state_lock) | |
244 return; | |
245 | |
246 if (find_log_info(p->name)) | |
247 rm_log(find_log_info(p->name)); | |
248 else | |
249 show_log_dialog(p->name); | |
250 } | |
251 | |
252 static int close_callback(GtkWidget *widget, struct conversation *c) | |
253 { | |
254 gtk_widget_destroy(c->window); | |
255 delete_conversation(c); | |
256 return TRUE; | |
257 } | |
258 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
259 void set_font_face(GtkWidget *widget, struct conversation *c) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
260 { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
261 char *pre_fontface; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
262 int alloc = 0; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
263 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
264 if (!(font_options & OPT_FONT_FACE)) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
265 return; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
266 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
267 if (fontface) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
268 { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
269 pre_fontface = g_strconcat("<FONT FACE=\"", fontface, "\">", '\0'); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
270 alloc++; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
271 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
272 else |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
273 pre_fontface = "<FONT FACE=\"Helvetica\">"; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
274 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
275 surround(c->entry, pre_fontface, "</FONT>"); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
276 gtk_widget_grab_focus(c->entry); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
277 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
278 if (alloc) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
279 g_free(pre_fontface); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
280 return; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
281 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
282 |
66 | 283 static gint delete_event_convo(GtkWidget *w, GdkEventAny *e, struct conversation *c) |
284 { | |
285 delete_conversation(c); | |
286 return FALSE; | |
287 } | |
288 | |
289 | |
290 static void color_callback(GtkWidget *widget, struct conversation *c) | |
291 { | |
292 /* show_color_dialog(c); */ | |
293 gtk_widget_grab_focus(c->entry); | |
294 } | |
295 | |
296 static void add_callback(GtkWidget *widget, struct conversation *c) | |
297 { | |
298 if (find_buddy(c->name) != NULL) { | |
299 sprintf(debug_buff,"Removing '%s' from buddylist.\n", c->name); | |
300 debug_print(debug_buff); | |
301 remove_buddy(find_group_by_buddy(c->name), find_buddy(c->name)); | |
302 build_edit_tree(); | |
303 gtk_label_set_text(GTK_LABEL(GTK_BIN(c->add_button)->child), "Add"); | |
304 } | |
305 else | |
306 { | |
307 show_add_buddy(c->name, NULL); | |
308 } | |
309 | |
310 gtk_widget_grab_focus(c->entry); | |
311 } | |
312 | |
313 | |
314 static void block_callback(GtkWidget *widget, struct conversation *c) | |
315 { | |
316 show_add_perm(c->name); | |
317 gtk_widget_grab_focus(c->entry); | |
318 } | |
319 | |
320 static void warn_callback(GtkWidget *widget, struct conversation *c) | |
321 { | |
322 show_warn_dialog(c->name); | |
323 gtk_widget_grab_focus(c->entry); | |
324 } | |
325 | |
326 static void info_callback(GtkWidget *widget, struct conversation *c) | |
327 { | |
328 serv_get_info(c->name); | |
329 gtk_widget_grab_focus(c->entry); | |
330 } | |
331 | |
332 gboolean user_keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c) | |
333 { | |
334 int pos; | |
335 if(event->keyval==GDK_Return) { | |
336 if(!(event->state & GDK_SHIFT_MASK)){ | |
337 gtk_signal_emit_by_name(GTK_OBJECT(entry), "activate", c); | |
338 //to stop the putting in of the enter character | |
339 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); | |
340 } else { | |
341 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); | |
342 pos=gtk_editable_get_position(GTK_EDITABLE(entry)); | |
343 gtk_editable_insert_text(GTK_EDITABLE(entry), "\n", 1, &pos); | |
344 } | |
345 } | |
346 | |
347 return TRUE; | |
348 | |
349 } | |
350 | |
351 | |
352 static void send_callback(GtkWidget *widget, struct conversation *c) | |
353 { | |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
354 char *buf = g_malloc(BUF_LEN * 4); |
66 | 355 char *buf2; |
356 gchar *buf4; | |
357 int hdrlen; | |
358 | |
359 buf4 = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1); | |
360 g_snprintf(buf, BUF_LONG, "%s", buf4); | |
361 g_free(buf4); | |
362 | |
363 if (!strlen(buf)) { | |
364 return; | |
365 } | |
366 | |
367 if (general_options & OPT_GEN_SEND_LINKS) { | |
368 linkify_text(buf); | |
369 } | |
370 | |
371 /* Let us determine how long the message CAN be. | |
372 * toc_send_im is 11 chars long + 2 quotes. | |
373 * + 2 spaces + 6 for the header + 2 for good | |
374 * measure = 23 bytes + the length of normalize c->name */ | |
375 | |
376 buf2 = g_malloc(BUF_LONG); | |
377 | |
378 hdrlen = 23 + strlen(normalize(c->name)); | |
379 | |
380 /* printf("%d %d %d\n", strlen(buf), hdrlen, BUF_LONG);*/ | |
381 | |
382 if (font_options & OPT_FONT_BOLD) { | |
383 g_snprintf(buf2, BUF_LONG, "<B>%s</B>", buf); | |
384 strcpy(buf, buf2); | |
385 } | |
386 | |
387 if (font_options & OPT_FONT_ITALIC) { | |
388 g_snprintf(buf2, BUF_LONG, "<I>%s</I>", buf); | |
389 strcpy(buf, buf2); | |
390 } | |
391 | |
392 if (font_options & OPT_FONT_UNDERLINE) { | |
393 g_snprintf(buf2, BUF_LONG, "<U>%s</U>", buf); | |
394 strcpy(buf, buf2); | |
395 } | |
396 | |
397 if (font_options & OPT_FONT_STRIKE) { | |
398 g_snprintf(buf2, BUF_LONG, "<STRIKE>%s</STRIKE>", buf); | |
399 strcpy(buf, buf2); | |
400 } | |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
401 |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
402 #ifdef GAIM_PLUGINS |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
403 { |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
404 GList *ca = callbacks; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
405 struct gaim_callback *g; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
406 void (*function)(char *, char **, void *); |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
407 while (ca) { |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
408 g = (struct gaim_callback *)(ca->data); |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
409 if (g->event == event_im_send && g->function != NULL) { |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
410 function = g->function; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
411 (*function)(c->name, &buf, g->data); |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
412 } |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
413 ca = ca->next; |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
414 } |
102
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
415 if (buf == NULL) { |
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
416 g_free(buf2); |
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
417 return; |
8c301530b2a3
[gaim-migrate @ 112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
418 } |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
419 } |
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
420 #endif |
66 | 421 |
422 write_to_conv(c, buf, WFLAG_SEND); | |
423 | |
424 gtk_editable_delete_text(GTK_EDITABLE(c->entry), 0, -1); | |
425 | |
426 escape_text(buf); | |
427 if (escape_message(buf) > MSG_LEN - hdrlen) { | |
428 do_error_dialog("Message too long, some data truncated.", "Error"); | |
429 } | |
430 | |
431 serv_send_im(c->name, buf, 0); | |
432 | |
433 quiet_set(c->bold, FALSE); | |
434 quiet_set(c->strike, FALSE); | |
435 quiet_set(c->italic, FALSE); | |
436 quiet_set(c->underline, FALSE); | |
437 quiet_set(c->palette, FALSE); | |
438 quiet_set(c->link, FALSE); | |
439 | |
440 if (c->makesound && (sound_options & OPT_SOUND_SEND)) | |
441 play_sound(SEND); | |
442 | |
443 if (awaymessage != NULL) { | |
444 do_im_back(); | |
445 } | |
446 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
447 set_font_face(NULL, c); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
448 |
66 | 449 gtk_widget_grab_focus(c->entry); |
450 | |
451 g_free(buf2); | |
101
a9aa982272f9
[gaim-migrate @ 111]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
88
diff
changeset
|
452 g_free(buf); |
66 | 453 } |
454 | |
455 static int | |
456 entry_key_pressed(GtkWidget *w, GtkWidget *entry) | |
457 { | |
458 check_everything(w); | |
459 return TRUE; | |
460 } | |
461 | |
462 /*------------------------------------------------------------------------*/ | |
463 /* HTML-type stuff */ | |
464 /*------------------------------------------------------------------------*/ | |
465 | |
466 int count_tag(GtkWidget *entry, char *s1, char *s2) | |
467 { | |
468 char *p1, *p2; | |
469 int res=0; | |
470 char *tmp, *tmpo, h; | |
471 tmpo = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
472 h = tmpo[GTK_EDITABLE(entry)->current_pos]; | |
473 tmpo[GTK_EDITABLE(entry)->current_pos]='\0'; | |
474 tmp=tmpo; | |
475 do { | |
476 p1 = strstr(tmp, s1); | |
477 p2 = strstr(tmp, s2); | |
478 if (p1 && p2) { | |
479 if (p1 < p2) { | |
480 res=1; | |
481 tmp = p1 +strlen(s1); | |
482 } else if (p2 < p1) { | |
483 res = 0; | |
484 tmp = p2 + strlen(s2); | |
485 } | |
486 } else { | |
487 if (p1) { | |
488 res = 1; | |
489 tmp = p1 + strlen(s1); | |
490 } else if (p2) { | |
491 res = 0; | |
492 tmp = p2 + strlen(s2); | |
493 } | |
494 } | |
495 } while (p1 || p2); | |
496 tmpo[GTK_EDITABLE(entry)->current_pos]=h; | |
497 g_free(tmpo); | |
498 return res; | |
499 } | |
500 | |
501 | |
502 int invert_tags(GtkWidget *entry, char *s1, char *s2, int really) | |
503 { | |
504 int start = GTK_EDITABLE(entry)->selection_start_pos; | |
505 int finish = GTK_EDITABLE(entry)->selection_end_pos; | |
506 char *s; | |
507 | |
508 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
509 if (!strncasecmp(&s[start], s1, strlen(s1)) && | |
510 !strncasecmp(&s[finish - strlen(s2)], s2, strlen(s2))) { | |
511 if (really) { | |
512 gtk_editable_delete_text(GTK_EDITABLE(entry), start, start + strlen(s1)); | |
513 gtk_editable_delete_text(GTK_EDITABLE(entry), finish - strlen(s2) - strlen(s1), finish - strlen(s1)); | |
514 } | |
515 g_free(s); | |
516 return 1; | |
517 } | |
518 g_free(s); | |
519 return 0; | |
520 } | |
521 | |
522 | |
523 void remove_tags(GtkWidget *entry, char *tag) | |
524 { | |
525 char *s; | |
526 char *t; | |
527 int start = GTK_EDITABLE(entry)->selection_start_pos; | |
528 int finish = GTK_EDITABLE(entry)->selection_end_pos; | |
529 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
530 t = s; | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
531 if (strstr(tag, "<FONT SIZE=")) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
532 { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
533 while((t = strstr(t, "<FONT SIZE="))) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
534 if (((t-s) < finish) && ((t-s) >= start)) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
535 gtk_editable_delete_text(GTK_EDITABLE(entry), (t-s), (t-s) + strlen(tag)); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
536 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
537 t = s; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
538 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
539 else t++; |
68 | 540 } |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
541 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
542 else |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
543 { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
544 while((t = strstr(t, tag))) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
545 if (((t-s) < finish) && ((t-s) >= start)) { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
546 gtk_editable_delete_text(GTK_EDITABLE(entry), (t-s), (t-s) + strlen(tag)); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
547 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
548 t = s; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
549 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
550 else t++; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
551 } |
66 | 552 } |
553 g_free(s); | |
554 } | |
555 | |
556 void surround(GtkWidget *entry, char *pre, char *post) | |
557 { | |
558 int pos = GTK_EDITABLE(entry)->current_pos; | |
559 int dummy; | |
560 int start, finish; | |
561 if (GTK_EDITABLE(entry)->has_selection) { | |
562 remove_tags(entry, pre); | |
563 remove_tags(entry, post); | |
564 start = GTK_EDITABLE(entry)->selection_start_pos; | |
565 finish = GTK_EDITABLE(entry)->selection_end_pos; | |
566 if (start > finish) { | |
567 dummy = finish; | |
568 finish = start; | |
569 start = dummy; | |
570 } | |
571 dummy = start; | |
572 gtk_editable_insert_text(GTK_EDITABLE(entry), pre, strlen(pre), &dummy); | |
573 dummy = finish + strlen(pre); | |
574 gtk_editable_insert_text(GTK_EDITABLE(entry), post, strlen(post), &dummy); | |
575 gtk_editable_select_region(GTK_EDITABLE(entry), start, finish + strlen(pre) + strlen(post)); | |
576 } else { | |
577 gtk_editable_insert_text(GTK_EDITABLE(entry), pre, strlen(pre), &pos); | |
578 dummy = pos; | |
579 gtk_editable_insert_text(GTK_EDITABLE(entry), post, strlen(post), &dummy); | |
580 gtk_editable_set_position(GTK_EDITABLE(entry), pos); | |
581 } | |
582 gtk_widget_grab_focus(entry); | |
583 } | |
584 | |
585 static void advance_past(GtkWidget *entry, char *pre, char *post) | |
586 { | |
587 char *s, *s2; | |
588 int pos; | |
589 if (invert_tags(entry, pre, post, 1)) | |
590 return; | |
591 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
592 pos = GTK_EDITABLE(entry)->current_pos; | |
593 sprintf(debug_buff,"Currently at %d\n",pos); | |
594 debug_print(debug_buff); | |
595 s2= strstr(&s[pos], post); | |
596 if (s2) | |
597 pos = s2 - s + strlen(post); | |
598 else | |
187 | 599 pos=strlen(s); |
66 | 600 sprintf(debug_buff,"Setting position to %d\n",pos); |
601 debug_print(debug_buff); | |
602 gtk_editable_set_position(GTK_EDITABLE(entry), pos); | |
603 gtk_widget_grab_focus(entry); | |
604 } | |
605 | |
606 static void toggle_color(GtkWidget *color, GtkWidget *entry) | |
607 { | |
608 if (state_lock) | |
609 return; | |
610 if (GTK_TOGGLE_BUTTON(color)->active) | |
611 show_color_dialog(entry, color); | |
189
50dc3db25513
[gaim-migrate @ 199]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
187
diff
changeset
|
612 else |
50dc3db25513
[gaim-migrate @ 199]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
187
diff
changeset
|
613 advance_past(entry, "<FONT COLOR>", "</FONT>" ); |
66 | 614 } |
615 | |
616 static void do_link(GtkWidget *linky, GtkWidget *entry) | |
617 { | |
618 if (state_lock) | |
619 return; | |
620 if (GTK_TOGGLE_BUTTON(linky)->active) | |
621 show_add_link(entry, linky); | |
622 else | |
623 advance_past(entry, "<A HREF>", "</A>" ); | |
624 } | |
625 | |
626 static void do_strike(GtkWidget *strike, GtkWidget *entry) | |
627 { | |
628 if (state_lock) | |
629 return; | |
630 if (GTK_TOGGLE_BUTTON(strike)->active) | |
631 surround(entry, "<STRIKE>","</STRIKE>"); | |
632 else | |
633 advance_past(entry, "<STRIKE>", "</STRIKE>"); | |
634 } | |
635 | |
636 static void do_bold(GtkWidget *bold, GtkWidget *entry) | |
637 { | |
638 if (state_lock) | |
639 return; | |
640 if (GTK_TOGGLE_BUTTON(bold)->active) | |
641 surround(entry, "<B>","</B>"); | |
642 else | |
643 advance_past(entry, "<B>", "</B>"); | |
644 } | |
645 | |
646 static void do_underline(GtkWidget *underline, GtkWidget *entry) | |
647 { | |
648 if (state_lock) | |
649 return; | |
650 if (GTK_TOGGLE_BUTTON(underline)->active) | |
651 surround(entry, "<U>","</U>"); | |
652 else | |
653 advance_past(entry, "<U>", "</U>"); | |
654 } | |
655 | |
656 static void do_italic(GtkWidget *italic, GtkWidget *entry) | |
657 { | |
658 if (state_lock) | |
659 return; | |
660 if (GTK_TOGGLE_BUTTON(italic)->active) | |
661 surround(entry, "<I>","</I>"); | |
662 else | |
663 advance_past(entry, "<I>", "</I>"); | |
664 } | |
665 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
666 /* html code to modify font sizes must all be the same length, */ |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
667 /* currently set to 15 chars */ |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
668 |
66 | 669 static void do_small(GtkWidget *small, GtkWidget *entry) |
670 { | |
671 if (state_lock) | |
672 return; | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
673 surround(entry, "<FONT SIZE=\"1\">","</FONT>"); |
66 | 674 } |
675 | |
676 static void do_normal(GtkWidget *normal, GtkWidget *entry) | |
677 { | |
678 if (state_lock) | |
679 return; | |
88 | 680 surround(entry, "<FONT SIZE=\"3\">","</FONT>"); |
66 | 681 } |
682 | |
683 static void do_big(GtkWidget *big, GtkWidget *entry) | |
684 { | |
685 if (state_lock) | |
686 return; | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
687 surround(entry, "<FONT SIZE=\"5\">","</FONT>"); |
66 | 688 } |
689 | |
690 void check_everything(GtkWidget *entry) | |
691 { | |
692 struct conversation *c; | |
206 | 693 |
66 | 694 c = (struct conversation *)gtk_object_get_user_data(GTK_OBJECT(entry)); |
695 if (!c) return; | |
696 if (invert_tags(entry, "<B>", "</B>", 0)) | |
697 quiet_set(c->bold, TRUE); | |
698 else if (count_tag(entry, "<B>", "</B>")) | |
699 quiet_set(c->bold, TRUE); | |
700 else | |
701 quiet_set(c->bold,FALSE); | |
702 if (invert_tags(entry, "<I>", "</I>", 0)) | |
703 quiet_set(c->italic, TRUE); | |
704 else if (count_tag(entry, "<I>", "</I>")) | |
705 quiet_set(c->italic, TRUE); | |
706 else | |
707 quiet_set(c->italic, FALSE); | |
708 | |
709 if (invert_tags(entry, "<FONT COLOR", "</FONT>", 0)) | |
710 quiet_set(c->palette, TRUE); | |
711 else if (count_tag(entry, "<FONT COLOR", "</FONT>")) | |
712 quiet_set(c->palette, TRUE); | |
713 else | |
714 quiet_set(c->palette, FALSE); | |
715 | |
716 if (invert_tags(entry, "<A HREF", "</A>", 0)) | |
717 quiet_set(c->link, TRUE); | |
718 else if (count_tag(entry, "<A HREF", "</A>")) | |
719 quiet_set(c->link, TRUE); | |
720 else | |
721 quiet_set(c->link, FALSE); | |
722 | |
723 if (invert_tags(entry, "<U>", "</U>", 0)) | |
724 quiet_set(c->underline, TRUE); | |
725 else if (count_tag(entry, "<U>", "</U>")) | |
726 quiet_set(c->underline, TRUE); | |
727 else | |
728 quiet_set(c->underline, FALSE); | |
729 | |
730 if (invert_tags(entry, "<STRIKE>", "</STRIKE>", 0)) | |
731 quiet_set(c->strike, TRUE); | |
732 else if (count_tag(entry, "<STRIKE>", "</STRIKE>")) | |
733 quiet_set(c->strike, TRUE); | |
734 else | |
735 quiet_set(c->strike, FALSE); | |
736 } | |
737 | |
738 | |
739 /*------------------------------------------------------------------------*/ | |
740 /* Takin care of the window.. */ | |
741 /*------------------------------------------------------------------------*/ | |
742 | |
743 | |
744 void write_to_conv(struct conversation *c, char *what, int flags) | |
745 { | |
746 char *buf = g_malloc(BUF_LONG); | |
747 char *buf2 = g_malloc(BUF_LONG); | |
748 char *who = NULL; | |
749 FILE *fd; | |
750 char colour[10]; | |
751 | |
752 if (flags & WFLAG_SYSTEM) { | |
753 | |
754 gtk_html_freeze(GTK_HTML(c->text)); | |
755 | |
756 gtk_html_append_text(GTK_HTML(c->text), what, 0); | |
757 | |
758 gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0); | |
759 | |
760 gtk_html_thaw(GTK_HTML(c->text)); | |
761 | |
762 | |
763 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { | |
764 char *t1; | |
765 | |
766 if (general_options & OPT_GEN_STRIP_HTML) { | |
767 t1 = strip_html(what); | |
768 } else { | |
769 t1 = what; | |
770 } | |
771 fd = open_log_file(c); | |
772 fprintf(fd, "%s\n", t1); | |
773 fclose(fd); | |
774 if (general_options & OPT_GEN_STRIP_HTML) { | |
775 g_free(t1); | |
776 } | |
777 } | |
778 | |
779 } else { | |
780 | |
781 if (flags & WFLAG_RECV) { | |
782 strcpy(colour, "#ff0000"); | |
145
41bd1cd48571
[gaim-migrate @ 155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
128
diff
changeset
|
783 who = c->name; |
66 | 784 } else if (flags & WFLAG_SEND) { |
785 strcpy(colour, "#0000ff"); | |
786 who = current_user->username; | |
787 } | |
788 | |
145
41bd1cd48571
[gaim-migrate @ 155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
128
diff
changeset
|
789 if (flags & WFLAG_AUTO) |
66 | 790 sprintf(buf2, " %s", AUTO_RESPONSE); |
791 else | |
792 buf2[0]=0; /* sprintf(buf2, ""); */ | |
793 | |
794 if (display_options & OPT_DISP_SHOW_TIME) | |
795 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s %s:%s</B></FONT> ", colour, date(), who, buf2); | |
796 else | |
797 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s:%s</B></FONT> ", colour, who, buf2); | |
798 | |
799 gtk_html_freeze(GTK_HTML(c->text)); | |
800 | |
801 gtk_html_append_text(GTK_HTML(c->text), buf, 0); | |
802 gtk_html_append_text(GTK_HTML(c->text), what, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0); | |
803 | |
804 gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0); | |
805 | |
806 | |
807 gtk_html_thaw(GTK_HTML(c->text)); | |
808 | |
809 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { | |
810 char *t1, *t2; | |
811 | |
812 if (general_options & OPT_GEN_STRIP_HTML) { | |
813 t1 = strip_html(buf); | |
814 t2 = strip_html(what); | |
815 } else { | |
816 t1 = buf; | |
817 t2 = what; | |
818 } | |
819 fd = open_log_file(c); | |
820 fprintf(fd, "%s%s\n", t1, t2); | |
821 fclose(fd); | |
822 if (general_options & OPT_GEN_STRIP_HTML) { | |
823 g_free(t1); | |
824 g_free(t2); | |
825 } | |
826 } | |
827 } | |
828 | |
829 /* if (!GTK_WIDGET_MAPPED(c->window)) { | |
830 | |
831 if (dark_icon_pm == NULL) | |
832 dark_icon_pm = gdk_pixmap_create_from_xpm_d(c->window->window, &dark_icon_bm, | |
833 NULL, (gchar **)aimicon2_xpm); | |
834 gdk_window_set_icon(c->window->window, NULL, dark_icon_pm, dark_icon_bm); | |
835 } | |
836 */ | |
837 | |
838 if (general_options & OPT_GEN_POPUP_WINDOWS) | |
81 | 839 gdk_window_show(c->window->window); |
66 | 840 |
841 | |
842 g_free(buf); | |
843 g_free(buf2); | |
844 } | |
845 | |
846 | |
847 | |
206 | 848 static void check_spelling( GtkEditable * editable, gchar * new_text, |
849 gint length, gint * position, | |
850 gpointer data ) | |
851 { | |
207 | 852 if (general_options & OPT_GEN_CHECK_SPELLING) |
853 { | |
854 gtk_signal_handler_block_by_func(GTK_OBJECT(editable), | |
855 GTK_SIGNAL_FUNC(check_spelling), data); | |
856 gtk_text_set_point(GTK_TEXT(editable), *position); | |
857 gtk_text_insert(GTK_TEXT(editable), NULL, &(GTK_WIDGET(editable)->style->fg[0]), NULL, new_text, length ); | |
858 if(isspace(new_text[0])) | |
859 { | |
860 gtk_text_freeze(GTK_TEXT(editable)); | |
209 | 861 spell_checker(GTK_WIDGET(editable)); |
207 | 862 gtk_text_thaw(GTK_TEXT(editable)); |
863 } | |
864 gtk_signal_handler_unblock_by_func(GTK_OBJECT(editable), | |
865 GTK_SIGNAL_FUNC(check_spelling), data); | |
866 gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert-text"); | |
867 } | |
206 | 868 } |
66 | 869 |
870 | |
871 void show_conv(struct conversation *c) | |
872 { | |
873 GtkWidget *win; | |
874 char buf[256]; | |
875 GtkWidget *text; | |
876 GtkWidget *sw; | |
877 GtkWidget *send; | |
878 GtkWidget *info; | |
879 GtkWidget *warn; | |
880 GtkWidget *block; | |
881 GtkWidget *color; | |
882 GtkWidget *close; | |
883 GtkWidget *entry; | |
884 GtkWidget *toolbar; | |
885 GtkWidget *bbox; | |
886 GtkWidget *vbox; | |
81 | 887 GtkWidget *vbox2; |
888 GtkWidget *paned; | |
66 | 889 GtkWidget *add; |
890 GdkPixmap *strike_i, *small_i, *normal_i, *big_i, *bold_i, *italic_i, *underline_i, *speaker_i, *wood_i, *palette_i, *link_i; | |
891 GtkWidget *strike_p, *small_p, *normal_p, *big_p, *bold_p, *italic_p, *underline_p, *speaker_p, *wood_p, *palette_p, *link_p; | |
892 GtkWidget *strike, *small, *normal, *big, *bold, *italic, *underline, *speaker, *wood, *palette, *link; | |
893 GdkBitmap *mask; | |
894 | |
895 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
896 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); | |
897 | |
898 gtk_widget_realize(win); | |
899 aol_icon(win->window); | |
900 | |
901 | |
902 c->window = win; | |
903 | |
904 send = gtk_button_new_with_label("Send"); | |
905 info = gtk_button_new_with_label("Info"); | |
906 warn = gtk_button_new_with_label("Warn"); | |
907 color = gtk_button_new_with_label("Color"); | |
908 close = gtk_button_new_with_label("Close"); | |
909 if (find_buddy(c->name) != NULL) { | |
910 add = gtk_button_new_with_label("Remove"); | |
911 } | |
912 else { | |
913 add = gtk_button_new_with_label("Add"); | |
914 } | |
915 block = gtk_button_new_with_label("Block"); | |
916 | |
917 | |
918 bbox = gtk_hbox_new(TRUE, 0); | |
919 vbox = gtk_vbox_new(FALSE, 0); | |
81 | 920 vbox2 = gtk_vbox_new(FALSE, 0); |
921 paned = gtk_vpaned_new(); | |
66 | 922 |
81 | 923 gtk_paned_pack1(GTK_PANED(paned), vbox, FALSE, TRUE); |
924 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, FALSE); | |
925 gtk_widget_show(vbox2); | |
926 gtk_widget_show(paned); | |
927 | |
66 | 928 entry = gtk_text_new(NULL, NULL); |
929 gtk_text_set_editable(GTK_TEXT(entry), TRUE); | |
930 gtk_text_set_word_wrap(GTK_TEXT(entry), TRUE); | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
931 |
66 | 932 /* Toolbar */ |
933 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); | |
934 | |
935 link_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, | |
936 &win->style->white, link_xpm ); | |
937 link_p = gtk_pixmap_new(link_i, mask); | |
938 gtk_widget_show(link_p); | |
939 | |
940 palette_i = gdk_pixmap_create_from_xpm_d (win->window, &mask, | |
941 &win->style->white, palette_xpm ); | |
942 palette_p = gtk_pixmap_new(palette_i, mask); | |
943 gtk_widget_show(palette_p); | |
944 | |
945 wood_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
946 &win->style->white, wood_xpm ); | |
947 wood_p = gtk_pixmap_new(wood_i, mask); | |
948 gtk_widget_show(wood_p); | |
949 speaker_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
950 &win->style->white, speaker_xpm ); | |
951 speaker_p = gtk_pixmap_new(speaker_i, mask); | |
952 gtk_widget_show(speaker_p); | |
953 c->makesound=1; | |
954 strike_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
955 &win->style->white, strike_xpm ); | |
956 strike_p = gtk_pixmap_new(strike_i, mask); | |
957 gtk_widget_show(strike_p); | |
958 bold_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
959 &win->style->white, bold_xpm ); | |
960 bold_p = gtk_pixmap_new(bold_i, mask); | |
961 gtk_widget_show(bold_p); | |
962 italic_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
963 &win->style->white, italic_xpm ); | |
964 italic_p = gtk_pixmap_new(italic_i, mask); | |
965 gtk_widget_show(italic_p); | |
966 underline_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
967 &win->style->white, underline_xpm ); | |
968 underline_p = gtk_pixmap_new(underline_i, mask); | |
969 gtk_widget_show(underline_p); | |
970 small_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
971 &win->style->white, small_xpm ); | |
972 small_p = gtk_pixmap_new(small_i, mask); | |
973 gtk_widget_show(small_p); | |
974 normal_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
975 &win->style->white, normal_xpm ); | |
976 normal_p = gtk_pixmap_new(normal_i, mask); | |
977 gtk_widget_show(normal_p); | |
978 big_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, | |
979 &win->style->white, big_xpm ); | |
980 big_p = gtk_pixmap_new(big_i, mask); | |
981 gtk_widget_show(big_p); | |
982 | |
983 | |
984 bold = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
985 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, | |
986 "Bold", "Bold Text", "Bold", bold_p, | |
987 GTK_SIGNAL_FUNC(do_bold), entry); | |
988 italic = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
989 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
990 NULL, "Italics", "Italics Text", | |
991 "Italics", italic_p, GTK_SIGNAL_FUNC(do_italic), entry); | |
992 underline = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
993 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
994 NULL, "Underline", "Underline Text", | |
995 "Underline", underline_p, GTK_SIGNAL_FUNC(do_underline), entry); | |
996 strike = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
997 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
998 NULL, "Strike", "Strike through Text", | |
999 "Strike", strike_p, GTK_SIGNAL_FUNC(do_strike), entry); | |
1000 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); | |
1001 small = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Small", "Decrease font size", "Small", small_p, GTK_SIGNAL_FUNC(do_small), entry); | |
1002 normal = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Normal", "Normal font size", "Normal", normal_p, GTK_SIGNAL_FUNC(do_normal), entry); | |
1003 big = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Big", "Increase font size", "Big", big_p, GTK_SIGNAL_FUNC(do_big), entry); | |
1004 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); | |
1005 link = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
1006 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, "Link", "Insert Link", | |
1007 "Link", link_p, GTK_SIGNAL_FUNC(do_link), entry); | |
1008 palette = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
1009 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
1010 NULL, "Color", "Text Color", | |
1011 "Color", palette_p, GTK_SIGNAL_FUNC(toggle_color), entry); | |
1012 wood = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
1013 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
1014 NULL, "Logging", "Enable logging", | |
1015 "Logging", wood_p, GTK_SIGNAL_FUNC(toggle_loggle), c); | |
1016 speaker = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), | |
1017 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, | |
1018 NULL, "Sound", "Enable sounds", | |
1019 "Sound", speaker_p, GTK_SIGNAL_FUNC(set_option), &c->makesound); | |
1020 c->makesound=0; | |
1021 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(speaker), TRUE); | |
1022 | |
1023 state_lock = 1; | |
1024 if (find_log_info(c->name)) | |
1025 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), TRUE); | |
1026 else | |
1027 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), FALSE); | |
1028 state_lock = 0; | |
1029 | |
1030 gtk_widget_show(toolbar); | |
1031 | |
1032 c->entry = entry; | |
1033 c->bold = bold; | |
1034 c->strike = strike; | |
1035 c->italic = italic; | |
1036 c->underline = underline; | |
1037 c->log_button = wood; | |
1038 c->palette = palette; | |
1039 c->link = link; | |
1040 c->add_button = add; | |
1041 | |
1042 gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE); | |
1043 | |
1044 gtk_widget_set_sensitive(c->bold, ((font_options & OPT_FONT_BOLD)) ? FALSE : TRUE); | |
1045 gtk_widget_set_sensitive(c->italic, ((font_options & OPT_FONT_ITALIC)) ? FALSE : TRUE); | |
1046 gtk_widget_set_sensitive(c->underline, ((font_options & OPT_FONT_UNDERLINE)) ? FALSE : TRUE); | |
1047 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); | |
1048 | |
1049 gtk_object_set_user_data(GTK_OBJECT(entry), c); | |
1050 | |
1051 | |
1052 | |
1053 gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(send_callback),c); | |
1054 | |
1055 /* Text box */ | |
1056 | |
1057 | |
1058 text = gtk_html_new(NULL, NULL); | |
1059 | |
1060 gtk_html_set_editable(GTK_HTML(text), FALSE); | |
1061 /* gtk_html_set_transparent(GTK_HTML(text), (transparent) ? TRUE : FALSE);*/ | |
1062 c->text = text; | |
1063 | |
1064 sw = gtk_scrolled_window_new (NULL, NULL); | |
1065 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | |
1066 GTK_POLICY_NEVER, | |
1067 GTK_POLICY_ALWAYS); | |
1068 gtk_widget_show(sw); | |
1069 gtk_container_add(GTK_CONTAINER(sw), text); | |
1070 gtk_widget_show(text); | |
1071 | |
1072 | |
1073 | |
1074 | |
1075 GTK_HTML (text)->hadj->step_increment = 10.0; | |
1076 GTK_HTML (text)->vadj->step_increment = 10.0; | |
1077 gtk_widget_set_usize(sw, 320, 150); | |
1078 | |
1079 | |
1080 | |
1081 /* Ready and pack buttons */ | |
1082 gtk_object_set_user_data(GTK_OBJECT(win), c); | |
1083 gtk_object_set_user_data(GTK_OBJECT(close), c); | |
1084 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_callback), c); | |
1085 gtk_signal_connect(GTK_OBJECT(send), "clicked", GTK_SIGNAL_FUNC(send_callback), c); | |
1086 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(add_callback), c); | |
1087 gtk_signal_connect(GTK_OBJECT(info), "clicked", GTK_SIGNAL_FUNC(info_callback), c); | |
1088 gtk_signal_connect(GTK_OBJECT(warn), "clicked", GTK_SIGNAL_FUNC(warn_callback), c); | |
1089 gtk_signal_connect(GTK_OBJECT(block), "clicked", GTK_SIGNAL_FUNC(block_callback), c); | |
1090 gtk_signal_connect(GTK_OBJECT(color), "clicked", GTK_SIGNAL_FUNC(color_callback), c); | |
1091 | |
1092 gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(user_keypress_callback), c); | |
81 | 1093 gtk_widget_set_usize(entry, 300, 25); |
66 | 1094 |
1095 gtk_box_pack_start(GTK_BOX(bbox), send, TRUE, TRUE, 5); | |
1096 gtk_box_pack_start(GTK_BOX(bbox), info, TRUE, TRUE, 5); | |
1097 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 5); | |
1098 gtk_box_pack_start(GTK_BOX(bbox), block, TRUE, TRUE, 5); | |
1099 gtk_box_pack_start(GTK_BOX(bbox), color, TRUE, TRUE, 5); | |
1100 gtk_box_pack_start(GTK_BOX(bbox), add, TRUE, TRUE, 5); | |
1101 gtk_box_pack_start(GTK_BOX(bbox), close, TRUE, TRUE, 5); | |
1102 | |
1103 /* pack and fill the rest */ | |
1104 | |
1105 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 5); | |
81 | 1106 gtk_box_pack_start(GTK_BOX(vbox2), toolbar, FALSE, FALSE, 5); |
1107 gtk_box_pack_start(GTK_BOX(vbox2), entry, TRUE, TRUE, 5); | |
1108 gtk_box_pack_start(GTK_BOX(vbox2), bbox, FALSE, FALSE, 5); | |
66 | 1109 |
1110 | |
1111 | |
1112 | |
1113 gtk_widget_show(send); | |
1114 gtk_widget_show(info); | |
1115 gtk_widget_show(warn); | |
1116 /* gtk_widget_show(color); */ | |
1117 gtk_widget_show(close); | |
1118 gtk_widget_show(add); | |
1119 gtk_widget_show(block); | |
1120 gtk_widget_show(bbox); | |
1121 gtk_widget_show(vbox); | |
1122 gtk_widget_show(entry); | |
1123 gtk_widget_show(text); | |
1124 | |
67 | 1125 |
81 | 1126 gtk_container_add(GTK_CONTAINER(win), paned); |
66 | 1127 gtk_container_border_width(GTK_CONTAINER(win), 10); |
1128 | |
1129 if ((find_log_info(c->name)) || ((general_options & OPT_GEN_LOG_ALL))) | |
1130 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name); | |
1131 else | |
1132 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, c->name); | |
1133 gtk_window_set_title(GTK_WINDOW(win), buf); | |
1134 gtk_window_set_focus(GTK_WINDOW(win),entry); | |
1135 | |
1136 gtk_signal_connect(GTK_OBJECT(win), "delete_event", GTK_SIGNAL_FUNC(delete_event_convo), c); | |
206 | 1137 gtk_signal_connect(GTK_OBJECT(entry), "insert-text", GTK_SIGNAL_FUNC(check_spelling), entry); |
66 | 1138 gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(entry_key_pressed), entry); |
1139 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
1140 set_font_face(NULL, c); |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
1141 |
66 | 1142 gtk_widget_show(win); |
1143 } | |
1144 | |
1145 |