changeset 4168:ebfb80bbe1ed

[gaim-migrate @ 4397] (00:16:51) faceprint: apply my g-signal patch too! </whine> (00:17:02) ChipX86: the what? (00:17:20) faceprint: sorry (00:17:23) faceprint: g-timeout, rather (00:17:28) ChipX86: ah good (00:17:33) faceprint: http://faceprint.com/code/gaim/g-timeout.20030101.1301.diff (00:17:33) ChipX86: yes, APPLY THAT (00:17:38) ChipX86: I need that (00:17:40) LSchiere: one at a time (00:17:51) faceprint: ChipX86: you need that? (00:17:56) ChipX86: for the conversation rewrite (00:17:59) faceprint: ahh (00:18:08) faceprint: it also fixes a memleak for msn users committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 02 Jan 2003 05:20:55 +0000
parents 7002b6f16bdf
children 40d35a98f481
files plugins/chkmail.c plugins/filectl.c plugins/gtik.c plugins/mailchk.c plugins/ticker/gtkticker.c plugins/ticker/ticker.c plugins/timestamp.c src/aim.c src/browser.c src/buddy.c src/conversation.c src/gtkticker.c src/server.c src/ui.h src/win32/win32dep.c
diffstat 15 files changed, 74 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/chkmail.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/plugins/chkmail.c	Thu Jan 02 05:20:55 2003 +0000
@@ -145,7 +145,7 @@
 	gaim_signal_connect(handle, event_blist_update, setup_mail_list, NULL);
 	setup_mail_list();
 	
-	mytimer = gtk_timeout_add(30000, (GtkFunction)check_mail, NULL);
+	mytimer = g_timeout_add(30000, check_mail, NULL);
 }
 
 void check_mail() {
@@ -167,7 +167,7 @@
 	int newnum;
 
 	printf("um\n");
-	gtk_timeout_remove(mytimer);
+	g_source_remove(mytimer);
 
 	printf("nm1\n");
 	newnum = num_msgs();
@@ -184,7 +184,7 @@
 	}
 
 	lastnum = newnum;
-	mytimer = gtk_timeout_add(30000, (GtkFunction)check_mail, NULL);
+	mytimer = g_timeout_add(30000, check_mail, NULL);
 	printf("sml1\n");
 	setup_mail_list();
 	printf("sml2\n");
@@ -193,7 +193,7 @@
 
 
 void gaim_plugin_remove() {
-	gtk_timeout_remove(mytimer);
+	g_source_remove(mytimer);
 	while (state == 1) { }
 	destroy_mail_list();
 	handle = NULL;
--- a/plugins/filectl.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/plugins/filectl.c	Thu Jan 02 05:20:55 2003 +0000
@@ -110,12 +110,12 @@
 char *gaim_plugin_init(GModule *h) {
 	handle = h;
 	init_file();
-	check = gtk_timeout_add(5000, (GtkFunction)check_file, NULL);
+	check = g_timeout_add(5000, check_file, NULL);
 	return NULL;
 }
 
 void gaim_plugin_remove() {
-	gtk_timeout_remove(check);
+	g_source_remove(check);
 }
 
 struct gaim_plugin_description desc; 
--- a/plugins/gtik.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/plugins/gtik.c	Thu Jan 02 05:20:55 2003 +0000
@@ -136,8 +136,8 @@
 	void remove_self(GtkWidget *w, void *handle)
 	{
 		gtk_signal_disconnect(GTK_OBJECT(applet), destroycb);
-		if (drawTimeID > 0) { gtk_timeout_remove(drawTimeID); }
-		if (updateTimeID >0) { gtk_timeout_remove(updateTimeID); }
+		if (drawTimeID > 0) { g_source_remove(drawTimeID); }
+		if (updateTimeID >0) { g_source_remove(updateTimeID); }
 		gtk_widget_destroy(applet);
 		gaim_plugin_unload(handle);
 	}
@@ -892,9 +892,9 @@
 
 
 		/* KEEPING TIMER ID FOR CLEANUP IN DESTROY */
-		drawTimeID   = gtk_timeout_add(2,Repaint,drawing_area);
-		updateTimeID = gtk_timeout_add(props.timeout * 60000,
-				   (gpointer)updateOutput,"NULL");
+		drawTimeID   = g_timeout_add(2,Repaint,drawing_area);
+		updateTimeID = g_timeout_add(props.timeout * 60000,
+				   updateOutput,"NULL");
 
 
 		return NULL;
@@ -918,8 +918,8 @@
 	/*-----------------------------------------------------------------*/
 	void gaim_plugin_remove() {
 		gtk_signal_disconnect(GTK_OBJECT(applet), destroycb);
-		if (drawTimeID > 0) { gtk_timeout_remove(drawTimeID); }
-		if (updateTimeID >0) { gtk_timeout_remove(updateTimeID); }
+		if (drawTimeID > 0) { g_source_remove(drawTimeID); }
+		if (updateTimeID >0) { g_source_remove(updateTimeID); }
 		gtk_widget_destroy(applet);
 	}
 
--- a/plugins/mailchk.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/plugins/mailchk.c	Thu Jan 02 05:20:55 2003 +0000
@@ -84,13 +84,13 @@
 static void mail_signon(struct gaim_connection *gc)
 {
 	if (blist && !timer)
-		timer = gtk_timeout_add(2000, check_timeout, NULL);
+		timer = g_timeout_add(2000, check_timeout, NULL);
 }
 
 static void mail_signoff(struct gaim_connection *gc)
 {
 	if (!blist && timer) {
-		gtk_timeout_remove(timer);
+		g_source_remove(timer);
 		timer = 0;
 	}
 }
@@ -100,7 +100,7 @@
 	if (!check_timeout(NULL))
 		return "Could not read $MAIL or /var/spool/mail/$USER";
 	if (blist)
-		timer = gtk_timeout_add(2000, check_timeout, NULL);
+		timer = g_timeout_add(2000, check_timeout, NULL);
 	gaim_signal_connect(m, event_signon, mail_signon, NULL);
 	gaim_signal_connect(m, event_signoff, mail_signoff, NULL);
 	return NULL;
@@ -109,7 +109,7 @@
 void gaim_plugin_remove()
 {
 	if (timer)
-		gtk_timeout_remove(timer);
+		g_source_remove(timer);
 	timer = 0;
 	if (mail)
 		gtk_widget_destroy(mail);
--- a/plugins/ticker/gtkticker.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/plugins/ticker/gtkticker.c	Thu Jan 02 05:20:55 2003 +0000
@@ -229,8 +229,7 @@
   	g_return_if_fail (GTK_IS_TICKER (ticker));
 	if ( ticker->timer != 0 )
 		return;
-	ticker->timer = gtk_timeout_add(ticker->interval, 
-		ticker_timeout, ticker);
+	ticker->timer = g_timeout_add(ticker->interval, ticker_timeout, ticker);
 }
 
 void       
@@ -240,7 +239,7 @@
   	g_return_if_fail (GTK_IS_TICKER (ticker));
 	if ( ticker->timer == 0 )
 		return;
-	gtk_timeout_remove( ticker->timer );
+	g_source_remove(ticker->timer);
 	ticker->timer = 0;
 	
 }
--- a/plugins/ticker/ticker.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/plugins/ticker/ticker.c	Thu Jan 02 05:20:55 2003 +0000
@@ -111,9 +111,9 @@
         */
 	gtk_ticker_start_scroll( GTK_TICKER( ticker ) );
 
-	gtk_timeout_add( 60000, BuddyTickerMessageRemove, (gpointer)  NULL );
+	g_timeout_add( 60000, BuddyTickerMessageRemove, NULL);
 
-        gtk_widget_show_all (ticker);
+	gtk_widget_show_all (ticker);
 
 }
 
