Mercurial > pidgin.yaz
changeset 27818:bc6cc2c04476
propagate from branch 'im.pidgin.pidgin' (head 570c5daf55a59f3c7271d3b5a50bd4d3024f7a80)
to branch 'im.pidgin.pidgin.yaz' (head 137baae4f5678bc69dd6cc8a73f8f9073cd60c02)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 08 Apr 2008 06:17:41 +0000 |
parents | 3c26ef82d556 (current diff) 8469385cfb73 (diff) |
children | 030185a59a1a |
files | pidgin/gtkconv.c pidgin/gtkimhtml.c |
diffstat | 4 files changed, 91 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Apr 05 13:15:49 2008 +0000 +++ b/ChangeLog Tue Apr 08 06:17:41 2008 +0000 @@ -4,6 +4,10 @@ libpurple: * In MySpaceIM, messages from spambots are discarded (Justin Williams) + Pidgin: + * The typing notification in the conversation history can be disabled or + customized (font, color etc.) in .gtkrc-2.0. + version 2.4.1 (03/31/2008): http://developer.pidgin.im/query?status=closed&milestone=2.4.1
--- a/doc/gtkrc-2.0 Sat Apr 05 13:15:49 2008 +0000 +++ b/doc/gtkrc-2.0 Tue Apr 08 06:17:41 2008 +0000 @@ -28,12 +28,27 @@ # Set the widget style for IMHtml widgets in notify dialogs widget "*pidgin_notify_imhtml" style "imhtml-fix" -# The following lets you customize the color of hyperlinks -# and also the text cursors. The link color thing is Pidgin specific -# but the rest work for any Gtk2 program. You can search the Gtk2 -# docs for other style properties. +# It is safe to remove any undesired settings from the following style "my-style-name" { + # Change the color of hyperlinks. GtkIMHtml::hyperlink-color = "#000080" + # Change the color of the nick in highlighted messages, e.g. messages containing your nick + GtkIMHtml::highlight-name-color = "#AF7F00" + # Change the color of the nick in received message + GtkIMHtml::receive-name-color = "#cc0000" + # Change the color of the nick in sent message + GtkIMHtml::send-name-color = "#204a87" + # Change the color of the nick in action messages, e.g. "/me likes pidgin" + GtkIMHtml::action-name-color = "#062585" + # Change the font of the typing notification in conversation history. + GtkIMHtml::typing-notification-font = "italic light 8.0" + # Change the color of the typing notification + GtkIMHtml::typing-notification-color = "#ff0000" + # Disable the typing notification + GtkIMHtml::typing-notification-enable = 1 + + # The following settings will change the behaviour in all GTK+ applications + # Change the cursor color GtkWidget::cursor-color = "#0000FF" GtkWidget::secondary-cursor-color = "#00FF00" #for mixed ltr and rtl }
--- a/pidgin/gtkconv.c Sat Apr 05 13:15:49 2008 +0000 +++ b/pidgin/gtkconv.c Tue Apr 08 06:17:41 2008 +0000 @@ -176,7 +176,7 @@ int width, int height); static gboolean pidgin_conv_xy_to_right_infopane(PidginWindow *win, int x, int y); -static GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name) { +static const GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name) { static GdkColor col; GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); float scale; @@ -3480,9 +3480,13 @@ static void update_typing_message(PidginConversation *gtkconv, const char *message) { - GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)); + GtkTextBuffer *buffer; GtkTextMark *stmark, *enmark; + if (g_object_get_data(G_OBJECT(gtkconv->imhtml), "disable-typing-notification")) + return; + + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)); stmark = gtk_text_buffer_get_mark(buffer, "typing-notification-start"); enmark = gtk_text_buffer_get_mark(buffer, "typing-notification-end"); if (stmark && enmark) { @@ -4990,6 +4994,40 @@ return FALSE; } +static void set_typing_font(GtkWidget *widget, GtkStyle *style, PidginConversation *gtkconv) +{ + static PangoFontDescription *font_desc = NULL; + static GdkColor *color = NULL; + static gboolean enable = TRUE; + + if (font_desc == NULL) { + char *string = NULL; + gtk_widget_style_get(widget, + "typing-notification-font", &string, + "typing-notification-color", &color, + "typing-notification-enable", &enable, + NULL); + font_desc = pango_font_description_from_string(string); + g_free(string); + if (color == NULL) { + GdkColor def = {0, 0x8888, 0x8888, 0x8888}; + color = gdk_color_copy(&def); + } + } + + gtk_text_buffer_create_tag(GTK_IMHTML(widget)->text_buffer, "TYPING-NOTIFICATION", + "foreground-gdk", color, + "font-desc", font_desc, + NULL); + + if (!enable) { + g_object_set_data(G_OBJECT(widget), "disable-typing-notification", GINT_TO_POINTER(TRUE)); + /* or may be 'gtkconv->disable_typing = TRUE;' instead? */ + } + + g_signal_handlers_disconnect_by_func(G_OBJECT(widget), set_typing_font, gtkconv); +} + /************************************************************************** * Conversation UI operations **************************************************************************/ @@ -5071,12 +5109,7 @@ g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", G_CALLBACK(conv_dnd_recv), gtkconv); - gtk_text_buffer_create_tag(GTK_IMHTML(gtkconv->imhtml)->text_buffer, "TYPING-NOTIFICATION", - "foreground", "#888888", - "justification", GTK_JUSTIFY_LEFT, /* XXX: RTL'ify */ - "weight", PANGO_WEIGHT_LIGHT, - "scale", PANGO_SCALE_SMALL, - NULL); + g_signal_connect(gtkconv->imhtml, "style-set", G_CALLBACK(set_typing_font), gtkconv); /* Setup the container for the tab. */ gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); @@ -5673,8 +5706,8 @@ if(col) { g_snprintf(color, sizeof(color), "#%02X%02X%02X", col->red >> 8, col->green >> 8, col->blue >> 8); - } - else { + gdk_color_free(col); + } else { if (flags & PURPLE_MESSAGE_NICK) strcpy(color, DEFAULT_HIGHLIGHT_COLOR); else @@ -5697,14 +5730,14 @@ if(col) { g_snprintf(color, sizeof(color), "#%02X%02X%02X", col->red >> 8, col->green >> 8, col->blue >> 8); - } - else { + gdk_color_free(col); + } else { strcpy(color, DEFAULT_HIGHLIGHT_COLOR); } } else if (flags & PURPLE_MESSAGE_RECV) { if (type == PURPLE_CONV_TYPE_CHAT) { - GdkColor *col = get_nick_color(gtkconv, name); + const GdkColor *col = get_nick_color(gtkconv, name); g_snprintf(color, sizeof(color), "#%02X%02X%02X", col->red >> 8, col->green >> 8, col->blue >> 8); @@ -5714,8 +5747,8 @@ if(col) { g_snprintf(color, sizeof(color), "#%02X%02X%02X", col->red >> 8, col->green >> 8, col->blue >> 8); - } - else { + gdk_color_free(col); + } else { strcpy(color, DEFAULT_RECV_COLOR); } } @@ -5726,8 +5759,8 @@ if(col) { g_snprintf(color, sizeof(color), "#%02X%02X%02X", col->red >> 8, col->green >> 8, col->blue >> 8); - } - else { + gdk_color_free(col); + } else { strcpy(color, DEFAULT_SEND_COLOR); } }
--- a/pidgin/gtkimhtml.c Sat Apr 05 13:15:49 2008 +0000 +++ b/pidgin/gtkimhtml.c Tue Apr 08 06:17:41 2008 +0000 @@ -1424,6 +1424,24 @@ _("Color to draw the name of an action message."), GDK_TYPE_COLOR, G_PARAM_READABLE)); + /* Customizable typing notification ... sort of. Example: + * GtkIMHtml::typing-notification-font = "monospace italic light 8.0" + * GtkIMHtml::typing-notification-color = "#ff0000" + * GtkIMHtml::typing-notification-enable = 1 + */ + gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("typing-notification-color", + _("Typing notification color"), + _("The color to use for the typing notification font"), + GDK_TYPE_COLOR, G_PARAM_READABLE)); + gtk_widget_class_install_style_property(widget_class, g_param_spec_string("typing-notification-font", + _("Typing notification font"), + _("The font to use for the typing notification"), + "light 8.0", G_PARAM_READABLE)); + gtk_widget_class_install_style_property(widget_class, g_param_spec_boolean("typing-notification-enable", + _("Enable typing notification"), + _("Enable typing notification"), + TRUE, G_PARAM_READABLE)); + binding_set = gtk_binding_set_by_class (parent_class); gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD); gtk_binding_entry_add_signal (binding_set, GDK_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC);