changeset 10354:0c985021a1d8

[gaim-migrate @ 11571] Removed "Auto-expand contacts," defaulted to "no." Added the auto-expand functionality to when a drag is being accepted (useful for organizing your list and for choosing a specific account to file transfer to if need be). I may have missed a few kinks in changing it over, so test this. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 13 Dec 2004 02:17:04 +0000
parents fc7168f9ecb0
children d3545b0c6b1c
files ChangeLog src/gtkblist.c src/gtkblist.h src/gtkprefs.c
diffstat 4 files changed, 87 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Dec 13 02:02:05 2004 +0000
+++ b/ChangeLog	Mon Dec 13 02:17:04 2004 +0000
@@ -14,7 +14,8 @@
 	* Smiley selection dialog rewritten to look nicer (Nathan Fredrickson)
 	* If Gaim is exited with the buddy list hidden in the docklet, it will
 	  remain hidden when Gaim is started again (Scott Shedden)
-	
+	* Contacts will auto-expand when dragging into the buddy list.
+
 	Bug fixes:
 	* Some memory leaks plugged (Miah Gregory, Felipe Contreras)
 	* People using input methods can now use Enter again.
@@ -37,7 +38,7 @@
 	* Removed "Display remote nicknames if no alias is set"
 	* Removed "Show idle times" and "Show warning levels" from the buddy list
 	  defaulted to "Yes".
-
+	* Removed "Auto-expand contacts" default to "No".
 version 1.0.2 (10/19/2004):
 	Bug Fixes:
 	* MSN file transfers work on big endian machines (Jean-Francois Roy and
--- a/src/gtkblist.c	Mon Dec 13 02:02:05 2004 +0000
+++ b/src/gtkblist.c	Mon Dec 13 02:17:04 2004 +0000
@@ -2098,6 +2098,46 @@
 #endif
 }
 
+
+static gboolean gaim_gtk_blist_expand_timeout(GtkWidget *tv)
+{
+	GtkTreePath *path;
+	GtkTreeIter iter;
+	GaimBlistNode *node;
+	GValue val = {0};
+	struct _gaim_gtk_blist_node *gtknode;
+
+	if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->tip_rect.x, gtkblist->tip_rect.y, &path, NULL, NULL, NULL))
+		return FALSE;
+	gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
+	gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
+	node = g_value_get_pointer(&val);
+
+	if(!GAIM_BLIST_NODE_IS_CONTACT(node))
+		return FALSE;
+
+	gtknode = node->ui_data;
+
+	if (!gtknode->contact_expanded) {
+		GtkTreeIter i;
+		
+		gaim_gtk_blist_expand_contact_cb(NULL, node);
+		
+		gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &gtkblist->contact_rect);
+		gdk_drawable_get_size(GDK_DRAWABLE(tv->window), &(gtkblist->contact_rect.width), NULL);
+		gtkblist->mouseover_contact = node;
+		gtk_tree_path_down (path);
+		while (gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &i, path)) {
+			GdkRectangle rect;
+			gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &rect);
+			gtkblist->contact_rect.height += rect.height;
+			gtk_tree_path_next(path);
+		}
+	}
+	gtk_tree_path_free(path);
+	return FALSE;
+}
+
 static gboolean gaim_gtk_blist_tooltip_timeout(GtkWidget *tv)
 {
 	GtkTreePath *path;
@@ -2130,40 +2170,6 @@
 
 	gtknode = node->ui_data;
 
-	if (node->child && GAIM_BLIST_NODE_IS_CONTACT(node) &&
-			(((GaimContact*)node)->online > 1 ||
-			 (gaim_blist_node_get_bool(node, "show_offline") &&
-			  ((GaimContact*)node)->currentsize > 1)) &&
-			!gtknode->contact_expanded &&
-			gaim_prefs_get_bool("/gaim/gtk/blist/auto_expand_contacts")) {
-		GtkTreeIter i;
-		gaim_gtk_blist_expand_contact_cb(NULL, node);
-		tooltip_top = TRUE; /* When the person expands, the new screennames will be below.
-							   We'll draw the tip above the cursor so that the user can see
-							   the included buddies */
-
-		while (gtk_events_pending())
-			gtk_main_iteration();
-
-		/* we check to see if we're still supposed to be moving, now that gtk events have
-		 * happened, and the mouse might not still be in the buddy list */
-		if(!gtkblist->timeout) {
-			gaim_gtk_blist_collapse_contact_cb(NULL, node);
-			return FALSE;
-		}
-
-		gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &gtkblist->contact_rect);
-		gdk_drawable_get_size(GDK_DRAWABLE(tv->window), &(gtkblist->contact_rect.width), NULL);
-		gtkblist->mouseover_contact = node;
-		gtk_tree_path_down (path);
-		while (gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &i, path)) {
-			GdkRectangle rect;
-			gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &rect);
-			gtkblist->contact_rect.height += rect.height;
-			gtk_tree_path_next(path);
-		}
-	}
-
 	gtk_tree_path_free(path);
 
 	tooltiptext = gaim_get_tooltip_text(node);
