Mercurial > pidgin
changeset 11267:477e5cca8287
[gaim-migrate @ 13449]
Combining the Message Text tab in the preferences into the Conversation tab.
Along the way, I found and fixed a number of bugs relating to the formatting toolbar, etc.
This also includes part of patch #1240388 from Sadrul. I'm still seeing a couple bugs with the backcolor stuff, but I confirmed they were there before this change. Hopefully I haven't introduced any new bugs. Holler at me if I did.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 15 Aug 2005 04:15:22 +0000 |
parents | a0e769ca84cf |
children | e17f09e77785 |
files | plugins/ChangeLog.API src/gtkconv.c src/gtkimhtml.c src/gtkimhtml.h src/gtkimhtmltoolbar.c src/gtkprefs.c |
diffstat | 6 files changed, 388 insertions(+), 335 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChangeLog.API Mon Aug 15 04:15:11 2005 +0000 +++ b/plugins/ChangeLog.API Mon Aug 15 04:15:22 2005 +0000 @@ -68,6 +68,9 @@ to send messages to the specified account * Changed: A new blocked icon: pixmaps/status/default/blocked.png * Removed: All warning stuff from the core. + * Changed: gtk_imhtml_toggle_bold, gtk_imhtml_toggle_italic, + gtk_imhtml_toggle_underline, gtk_imhtml_toggle_strike: + no longer return a value Signals: * Changed: "received-im-msg" and "received-chat-msg" to match, both
--- a/src/gtkconv.c Mon Aug 15 04:15:11 2005 +0000 +++ b/src/gtkconv.c Mon Aug 15 04:15:22 2005 +0000 @@ -300,64 +300,85 @@ } static void +clear_format(GaimGtkConversation *c) +{ + gboolean bold, italic, uline; + bold = italic = uline = FALSE; + + gtk_imhtml_get_current_format(GTK_IMHTML(c->entry), &bold, &italic, &uline); + if (bold) + gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); + if (italic) + gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); + if (uline) + gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); + + gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), 3); + gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), NULL); + + gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), NULL); + gtk_imhtml_toggle_backcolor(GTK_IMHTML(c->entry), NULL); + gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), NULL); + + gtk_widget_grab_focus(c->entry); +} + +static void default_formatize(GaimGtkConversation *c) { GaimConversation *conv = c->active_conv; if (conv->features & GAIM_CONNECTION_HTML) { - if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_formatting")) + char *color; + GdkColor fg_color, bg_color; + + if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) + gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); + + if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) + gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); + + if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline") != GTK_IMHTML(c->entry)->edit.underline) + gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); + + gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), + gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); + + if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) + gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), + gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); + + if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) { - char *color; - GdkColor fg_color, bg_color; - - if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) - gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); - - if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) - gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); - - if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline") != GTK_IMHTML(c->entry)->edit.underline) - gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); - - gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), - gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); - - if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) - gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), - gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); - - if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) - { - gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), - &fg_color); - color = g_strdup_printf("#%02x%02x%02x", - fg_color.red / 256, - fg_color.green / 256, - fg_color.blue / 256); - } - else - color = g_strdup(""); - - gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); - g_free(color); - - if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && - strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) - { - gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), - &bg_color); - color = g_strdup_printf("#%02x%02x%02x", - bg_color.red / 256, - bg_color.green / 256, - bg_color.blue / 256); - } - else - color = g_strdup(""); - - gtk_imhtml_toggle_backcolor(GTK_IMHTML(c->entry), color); - g_free(color); + gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), + &fg_color); + color = g_strdup_printf("#%02x%02x%02x", + fg_color.red / 256, + fg_color.green / 256, + fg_color.blue / 256); } + else + color = g_strdup(""); + + gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); + g_free(color); + + if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && + strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) + { + gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), + &bg_color); + color = g_strdup_printf("#%02x%02x%02x", + bg_color.red / 256, + bg_color.green / 256, + bg_color.blue / 256); + } + else + color = g_strdup(""); + + gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); + g_free(color); if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) @@ -586,7 +607,6 @@ if (check_for_and_do_command(conv)) { gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); - default_formatize(gtkconv); return; } @@ -628,7 +648,6 @@ g_free(buf); gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); - default_formatize(gtkconv); } static void @@ -1771,6 +1790,7 @@ conv->send_history = conv->send_history->next; gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); + clear_format(gtkconv); gtk_imhtml_append_text_with_images( GTK_IMHTML(gtkconv->entry), conv->send_history->data, 0, NULL); @@ -1794,13 +1814,19 @@ conv->send_history = conv->send_history->prev; gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); + clear_format(gtkconv); gtk_imhtml_append_text_with_images( GTK_IMHTML(gtkconv->entry), conv->send_history->data, 0, NULL); /* this is mainly just a hack so the formatting at the * cursor gets picked up. */ - gtk_text_buffer_get_end_iter(buffer, &iter); - gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); + if (*(char *)conv->send_history->data) { + gtk_text_buffer_get_end_iter(buffer, &iter); + gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); + } else { + /* Restore the default formatting */ + default_formatize(gtkconv); + } } return TRUE; @@ -4998,7 +5024,7 @@ gtk_font_options |= GTK_IMHTML_NO_COMMENTS; - if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_formatting")) + if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES; /* this is gonna crash one day, I can feel it. */ @@ -6207,13 +6233,8 @@ gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); -#if 0 - gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_colors", FALSE); - gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_fonts", FALSE); - gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_font_sizes", FALSE); -#else - gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_formatting", FALSE); -#endif + gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); + gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE);
--- a/src/gtkimhtml.c Mon Aug 15 04:15:11 2005 +0000 +++ b/src/gtkimhtml.c Mon Aug 15 04:15:22 2005 +0000 @@ -108,6 +108,12 @@ static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data); static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data); static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext); +static void imhtml_toggle_bold(GtkIMHtml *imhtml); +static void imhtml_toggle_italic(GtkIMHtml *imhtml); +static void imhtml_toggle_strike(GtkIMHtml *imhtml); +static void imhtml_toggle_underline(GtkIMHtml *imhtml); +static void imhtml_font_grow(GtkIMHtml *imhtml); +static void imhtml_font_shrink(GtkIMHtml *imhtml); /* POINT_SIZE converts from AIM font sizes to a point size scale factor. */ #define MAX_FONT_SIZE 7 @@ -952,9 +958,9 @@ gtk_imhtml_close_tags(imhtml, &iter); gtk_imhtml_insert_html_at_iter(imhtml, text, flags, &iter); - if (!imhtml->wbfo && !plaintext) - gtk_imhtml_close_tags(imhtml, &iter); - gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); + if (!imhtml->wbfo && !plaintext) + gtk_imhtml_close_tags(imhtml, &iter); + gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), gtk_text_buffer_get_insert(imhtml->text_buffer), 0, FALSE, 0.0, 0.0); } @@ -1112,19 +1118,22 @@ switch (buttons) { case GTK_IMHTML_BOLD: - gtk_imhtml_toggle_bold(imhtml); + imhtml_toggle_bold(imhtml); break; case GTK_IMHTML_ITALIC: - gtk_imhtml_toggle_italic(imhtml); + imhtml_toggle_italic(imhtml); break; case GTK_IMHTML_UNDERLINE: - gtk_imhtml_toggle_underline(imhtml); + imhtml_toggle_underline(imhtml); + break; + case GTK_IMHTML_STRIKE: + imhtml_toggle_strike(imhtml); break; case GTK_IMHTML_SHRINK: - gtk_imhtml_font_shrink(imhtml); + imhtml_font_shrink(imhtml); break; case GTK_IMHTML_GROW: - gtk_imhtml_font_grow(imhtml); + imhtml_font_grow(imhtml); break; default: break; @@ -3799,6 +3808,15 @@ return NULL; } +char * +gtk_imhtml_get_current_background(GtkIMHtml *imhtml) +{ + if (imhtml->edit.background) + return g_strdup(imhtml->edit.background); + else + return NULL; +} + gint gtk_imhtml_get_current_fontsize(GtkIMHtml *imhtml) { @@ -3886,9 +3904,8 @@ g_slist_free(tags); } -gboolean gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) +static void imhtml_toggle_bold(GtkIMHtml *imhtml) { - GObject *object; GtkTextIter start, end; imhtml->edit.bold = !imhtml->edit.bold; @@ -3906,15 +3923,21 @@ gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); } - object = g_object_ref(G_OBJECT(imhtml)); - g_object_unref(object); - - return (imhtml->edit.bold != FALSE); } -gboolean gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) +void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) { GObject *object; + + g_return_if_fail(imhtml != NULL); + + object = g_object_ref(G_OBJECT(imhtml)); + g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_BOLD); + g_object_unref(object); +} + +static void imhtml_toggle_italic(GtkIMHtml *imhtml) +{ GtkTextIter start, end; imhtml->edit.italic = !imhtml->edit.italic; @@ -3931,15 +3954,20 @@ else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); } - object = g_object_ref(G_OBJECT(imhtml)); - g_object_unref(object); - - return imhtml->edit.italic != FALSE; } -gboolean gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) +void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) { GObject *object; + + g_return_if_fail(imhtml != NULL); + + object = g_object_ref(G_OBJECT(imhtml)); + g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_ITALIC); + g_object_unref(object);} + +static void imhtml_toggle_underline(GtkIMHtml *imhtml) +{ GtkTextIter start, end; imhtml->edit.underline = !imhtml->edit.underline; @@ -3956,15 +3984,21 @@ else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); } - object = g_object_ref(G_OBJECT(imhtml)); - g_object_unref(object); - - return imhtml->edit.underline != FALSE; } -gboolean gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) +void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) { GObject *object; + + g_return_if_fail(imhtml != NULL); + + object = g_object_ref(G_OBJECT(imhtml)); + g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_UNDERLINE); + g_object_unref(object); +} + +static void imhtml_toggle_strike(GtkIMHtml *imhtml) +{ GtkTextIter start, end; imhtml->edit.strike = !imhtml->edit.strike; @@ -3981,21 +4015,26 @@ else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); } +} + +void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) +{ + GObject *object; + + g_return_if_fail(imhtml != NULL); + object = g_object_ref(G_OBJECT(imhtml)); + g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_STRIKE); g_object_unref(object); - - return imhtml->edit.strike != FALSE; } void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size) { GObject *object; GtkTextIter start, end; - GtkIMHtmlButtons b = 0; imhtml->edit.fontsize = size; - if (imhtml->wbfo) { gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); remove_font_size(imhtml, &start, &end, TRUE); @@ -4008,14 +4047,12 @@ } object = g_object_ref(G_OBJECT(imhtml)); - b |= GTK_IMHTML_SHRINK; - b |= GTK_IMHTML_GROW; + g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK | GTK_IMHTML_GROW); g_object_unref(object); } -void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) +static void imhtml_font_shrink(GtkIMHtml *imhtml) { - GObject *object; GtkTextIter start, end; if (imhtml->edit.fontsize == 1) @@ -4036,13 +4073,21 @@ gtk_text_buffer_apply_tag(imhtml->text_buffer, find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); } +} + +void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) +{ + GObject *object; + + g_return_if_fail(imhtml != NULL); + object = g_object_ref(G_OBJECT(imhtml)); + g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK); g_object_unref(object); } -void gtk_imhtml_font_grow(GtkIMHtml *imhtml) +static void imhtml_font_grow(GtkIMHtml *imhtml) { - GObject *object; GtkTextIter start, end; if (imhtml->edit.fontsize == MAX_FONT_SIZE) @@ -4063,11 +4108,20 @@ gtk_text_buffer_apply_tag(imhtml->text_buffer, find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); } +} + +void gtk_imhtml_font_grow(GtkIMHtml *imhtml) +{ + GObject *object; + + g_return_if_fail(imhtml != NULL); + object = g_object_ref(G_OBJECT(imhtml)); + g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_GROW); g_object_unref(object); } -#define gtk_imhtml_toggle_str_tag(imhtml, color, edit_field, remove_func, find_func) { \ +#define gtk_imhtml_toggle_str_tag(imhtml, color, edit_field, remove_func, find_func, button) { \ GObject *object; \ GtkTextIter start, end; \ \ @@ -4101,6 +4155,7 @@ } \ \ object = g_object_ref(G_OBJECT(imhtml)); \ + g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); \ g_object_unref(object); \ \ return edit_field != NULL; \ @@ -4108,22 +4163,22 @@ gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color) { - gtk_imhtml_toggle_str_tag(imhtml, color, imhtml->edit.forecolor, remove_font_forecolor, find_font_forecolor_tag); + gtk_imhtml_toggle_str_tag(imhtml, color, imhtml->edit.forecolor, remove_font_forecolor, find_font_forecolor_tag, GTK_IMHTML_FORECOLOR); } gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color) { - gtk_imhtml_toggle_str_tag(imhtml, color, imhtml->edit.backcolor, remove_font_backcolor, find_font_backcolor_tag); + gtk_imhtml_toggle_str_tag(imhtml, color, imhtml->edit.backcolor, remove_font_backcolor, find_font_backcolor_tag, GTK_IMHTML_BACKCOLOR); } gboolean gtk_imhtml_toggle_background(GtkIMHtml *imhtml, const char *color) { - gtk_imhtml_toggle_str_tag(imhtml, color, imhtml->edit.background, remove_font_background, find_font_background_tag); + gtk_imhtml_toggle_str_tag(imhtml, color, imhtml->edit.background, remove_font_background, find_font_background_tag, GTK_IMHTML_BACKGROUND); } gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face) { - gtk_imhtml_toggle_str_tag(imhtml, face, imhtml->edit.fontface, remove_font_face, find_font_face_tag); + gtk_imhtml_toggle_str_tag(imhtml, face, imhtml->edit.fontface, remove_font_face, find_font_face_tag, GTK_IMHTML_FACE); } void gtk_imhtml_toggle_link(GtkIMHtml *imhtml, const char *url) @@ -4137,8 +4192,6 @@ imhtml->edit.link = NULL; - - if (url) { g_snprintf(str, sizeof(str), "LINK %d", linkno++); str[47] = '\0';
--- a/src/gtkimhtml.h Mon Aug 15 04:15:11 2005 +0000 +++ b/src/gtkimhtml.h Mon Aug 15 04:15:22 2005 +0000 @@ -579,37 +579,29 @@ * Toggles bold at the cursor location or selection in a GTK+ IM/HTML. * * @param imhtml The GTK+ IM/HTML. - * - * @return @c TRUE if bold was turned on, or @c FALSE if it was turned off. */ -gboolean gtk_imhtml_toggle_bold(GtkIMHtml *imhtml); +void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml); /** * Toggles italic at the cursor location or selection in a GTK+ IM/HTML. * * @param imhtml The GTK+ IM/HTML. - * - * @return @c TRUE if italic was turned on, or @c FALSE if it was turned off. */ -gboolean gtk_imhtml_toggle_italic(GtkIMHtml *imhtml); +void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml); /** * Toggles underline at the cursor location or selection in a GTK+ IM/HTML. * * @param imhtml The GTK+ IM/HTML. - * - * @return @c TRUE if underline was turned on, or @c FALSE if it was turned off. */ -gboolean gtk_imhtml_toggle_underline(GtkIMHtml *imhtml); +void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml); /** * Toggles strikethrough at the cursor location or selection in a GTK+ IM/HTML. * * @param imhtml The GTK+ IM/HTML. - * - * @return @c TRUE if strikethrough was turned on, or @c FALSE if it was turned off. */ -gboolean gtk_imhtml_toggle_strike(GtkIMHtml *imhtml); +void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml); /** * Toggles a foreground color at the current location or selection in a GTK
--- a/src/gtkimhtmltoolbar.c Mon Aug 15 04:15:11 2005 +0000 +++ b/src/gtkimhtmltoolbar.c Mon Aug 15 04:15:22 2005 +0000 @@ -40,67 +40,32 @@ static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar) { - GObject *object; - - g_return_if_fail(toolbar); - - /* block the format_function_toggle handler */ - object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml))); - g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, - NULL, toolbar); + g_return_if_fail(toolbar != NULL); gtk_imhtml_toggle_bold(GTK_IMHTML(toolbar->imhtml)); - g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, - NULL, toolbar); - g_object_unref(object); - gtk_widget_grab_focus(toolbar->imhtml); } static void do_italic(GtkWidget *italic, GtkIMHtmlToolbar *toolbar) { - GObject *object; - - g_return_if_fail(toolbar); - - /* block the format_function_toggle handler */ - object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml))); - g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, - NULL, toolbar); + g_return_if_fail(toolbar != NULL); gtk_imhtml_toggle_italic(GTK_IMHTML(toolbar->imhtml)); - g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, - NULL, toolbar); - g_object_unref(object); - gtk_widget_grab_focus(toolbar->imhtml); } static void do_underline(GtkWidget *underline, GtkIMHtmlToolbar *toolbar) { - GObject *object; - - g_return_if_fail(toolbar); - - /* block the format_function_toggle handler */ - object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml))); - g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, - NULL, toolbar); + g_return_if_fail(toolbar != NULL); gtk_imhtml_toggle_underline(GTK_IMHTML(toolbar->imhtml)); - g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, - NULL, toolbar); - g_object_unref(object); - gtk_widget_grab_focus(toolbar->imhtml); } static void do_small(GtkWidget *smalltb, GtkIMHtmlToolbar *toolbar) { - g_return_if_fail(toolbar); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size))) - gtk_imhtml_font_shrink(GTK_IMHTML(toolbar->imhtml)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size), FALSE); + g_return_if_fail(toolbar != NULL); + gtk_imhtml_font_shrink(GTK_IMHTML(toolbar->imhtml)); gtk_widget_grab_focus(toolbar->imhtml); } @@ -108,9 +73,7 @@ do_big(GtkWidget *large, GtkIMHtmlToolbar *toolbar) { g_return_if_fail(toolbar); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->larger_size))) - gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->larger_size), FALSE); + gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml)); gtk_widget_grab_focus(toolbar->imhtml); } @@ -119,7 +82,7 @@ GtkIMHtmlToolbar *toolbar) { if (widget != NULL) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->font), FALSE); + gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), ""); if (toolbar->font_dialog != NULL) { @@ -161,7 +124,6 @@ *space = '\0'; gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), fontname); - g_free(fontname); cancel_toolbar_font(NULL, toolbar); @@ -170,40 +132,39 @@ static void toggle_font(GtkWidget *font, GtkIMHtmlToolbar *toolbar) { - char *fontname; - g_return_if_fail(toolbar); - fontname = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml)); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(font))) { + char *fontname = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml)); - if (!toolbar->font_dialog) { - toolbar->font_dialog = gtk_font_selection_dialog_new(_("Select Font")); + if (!toolbar->font_dialog) { + toolbar->font_dialog = gtk_font_selection_dialog_new(_("Select Font")); - g_object_set_data(G_OBJECT(toolbar->font_dialog), "gaim_toolbar", toolbar); + g_object_set_data(G_OBJECT(toolbar->font_dialog), "gaim_toolbar", toolbar); - if(fontname) { - char fonttif[128]; - g_snprintf(fonttif, sizeof(fonttif), "%s 12", fontname); - gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog), - fonttif); - g_free(fontname); - } else { - gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog), - DEFAULT_FONT_FACE); + if(fontname) { + char *fonttif = g_strdup_printf("%s 12", fontname); + g_free(fontname); + gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog), + fonttif); + g_free(fonttif); + } else { + gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog), + DEFAULT_FONT_FACE); + } + + g_signal_connect(G_OBJECT(toolbar->font_dialog), "delete_event", + G_CALLBACK(destroy_toolbar_font), toolbar); + g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)->ok_button), "clicked", + G_CALLBACK(apply_font), toolbar->font_dialog); + g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)->cancel_button), "clicked", + G_CALLBACK(cancel_toolbar_font), toolbar); + g_signal_connect_after(G_OBJECT(toolbar->font_dialog), "realize", + G_CALLBACK(realize_toolbar_font), toolbar); } - - g_signal_connect(G_OBJECT(toolbar->font_dialog), "delete_event", - G_CALLBACK(destroy_toolbar_font), toolbar); - g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)->ok_button), "clicked", - G_CALLBACK(apply_font), toolbar->font_dialog); - g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)->cancel_button), "clicked", - G_CALLBACK(cancel_toolbar_font), toolbar); - g_signal_connect_after(G_OBJECT(toolbar->font_dialog), "realize", - G_CALLBACK(realize_toolbar_font), toolbar); - gtk_window_present(GTK_WINDOW(toolbar->font_dialog)); } else { - cancel_toolbar_font(NULL, toolbar); + cancel_toolbar_font(font, toolbar); } gtk_widget_grab_focus(toolbar->imhtml); } @@ -213,7 +174,7 @@ GtkIMHtmlToolbar *toolbar) { if (widget != NULL) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->fgcolor), FALSE); + gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), ""); if (toolbar->fgcolor_dialog != NULL) { @@ -241,8 +202,8 @@ text_color.green / 256, text_color.blue / 256); gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), open_tag); + g_free(open_tag); - g_free(open_tag); cancel_toolbar_fgcolor(NULL, toolbar); } @@ -272,13 +233,10 @@ G_CALLBACK(do_fgcolor), colorsel); g_signal_connect(G_OBJECT (GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog)->cancel_button), "clicked", G_CALLBACK(cancel_toolbar_fgcolor), toolbar); - } gtk_window_present(GTK_WINDOW(toolbar->fgcolor_dialog)); - } else if (toolbar->fgcolor_dialog != NULL) { + } else { cancel_toolbar_fgcolor(color, toolbar); - } else { - /* gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); */ } gtk_widget_grab_focus(toolbar->imhtml); } @@ -287,8 +245,12 @@ destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event, GtkIMHtmlToolbar *toolbar) { - if (widget != NULL) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->bgcolor), FALSE); + if (widget != NULL) { + if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, NULL, NULL)) + gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), ""); + else + gtk_imhtml_toggle_background(GTK_IMHTML(toolbar->imhtml), ""); + } if (toolbar->bgcolor_dialog != NULL) { @@ -319,8 +281,8 @@ gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), open_tag); else gtk_imhtml_toggle_background(GTK_IMHTML(toolbar->imhtml), open_tag); + g_free(open_tag); - g_free(open_tag); cancel_toolbar_bgcolor(NULL, toolbar); } @@ -353,10 +315,8 @@ } gtk_window_present(GTK_WINDOW(toolbar->bgcolor_dialog)); - } else if (toolbar->bgcolor_dialog != NULL) { + } else { cancel_toolbar_bgcolor(color, toolbar); - } else { - /* gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); */ } gtk_widget_grab_focus(toolbar->imhtml); } @@ -805,24 +765,6 @@ g_object_unref(object); } -static void toggle_button_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) -{ - if (buttons & GTK_IMHTML_BOLD) - toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), - !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)), - toolbar); - - if (buttons & GTK_IMHTML_ITALIC) - toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), - !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)), - toolbar); - - if (buttons & GTK_IMHTML_UNDERLINE) - toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), - !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)), - toolbar); -} - static void reset_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) { if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold))) @@ -840,6 +782,8 @@ static void update_buttons(GtkIMHtmlToolbar *toolbar) { gboolean bold, italic, underline; + char *tmp; + char *tmp2; bold = italic = underline = FALSE; gtk_imhtml_get_current_format(GTK_IMHTML(toolbar->imhtml), @@ -856,6 +800,32 @@ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)) != underline) toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), underline, toolbar); + + /* These buttons aren't ever "active". */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->larger_size), FALSE); + + tmp = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml)); + toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->font), + (tmp != NULL), toolbar); + g_free(tmp); + + tmp = gtk_imhtml_get_current_forecolor(GTK_IMHTML(toolbar->imhtml)); + toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->fgcolor), + (tmp != NULL), toolbar); + g_free(tmp); + + tmp = gtk_imhtml_get_current_backcolor(GTK_IMHTML(toolbar->imhtml)); + tmp2 = gtk_imhtml_get_current_background(GTK_IMHTML(toolbar->imhtml)); + toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bgcolor), + (tmp != NULL || tmp2 != NULL), toolbar); + g_free(tmp); + g_free(tmp2); +} + +static void toggle_button_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) +{ + update_buttons(toolbar); } static void update_format_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) { @@ -1117,7 +1087,7 @@ toolbar->imhtml = imhtml; g_signal_connect(G_OBJECT(imhtml), "format_buttons_update", G_CALLBACK(update_buttons_cb), toolbar); - g_signal_connect(G_OBJECT(imhtml), "format_function_toggle", G_CALLBACK(toggle_button_cb), toolbar); + g_signal_connect_after(G_OBJECT(imhtml), "format_function_toggle", G_CALLBACK(toggle_button_cb), toolbar); g_signal_connect(G_OBJECT(imhtml), "format_function_clear", G_CALLBACK(reset_buttons_cb), toolbar); g_signal_connect(G_OBJECT(imhtml), "format_function_update", G_CALLBACK(update_format_cb), toolbar); g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", G_CALLBACK(mark_set_cb), toolbar); @@ -1129,17 +1099,7 @@ gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), &bold, &italic, &underline); - if(bold) - toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold, - toolbar); - - if(italic) - toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic, - toolbar); - - if(underline) - toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), - underline, toolbar); + update_buttons(toolbar); } void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id)
--- a/src/gtkprefs.c Mon Aug 15 04:15:11 2005 +0000 +++ b/src/gtkprefs.c Mon Aug 15 04:15:22 2005 +0000 @@ -205,7 +205,7 @@ GaimPrefType type, const char *key, GList *menuitems) { GtkWidget *dropdown, *opt, *menu; - GtkWidget *label; + GtkWidget *label = NULL; GtkWidget *hbox; gchar *text; const char *stored_str = NULL; @@ -216,14 +216,18 @@ g_return_val_if_fail(menuitems != NULL, NULL); - hbox = gtk_hbox_new(FALSE, 5); - /*gtk_container_add (GTK_CONTAINER (box), hbox);*/ - gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); - gtk_widget_show(hbox); - - label = gtk_label_new_with_mnemonic(title); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - gtk_widget_show(label); + if (title != NULL) { + hbox = gtk_hbox_new(FALSE, 5); + /*gtk_container_add (GTK_CONTAINER (box), hbox);*/ + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); + gtk_widget_show(hbox); + + label = gtk_label_new_with_mnemonic(title); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + } else { + hbox = box; + } #if 0 /* GTK_CHECK_VERSION(2,4,0) */ if(type == GAIM_PREF_INT) @@ -236,7 +240,10 @@ menu = gtk_menu_new(); #endif - gtk_label_set_mnemonic_widget(GTK_LABEL(label), dropdown); + if (label != NULL) { + gtk_label_set_mnemonic_widget(GTK_LABEL(label), dropdown); + gaim_set_accessible_label (dropdown, label); + } if (type == GAIM_PREF_INT) stored_int = gaim_prefs_get_int(key); @@ -289,7 +296,6 @@ gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu); gtk_box_pack_start(GTK_BOX(hbox), dropdown, FALSE, FALSE, 0); gtk_widget_show(dropdown); - gaim_set_accessible_label (dropdown, label); return label; } @@ -741,26 +747,7 @@ } static void -formatting_reset_cb(GtkWidget *w, GtkWidget *imhtml) { - gboolean bold, italic, uline; - bold = italic = uline = FALSE; - - gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), &bold, &italic, &uline); - if (bold) - gtk_imhtml_toggle_bold(GTK_IMHTML(imhtml)); - if (italic) - gtk_imhtml_toggle_italic(GTK_IMHTML(imhtml)); - if (uline) - gtk_imhtml_toggle_underline(GTK_IMHTML(imhtml)); - - gtk_imhtml_font_set_size(GTK_IMHTML(imhtml), 3); - gtk_imhtml_toggle_forecolor(GTK_IMHTML(imhtml), NULL); - gtk_imhtml_toggle_backcolor(GTK_IMHTML(imhtml), NULL); - gtk_imhtml_toggle_fontface(GTK_IMHTML(imhtml), NULL); -} - -static void -formatting_toggle_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *bah) +formatting_toggle_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *toolbar) { gboolean bold, italic, uline; @@ -797,7 +784,32 @@ } if (buttons & GTK_IMHTML_BACKCOLOR) { - char *color = gtk_imhtml_get_current_backcolor(GTK_IMHTML(imhtml)); + char *color; + GObject *object; + + color = gtk_imhtml_get_current_backcolor(GTK_IMHTML(imhtml)); + if (!color) + color = g_strdup(""); + + /* Block the signal to prevent a loop. */ + object = g_object_ref(G_OBJECT(imhtml)); + g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, + NULL, toolbar); + /* Clear the backcolor. */ + gtk_imhtml_toggle_backcolor(GTK_IMHTML(imhtml), ""); + /* Unblock the signal. */ + g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, + NULL, toolbar); + g_object_unref(object); + + /* This will fire a toggle signal and get saved below. */ + gtk_imhtml_toggle_background(GTK_IMHTML(imhtml), color); + + g_free(color); + } + + if (buttons & GTK_IMHTML_BACKGROUND) { + char *color = gtk_imhtml_get_current_background(GTK_IMHTML(imhtml)); if (!color) color = g_strdup(""); @@ -806,73 +818,27 @@ } } -static GtkWidget * -messages_page() -{ - GtkWidget *ret; - GtkWidget *vbox, *fontvbox; - GtkWidget *imhtml; - GtkWidget *toolbar; - GtkWidget *frame; - GtkWidget *option; - GtkWidget *button; - - ret = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); - gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); - - vbox = gaim_gtk_make_frame (ret, _("Display")); -#ifdef USE_GTKSPELL - gaim_gtk_prefs_checkbox(_("_Highlight misspelled words"), - "/gaim/gtk/conversations/spellcheck", vbox); -#endif - vbox = gaim_gtk_make_frame (ret, _("Ignore")); - gaim_gtk_prefs_checkbox(_("Ignore _formatting"), - "/gaim/gtk/conversations/ignore_formatting", vbox); - - vbox = gaim_gtk_make_frame (ret, _("Default Formatting")); - - option = gaim_gtk_prefs_checkbox(_("_Send default formatting with outgoing messages"), - "/gaim/gtk/conversations/send_formatting", vbox); - - - fontvbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(vbox), fontvbox); - - frame = gaim_gtk_create_imhtml(TRUE, &imhtml, &toolbar); - gtk_widget_set_name(imhtml, "gaim_gtkprefs_font_imhtml"); - gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(imhtml), TRUE); - gtk_imhtml_append_text(GTK_IMHTML(imhtml), _("This is how your outgoing message text will appear when you use protocols that support formatting. :)"), 0); - gtk_box_pack_start(GTK_BOX(fontvbox), frame, FALSE, FALSE, 0); - - button = gtk_button_new_with_mnemonic(_("_Clear Formatting")); - gtk_box_pack_start(GTK_BOX(fontvbox), button, FALSE, FALSE, 0); - - if (!gaim_prefs_get_bool("/gaim/gtk/conversations/send_formatting")) - gtk_widget_set_sensitive(fontvbox, FALSE); - - if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) +static void +formatting_reset_cb(GtkWidget *w, GtkWidget *imhtml) { + gboolean bold, italic, uline; + bold = italic = uline = FALSE; + + gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), &bold, &italic, &uline); + if (bold) gtk_imhtml_toggle_bold(GTK_IMHTML(imhtml)); - if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) + if (italic) gtk_imhtml_toggle_italic(GTK_IMHTML(imhtml)); - if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) + if (uline) gtk_imhtml_toggle_underline(GTK_IMHTML(imhtml)); - gtk_imhtml_font_set_size(GTK_IMHTML(imhtml), gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); - gtk_imhtml_toggle_forecolor(GTK_IMHTML(imhtml), gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor")); - gtk_imhtml_toggle_backcolor(GTK_IMHTML(imhtml), gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor")); - gtk_imhtml_toggle_fontface(GTK_IMHTML(imhtml), gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); - - g_signal_connect(G_OBJECT(button), "clicked", - G_CALLBACK(formatting_reset_cb), imhtml); - - g_signal_connect(G_OBJECT(option), "clicked", - G_CALLBACK(gaim_gtk_toggle_sensitive), fontvbox); - - g_signal_connect(G_OBJECT(imhtml), "format_function_toggle", - G_CALLBACK(formatting_toggle_cb), NULL); - - gtk_widget_show_all(ret); - return ret; + gtk_imhtml_font_set_size(GTK_IMHTML(imhtml), 3); + gtk_imhtml_toggle_fontface(GTK_IMHTML(imhtml), NULL); + + gtk_imhtml_toggle_forecolor(GTK_IMHTML(imhtml), NULL); + gtk_imhtml_toggle_backcolor(GTK_IMHTML(imhtml), NULL); + gtk_imhtml_toggle_background(GTK_IMHTML(imhtml), NULL); + + gtk_widget_grab_focus(imhtml); } static GtkWidget * @@ -926,25 +892,78 @@ { GtkWidget *ret; GtkWidget *vbox, *vbox2; + GtkWidget *hbox; GtkWidget *label; - GtkSizeGroup *sg; GList *names = NULL; + GtkWidget *frame; + GtkWidget *imhtml; + GtkWidget *toolbar; + GtkWidget *button; ret = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); - sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); vbox = gaim_gtk_make_frame(ret, _("Conversations")); gaim_gtk_prefs_checkbox(_("Send unknown \"_slash\" commands as messages"), "/gaim/gtk/conversations/passthrough_unknown_commands", vbox); - + gaim_gtk_prefs_checkbox(_("Show _formatting on incoming messages"), + "/gaim/gtk/conversations/show_incoming_formatting", vbox); gaim_gtk_prefs_checkbox(_("Show buddy _icons"), "/gaim/gtk/conversations/im/show_buddy_icons", vbox); gaim_gtk_prefs_checkbox(_("Enable buddy ic_on animation"), "/gaim/gtk/conversations/im/animate_buddy_icons", vbox); gaim_gtk_prefs_checkbox(_("_Notify buddies that you are typing to them"), "/core/conversations/im/send_typing", vbox); +#ifdef USE_GTKSPELL + gaim_gtk_prefs_checkbox(_("_Highlight misspelled words"), + "/gaim/gtk/conversations/spellcheck", vbox); +#endif + + hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + + frame = gaim_gtk_create_imhtml(TRUE, &imhtml, &toolbar); + gtk_widget_set_name(imhtml, "gaim_gtkprefs_font_imhtml"); + gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(imhtml), TRUE); + gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), + GTK_IMHTML_BOLD | + GTK_IMHTML_ITALIC | + GTK_IMHTML_UNDERLINE | + GTK_IMHTML_GROW | + GTK_IMHTML_SHRINK | + GTK_IMHTML_FACE | + GTK_IMHTML_FORECOLOR | + GTK_IMHTML_BACKCOLOR | + GTK_IMHTML_BACKGROUND); + + gtk_imhtml_append_text(GTK_IMHTML(imhtml), _("This is how your outgoing message text will appear when you use protocols that support formatting. :)"), 0); + + gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, FALSE, 0); + + vbox2 = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0); + button = gtk_button_new_with_mnemonic(_("_Clear Formatting")); + gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, FALSE, 0); + + if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) + gtk_imhtml_toggle_bold(GTK_IMHTML(imhtml)); + if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) + gtk_imhtml_toggle_italic(GTK_IMHTML(imhtml)); + if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) + gtk_imhtml_toggle_underline(GTK_IMHTML(imhtml)); + + gtk_imhtml_font_set_size(GTK_IMHTML(imhtml), gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); + gtk_imhtml_toggle_forecolor(GTK_IMHTML(imhtml), gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor")); + gtk_imhtml_toggle_background(GTK_IMHTML(imhtml), gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor")); + gtk_imhtml_toggle_fontface(GTK_IMHTML(imhtml), gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); + + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK(formatting_reset_cb), imhtml); + + g_signal_connect_after(G_OBJECT(imhtml), "format_function_toggle", + G_CALLBACK(formatting_toggle_cb), toolbar); + /* All the tab options! */ vbox = gaim_gtk_make_frame(ret, _("Tab Options")); @@ -966,21 +985,20 @@ gaim_gtk_prefs_checkbox(_("Show close b_utton on tabs"), "/gaim/gtk/conversations/close_on_tabs", vbox2); - label = gaim_gtk_prefs_dropdown(vbox2, _("Tab p_lacement:"), GAIM_PREF_INT, + hbox = gtk_hbox_new(FALSE, 9); + gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); + + label = gaim_gtk_prefs_dropdown(hbox, _("_Placement:"), GAIM_PREF_INT, "/gaim/gtk/conversations/tab_side", _("Top"), GTK_POS_TOP, _("Bottom"), GTK_POS_BOTTOM, _("Left"), GTK_POS_LEFT, _("Right"), GTK_POS_RIGHT, NULL); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); names = gaim_conv_placement_get_options(); - label = gaim_gtk_prefs_dropdown_from_list(vbox2, _("New conversation _placement:"), + label = gaim_gtk_prefs_dropdown_from_list(hbox, _("N_ew conversations:"), GAIM_PREF_STRING, "/gaim/gtk/conversations/placement", names); - gtk_size_group_add_widget(sg, label); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); g_list_free(names); gtk_widget_show_all(ret); @@ -2114,7 +2132,6 @@ GList *l; prefs_notebook_add_page(_("Buddy List"), NULL, list_page(), &c, &p, notebook_page++); prefs_notebook_add_page(_("Conversations"), NULL, conv_page(), &c, &p, notebook_page++); - prefs_notebook_add_page(_("Message Text"), NULL, messages_page(), &c2, &c, notebook_page++); prefs_notebook_add_page(_("Smiley Themes"), NULL, theme_page(), &c2, &c, notebook_page++); prefs_notebook_add_page(_("Sounds"), NULL, sound_page(), &c, &p, notebook_page++); prefs_notebook_add_page(_("Network"), NULL, network_page(), &p, NULL, notebook_page++); @@ -2283,9 +2300,15 @@ "/gaim/gtk/conversations/send_formatting"); gaim_prefs_rename("/gaim/gtk/debug/timestamps", "/core/debug/timestamps"); - gaim_prefs_rename("/gaim/gtk/conversations/ignore_colors", "/gaim/gtk/conversations/ignore_formatting"); gaim_prefs_rename("/gaim/gtk/conversations/im/raise_on_events", "/plugins/gtk/X11/notify/method_raise"); + /* I'm leaving both of these to support people that were running 2.0.0cvs before this change. + * The latter can be removed before 2.0.0 is released, or after that if it's forgotten. */ + gaim_prefs_rename_boolean_toggle("/gaim/gtk/conversations/ignore_colors", + "/gaim/gtk/conversations/show_incoming_formatting"); + gaim_prefs_rename_boolean_toggle("/gaim/gtk/conversations/ignore_formatting", + "/gaim/gtk/conversations/show_incoming_formatting"); + /* Remove some no-longer-used prefs */ gaim_prefs_remove("/gaim/gtk/blist/auto_expand_contacts"); gaim_prefs_remove("/gaim/gtk/blist/button_style"); @@ -2299,6 +2322,7 @@ gaim_prefs_remove("/gaim/gtk/conversations/enter_sends"); gaim_prefs_remove("/gaim/gtk/conversations/html_shortcuts"); gaim_prefs_remove("/gaim/gtk/conversations/icons_on_tabs"); + gaim_prefs_remove("/gaim/gtk/conversations/send_formatting"); gaim_prefs_remove("/gaim/gtk/conversations/show_smileys"); gaim_prefs_remove("/gaim/gtk/conversations/show_timestamps"); gaim_prefs_remove("/gaim/gtk/conversations/show_urls_as_links");