changeset 397:a7be56e84870

Merge vd(list|tree)_release_cb() in vd_release_cb(). I made some assumptions here i hope correct.
author zas_
date Thu, 17 Apr 2008 17:35:51 +0000
parents a01535f52b56
children c4080362d619
files src/view_dir.c src/view_dir.h src/view_dir_list.c src/view_dir_tree.c
diffstat 4 files changed, 47 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/src/view_dir.c	Thu Apr 17 17:19:41 2008 +0000
+++ b/src/view_dir.c	Thu Apr 17 17:35:51 2008 +0000
@@ -937,3 +937,47 @@
 		     "cell-background-set", set, NULL);
 }
 
+gint vd_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+{
+	ViewDir *vd = data;
+	GtkTreePath *tpath;
+	GtkTreeIter iter;
+	FileData *fd = NULL;
+
+	vd_color_set(vd, vd->click_fd, FALSE);
+
+	if (bevent->button != 1) return TRUE;
+
+	if ((bevent->x != 0 || bevent->y != 0) &&
+	    gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
+					  &tpath, NULL, NULL, NULL))
+		{
+		GtkTreeModel *store;
+
+		store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
+		gtk_tree_model_get_iter(store, &iter, tpath);
+		switch (vd->type)
+			{
+			case DIRVIEW_LIST:
+				gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
+				break;
+			case DIRVIEW_TREE:
+				{
+				NodeData *nd;
+				gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
+				fd = (nd) ? nd->fd : NULL;
+				};
+				break;
+			}
+		
+		gtk_tree_path_free(tpath);
+		}
+
+	if (fd && vd->click_fd == fd)
+		{
+		vdlist_select_row(vd, vd->click_fd);
+		}
+
+	return TRUE;
+}
+
--- a/src/view_dir.h	Thu Apr 17 17:19:41 2008 +0000
+++ b/src/view_dir.h	Thu Apr 17 17:35:51 2008 +0000
@@ -50,6 +50,7 @@
 void vd_activate_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data);
 void vd_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data);
 
+gint vd_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);
 
 #endif
 
--- a/src/view_dir_list.c	Thu Apr 17 17:19:41 2008 +0000
+++ b/src/view_dir_list.c	Thu Apr 17 17:35:51 2008 +0000
@@ -349,37 +349,6 @@
 	return TRUE;
 }
 
-static gint vdlist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
-{
-	ViewDir *vd = data;
-	GtkTreePath *tpath;
-	GtkTreeIter iter;
-	FileData *fd = NULL;
-
-	vd_color_set(vd, vd->click_fd, FALSE);
-
-	if (bevent->button != 1) return TRUE;
-
-	if ((bevent->x != 0 || bevent->y != 0) &&
-	    gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
-					  &tpath, NULL, NULL, NULL))
-		{
-		GtkTreeModel *store;
-
-		store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
-		gtk_tree_model_get_iter(store, &iter, tpath);
-		gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
-		gtk_tree_path_free(tpath);
-		}
-
-	if (fd && vd->click_fd == fd)
-		{
-		vdlist_select_row(vd, vd->click_fd);
-		}
-
-	return TRUE;
-}
-
 static void vdlist_destroy_cb(GtkWidget *widget, gpointer data)
 {
 	ViewDir *vd = data;
@@ -441,7 +410,7 @@
 	g_signal_connect(G_OBJECT(vd->view), "button_press_event",
 			 G_CALLBACK(vdlist_press_cb), vd);
 	g_signal_connect(G_OBJECT(vd->view), "button_release_event",
-			 G_CALLBACK(vdlist_release_cb), vd);
+			 G_CALLBACK(vd_release_cb), vd);
 
 	if (path) vdlist_set_path(vd, path);
 
--- a/src/view_dir_tree.c	Thu Apr 17 17:19:41 2008 +0000
+++ b/src/view_dir_tree.c	Thu Apr 17 17:35:51 2008 +0000
@@ -863,38 +863,6 @@
 	return (bevent->button != 1);
 }
 
-static gint vdtree_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
-{
-	ViewDir *vd = data;
-	GtkTreePath *tpath;
-	GtkTreeIter iter;
-	NodeData *nd = NULL;
-
-	if (!vd->click_fd) return FALSE;
-	vd_color_set(vd, vd->click_fd, FALSE);
-
-	if (bevent->button != 1) return TRUE;
-
-	if ((bevent->x != 0 || bevent->y != 0) &&
-	    gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
-					  &tpath, NULL, NULL, NULL))
-		{
-		GtkTreeModel *store;
-
-		store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
-		gtk_tree_model_get_iter(store, &iter, tpath);
-		gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
-		gtk_tree_path_free(tpath);
-		}
-
-	if (nd && vd->click_fd == nd->fd)
-		{
-		vdtree_select_row(vd, vd->click_fd);
-		}
-
-	return FALSE;
-}
-
 static void vdtree_row_expanded(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data)
 {
 	ViewDir *vd = data;
@@ -1033,7 +1001,7 @@
 	g_signal_connect(G_OBJECT(vd->view), "button_press_event",
 			 G_CALLBACK(vdtree_press_cb), vd);
 	g_signal_connect(G_OBJECT(vd->view), "button_release_event",
-			 G_CALLBACK(vdtree_release_cb), vd);
+			 G_CALLBACK(vd_release_cb), vd);
 
 	vdtree_set_path(vd, path);