changeset 12232:375f1f3817a8

[gaim-migrate @ 14534] Displaying large logs is slow. Let's show the busy cursor whenever possible. This currently doesn't show the busy cursor over the IMHTMLs in a conversation window even though I set a busy cursor for the conversation window. I looked into fixing that, but I'm not sure exactly what the best way to deal with it is. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sun, 27 Nov 2005 03:20:35 +0000
parents c342eb6e8cd3
children 02833a0ae716
files src/gtkblist.c src/gtkconv.c src/gtkdialogs.c src/gtklog.c
diffstat 4 files changed, 74 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Sun Nov 27 03:17:05 2005 +0000
+++ b/src/gtkblist.c	Sun Nov 27 03:20:35 2005 +0000
@@ -345,10 +345,16 @@
 
 static void gtk_blist_menu_showlog_cb(GtkWidget *w, GaimBlistNode *node)
 {
+	GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
 	GaimLogType type;
 	GaimAccount *account;
 	char *name = NULL;
 
+	gdk_window_set_cursor(gtkblist->window->window, cursor);
+	gdk_cursor_unref(cursor);
+	while (gtk_events_pending())
+		gtk_main_iteration();
+
 	if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
 		GaimBuddy *b = (GaimBuddy*) node;
 		type = GAIM_LOG_IM;
@@ -365,13 +371,21 @@
 		}
 	} else if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
 		gaim_gtk_log_show_contact((GaimContact *)node);
+		gdk_window_set_cursor(gtkblist->window->window, NULL);
 		return;
-	} else
-		return;
+	} else {
+		gdk_window_set_cursor(gtkblist->window->window, NULL);
+
+		/* This callback should not have been registered for a node
+		 * that doesn't match the type of one of the blocks above. */
+		g_return_if_reached();
+	}
 
 	if (name && account) {
 		gaim_gtk_log_show(type, name, account);
 		g_free(name);
+
+		gdk_window_set_cursor(gtkblist->window->window, NULL);
 	}
 }
 
@@ -1372,9 +1386,7 @@
 			gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(checkitem)));
 
 	if(gtkblist->window->window) {
-		GdkCursor *cursor = gdk_cursor_new(GDK_LEFT_PTR);
-		gdk_window_set_cursor(gtkblist->window->window, cursor);
-		gdk_cursor_unref(cursor);
+		gdk_window_set_cursor(gtkblist->window->window, NULL);
 	}
 }
 
--- a/src/gtkconv.c	Sun Nov 27 03:17:05 2005 +0000
+++ b/src/gtkconv.c	Sun Nov 27 03:20:35 2005 +0000
@@ -949,9 +949,12 @@
 	GaimGtkWindow *win = data;
 	GaimConversation *conv;
 	GaimLogType type;
+	GaimGtkBuddyList *gtkblist;
+	GdkCursor *cursor;
 	const char *name;
 	GaimAccount *account;
-	GSList *buddies, *cur;
+	GSList *buddies;
+	GSList *cur;
 
 	conv = gaim_gtk_conv_window_get_active_conversation(win);
 
@@ -962,6 +965,15 @@
 	else
 		return;
 
+	gtkblist = gaim_gtk_blist_get_default_gtk_blist();
+	cursor = gdk_cursor_new(GDK_WATCH);
+
+	gdk_window_set_cursor(gtkblist->window->window, cursor);
+	gdk_window_set_cursor(win->window->window, cursor);
+	gdk_cursor_unref(cursor);
+	while (gtk_events_pending())
+		gtk_main_iteration();
+
 	name = gaim_conversation_get_name(conv);
 	account = gaim_conversation_get_account(conv);
 
@@ -973,12 +985,17 @@
 		{
 			gaim_gtk_log_show_contact((GaimContact *)node->parent);
 			g_slist_free(buddies);
+			gdk_window_set_cursor(gtkblist->window->window, NULL);
+			gdk_window_set_cursor(win->window->window, NULL);
 			return;
 		}
 	}
 	g_slist_free(buddies);
 
 	gaim_gtk_log_show(type, name, account);
+
+	gdk_window_set_cursor(gtkblist->window->window, NULL);
+	gdk_window_set_cursor(win->window->window, NULL);
 }
 
 static void
@@ -1842,7 +1859,7 @@
 	{
 		if (event->keyval > '0' && event->keyval <= '9')
 		{
-			int switchto = event->keyval - '1';
+			guint switchto = event->keyval - '1';
 			if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win))
 				gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto);
 
--- a/src/gtkdialogs.c	Sun Nov 27 03:17:05 2005 +0000
+++ b/src/gtkdialogs.c	Sun Nov 27 03:20:35 2005 +0000
@@ -31,6 +31,7 @@
 #include "request.h"
 #include "util.h"
 
+#include "gtkblist.h"
 #include "gtkdialogs.h"
 #include "gtkimhtml.h"
 #include "gtkimhtmltoolbar.h"
