/dev/tomkiewicz/new-smileys: 25ad1e702bf3: Smileys: tweak style ...

Tomasz Wasilczyk twasilczyk at pidgin.im
Fri Apr 4 12:17:15 EDT 2014


Changeset: 25ad1e702bf393d5cd3d8ca9372b974f365d2779
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-04 18:17 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/tomkiewicz/new-smileys/rev/25ad1e702bf3

Description:

Smileys: tweak style a bit

diffstat:

 pidgin/gtkconv.c                          |  11 ++++--
 pidgin/themes/Contents/Resources/main.css |   6 +++
 pidgin/themes/Template.html               |  52 -------------------------------
 3 files changed, 13 insertions(+), 56 deletions(-)

diffs (105 lines):

diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -6596,19 +6596,22 @@ pidgin_conv_write_smiley(GString *out, P
 		purple_smiley_get_shortcut(smiley), -1);
 
 	if (purple_smiley_is_ready(smiley) && path) {
-		g_string_append_printf(out, "<img alt=\"%s\" src=\"%s\" />",
+		g_string_append_printf(out,
+			"<img class=\"emoticon\" alt=\"%s\" title=\"%s\" "
+			"src=\"%s\" />", escaped_shortcut,
 			escaped_shortcut, path);
 	} else if (purple_smiley_is_ready(smiley) && !path) {
 		PurpleStoredImage *img = purple_smiley_get_image(smiley);
 		int imgid = purple_imgstore_add_with_id(img);
 
-		g_string_append_printf(out, "<img alt=\"%s\" src=\""
+		g_string_append_printf(out, "<img class=\"emoticon\" "
+			"alt=\"%s\" title=\"%s\" src=\""
 			PURPLE_STORED_IMAGE_PROTOCOL "%d\" />",
-			escaped_shortcut, imgid);
+			escaped_shortcut, escaped_shortcut, imgid);
 	} else {
 		/* TODO: remove this background, maybe put something into css file? */
 		g_string_append_printf(out,
-			"<span class=\"pending-smiley\" style=\"background: #ccc\">%s</span>",
+			"<span class=\"emoticon pending\">%s</span>",
 			escaped_shortcut);
 		/* TODO: watch for "is-ready" state changes
 		 * (it's not possible without conv handle here) */
diff --git a/pidgin/themes/Contents/Resources/main.css b/pidgin/themes/Contents/Resources/main.css
--- a/pidgin/themes/Contents/Resources/main.css
+++ b/pidgin/themes/Contents/Resources/main.css
@@ -75,3 +75,9 @@ img
 	font-weight: bold;
 }
 
+/* Emoticons */
+
+.emoticon.pending
+{
+	cursor: progress;
+}
diff --git a/pidgin/themes/Template.html b/pidgin/themes/Template.html
--- a/pidgin/themes/Template.html
+++ b/pidgin/themes/Template.html
@@ -234,58 +234,6 @@
 			head.appendChild( documentFragment );
 		}
 
-		/* Converts emoticon images to textual emoticons; all emoticons in message if alt is held */
-		document.onclick = function imageCheck() {
-			var node = event.target;
-			if (node.tagName.toLowerCase() != 'img')
-				return;
-
-			imageSwap(node, false);
-		}
-
-		/* Converts textual emoticons to images if textToImagesFlag is true, otherwise vice versa */
-		function imageSwap(node, textToImagesFlag) {
-			var shouldScroll = nearBottom();
-
-			var images = [node];
-			if (event.altKey) {
-				while (node.id != "Chat" && node.parentNode.id != "Chat")
-					node = node.parentNode;
-				images = node.querySelectorAll(textToImagesFlag ? "a" : "img");
-			}
-
-			for (var i = 0; i < images.length; i++) {
-				textToImagesFlag ? textToImage(images[i]) : imageToText(images[i]);
-			}
-
-			alignChat(shouldScroll);
-		}
-
-		function textToImage(node) {
-			if (!node.getAttribute("isEmoticon"))
-				return;
-			//Swap the image/text
-			var img = document.createElement('img');
-			img.setAttribute('src', node.getAttribute('src'));
-			img.setAttribute('alt', node.firstChild.nodeValue);
-			img.className = node.className;
-			node.parentNode.replaceChild(img, node);
-		}
-
-		function imageToText(node)
-		{
-			if (client.zoomImage(node) || !node.alt)
-				return;
-			var a = document.createElement('a');
-			a.setAttribute('onclick', 'imageSwap(this, true)');
-			a.setAttribute('src', node.getAttribute('src'));
-			a.setAttribute('isEmoticon', true);
-			a.className = node.className;
-			var text = document.createTextNode(node.alt);
-			a.appendChild(text);
-			node.parentNode.replaceChild(a, node);
-		}
-
 		//If true is passed, view will be scrolled down
 		function alignChat(shouldScroll) {
 			if (shouldScroll)



More information about the Commits mailing list