--- a/plugins/timestamp.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/plugins/timestamp.c	Thu Jan 02 05:20:55 2003 +0000
@@ -31,10 +31,9 @@
 {
 	struct conversation *c = find_conversation(name);
 	do_timestamp(c);
-	
+
 	timestamp_timeouts = g_slist_append(timestamp_timeouts,
-			GINT_TO_POINTER(gtk_timeout_add(TIMESTAMP_DELAY,
-				(GtkFunction)do_timestamp, c)));
+			GINT_TO_POINTER(g_timeout_add(TIMESTAMP_DELAY, do_timestamp, c)));
 
 }
 char *gaim_plugin_init(GModule *h) {
@@ -56,7 +55,7 @@
 	GSList *to;
 	to = timestamp_timeouts;
 	while (to) {
-		gtk_timeout_remove(GPOINTER_TO_INT(to->data));
+		g_source_remove(GPOINTER_TO_INT(to->data));
 		to = to->next;
 	}
 	g_slist_free(timestamp_timeouts);
--- a/src/aim.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/src/aim.c	Thu Jan 02 05:20:55 2003 +0000
@@ -136,10 +136,11 @@
 
 static int snd_tmout;
 int logins_not_muted = 1;
-static void sound_timeout()
+static gboolean sound_timeout(gpointer data)
 {
 	logins_not_muted = 1;
-	gtk_timeout_remove(snd_tmout);
+	g_source_remove(snd_tmout);
+	return FALSE;
 }
 
 /* we need to do this for Oscar because serv_login only starts the login
@@ -149,7 +150,7 @@
 {
 	if ((sound_options & OPT_SOUND_LOGIN) && (sound_options & OPT_SOUND_SILENT_SIGNON)) {
 		logins_not_muted = 0;
-		snd_tmout = gtk_timeout_add(10000, (GtkFunction)sound_timeout, NULL);
+		snd_tmout = g_timeout_add(10000, sound_timeout, NULL);
 	}
 }
 
--- a/src/browser.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/src/browser.c	Thu Jan 02 05:20:55 2003 +0000
@@ -486,8 +486,9 @@
 }
 
 
-gint check_netscape(char *msg)
+gboolean check_netscape(gpointer data)
 {
+	char *msg = data;
 	int status;
 	GdkWindow *window;
 
@@ -561,7 +562,7 @@
 			_exit(0);
 		} else {
 			char *tmp = g_strdup(command);
-			gtk_timeout_add(200, (GtkFunction)check_netscape, tmp);
+			g_timeout_add(200, check_netscape, tmp);
 		}
 	}
 
--- a/src/buddy.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/src/buddy.c	Thu Jan 02 05:20:55 2003 +0000
@@ -145,7 +145,7 @@
 				if (!bs->connlist) {
 					gs->members = g_slist_remove(gs->members, bs);
 					if (bs->log_timer > 0)
-						gtk_timeout_remove(bs->log_timer);
+						g_source_remove(bs->log_timer);
 					bs->log_timer = 0;
 					remove_buddy_show(gs, bs);
 					g_free(bs->show);
@@ -199,7 +199,7 @@
 					if (!bs->connlist) {
 						gs->members = g_slist_remove(gs->members, bs);
 						if (bs->log_timer > 0)
-							gtk_timeout_remove(bs->log_timer);
+							g_source_remove(bs->log_timer);
 						bs->log_timer = 0;
 						remove_buddy_show(gs, bs);
 						g_free(bs->show);
@@ -274,7 +274,7 @@
 		if (!bs->connlist) {
 			gs->members = g_slist_remove(gs->members, bs);
 			if (bs->log_timer > 0)
-				gtk_timeout_remove(bs->log_timer);
+				g_source_remove(bs->log_timer);
 			bs->log_timer = 0;
 			remove_buddy_show(gs, bs);
 			g_free(bs->show);
@@ -303,7 +303,7 @@
 			debug_printf("buddy_show still exists: %s\n", b->name);
 			m = g_slist_remove(m, b);
 			if (b->log_timer > 0)
-				gtk_timeout_remove(b->log_timer);
+				g_source_remove(b->log_timer);
 			b->log_timer = 0;
 			gtk_tree_remove_item(GTK_TREE(g->tree), b->item);
 			g_free(b->show);
@@ -904,7 +904,7 @@
 				if (!g_slist_length(bs->connlist)) {
 					gs->members = g_slist_remove(gs->members, bs);
 					if (bs->log_timer > 0)
-						gtk_timeout_remove(bs->log_timer);
+						g_source_remove(bs->log_timer);
 					bs->log_timer = 0;
 					remove_buddy_show(gs, bs);
 					g_free(bs->show);
@@ -1012,7 +1012,7 @@
 			bs = (struct buddy_show *)m->data;
 			m = g_slist_remove(m, bs);
 			if (bs->log_timer > 0)
-				gtk_timeout_remove(bs->log_timer);
+				g_source_remove(bs->log_timer);
 			g_free(bs->show);
 			g_free(bs->name);
 			g_free(bs);
@@ -2099,8 +2099,9 @@
 	}
 }
 
-static gint log_timeout(struct buddy_show *b)
+static gboolean log_timeout(gpointer data)
 {
+	struct buddy_show *b = data;
 	/* this part is really just a bad hack because of a bug I can't find */
 	GSList *s = shows;
 	while (s) {
@@ -2116,7 +2117,7 @@
 		s = s->next;
 	}
 	if (!s)
-		return 0;
+		return FALSE;
 
 	/* this is the real part. */
 	if (!b->connlist) {
@@ -2133,7 +2134,7 @@
 			g_free(g->name);
 			g_free(g);
 		}
-		gtk_timeout_remove(b->log_timer);
+		g_source_remove(b->log_timer);
 		b->log_timer = 0;
 		g_free(b->name);
 		g_free(b->show);
@@ -2157,11 +2158,11 @@
 			gtk_widget_hide(b->pix);
 		gdk_pixmap_unref(pm);
 		gdk_bitmap_unref(bm);
-		gtk_timeout_remove(b->log_timer);
+		g_source_remove(b->log_timer);
 		b->log_timer = 0;
 		b->sound = 0;
 	}