@@ -2293,6 +2299,38 @@
 	return FALSE;
 }
 
+static gboolean gaim_gtk_blist_drag_motion_cb(GtkWidget *tv, GdkDragContext *drag_context,
+					      gint x, gint y, guint time, gpointer user_data)
+{
+	GtkTreePath *path;
+	int delay;
+
+	delay = 500;
+
+	if (gtkblist->drag_timeout) {
+		if ((y > gtkblist->tip_rect.y) && ((y - gtkblist->tip_rect.height) < gtkblist->tip_rect.y))
+			return FALSE;
+		/* We've left the cell.  Remove the timeout and create a new one below */
+		g_source_remove(gtkblist->drag_timeout);
+	}
+
+	gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), x, y, &path, NULL, NULL, NULL);
+	gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &gtkblist->tip_rect);
+
+	if (path)
+		gtk_tree_path_free(path);
+	gtkblist->drag_timeout = g_timeout_add(delay, (GSourceFunc)gaim_gtk_blist_expand_timeout, tv);
+
+	if (gtkblist->mouseover_contact) {
+		if ((y < gtkblist->contact_rect.y) || ((y - gtkblist->contact_rect.height) > gtkblist->contact_rect.y)) {
+			gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact);
+			gtkblist->mouseover_contact = NULL;
+		}
+	}
+
+	return FALSE;
+}
+
 static gboolean gaim_gtk_blist_motion_cb (GtkWidget *tv, GdkEventMotion *event, gpointer null)
 {
 	GtkTreePath *path;
@@ -2335,6 +2373,12 @@
 		g_source_remove(gtkblist->timeout);
 		gtkblist->timeout = 0;
 	}
+	
+	if (gtkblist->drag_timeout) {
+		g_source_remove(gtkblist->drag_timeout);
+		gtkblist->drag_timeout = 0;
+	}
+
 	gaim_gtk_blist_tooltip_destroy();
 
 	if (gtkblist->mouseover_contact &&
@@ -3205,6 +3249,8 @@
 
  	g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL);
 	g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-get", G_CALLBACK(gaim_gtk_blist_drag_data_get_cb), NULL);
+	
+	g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-motion", G_CALLBACK(gaim_gtk_blist_drag_motion_cb), NULL);
 
 	/* Tooltips */
 	g_signal_connect(G_OBJECT(gtkblist->treeview), "motion-notify-event", G_CALLBACK(gaim_gtk_blist_motion_cb), NULL);
@@ -3798,9 +3844,12 @@
 		g_source_remove(gtkblist->refresh_timer);
 	if (gtkblist->timeout)
 		g_source_remove(gtkblist->timeout);
+	if (gtkblist->drag_timeout)
+		g_source_remove(gtkblist->drag_timeout);
 
 	gtkblist->refresh_timer = 0;
 	gtkblist->timeout = 0;
+	gtkblist->drag_timeout = 0;
 	gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL;
 	gtkblist->treemodel = NULL;
 	gtkblist->idle_column = NULL;
@@ -4517,7 +4566,6 @@
 
 	/* Initialize prefs */
 	gaim_prefs_add_none("/gaim/gtk/blist");
-	gaim_prefs_add_bool("/gaim/gtk/blist/auto_expand_contacts", TRUE);
 	gaim_prefs_add_bool("/gaim/gtk/blist/show_buddy_icons", TRUE);
 	gaim_prefs_add_bool("/gaim/gtk/blist/show_empty_groups", FALSE);
 	gaim_prefs_add_bool("/gaim/gtk/blist/show_offline_buddies", FALSE);
--- a/src/gtkblist.h	Mon Dec 13 02:02:05 2004 +0000
+++ b/src/gtkblist.h	Mon Dec 13 02:17:04 2004 +0000
@@ -71,6 +71,7 @@
 	guint refresh_timer;            /**< The timer for refreshing every 30 seconds */
 
 	guint      timeout;              /**< The timeout for the tooltip. */
+	guint      drag_timeout;         /**< The timeout for expanding contacts on drags */
 	GdkRectangle tip_rect;           /**< This is the bounding rectangle of the
 					      cell we're currently hovering over.  This is
 					      used for tooltips. */
--- a/src/gtkprefs.c	Mon Dec 13 02:02:05 2004 +0000
+++ b/src/gtkprefs.c	Mon Dec 13 02:17:04 2004 +0000
@@ -855,8 +855,6 @@
 	vbox = gaim_gtk_make_frame (ret, _("Buddy Display"));
 	gaim_gtk_prefs_checkbox(_("Show more buddy details"),
 			"/gaim/gtk/blist/show_buddy_icons", vbox);
-	gaim_gtk_prefs_checkbox(_("_Automatically expand contacts"),
-			"/gaim/gtk/blist/auto_expand_contacts", vbox);
 
 	gtk_widget_show_all(ret);