Mercurial > pidgin.yaz
comparison src/conversation.c @ 275:f9eb3eb9ffde
[gaim-migrate @ 285]
More patches from our friend fflewddur
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 28 May 2000 17:16:39 +0000 |
parents | 985635758c33 |
children | 0f14e6d8a51b |
comparison
equal
deleted
inserted
replaced
274:4dc94ab60421 | 275:f9eb3eb9ffde |
---|---|
51 GdkBitmap *dark_icon_bm = NULL; | 51 GdkBitmap *dark_icon_bm = NULL; |
52 | 52 |
53 char *fontface; | 53 char *fontface; |
54 | 54 |
55 void check_everything(GtkWidget *entry); | 55 void check_everything(GtkWidget *entry); |
56 char *get_tag_by_prefix(GtkWidget *entry, const char *prefix); | |
56 gboolean user_keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c); | 57 gboolean user_keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c); |
57 | 58 |
58 /*------------------------------------------------------------------------*/ | 59 /*------------------------------------------------------------------------*/ |
59 /* Helpers */ | 60 /* Helpers */ |
60 /*------------------------------------------------------------------------*/ | 61 /*------------------------------------------------------------------------*/ |
133 } | 134 } |
134 g_free(cuser); | 135 g_free(cuser); |
135 return NULL; | 136 return NULL; |
136 } | 137 } |
137 | 138 |
139 /* given the first part of a tag, returns the length up to the final '>'; | |
140 useful for 'remove_tags' calls on variable data, such as <font face> | |
141 tags */ | |
142 char *get_tag_by_prefix(GtkWidget *entry, const char *prefix) | |
143 { | |
144 char *s, *t; | |
145 int i = 0; | |
146 | |
147 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
148 t = s; | |
149 | |
150 if (t = strstr(s, prefix)) | |
151 { | |
152 for (i = 1; t[i] != '\0'; i++) | |
153 { | |
154 | |
155 if (t[i] == '>') | |
156 break; | |
157 } | |
158 | |
159 t = gtk_editable_get_chars(GTK_EDITABLE(entry), (t-s), (t-s) + i + 1); | |
160 } | |
161 return t; | |
162 } | |
163 | |
138 /* --------------------------------------------------- | 164 /* --------------------------------------------------- |
139 * Function to remove a log file entry | 165 * Function to remove a log file entry |
140 * --------------------------------------------------- | 166 * --------------------------------------------------- |
141 */ | 167 */ |
142 | 168 |
270 return TRUE; | 296 return TRUE; |
271 } | 297 } |
272 | 298 |
273 void set_font_face(GtkWidget *widget, struct conversation *c) | 299 void set_font_face(GtkWidget *widget, struct conversation *c) |
274 { | 300 { |
275 char *pre_fontface; | 301 char *pre_fontface, *old_font_face; |
276 int alloc = 0; | 302 int alloc = 0, length; |
277 | 303 |
278 if (!(font_options & OPT_FONT_FACE)) | 304 if (!(font_options & OPT_FONT_FACE)) |
279 return; | 305 return; |
280 | 306 |
281 if (c->current_fontface && strcmp(c->current_fontface, "(null)")) | 307 if (c->current_fontface && strcmp(c->current_fontface, "(null)")) |
290 { | 316 { |
291 g_free(pre_fontface); | 317 g_free(pre_fontface); |
292 alloc--; | 318 alloc--; |
293 pre_fontface = "<FONT FACE=\"Helvetica\">"; | 319 pre_fontface = "<FONT FACE=\"Helvetica\">"; |
294 } | 320 } |
295 | 321 |
322 if (old_font_face = get_tag_by_prefix(c->entry, "<FONT FACE")) | |
323 { | |
324 remove_tags(c->entry, old_font_face); | |
325 remove_tags(c->entry, "</FONT>"); | |
326 } | |
327 | |
296 surround(c->entry, pre_fontface, "</FONT>"); | 328 surround(c->entry, pre_fontface, "</FONT>"); |
297 gtk_widget_grab_focus(c->entry); | 329 gtk_widget_grab_focus(c->entry); |
298 | 330 |
299 if (alloc) | 331 if (alloc) |
300 g_free(pre_fontface); | 332 g_free(pre_fontface); |
333 | |
334 g_free(old_font_face); /* mem allocated in get_tag_by_prefix() */ | |
301 return; | 335 return; |
302 } | 336 } |
303 | 337 |
304 static gint delete_event_convo(GtkWidget *w, GdkEventAny *e, struct conversation *c) | 338 static gint delete_event_convo(GtkWidget *w, GdkEventAny *e, struct conversation *c) |
305 { | 339 { |
541 } | 575 } |
542 | 576 |
543 | 577 |
544 void remove_tags(GtkWidget *entry, char *tag) | 578 void remove_tags(GtkWidget *entry, char *tag) |
545 { | 579 { |
546 char *s; | 580 char *s, *t; |
547 char *t; | |
548 int start = GTK_EDITABLE(entry)->selection_start_pos; | 581 int start = GTK_EDITABLE(entry)->selection_start_pos; |
549 int finish = GTK_EDITABLE(entry)->selection_end_pos; | 582 int finish = GTK_EDITABLE(entry)->selection_end_pos; |
550 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | 583 int temp; |
584 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
551 t = s; | 585 t = s; |
586 | |
587 if (start > finish) | |
588 { | |
589 temp = start; | |
590 start = finish; | |
591 finish = temp; | |
592 } | |
593 | |
552 if (strstr(tag, "<FONT SIZE=")) | 594 if (strstr(tag, "<FONT SIZE=")) |
553 { | 595 { |
554 while((t = strstr(t, "<FONT SIZE="))) { | 596 while((t = strstr(t, "<FONT SIZE="))) { |
555 if (((t-s) < finish) && ((t-s) >= start)) { | 597 if (((t-s) < finish) && ((t-s) >= start)) { |
556 gtk_editable_delete_text(GTK_EDITABLE(entry), (t-s), (t-s) + strlen(tag)); | 598 gtk_editable_delete_text(GTK_EDITABLE(entry), (t-s), (t-s) + strlen(tag)); |