-	return 0;
+	return FALSE;
 }
 
 static char *caps_string(guint caps)
@@ -2390,8 +2391,8 @@
 			gdk_bitmap_unref(bm);
 			b->present = 2;
 			if (bs->log_timer > 0)
-				gtk_timeout_remove(bs->log_timer);
-			bs->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs);
+				g_source_remove(bs->log_timer);
+			bs->log_timer = g_timeout_add(10000, log_timeout, bs);
 			if ((bs->sound != 2) && (im_options & OPT_IM_LOGON)) {
 				struct conversation *c = find_conversation(b->name);
 				if (c) {
@@ -2443,8 +2444,8 @@
 		bs->connlist = g_slist_remove(bs->connlist, gc);
 		update_num_group(gs);
 		if (bs->log_timer > 0)
-			gtk_timeout_remove(bs->log_timer);
-		bs->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs);
+			g_source_remove(bs->log_timer);
+		bs->log_timer = g_timeout_add(10000, log_timeout, bs);
 		pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, logout_icon_xpm);
 		gtk_widget_hide(bs->pix);
 		gtk_pixmap_set(GTK_PIXMAP(bs->pix), pm, bm);
--- a/src/conversation.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/src/conversation.c	Thu Jan 02 05:20:55 2003 +0000
@@ -364,9 +364,9 @@
 	}
 	g_list_free(c->send_history);
 	if (c->typing_timeout)
-		gtk_timeout_remove(c->typing_timeout);
+		g_source_remove(c->typing_timeout);
 	if (c->type_again_timeout)
-		gtk_timeout_remove(c->type_again_timeout);
+		g_source_remove(c->type_again_timeout);
 	g_string_free(c->history, TRUE);
 	g_free(c);
 }
@@ -1138,8 +1138,8 @@
 	/* we know we got something, so we at least have to make sure we don't send
 	 * TYPED any time soon */
 	if(c->type_again_timeout)
-		gtk_timeout_remove(c->type_again_timeout);
-	c->type_again_timeout = gtk_timeout_add(SEND_TYPED_TIMEOUT, send_typed, c);
+		g_source_remove(c->type_again_timeout);
+	c->type_again_timeout = g_timeout_add(SEND_TYPED_TIMEOUT, send_typed, c);
 
 	/* we send typed if this is the first character typed, or if we're due
 	 * to send another one */
@@ -1162,8 +1162,10 @@
 		return;
 
 	if(gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) {
-		if(c->type_again_timeout)
-			gtk_timeout_remove(c->type_again_timeout);
+		if(c->type_again_timeout) {
+			g_source_remove(c->type_again_timeout);
+			c->type_again_timeout = 0;
+		}
 		serv_send_typing(c->gc, c->name, NOT_TYPING);
 	} else {
 		/* we're deleting, but not all of it, so it counts as typing */
@@ -2777,18 +2779,16 @@
 }
 
 /* This returns a boolean, so that it can timeout */
-gboolean reset_typing(char *name) {
+gboolean reset_typing(gpointer data) {
+	char *name = data;
 	struct conversation *c = find_conversation(name);
-	if (!c) {
-		g_free(name);
+	if (!c)
 		return FALSE;
-	}
 
 	/* Reset the title (if necessary) */
 	c->typing_state = NOT_TYPING;
 	update_convo_status(c);
 
-	g_free(name);
 	c->typing_timeout = 0;
 	return FALSE;
 }
@@ -3517,14 +3517,14 @@
 		gdk_bitmap_unref(bm);
 	delay = gdk_pixbuf_animation_iter_get_delay_time(c->iter) / 10;
 
-	c->icon_timer = gtk_timeout_add(delay * 10, redraw_icon, c);
+	c->icon_timer = g_timeout_add(delay * 10, redraw_icon, c);
 	return FALSE;
 }
 
 static void stop_anim(GtkObject *obj, struct conversation *c)
 {
 	if (c->icon_timer)
-		gtk_timeout_remove(c->icon_timer);
+		g_source_remove(c->icon_timer);
 	c->icon_timer = 0;
 }
 
@@ -3533,7 +3533,7 @@
 	int delay;
 	delay = gdk_pixbuf_animation_iter_get_delay_time(c->iter) / 10;
 	if (c->anim)
