changeset 22632:8469385cfb73

merge of '47385c29904d4755361546c34319cf036d5a8723' and 'a32d1e1358009ce730a50b32e63fbe6c3a63c4fb'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 05 Apr 2008 19:37:26 +0000
parents d2a5d298de66 (diff) 29f20ae16bf9 (current diff)
children bcc355f38ba4 1f16cb128a3a
files
diffstat 4 files changed, 91 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Apr 05 11:12:13 2008 +0000
+++ b/ChangeLog	Sat Apr 05 19:37:26 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 11:12:13 2008 +0000
+++ b/doc/gtkrc-2.0	Sat Apr 05 19:37:26 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 11:12:13 2008 +0000
+++ b/pidgin/gtkconv.c	Sat Apr 05 19:37:26 2008 +0000
@@ -171,7 +171,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;
@@ -3411,9 +3411,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) {
@@ -4900,6 +4904,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
  **************************************************************************/
@@ -4981,12 +5019,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);
@@ -5583,8 +5616,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
@@ -5607,14 +5640,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);
@@ -5624,8 +5657,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);
 						}
 					}
@@ -5636,8 +5669,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 11:12:13 2008 +0000
+++ b/pidgin/gtkimhtml.c	Sat Apr 05 19:37:26 2008 +0000
@@ -1416,6 +1416,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);