pidgin: c4a9f171: A patch from Arunan Balasubramaniam to u...

qulogic at pidgin.im qulogic at pidgin.im
Fri Apr 10 03:36:10 EDT 2009


-----------------------------------------------------------------
Revision: c4a9f171d2b79dc2380555bf901bebb19c19ccd6
Ancestor: fe4f5d91d1605cf93c53470e59d4bf8da6c5c840
Author: foss at abala.me
Date: 2009-04-10T06:32:57
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c4a9f171d2b79dc2380555bf901bebb19c19ccd6

Modified files:
        pidgin/gtkblist.c pidgin/gtkconv.c pidgin/gtkdebug.c
        pidgin/gtksound.c pidgin/gtkstatusbox.c pidgin/gtkutils.c
        pidgin/plugins/cap/cap.c pidgin/plugins/mailchk.c

ChangeLog: 

A patch from Arunan Balasubramaniam to use timeouts in seconds instead of
milliseconds in Pidgin. This enables grouping of timers for greater power
efficiency.

Fixes #8834.

-------------- next part --------------
============================================================
--- pidgin/gtkblist.c	805acaf8f242e7b5271fc70a0fc0b5c92e8ff368
+++ pidgin/gtkblist.c	e9a4cf63db522a4ba8199554e0546b588d13ba58
@@ -5795,7 +5795,7 @@ static void pidgin_blist_show(PurpleBudd
 	purple_blist_set_visible(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/list_visible"));
 
 	/* start the refresh timer */
-	gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)pidgin_blist_refresh_timer, list);
+	gtkblist->refresh_timer = purple_timeout_add_seconds(30, (GSourceFunc)pidgin_blist_refresh_timer, list);
 
 	handle = pidgin_blist_get_handle();
 
@@ -5916,7 +5916,7 @@ pidgin_blist_update_refresh_timeout()
 	blist = purple_get_blist();
 	gtkblist = PIDGIN_BLIST(purple_get_blist());
 
