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