changeset 24213:3a5ae157b730

Unbreak ABI. Cleanup some code. Select the status message when changing status, so it's easier to erase the old message and enter a completely new message.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 02 Oct 2008 01:02:44 +0000
parents 3266c00d71a4
children f8ffea0d1c65 a7e1edeb3ac6
files pidgin/gtkstatusbox.c pidgin/gtkstatusbox.h
diffstat 2 files changed, 40 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkstatusbox.c	Tue Sep 30 17:05:40 2008 +0000
+++ b/pidgin/gtkstatusbox.c	Thu Oct 02 01:02:44 2008 +0000
@@ -397,6 +397,11 @@
 	status_box->icon_box = gtk_event_box_new();
 	gtk_widget_set_parent(status_box->icon_box, GTK_WIDGET(status_box));
 	gtk_widget_show(status_box->icon_box);
+#if 0
+	gtk_widget_set_tooltip_text(status_box->icon_box,
+			status_box->account ? _("Click to change your buddyicon for this account.") :
+				_("Click to change your buddyicon for all accounts."));
+#endif
 
 	if (status_box->account &&
 		!purple_account_get_bool(status_box->account, "use-global-buddyicon", TRUE))
@@ -1199,69 +1204,22 @@
 	}
 
 	status_box->connecting_index = 0;
-	status_box->connecting_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT0,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT1,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT2,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT3,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[4] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT4,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[5] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT5,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[6] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT6,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[7] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT7,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[8] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT8,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[9] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT9,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[10] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT10,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[11] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT11,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[12] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT12,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[13] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT13,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[14] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT14,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[15] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT15,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[16] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT16,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[17] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT17,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[18] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT18,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[19] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT19,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[20] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT20,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[21] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT21,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[22] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT22,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[23] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT23,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[24] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT24,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[25] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT25,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[26] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT26,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[27] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT27,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[28] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT28,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[29] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT29,
-								     icon_size, "PidginStatusBox");
-	status_box->connecting_pixbufs[30] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_CONNECT30,
-								     icon_size, "PidginStatusBox");
-
+
+#define CACHE_ANIMATION_CONNECT(index) \
+	status_box->connecting_pixbufs[index] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox),\
+			PIDGIN_STOCK_ANIMATION_CONNECT ## index, icon_size, "PidginStatusBox")
+
+	CACHE_ANIMATION_CONNECT(0);
+	CACHE_ANIMATION_CONNECT(1);
+	CACHE_ANIMATION_CONNECT(2);
+	CACHE_ANIMATION_CONNECT(3);
+	CACHE_ANIMATION_CONNECT(4);
+	CACHE_ANIMATION_CONNECT(5);
+	CACHE_ANIMATION_CONNECT(6);
+	CACHE_ANIMATION_CONNECT(7);
+	CACHE_ANIMATION_CONNECT(8);
+
+#undef CACHE_ANIMATION_CONNECT
 
 	for (i = 0; i < G_N_ELEMENTS(status_box->typing_pixbufs); i++) {
 		if (status_box->typing_pixbufs[i] != NULL)
@@ -1269,16 +1227,18 @@
 	}
 
 	status_box->typing_index = 0;
-	status_box->typing_pixbufs[0] =  gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_TYPING0,
-								     icon_size, "PidginStatusBox");
-	status_box->typing_pixbufs[1] =  gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_TYPING1,
-								     icon_size, "PidginStatusBox");
-	status_box->typing_pixbufs[2] =  gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_TYPING2,
-								     icon_size, "PidginStatusBox");
-	status_box->typing_pixbufs[3] =  gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_TYPING3,
-								     icon_size, "PidginStatusBox");
-	status_box->typing_pixbufs[4] =  gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_TYPING4,
-								     icon_size, "PidginStatusBox");
+
+#define CACHE_ANIMATION_TYPING(index) \
+	status_box->typing_pixbufs[index] =  gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), \
+			PIDGIN_STOCK_ANIMATION_TYPING ## index, icon_size, "PidginStatusBox")
+
+	CACHE_ANIMATION_TYPING(0);
+	CACHE_ANIMATION_TYPING(1);
+	CACHE_ANIMATION_TYPING(2);
+	CACHE_ANIMATION_TYPING(3);
+	CACHE_ANIMATION_TYPING(4);
+
+#undef CACHE_ANIMATION_TYPING
 }
 
 static void account_enabled_cb(PurpleAccount *acct, PidginStatusBox *status_box)
@@ -2712,9 +2672,15 @@
 	{
 		if (status_box->imhtml_visible)
 		{
+			GtkTextIter start, end;
+			GtkTextBuffer *buffer;
 			gtk_widget_show_all(status_box->vbox);
 			status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
 			gtk_widget_grab_focus(status_box->imhtml);
+			buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml));
+			gtk_text_buffer_get_bounds(buffer, &start, &end);
+			gtk_text_buffer_move_mark(buffer, gtk_text_buffer_get_mark(buffer, "insert"), &end);
+			gtk_text_buffer_move_mark(buffer, gtk_text_buffer_get_mark(buffer, "selection_bound"), &start);
 		}
 		else
 		{
--- a/pidgin/gtkstatusbox.h	Tue Sep 30 17:05:40 2008 +0000
+++ b/pidgin/gtkstatusbox.h	Thu Oct 02 01:02:44 2008 +0000
@@ -111,7 +111,7 @@
 
 	GdkPixbuf *error_pixbuf;
 	int connecting_index;
-	GdkPixbuf *connecting_pixbufs[31];
+	GdkPixbuf *connecting_pixbufs[9];
 	int typing_index;
 	GdkPixbuf *typing_pixbufs[6];