-	    c->icon_timer = gtk_timeout_add(delay * 10, redraw_icon, c);
+	    c->icon_timer = g_timeout_add(delay * 10, redraw_icon, c);
 }
 
 static int des_save_icon(GtkObject *obj, GdkEvent *e, struct conversation *c)
@@ -3652,7 +3652,7 @@
 		gdk_pixbuf_animation_unref(c->anim);
 	c->anim = NULL;
 	if (c->icon_timer)
-		gtk_timeout_remove(c->icon_timer);
+		g_source_remove(c->icon_timer);
 	c->icon_timer = 0;
 	if(c->iter)
 		g_object_unref(G_OBJECT(c->iter));
@@ -3730,7 +3730,7 @@
 						GDK_INTERP_NEAREST);
 	
 	if (delay)
-		c->icon_timer = gtk_timeout_add(delay * 10, redraw_icon, c);
+		c->icon_timer = g_timeout_add(delay * 10, redraw_icon, c);
 	
 
 	gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100);
--- a/src/gtkticker.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/src/gtkticker.c	Thu Jan 02 05:20:55 2003 +0000
@@ -236,7 +236,7 @@
   	g_return_if_fail (GTK_IS_TICKER (ticker));
 	if ( ticker->timer != 0 )
 		return;
-	ticker->timer = gtk_timeout_add(ticker->interval, 
+	ticker->timer = g_timeout_add(ticker->interval,
 		ticker_timeout, ticker);
 }
 
@@ -247,7 +247,7 @@
   	g_return_if_fail (GTK_IS_TICKER (ticker));
 	if ( ticker->timer == 0 )
 		return;
-	gtk_timeout_remove( ticker->timer );
+	g_source_remove(ticker->timer);
 	ticker->timer = 0;
 	
 }
--- a/src/server.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/src/server.c	Thu Jan 02 05:20:55 2003 +0000
@@ -190,7 +190,7 @@
 	}
 
 	if (cnv && cnv->type_again_timeout)
-		gtk_timeout_remove(cnv->type_again_timeout);
+		g_source_remove(cnv->type_again_timeout);
 
 	return val;
 }
@@ -881,9 +881,9 @@
 	 do_pounce(gc, name, OPT_POUNCE_TYPING);
 	 if (timeout > 0) {
 		 if (cnv->typing_timeout)
-			 gtk_timeout_remove (cnv->typing_timeout);
-		 cnv->typing_timeout = gtk_timeout_add(timeout * 1000,(GtkFunction)reset_typing,
-						       g_strdup(name));
+			 g_source_remove (cnv->typing_timeout);
+		 cnv->typing_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE,
+				 timeout * 1000, reset_typing, g_strdup(name), g_free);
 	 }
 }
 
@@ -892,7 +892,8 @@
 	if(!c)
 		return;
 	if (c->typing_timeout) {
-		gtk_timeout_remove (c->typing_timeout);
+		g_source_remove(c->typing_timeout);
+		c->typing_timeout=0;
 	}
 	c->typing_state = NOT_TYPING;
 	update_convo_status(c);
--- a/src/ui.h	Thu Jan 02 05:18:16 2003 +0000
+++ b/src/ui.h	Thu Jan 02 05:20:55 2003 +0000
@@ -429,7 +429,7 @@
 extern void set_convo_titles();
 extern void update_progress(struct conversation *, float);
 extern void update_convo_status(struct conversation *);
-extern gboolean reset_typing(char *);
+extern gboolean reset_typing(gpointer);
 extern void set_anim();
 
 /* Functions in dialogs.c */
--- a/src/win32/win32dep.c	Thu Jan 02 05:18:16 2003 +0000
+++ b/src/win32/win32dep.c	Thu Jan 02 05:20:55 2003 +0000
@@ -72,7 +72,7 @@
 static void halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, WGAIM_FLASH_INFO *finfo) {
 	/* Stop flashing and remove filter */
 	debug_printf("Removing timeout\n");
-	gtk_timeout_remove(finfo->t_handle);
+	g_source_remove(finfo->t_handle);
 	debug_printf("Disconnecting signal handler\n");
 	g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler);
 	debug_printf("done\n");
@@ -200,7 +200,7 @@
 		WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1);
 
 		/* Start Flashing window */
-		finfo->t_handle = gtk_timeout_add(1000, flash_window_cb, GDK_WINDOW_HWND(window->window));
+		finfo->t_handle = g_timeout_add(1000, flash_window_cb, GDK_WINDOW_HWND(window->window));
 		finfo->sig_handler = g_signal_connect(G_OBJECT(window), "focus-in-event", G_CALLBACK(halt_flash_filter), finfo);
 	}
 }