[Cxplorer-cvs 01284] CVS update: cxplorer/src

Back to archive index

Yasumichi Akahoshi yasum****@users*****
2005年 9月 26日 (月) 18:56:15 JST


Index: cxplorer/src/cxp-right-pane.c
diff -u cxplorer/src/cxp-right-pane.c:1.73 cxplorer/src/cxp-right-pane.c:1.74
--- cxplorer/src/cxp-right-pane.c:1.73	Mon Sep 26 14:26:52 2005
+++ cxplorer/src/cxp-right-pane.c	Mon Sep 26 18:56:15 2005
@@ -135,6 +135,7 @@
 							 gpointer userdata);
 void cxp_right_pane_drag_data_get(GtkWidget *widget, GdkDragContext *dc, GtkSelectionData *selection_data, guint info, guint t, gpointer data);
 void cxp_right_pane_drag_data_delete (GtkWidget *widget, GdkDragContext *dc, gpointer data);
+void cxp_right_pane_drag_data_received (GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data);
 
 GType cxp_right_pane_get_type (void)
 {
@@ -221,6 +222,7 @@
 	gtk_container_add (GTK_CONTAINER (scrolled_window), priv->file_list);
 	gtk_widget_show (priv->file_list);
 	gtk_drag_source_set(priv->file_list, GDK_BUTTON1_MASK, cxp_target_types, G_N_ELEMENTS(cxp_target_types), GDK_ACTION_MOVE);
+	gtk_drag_dest_set (priv->file_list, GTK_DEST_DEFAULT_ALL, cxp_target_types, G_N_ELEMENTS(cxp_target_types), GDK_ACTION_MOVE);
 
 	priv->expander = gtk_expander_new (_("<b>Preview</b>"));
 	gtk_expander_set_use_markup (GTK_EXPANDER (priv->expander), TRUE);
@@ -253,6 +255,8 @@
 			G_CALLBACK (cxp_right_pane_drag_data_get), self);
 	g_signal_connect (priv->file_list, "drag_data_delete",
 			G_CALLBACK (cxp_right_pane_drag_data_delete), self);
+	g_signal_connect (priv->file_list, "drag_data_received",
+			G_CALLBACK (cxp_right_pane_drag_data_received), self);
 	g_signal_connect (priv->file_list, "key-press-event",
 			  G_CALLBACK (cxp_right_pane_on_key_pressed), self);
 	g_signal_connect (priv->expander, "notify::expanded",
@@ -1419,3 +1423,49 @@
 
 	g_signal_stop_emission_by_name (priv->file_list, "drag_data_delete");
 }
+
+void cxp_right_pane_drag_data_received (GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data)
+{
+	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (data);
+	gchar *move_files;
+	gchar **move_file;
+	gchar *src_base;
+	gchar *dest_dir;
+	gchar *dest_path;
+	guint index;
+	GtkTreeViewDropPosition pos;
+	GtkTreeModel *model;
+	GtkTreePath *path;
+	GtkTreeIter iter;
+
+	model = gtk_tree_view_get_model (GTK_TREE_VIEW(priv->file_list));
+	if(gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW(priv->file_list), x, y, &path, &pos))
+	{
+		if (gtk_tree_model_get_iter(model, &iter, path))
+		{
+			gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH, &dest_dir, -1);
+			if(g_file_test(dest_dir, G_FILE_TEST_IS_DIR))
+			{
+				move_files = selection_data->data;
+				move_file = g_strsplit (move_files, "\n", 0);
+				for(index=0; move_file[index] != NULL; index++)
+				{
+					if(g_file_test(move_file[index], G_FILE_TEST_EXISTS))
+					{
+						src_base = g_path_get_basename (move_file[index]);
+						dest_path = g_build_filename (dest_dir, src_base, NULL);
+						errno = 0;
+						if(rename(move_file[index], dest_path) == -1)
+						{
+							cxp_error_dialog_run_about_file (src_base);
+						}
+						g_free (dest_path);
+						g_free (src_base);
+					}
+				}
+				g_free (dest_dir);
+				g_strfreev (move_file);
+			}
+		}
+	}
+}


Cxplorer-cvs メーリングリストの案内
Back to archive index