-	gtkblist->refresh_timer = g_timeout_add(30000,(GSourceFunc)pidgin_blist_refresh_timer, blist);
+	gtkblist->refresh_timer = purple_timeout_add_seconds(30,(GSourceFunc)pidgin_blist_refresh_timer, blist);
 }
 
 static gboolean get_iter_from_node(PurpleBlistNode *node, GtkTreeIter *iter) {
@@ -6637,7 +6637,7 @@ static void pidgin_blist_destroy(PurpleB
 	pidgin_blist_tooltip_destroy();
 
 	if (gtkblist->refresh_timer)
-		g_source_remove(gtkblist->refresh_timer);
+		purple_timeout_remove(gtkblist->refresh_timer);
 	if (gtkblist->timeout)
 		g_source_remove(gtkblist->timeout);
 	if (gtkblist->drag_timeout)
@@ -7452,7 +7452,7 @@ static void buddy_signonoff_cb(PurpleBud
 
 	if(gtknode->recent_signonoff_timer > 0)
 		purple_timeout_remove(gtknode->recent_signonoff_timer);
-	gtknode->recent_signonoff_timer = purple_timeout_add(10000,
+	gtknode->recent_signonoff_timer = purple_timeout_add_seconds(10,
 			(GSourceFunc)buddy_signonoff_timeout_cb, buddy);
 }
 
============================================================
--- pidgin/gtkconv.c	48ccd8ac1e2c6604ab4967892b4796f7acb6cceb
+++ pidgin/gtkconv.c	b9e0de7636b23d4921b1cab4a0a5147cc1fccd49
@@ -7514,7 +7514,7 @@ update_buddy_status_changed(PurpleBuddy 
 	}
 
 	/* In case a conversation is started after the buddy has signed-on/off */
-	g_timeout_add(11000, (GSourceFunc)update_buddy_status_timeout, buddy);
+	purple_timeout_add_seconds(11, (GSourceFunc)update_buddy_status_timeout, buddy);
 }
 
 static void
============================================================
--- pidgin/gtkdebug.c	2df81bffb9546e38ab42d114edfbd745b9dfebb6
+++ pidgin/gtkdebug.c	bb0222df5693ebda1e84f3dad8fabc2ba9d53a6c
@@ -94,7 +94,7 @@ debug_window_destroy(GtkWidget *w, GdkEv
 	if(debug_win->timer != 0) {
 		const gchar *text;
 
-		g_source_remove(debug_win->timer);
+		purple_timeout_remove(debug_win->timer);
 
 		text = gtk_entry_get_text(GTK_ENTRY(debug_win->expression));
 		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/debug/regex", text);
@@ -552,7 +552,7 @@ regex_changed_cb(GtkWidget *w, DebugWind
 	}
 
 	if(win->timer == 0)
-		win->timer = purple_timeout_add(5000, (GSourceFunc)regex_timer_cb, win);
+		win->timer = purple_timeout_add_seconds(5, (GSourceFunc)regex_timer_cb, win);
 
 	regex_compile(win);
 }
============================================================
--- pidgin/gtksound.c	3ab401fcafc9a020fff1a06df2911d9fc22f2845
+++ pidgin/gtksound.c	61e07f65e9b74617429abb08d55ef3d2fa4cb9a6
@@ -226,9 +226,9 @@ account_signon_cb(PurpleConnection *gc, 
 account_signon_cb(PurpleConnection *gc, gpointer data)
 {
 	if (mute_login_sounds_timeout != 0)
-		g_source_remove(mute_login_sounds_timeout);
+		purple_timeout_remove(mute_login_sounds_timeout);
 	mute_login_sounds = TRUE;
-	mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL);
+	mute_login_sounds_timeout = purple_timeout_add_seconds(10, unmute_login_sounds_cb, NULL);
 }
 
 const char *
============================================================
--- pidgin/gtkstatusbox.c	8d91afa31e6a41412efe78b3f6aa09973b24422f
+++ pidgin/gtkstatusbox.c	93a31b2a51ea84302d9017bdfffb43ff53d48201
@@ -67,7 +67,8 @@
 #  endif
 #endif
 
-#define TYPING_TIMEOUT 4000
+/* Timeout for typing notifications in seconds */
+#define TYPING_TIMEOUT 4
 
 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data);
 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data);
@@ -1155,7 +1156,7 @@ static gboolean imhtml_remove_focus(GtkW
 	/* Reset the status if Escape was pressed */
 	if (event->keyval == GDK_Escape)
 	{
-		g_source_remove(status_box->typing);
+		purple_timeout_remove(status_box->typing);
 		status_box->typing = 0;
 		if (status_box->account != NULL)
 			update_to_reflect_account_status(status_box, status_box->account,
@@ -1168,8 +1169,8 @@ static gboolean imhtml_remove_focus(GtkW
 	}
 
 	pidgin_status_box_pulse_typing(status_box);
-	g_source_remove(status_box->typing);
-	status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
+	purple_timeout_remove(status_box->typing);
+	status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
 
 	return FALSE;
 }
@@ -2596,7 +2597,7 @@ static void remove_typing_cb(PidginStatu
 		return;
 	}
 
-	g_source_remove(status_box->typing);
+	purple_timeout_remove(status_box->typing);
 	status_box->typing = 0;
 
 	activate_currently_selected_status(status_box);
@@ -2624,7 +2625,7 @@ static void pidgin_status_box_changed(Pi
 			   DATA_COLUMN, &data,
 			   -1);
 	if (status_box->typing != 0)
-		g_source_remove(status_box->typing);
+		purple_timeout_remove(status_box->typing);
 	status_box->typing = 0;
 
 	if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box)))
@@ -2692,7 +2693,7 @@ static void pidgin_status_box_changed(Pi
 			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);
+			status_box->typing = purple_timeout_add_seconds(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);
@@ -2741,9 +2742,9 @@ static void imhtml_changed_cb(GtkTextBuf
 	{
 		if (status_box->typing != 0) {
 			pidgin_status_box_pulse_typing(status_box);
-			g_source_remove(status_box->typing);
+			purple_timeout_remove(status_box->typing);
 		}
-		status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
+		status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
 	}
 	pidgin_status_box_refresh(status_box);
 }
============================================================
--- pidgin/gtkutils.c	eabb9d677f339f0ec49f920eebb6906267840094
+++ pidgin/gtkutils.c	f818ac92f5362cf71c9f0699829bb094ef1be6d3
@@ -950,7 +950,7 @@ pidgin_save_accels_cb(GtkAccelGroup *acc
 	           "accel changed, scheduling save.\n");
 
 	if (!accels_save_timer)
-		accels_save_timer = g_timeout_add(5000, pidgin_save_accels,
+		accels_save_timer = purple_timeout_add_seconds(5, pidgin_save_accels,
 		                                  NULL);
 }
 
============================================================
--- pidgin/plugins/cap/cap.c	38235d764da257742a1ea4fe0b989acd6f04b5de
+++ pidgin/plugins/cap/cap.c	7eeb66f4f88299e51e470dff130793a447aef762
@@ -135,7 +135,7 @@ static void destroy_stats(gpointer data)
 	/* g_free(stats->hourly_usage); */
 	/* g_free(stats->daily_usage); */
 	if (stats->timeout_source_id != 0)
