Mercurial > pidgin.yaz
changeset 8741:b994b0223335
[gaim-migrate @ 9496]
Janitorial work! Removed some functions that gtkimhtml made useless.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 21 Apr 2004 06:48:16 +0000 |
parents | 61a090413b93 |
children | 075f2e7cec73 |
files | src/gtkutils.c src/gtkutils.h |
diffstat | 2 files changed, 1 insertions(+), 194 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkutils.c Wed Apr 21 06:13:49 2004 +0000 +++ b/src/gtkutils.c Wed Apr 21 06:48:16 2004 +0000 @@ -93,170 +93,6 @@ (*text != '\0')); } -static void -gaim_gtk_remove_tags(GaimGtkConversation *gtkconv, const char *tag) -{ - GtkTextIter start, end, m_start, m_end; - - if (gtkconv == NULL || tag == NULL) - return; - - if (!gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer, - &start, &end)) - return; - - /* FIXMEif (strstr(tag, "<FONT SIZE=")) { - while ((t = strstr(t, "<FONT SIZE="))) { - if (((t - s) < finish) && ((t - s) >= start)) { - gtk_editable_delete_text(GTK_EDITABLE(entry), (t - s), - (t - s) + strlen(tag)); - g_free(s); - s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); - t = s; - } else - t++; - } - } else*/ { - while (gtk_text_iter_forward_search(&start, tag, 0, &m_start, - &m_end, &end)) { - - gtk_text_buffer_delete(gtkconv->entry_buffer, &m_start, &m_end); - gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer, - &start, &end); - } - } -} - -void -gaim_gtk_surround(GaimGtkConversation *gtkconv, - const char *pre, const char *post) -{ - GtkTextIter start, end; - GtkTextMark *mark_start, *mark_end; - GtkTextBuffer *entry_buffer; - - if (gtkconv == NULL || pre == NULL || post == NULL) - return; - - entry_buffer = gtkconv->entry_buffer; - - if (gtk_text_buffer_get_selection_bounds(entry_buffer, - &start, &end)) { - gaim_gtk_remove_tags(gtkconv, pre); - gaim_gtk_remove_tags(gtkconv, post); - - mark_start = gtk_text_buffer_create_mark(entry_buffer, "m1", - &start, TRUE); - mark_end = gtk_text_buffer_create_mark(entry_buffer, "m2", - &end, FALSE); - gtk_text_buffer_insert(entry_buffer, &start, pre, -1); - gtk_text_buffer_get_selection_bounds(entry_buffer, &start, &end); - gtk_text_buffer_insert(entry_buffer, &end, post, -1); - gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start); - gtk_text_buffer_move_mark_by_name(entry_buffer, "selection_bound", - &start); - } else { - gtk_text_buffer_insert(entry_buffer, &start, pre, -1); - gtk_text_buffer_insert(entry_buffer, &start, post, -1); - mark_start = gtk_text_buffer_get_insert(entry_buffer); - gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start); - gtk_text_iter_backward_chars(&start, strlen(post)); - gtk_text_buffer_place_cursor(entry_buffer, &start); - } - - gtk_widget_grab_focus(gtkconv->entry); -} - -static gboolean -invert_tags(GtkTextBuffer *buffer, const char *s1, const char *s2, - gboolean really) -{ - GtkTextIter start1, start2, end1, end2; - char *b1, *b2; - - if (gtk_text_buffer_get_selection_bounds(buffer, &start1, &end2)) { - start2 = start1; - end1 = end2; - - if (!gtk_text_iter_forward_chars(&start2, strlen(s1))) - return FALSE; - - if (!gtk_text_iter_backward_chars(&end1, strlen(s2))) - return FALSE; - - b1 = gtk_text_buffer_get_text(buffer, &start1, &start2, FALSE); - b2 = gtk_text_buffer_get_text(buffer, &end1, &end2, FALSE); - - if (!g_ascii_strncasecmp(b1, s1, strlen(s1)) && - !g_ascii_strncasecmp(b2, s2, strlen(s2))) { - - if (really) { - GtkTextMark *m_end1, *m_end2; - - m_end1= gtk_text_buffer_create_mark(buffer, "m1", &end1, TRUE); - m_end2= gtk_text_buffer_create_mark(buffer, "m2", &end2, TRUE); - - gtk_text_buffer_delete(buffer, &start1, &start2); - gtk_text_buffer_get_iter_at_mark(buffer, &end1, m_end1); - gtk_text_buffer_get_iter_at_mark(buffer, &end2, m_end2); - gtk_text_buffer_delete(buffer, &end1, &end2); - gtk_text_buffer_delete_mark(buffer, m_end1); - gtk_text_buffer_delete_mark(buffer, m_end2); - } - - g_free(b1); - g_free(b2); - - return TRUE; - } - - g_free(b1); - g_free(b2); - } - - return FALSE; -} - -void -gaim_gtk_advance_past(GaimGtkConversation *gtkconv, - const char *pre, const char *post) -{ - GtkTextIter current_pos, start, end; - - if (invert_tags(gtkconv->entry_buffer, pre, post, TRUE)) - return; - - gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, ¤t_pos, - gtk_text_buffer_get_insert(gtkconv->entry_buffer)); - - if (gtk_text_iter_forward_search(¤t_pos, post, 0, - &start, &end, NULL)) - gtk_text_buffer_place_cursor(gtkconv->entry_buffer, &end); - else - gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, post, -1); - - gtk_widget_grab_focus(gtkconv->entry); -} - -void -gaim_gtk_set_font_face(GaimGtkConversation *gtkconv, - const char *font) -{ - if (gtkconv == NULL || font == NULL) - return; - - strncpy(gtkconv->fontface, - (font && *font ? font : DEFAULT_FONT_FACE), - sizeof(gtkconv->fontface)); - - gtkconv->has_font = TRUE; - - gtk_imhtml_toggle_fontface(GTK_IMHTML(gtkconv->entry), gtkconv->fontface); - - gtk_widget_grab_focus(gtkconv->entry); - -} - static int des_save_icon(GtkObject *obj, GdkEvent *e, GaimGtkConversation *gtkconv)
--- a/src/gtkutils.h Wed Apr 21 06:13:49 2004 +0000 +++ b/src/gtkutils.h Wed Apr 21 06:48:16 2004 +0000 @@ -52,6 +52,7 @@ GAIM_BROWSER_CURRENT, GAIM_BROWSER_NEW_WINDOW, GAIM_BROWSER_NEW_TAB + } GaimBrowserPlace; #endif /* _WIN32 */ @@ -66,36 +67,6 @@ void gaim_setup_imhtml(GtkWidget *imhtml); /** - * Surrounds the selected text in a conversation with the specified - * pre and post strings. - * - * @param gtkconv The GTK+ conversation. - * @param pre The prefix string. - * @param post The postfix string. - */ -void gaim_gtk_surround(GaimGtkConversation *gtkconv, - const char *pre, const char *post); - -/** - * Advances the cursor past the position of the specified tags. - * - * @param gtkconv The GTK+ conversation. - * @param pre The prefix string. - * @param post The postfix string. - */ -void gaim_gtk_advance_past(GaimGtkConversation *gtkconv, - const char *pre, const char *post); - -/** - * Surrounds the selected text with the specified font. - * - * @param gtkconv The GTK+ conversation. - * @param font The new font. - */ -void gaim_gtk_set_font_face(GaimGtkConversation *gtkconv, - const char *font); - -/** * Displays a dialog for saving the buddy icon in a conversation. * * @param obj @c NULL