changeset 395:c359fc2c5a1f

Move common menu position callback to view_dir.c.
author zas_
date Thu, 17 Apr 2008 16:33:31 +0000
parents 4a5e1377f3d7
children a01535f52b56
files src/view_dir.c src/view_dir.h src/view_dir_list.c src/view_dir_tree.c
diffstat 4 files changed, 28 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/src/view_dir.c	Thu Apr 17 14:51:32 2008 +0000
+++ b/src/view_dir.c	Thu Apr 17 16:33:31 2008 +0000
@@ -849,3 +849,26 @@
 			 G_CALLBACK(vd_dnd_drop_leave), vd);
 }
 
+/*
+ *----------------------------------------------------------------------------
+ * callbacks
+ *----------------------------------------------------------------------------
+ */
+
+void vd_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
+{
+	ViewDir *vd = data;
+	GtkTreeModel *store;
+	GtkTreeIter iter;
+	GtkTreePath *tpath;
+	gint cw, ch;
+
+	if (vd_find_row(vd, vd->click_fd, &iter) < 0) return;
+	store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
+	tpath = gtk_tree_model_get_path(store, &iter);
+	tree_view_get_cell_clamped(GTK_TREE_VIEW(vd->view), tpath, 0, TRUE, x, y, &cw, &ch);
+	gtk_tree_path_free(tpath);
+	*y += ch;
+	popup_menu_position_clamp(menu, x, y, 0);
+}
+
--- a/src/view_dir.h	Thu Apr 17 14:51:32 2008 +0000
+++ b/src/view_dir.h	Thu Apr 17 16:33:31 2008 +0000
@@ -45,6 +45,9 @@
 void vd_dnd_drop_scroll_cancel(ViewDir *vd);
 void vd_dnd_init(ViewDir *vd);
 
+void vd_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data);
+
+
 #endif
 
 
--- a/src/view_dir_list.c	Thu Apr 17 14:51:32 2008 +0000
+++ b/src/view_dir_list.c	Thu Apr 17 16:33:31 2008 +0000
@@ -284,23 +284,6 @@
 	g_free(path);
 }
 
-static void vdlist_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
-{
-	ViewDir *vd = data;
-	GtkTreeModel *store;
-	GtkTreeIter iter;
-	GtkTreePath *tpath;
-	gint cw, ch;
-
-	if (vd_find_row(vd, vd->click_fd, &iter) < 0) return;
-	store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
-	tpath = gtk_tree_model_get_path(store, &iter);
-	tree_view_get_cell_clamped(GTK_TREE_VIEW(vd->view), tpath, 0, TRUE, x, y, &cw, &ch);
-	gtk_tree_path_free(tpath);
-	*y += ch;
-	popup_menu_position_clamp(menu, x, y, 0);
-}
-
 static gint vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
 	ViewDir *vd = data;
@@ -329,7 +312,7 @@
 
 	vd->popup = vd_pop_menu(vd, vd->click_fd);
 
-	gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vdlist_menu_position_cb, vd, 0, GDK_CURRENT_TIME);
+	gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vd_menu_position_cb, vd, 0, GDK_CURRENT_TIME);
 
 	return TRUE;
 }
--- a/src/view_dir_tree.c	Thu Apr 17 14:51:32 2008 +0000
+++ b/src/view_dir_tree.c	Thu Apr 17 16:33:31 2008 +0000
@@ -738,23 +738,6 @@
  *----------------------------------------------------------------------------
  */
 
-static void vdtree_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
-{
-	ViewDir *vd = data;
-	GtkTreeModel *store;
-	GtkTreeIter iter;
-	GtkTreePath *tpath;
-	gint cw, ch;
-
-	if (vd_find_row(vd, vd->click_fd, &iter) < 0) return;
-	store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
-	tpath = gtk_tree_model_get_path(store, &iter);
-	tree_view_get_cell_clamped(GTK_TREE_VIEW(vd->view), tpath, 0, TRUE, x, y, &cw, &ch);
-	gtk_tree_path_free(tpath);
-	*y += ch;
-	popup_menu_position_clamp(menu, x, y, 0);
-}
-
 static gint vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
 	ViewDir *vd = data;
@@ -784,7 +767,7 @@
 			vd_color_set(vd, vd->click_fd, TRUE);
 
 			vd->popup = vd_pop_menu(vd, vd->click_fd);
-			gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vdtree_menu_position_cb, vd, 0, GDK_CURRENT_TIME);
+			gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vd_menu_position_cb, vd, 0, GDK_CURRENT_TIME);
 
 			return TRUE;
 			break;