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