@@ -676,9 +677,21 @@
 	username = g_strdup(gaim_normalize(account,
 		gaim_request_fields_get_string(fields,  "screenname")));
 
-	if(username != NULL && *username != '\0' && account != NULL )
+	if (username != NULL && *username != '\0' && account != NULL)
+	{
+		GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
+		GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
+
+		gdk_window_set_cursor(gtkblist->window->window, cursor);
+		gdk_cursor_unref(cursor);
+		while (gtk_events_pending())
+			gtk_main_iteration();
+
 		gaim_gtk_log_show(GAIM_LOG_IM, username, account);
 
+		gdk_window_set_cursor(gtkblist->window->window, NULL);
+	}
+
 	g_free(username);
 }
 
--- a/src/gtklog.c	Sun Nov 27 03:17:05 2005 +0000
+++ b/src/gtklog.c	Sun Nov 27 03:20:35 2005 +0000
@@ -87,13 +87,14 @@
 {
 	const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry));
 	GList *logs;
-	GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
+	GdkCursor *cursor;
 
 	if (lv->search != NULL)
 		g_free(lv->search);
 
 	gtk_tree_store_clear(lv->treestore);
-	if (strlen(search_term) == 0) {/* reset the tree */
+	if (!(*search_term)) {
+		/* reset the tree */
 		populate_log_tree(lv);
 		lv->search = NULL;
 		gtk_imhtml_search_clear(GTK_IMHTML(lv->imhtml));
@@ -102,22 +103,25 @@
 
 	lv->search = g_strdup(search_term);
 
+	cursor = gdk_cursor_new(GDK_WATCH);
 	gdk_window_set_cursor(lv->window->window, cursor);
+	gdk_cursor_unref(cursor);
 	while (gtk_events_pending())
 		gtk_main_iteration();
-	gdk_cursor_unref(cursor);
 
 	for (logs = lv->logs; logs != NULL; logs = logs->next) {
 		char *read = gaim_log_read((GaimLog*)logs->data, NULL);
-		if (gaim_strcasestr(read, search_term)) {
+		if (read && *read && gaim_strcasestr(read, search_term)) {
 			GtkTreeIter iter;
 			GaimLog *log = logs->data;
 			char title[64];
 			char *title_utf8; /* temporary variable for utf8 conversion */
+
 			gaim_strftime(title, sizeof(title), "%c", localtime(&log->time));
 			title_utf8 = gaim_utf8_try_convert(title);
 			strncpy(title, title_utf8, sizeof(title));
 			g_free(title_utf8);
+
 			gtk_tree_store_append (lv->treestore, &iter, NULL);
 			gtk_tree_store_set(lv->treestore, &iter,
 					   0, title,
@@ -126,10 +130,7 @@
 		g_free(read);
 	}
 
-
-	cursor = gdk_cursor_new(GDK_LEFT_PTR);
-	gdk_window_set_cursor(lv->window->window, cursor);
-	gdk_cursor_unref(cursor);
+	gdk_window_set_cursor(lv->window->window, NULL);
 }
 
 static gboolean destroy_cb(GtkWidget *w, gint resp, struct log_viewer_hash_t *ht) {
@@ -177,6 +178,7 @@
 	GValue val = { 0, };
 	GtkTreeModel *model = GTK_TREE_MODEL(viewer->treestore);
 	GaimLog *log = NULL;
+	GdkCursor *cursor;
 	GaimLogReadFlags flags;
 	char *read = NULL;
 	char time[64];
@@ -190,6 +192,16 @@
 	if (log == NULL)
 		return;
 
+	/* When we set the initial log, this gets called and the window is still NULL. */
+	if (viewer->window->window != NULL)
+	{
+		cursor = gdk_cursor_new(GDK_WATCH);
+		gdk_window_set_cursor(viewer->window->window, cursor);
+		gdk_cursor_unref(cursor);
+		while (gtk_events_pending())
+			gtk_main_iteration();
+	}
+
 	if (log->type != GAIM_LOG_SYSTEM) {
 		char *title;
 		char *title_utf8; /* temporary variable for utf8 conversion */
@@ -220,13 +232,16 @@
 	gtk_imhtml_append_text(GTK_IMHTML(viewer->imhtml), read,
 			       GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL |
 			       ((flags & GAIM_LOG_READ_NO_NEWLINE) ? GTK_IMHTML_NO_NEWLINE : 0));
+	g_free(read);
 
 	if (viewer->search != NULL) {
 		gtk_imhtml_search_clear(GTK_IMHTML(viewer->imhtml));
 		gtk_imhtml_search_find(GTK_IMHTML(viewer->imhtml), viewer->search);
 	}
 
-	g_free(read);
+	/* When we set the initial log, this gets called and the window is still NULL. */
+	if (viewer->window->window != NULL)
+		gdk_window_set_cursor(viewer->window->window, NULL);
 }
 
 /* I want to make this smarter, but haven't come up with a cool algorithm to do so, yet.