-		g_source_remove(stats->timeout_source_id);
+		purple_timeout_remove(stats->timeout_source_id);
 	g_free(stats);
 }
 
@@ -352,7 +352,7 @@ static void sent_im_msg(PurpleAccount *a
 	if (buddy == NULL)
 		return;
 
-	interval = purple_prefs_get_int("/plugins/gtk/cap/max_msg_difference") * 1000 * 60;
+	interval = purple_prefs_get_int("/plugins/gtk/cap/max_msg_difference") * 60;
 	words = word_count(message);
 
 	stats = get_stats_for(buddy);
@@ -361,9 +361,9 @@ static void sent_im_msg(PurpleAccount *a
 	stats->last_message = time(NULL);
 	stats->last_message_status_id = purple_status_get_id(get_status_for(buddy));
 	if(stats->timeout_source_id != 0)
-		g_source_remove(stats->timeout_source_id);
+		purple_timeout_remove(stats->timeout_source_id);
 
-	stats->timeout_source_id = g_timeout_add(interval, max_message_difference_cb, stats);
+	stats->timeout_source_id = purple_timeout_add_seconds(interval, max_message_difference_cb, stats);
 }
 
 /* received-im-msg */
@@ -386,7 +386,7 @@ received_im_msg(PurpleAccount *account, 
 	 * then cancel the timeout callback. */
 	if(stats->timeout_source_id != 0) {
 		purple_debug_info("cap", "Cancelling timeout callback\n");
-		g_source_remove(stats->timeout_source_id);
+		purple_timeout_remove(stats->timeout_source_id);
 		stats->timeout_source_id = 0;
 	}
 
@@ -697,7 +697,7 @@ static void cancel_conversation_timeouts
 static void cancel_conversation_timeouts(gpointer key, gpointer value, gpointer user_data) {
 	CapStatistics *stats = value;
 	if(stats->timeout_source_id != 0) {
-		g_source_remove(stats->timeout_source_id);
+		purple_timeout_remove(stats->timeout_source_id);
 		stats->timeout_source_id = 0;
 	}
 }
============================================================
--- pidgin/plugins/mailchk.c	6ae526cbe9e9ab03f0584bca32628db8d0189ef9
+++ pidgin/plugins/mailchk.c	497ffd8427cc691d6c78ccb04c2789b4a17eee72
@@ -13,7 +13,7 @@
 #define UNREAD_MAIL 0x02
 #define NEW_MAIL    0x04
 
-static guint32 timer = 0;
+static guint timer = 0;
 static GtkWidget *mail = NULL;
 
 static gint
@@ -93,7 +93,7 @@ signon_cb(PurpleConnection *gc)
 	PurpleBuddyList *list = purple_get_blist();
 	if (list && PURPLE_IS_GTK_BLIST(list) && !timer) {
 		check_timeout(NULL); /* we want the box to be drawn immediately */
-		timer = g_timeout_add(2000, check_timeout, NULL);
+		timer = purple_timeout_add_seconds(2, check_timeout, NULL);
 	}
 }
 
@@ -102,7 +102,7 @@ signoff_cb(PurpleConnection *gc)
 {
 	PurpleBuddyList *list = purple_get_blist();
 	if ((!list || !PURPLE_IS_GTK_BLIST(list) || !PIDGIN_BLIST(list)->vbox) && timer) {
-		g_source_remove(timer);
+		purple_timeout_remove(timer);
 		timer = 0;
 	}
 }
@@ -123,7 +123,7 @@ plugin_load(PurplePlugin *plugin)
 	}
 
 	if (list && PURPLE_IS_GTK_BLIST(list) && PIDGIN_BLIST(list)->vbox)
-		timer = g_timeout_add(2000, check_timeout, NULL);
+		timer = purple_timeout_add_seconds(2, check_timeout, NULL);
 
 	purple_signal_connect(conn_handle, "signed-on",
 						plugin, PURPLE_CALLBACK(signon_cb), NULL);
@@ -137,7 +137,7 @@ plugin_unload(PurplePlugin *plugin)
 plugin_unload(PurplePlugin *plugin)
 {
 	if (timer)
-		g_source_remove(timer);
+		purple_timeout_remove(timer);
 	timer = 0;
 	if (mail)
 		gtk_widget_destroy(mail);


More information about the Commits mailing list