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

Zurück zum Archiv-Index

Yasumichi Akahoshi yasum****@users*****
2005年 9月 23日 (金) 00:02:49 JST


Index: cxplorer/src/cxp-right-pane.c
diff -u cxplorer/src/cxp-right-pane.c:1.68 cxplorer/src/cxp-right-pane.c:1.69
--- cxplorer/src/cxp-right-pane.c:1.68	Thu Sep  8 19:47:41 2005
+++ cxplorer/src/cxp-right-pane.c	Fri Sep 23 00:02:49 2005
@@ -57,6 +57,17 @@
 	LAST_SIGNAL
 };
 
+enum
+{
+	TARGET_CXP_FILE_INFO,
+	TARGET_STRING
+};
+
+static GtkTargetEntry cxp_target_types[] = {
+	{"_CXP_FILE_INFO", 0, TARGET_CXP_FILE_INFO},
+	{"STRING", 0, TARGET_STRING}
+};
+
 static GObjectClass *parent_class = NULL;
 static guint cxp_right_pane_signals[LAST_SIGNAL] = { 0 };
 
@@ -79,19 +90,21 @@
 					     GtkTreePath * path,
 					     GtkTreeViewColumn * column,
 					     gpointer user_data);
-static void cxp_right_pane_on_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+static void cxp_right_pane_on_key_pressed (GtkWidget * widget,
+					   GdkEventKey * event,
+					   gpointer user_data);
 static void cxp_right_pane_draw_icon (GtkTreeViewColumn * tree_column,
 				      GtkCellRenderer * cell,
 				      GtkTreeModel * tree_model,
 				      GtkTreeIter * iter, gpointer data);
 static void cxp_right_pane_draw_filename (GtkTreeViewColumn * tree_column,
-				      GtkCellRenderer * cell,
-				      GtkTreeModel * tree_model,
-				      GtkTreeIter * iter, gpointer data);
+					  GtkCellRenderer * cell,
+					  GtkTreeModel * tree_model,
+					  GtkTreeIter * iter, gpointer data);
 static void cxp_right_pane_draw_filetype (GtkTreeViewColumn * tree_column,
-				      GtkCellRenderer * cell,
-				      GtkTreeModel * tree_model,
-				      GtkTreeIter * iter, gpointer data);
+					  GtkCellRenderer * cell,
+					  GtkTreeModel * tree_model,
+					  GtkTreeIter * iter, gpointer data);
 static void cxp_right_pane_draw_update_time (GtkTreeViewColumn * tree_column,
 					     GtkCellRenderer * cell,
 					     GtkTreeModel * tree_model,
@@ -110,8 +123,8 @@
 					 GtkTextBuffer * text_buffer,
 					 const gchar * filename);
 static void cxp_right_pane_preview_by_command (CxpRightPane * self,
-					 GtkTextBuffer * text_buffer,
-					 const gchar *command);
+					       GtkTextBuffer * text_buffer,
+					       const gchar * command);
 static gint cxp_right_pane_popup_handler (GtkWidget * widget, GdkEvent * event);
 static void cxp_right_pane_preview_expanded (GObject * object,
 					     GParamSpec * param_spec,
@@ -120,6 +133,12 @@
 							 GtkTreePath * path,
 							 GtkTreeIter * iter,
 							 gpointer userdata);
+void cxp_right_pane_clipboard_get (GtkClipboard * clipboard,
+			     GtkSelectionData * selection_data, guint info,
+			     gpointer user_data_or_owner);
+void cxp_right_pane_clipboard_clear (GtkClipboard * clipboard,
+			       gpointer user_data_or_owner);
+void cxp_right_pane_clipboard_received (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data);
 
 GType cxp_right_pane_get_type (void)
 {
@@ -315,6 +334,7 @@
 	GtkTreeViewColumn *column;
 	GtkTreeSelection *selection;
 	GtkCellRenderer *renderer;
+
 	//GtkTreeSortable *sortable;
 
 	file_list = gtk_tree_view_new ();
@@ -326,13 +346,13 @@
 
 	/* Sort setting */
 	/*
-	sortable = GTK_TREE_SORTABLE (store);
-	gtk_tree_sortable_set_sort_func (sortable, SORT_ID_NAME,
-					 cxp_right_pane_compare_by_default,
-					 NULL, NULL);
-	gtk_tree_sortable_set_sort_column_id (sortable, SORT_ID_NAME,
-					      GTK_SORT_ASCENDING);
-					      */
+	   sortable = GTK_TREE_SORTABLE (store);
+	   gtk_tree_sortable_set_sort_func (sortable, SORT_ID_NAME,
+	   cxp_right_pane_compare_by_default,
+	   NULL, NULL);
+	   gtk_tree_sortable_set_sort_column_id (sortable, SORT_ID_NAME,
+	   GTK_SORT_ASCENDING);
+	 */
 
 	/* 1st column */
 	column = gtk_tree_view_column_new ();
@@ -361,14 +381,16 @@
 	g_object_set (renderer, "xalign", 1.0, NULL);
 	column = gtk_tree_view_column_new_with_attributes (_("Size"), renderer,
 							   "text",
-							   FILE_LIST_COL_FILESIZE, NULL);
+							   FILE_LIST_COL_FILESIZE,
+							   NULL);
 	gtk_tree_view_column_set_resizable (column, TRUE);
 	gtk_tree_view_column_set_sort_column_id (column, SORT_ID_SIZE);
 	gtk_tree_view_append_column (GTK_TREE_VIEW (file_list), column);
 
 	/* 3rd column */
 	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Type"), renderer, NULL);
+	column = gtk_tree_view_column_new_with_attributes (_("Type"), renderer,
+							   NULL);
 	gtk_tree_view_column_set_cell_data_func (column, renderer,
 						 cxp_right_pane_draw_filetype,
 						 self, NULL);
@@ -429,8 +451,9 @@
 		model = gtk_tree_view_get_model (treeview);
 		if (gtk_tree_model_get_iter (model, &iter, treepath))
 		{
-			gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH,
-					    &fullpath, -1);
+			gtk_tree_model_get (model, &iter,
+					    FILE_LIST_COL_FULLPATH, &fullpath,
+					    -1);
 			cxp_right_pane_show_preview (self, text_buffer,
 						     fullpath);
 			g_free (fullpath);
@@ -483,26 +506,29 @@
 	g_free (fullpath);
 }
 
-static void cxp_right_pane_on_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+static void cxp_right_pane_on_key_pressed (GtkWidget * widget,
+					   GdkEventKey * event,
+					   gpointer user_data)
 {
 	CxpRightPane *self = CXP_RIGHT_PANE (user_data);
 	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (self);
 
 	switch (event->keyval)
 	{
-		case GDK_F2:
-			cxp_right_pane_rename_file_request (self);
-			break;
-		case GDK_Delete:
-			cxp_right_pane_delete_selected_files (self);
-			break;
-		case GDK_BackSpace:
-			g_signal_emit (self,
-					cxp_right_pane_signals
-					[UP_DIR_REQUEST_SIGNAL], 0);
-			break;
-		default:
-			GTK_WIDGET_GET_CLASS(priv->file_list)->key_press_event (widget, event);
+	case GDK_F2:
+		cxp_right_pane_rename_file_request (self);
+		break;
+	case GDK_Delete:
+		cxp_right_pane_delete_selected_files (self);
+		break;
+	case GDK_BackSpace:
+		g_signal_emit (self,
+			       cxp_right_pane_signals
+			       [UP_DIR_REQUEST_SIGNAL], 0);
+		break;
+	default:
+		GTK_WIDGET_GET_CLASS (priv->file_list)->key_press_event (widget,
+									 event);
 	}
 }
 
@@ -530,14 +556,15 @@
 }
 
 static void cxp_right_pane_draw_filename (GtkTreeViewColumn * tree_column,
-				      GtkCellRenderer * cell,
-				      GtkTreeModel * tree_model,
-				      GtkTreeIter * iter, gpointer data)
+					  GtkCellRenderer * cell,
+					  GtkTreeModel * tree_model,
+					  GtkTreeIter * iter, gpointer data)
 {
 	gchar *fullpath;
 	gchar *filename;
 
-	gtk_tree_model_get (tree_model, iter, FILE_LIST_COL_FULLPATH, &fullpath, -1);
+	gtk_tree_model_get (tree_model, iter, FILE_LIST_COL_FULLPATH, &fullpath,
+			    -1);
 	if ((filename = cxp_path_get_basename_of_utf8 (fullpath)) == NULL)
 	{
 		filename = g_strdup (_("(Invalid filename)"));
@@ -549,23 +576,24 @@
 }
 
 static void cxp_right_pane_draw_filetype (GtkTreeViewColumn * tree_column,
-				      GtkCellRenderer * cell,
-				      GtkTreeModel * tree_model,
-				      GtkTreeIter * iter, gpointer data)
+					  GtkCellRenderer * cell,
+					  GtkTreeModel * tree_model,
+					  GtkTreeIter * iter, gpointer data)
 {
 	gchar *mimetype;
 	gchar *comment = NULL;
 	mode_t mode;
 
-	gtk_tree_model_get (tree_model, iter, FILE_LIST_COL_MIMETYPE, &mimetype, FILE_LIST_COL_FILEMODE, &mode, -1);
+	gtk_tree_model_get (tree_model, iter, FILE_LIST_COL_MIMETYPE, &mimetype,
+			    FILE_LIST_COL_FILEMODE, &mode, -1);
 	switch (mode & S_IFMT)
 	{
-		case S_IFDIR:
-			comment = g_strdup (_("directory"));
-			break;
-		default:
-			comment = cxp_get_mime_comment (mimetype);
-			break;
+	case S_IFDIR:
+		comment = g_strdup (_("directory"));
+		break;
+	default:
+		comment = cxp_get_mime_comment (mimetype);
+		break;
 	}
 	g_object_set (cell, "text", comment, NULL);
 
@@ -617,12 +645,12 @@
 	gchar *error_msg;
 
 	gtk_tree_model_get_iter (model, &iter, path);
-	gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH, &srcpath,
-			    -1);
+	gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH, &srcpath, -1);
 	srcbase = cxp_path_get_basename_of_utf8 (srcpath);
 	if (strcmp (srcbase, new_text) == 0)
 	{
-		cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE(model), &iter, FALSE);
+		cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE (model),
+						  &iter, FALSE);
 		g_free (srcbase);
 		g_free (srcpath);
 		gtk_tree_path_free (path);
@@ -638,25 +666,32 @@
 		errno = 0;
 		if (rename (srcpath, destpath) == 0)
 		{
-			cxp_file_list_store_rename_file (CXP_FILE_LIST_STORE(model), &iter, destpath);
-			cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE(model), &iter, FALSE);
+			cxp_file_list_store_rename_file (CXP_FILE_LIST_STORE
+							 (model), &iter,
+							 destpath);
+			cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE
+							  (model), &iter,
+							  FALSE);
 		}
 		else
 		{
-			cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE(model), &iter, FALSE);
+			cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE
+							  (model), &iter,
+							  FALSE);
 			cxp_error_dialog_run_about_file (srcbase);
 		}
 	}
 	else
 	{
-		cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE(model), &iter, FALSE);
+		cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE (model),
+						  &iter, FALSE);
 		error_msg =
 			g_strdup_printf (_("%s is already exists."), new_text);
 		dialog = gtk_message_dialog_new (NULL,
 						 GTK_DIALOG_DESTROY_WITH_PARENT,
 						 GTK_MESSAGE_ERROR,
-						 GTK_BUTTONS_CLOSE,
-						 "%s", error_msg);
+						 GTK_BUTTONS_CLOSE, "%s",
+						 error_msg);
 		gtk_dialog_run (GTK_DIALOG (dialog));
 		gtk_widget_destroy (dialog);
 		g_free (error_msg);
@@ -763,56 +798,59 @@
 	stat (filename, &status);
 	switch (status.st_mode & S_IFMT)
 	{
-		case S_IFREG:
-			filetype = cxp_get_mime_type_for_file (filename);
-			if (g_str_has_prefix (filetype, "image") == TRUE)
+	case S_IFREG:
+		filetype = cxp_get_mime_type_for_file (filename);
+		if (g_str_has_prefix (filetype, "image") == TRUE)
+		{
+			if ((pixbuf =
+			     gdk_pixbuf_new_from_file (filename, NULL)) != NULL)
 			{
-				if ((pixbuf = gdk_pixbuf_new_from_file (filename, NULL)) != NULL)
-				{
-					gtk_text_buffer_get_iter_at_line (text_buffer,
-							&iter, 0);
-					gtk_text_buffer_insert_pixbuf (text_buffer,
-							&iter, pixbuf);
-					g_free (filetype);
+				gtk_text_buffer_get_iter_at_line (text_buffer,
+								  &iter, 0);
+				gtk_text_buffer_insert_pixbuf (text_buffer,
+							       &iter, pixbuf);
+				g_free (filetype);
 
-					return;
-				}
+				return;
 			}
+		}
 
-			key = g_strdup_printf ("/apps/cxp/mime-types/%s/preview", filetype);
-			g_strdelimit (key, "+", '@');	/* example: application/xhtml+xml => /apps/cxp/mime-types/application/xhtml @ xml/preview */
-			if ((preview_cmd = gconf_client_get_string (priv->client, key, NULL)) == NULL)
+		key = g_strdup_printf ("/apps/cxp/mime-types/%s/preview",
+				       filetype);
+		g_strdelimit (key, "+", '@');	/* example: application/xhtml+xml => /apps/cxp/mime-types/application/xhtml @ xml/preview */
+		if ((preview_cmd =
+		     gconf_client_get_string (priv->client, key, NULL)) == NULL)
+		{
+			if (g_str_has_prefix (filetype, "text") == TRUE)
 			{
-				if (g_str_has_prefix (filetype, "text") == TRUE)
-				{
-					preview_cmd =
-						gconf_client_get_string (priv->client,
-								"/apps/cxp/cxplorer/PreviewText",
-								NULL);
-				}
-				else
-				{
-					preview_cmd =
-						gconf_client_get_string (priv->client,
-								"/apps/cxp/cxplorer/PreviewBinary",
-								NULL);
-				}
+				preview_cmd =
+					gconf_client_get_string (priv->client,
+								 "/apps/cxp/cxplorer/PreviewText",
+								 NULL);
 			}
-			g_free (key);
-			g_free (filetype);
-			break;
-		case S_IFDIR:
-			preview_cmd =
-				gconf_client_get_string (priv->client,
-						"/apps/cxp/cxplorer/PreviewDir",
-						NULL);
-			break;
-		case S_IFCHR:
-		case S_IFBLK:
-		case S_IFIFO:
-		case S_IFSOCK:
-		default:
-			return;
+			else
+			{
+				preview_cmd =
+					gconf_client_get_string (priv->client,
+								 "/apps/cxp/cxplorer/PreviewBinary",
+								 NULL);
+			}
+		}
+		g_free (key);
+		g_free (filetype);
+		break;
+	case S_IFDIR:
+		preview_cmd =
+			gconf_client_get_string (priv->client,
+						 "/apps/cxp/cxplorer/PreviewDir",
+						 NULL);
+		break;
+	case S_IFCHR:
+	case S_IFBLK:
+	case S_IFIFO:
+	case S_IFSOCK:
+	default:
+		return;
 	}
 
 	cmd = g_strdup_printf ("%s '%s'", preview_cmd, filename);
@@ -823,8 +861,8 @@
 
 
 static void cxp_right_pane_preview_by_command (CxpRightPane * self,
-					 GtkTextBuffer * text_buffer,
-					 const gchar *command)
+					       GtkTextBuffer * text_buffer,
+					       const gchar * command)
 {
 	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (self);
 	const gchar *encoding;
@@ -837,20 +875,28 @@
 	GString *str;
 	GError *error;
 
-	max = gconf_client_get_int (priv->client, "/apps/cxp/cxplorer/PreviewLines", NULL);
+	max = gconf_client_get_int (priv->client,
+				    "/apps/cxp/cxplorer/PreviewLines", NULL);
 	g_shell_parse_argv (command, NULL, &args, NULL);
 
-	if(g_spawn_async_with_pipes (NULL, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, NULL, &sout, NULL, &error))
+	if (g_spawn_async_with_pipes
+	    (NULL, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, NULL,
+	     &sout, NULL, &error))
 	{
 		channel = g_io_channel_unix_new (sout);
-		if(g_get_charset(&encoding) == FALSE)
+		if (g_get_charset (&encoding) == FALSE)
 		{
 			g_io_channel_set_encoding (channel, encoding, NULL);
 		}
 		str = g_string_new ("");
-		for (loop=0; (loop<max) && (g_io_channel_read_line_string (channel, str, NULL, NULL) == G_IO_STATUS_NORMAL); loop++)
+		for (loop = 0;
+		     (loop < max)
+		     &&
+		     (g_io_channel_read_line_string (channel, str, NULL, NULL)
+		      == G_IO_STATUS_NORMAL); loop++)
 		{
-			gtk_text_buffer_insert_at_cursor (text_buffer, str->str, str->len);
+			gtk_text_buffer_insert_at_cursor (text_buffer, str->str,
+							  str->len);
 		}
 		g_io_channel_shutdown (channel, FALSE, NULL);
 		g_io_channel_unref (channel);
@@ -930,13 +976,13 @@
 							 GtkTreeIter * iter,
 							 gpointer user_data)
 {
-	GList **rowref_list = (GList **)user_data;
-	GtkTreeRowReference  *rowref;
+	GList **rowref_list = (GList **) user_data;
+	GtkTreeRowReference *rowref;
 
-	g_assert ( rowref_list != NULL );
+	g_assert (rowref_list != NULL);
 
-	rowref = gtk_tree_row_reference_new(model, path);
-	*rowref_list = g_list_append(*rowref_list, rowref);
+	rowref = gtk_tree_row_reference_new (model, path);
+	*rowref_list = g_list_append (*rowref_list, rowref);
 }
 
 /*
@@ -1021,8 +1067,9 @@
 		model = gtk_tree_view_get_model (treeview);
 		if (gtk_tree_model_get_iter (model, &iter, treepath))
 		{
-			gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH,
-					    &fullpath, -1);
+			gtk_tree_model_get (model, &iter,
+					    FILE_LIST_COL_FULLPATH, &fullpath,
+					    -1);
 
 			return fullpath;
 		}
@@ -1058,7 +1105,7 @@
 			model = gtk_tree_view_get_model (GTK_TREE_VIEW
 							 (priv->file_list));
 			iter = cxp_right_pane_append_file (right_pane,
-							  CXP_FILE_LIST_STORE 
+							   CXP_FILE_LIST_STORE
 							   (model), fullpath);
 			treepath = gtk_tree_model_get_path (model, &iter);
 			gtk_tree_view_set_cursor (GTK_TREE_VIEW
@@ -1090,7 +1137,7 @@
 void cxp_right_pane_delete_selected_files (CxpRightPane * right_pane)
 {
 	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (right_pane);
-	GList *rr_list = NULL;    /* list of GtkTreeRowReferences to remove */
+	GList *rr_list = NULL;	/* list of GtkTreeRowReferences to remove */
 	GList *node;
 	GtkTreeIter iter;
 	GtkTreeModel *model;
@@ -1099,22 +1146,28 @@
 	gchar *fullpath;
 
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->file_list));
-	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_list));
+	selection =
+		gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_list));
 	gtk_tree_selection_selected_foreach (selection,
 					     cxp_right_pane_delete_selected_file_foreach,
 					     &rr_list);
 
-	for ( node = rr_list;  node != NULL;  node = node->next )
+	for (node = rr_list; node != NULL; node = node->next)
 	{
-		path = gtk_tree_row_reference_get_path((GtkTreeRowReference*)(node->data));
+		path = gtk_tree_row_reference_get_path ((GtkTreeRowReference
+							 *) (node->data));
 		if (path)
 		{
-			if (gtk_tree_model_get_iter(model, &iter, path))
+			if (gtk_tree_model_get_iter (model, &iter, path))
 			{
-				gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH, &fullpath, -1);
+				gtk_tree_model_get (model, &iter,
+						    FILE_LIST_COL_FULLPATH,
+						    &fullpath, -1);
 				if (cxp_remove_file (fullpath) == TRUE)
 				{
-					cxp_file_list_store_remove (CXP_FILE_LIST_STORE(model), &iter);
+					cxp_file_list_store_remove
+						(CXP_FILE_LIST_STORE (model),
+						 &iter);
 				}
 				g_free (fullpath);
 			}
@@ -1122,54 +1175,51 @@
 	}
 }
 
-void cxp_right_pane_paste_from_clipboard (CxpRightPane * right_pane)
+void cxp_right_pane_copy_to_clipboard (CxpRightPane *right_pane)
 {
 	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (right_pane);
-	gchar *src;
-	gchar *cur_dir;
-	gchar *error_msg;
-	gchar *cmd;
-	gchar *standard_error;
-	gint exit_status;
+	GList *list, *cur;
+	GtkTreeIter iter;
+	GtkTreeModel *model;
+	GtkTreeSelection *selection;
+	GString *copy_files;
+	gchar *fullpath;
 	GtkClipboard *clipboard;
-	GtkWidget *dialog;
 
-	clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
-	if (gtk_clipboard_wait_is_text_available (clipboard))
+	selection =
+		gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_list));
+
+	list = gtk_tree_selection_get_selected_rows (selection, &model);
+
+	g_return_if_fail (list != NULL);
+
+	clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (right_pane)), GDK_SELECTION_CLIPBOARD);
+
+	cur = list;
+	copy_files = g_string_new ("");
+	while (cur != NULL)
 	{
-		src = gtk_clipboard_wait_for_text (clipboard);
-		if (g_file_test (src, G_FILE_TEST_IS_REGULAR))
-		{
-			cmd = g_strdup_printf ("cp --backup=t '%s' '%s'", src,
-					       priv->cur_dir);
-			g_spawn_command_line_sync (cmd, NULL, &standard_error,
-						   &exit_status, NULL);
-			if (exit_status == 0)
-			{
-				cur_dir = g_strdup (priv->cur_dir);
-				cxp_right_pane_change_directory (right_pane,
-								 cur_dir);
-				g_free (cur_dir);
-			}
-			else
-			{
-				error_msg =
-					g_locale_to_utf8 (standard_error, -1,
-							  NULL, NULL, NULL);
-				dialog = gtk_message_dialog_new (NULL,
-								 GTK_DIALOG_DESTROY_WITH_PARENT,
-								 GTK_MESSAGE_ERROR,
-								 GTK_BUTTONS_CLOSE,
-								 "%s",
-								 error_msg);
-				gtk_dialog_run (GTK_DIALOG (dialog));
-				gtk_widget_destroy (dialog);
-				g_free (error_msg);
-			}
-			g_free (cmd);
-		}
-		g_free (src);
+		gtk_tree_model_get_iter (model, &iter, cur->data);
+		gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH,
+				    &fullpath, -1);
+		g_string_append (copy_files, fullpath);
+		g_string_append_c (copy_files, '\n');
+		g_free (fullpath);
+		cur = g_list_next (cur);
 	}
+	g_list_foreach (list, gtk_tree_path_free, NULL);
+	g_list_free (list);
+
+	gtk_clipboard_set_with_data (clipboard, cxp_target_types, G_N_ELEMENTS (cxp_target_types), cxp_right_pane_clipboard_get, cxp_right_pane_clipboard_clear, copy_files);
+}
+
+void cxp_right_pane_paste_from_clipboard (CxpRightPane * right_pane)
+{
+	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (right_pane);
+	GtkClipboard *clipboard;
+
+	clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (right_pane)), GDK_SELECTION_CLIPBOARD);
+	gtk_clipboard_request_contents (clipboard, gdk_atom_intern ("_CXP_FILE_INFO", FALSE), cxp_right_pane_clipboard_received, right_pane);
 }
 
 void cxp_right_pane_rename_file_request (CxpRightPane * right_pane)
@@ -1187,13 +1237,12 @@
 	{
 		gtk_tree_view_get_cursor (GTK_TREE_VIEW (priv->file_list),
 					  &treepath, NULL);
-		column = gtk_tree_view_get_column (GTK_TREE_VIEW
-						   (priv->file_list),
-						   0);	/* FIXME: */
+		column = gtk_tree_view_get_column (GTK_TREE_VIEW (priv->file_list), 0);	/* FIXME: */
 		model = gtk_tree_view_get_model (GTK_TREE_VIEW
 						 (priv->file_list));
 		gtk_tree_model_get_iter (model, &iter, treepath);
-		cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE(model), &iter, TRUE);
+		cxp_file_list_store_set_editable (CXP_FILE_LIST_STORE (model),
+						  &iter, TRUE);
 		gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->file_list),
 					  treepath, column, TRUE);
 		gtk_tree_path_free (treepath);
@@ -1226,8 +1275,8 @@
 	while (cur != NULL)
 	{
 		gtk_tree_model_get_iter (model, &iter, cur->data);
-		gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH, &fullpath,
-				    -1);
+		gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH,
+				    &fullpath, -1);
 		g_string_append_printf (fullcmd, " '%s'", fullpath);
 		g_free (fullpath);
 		cur = g_list_next (cur);
@@ -1259,3 +1308,75 @@
 				  G_CALLBACK (cxp_right_pane_popup_handler),
 				  priv->popup_menu);
 }
+
+void cxp_right_pane_clipboard_get (GtkClipboard * clipboard,
+			     GtkSelectionData * selection_data, guint info,
+			     gpointer user_data_or_owner)
+{
+	GString *copy_files = user_data_or_owner;
+	
+	gtk_selection_data_set (selection_data,  gdk_atom_intern ("_CXP_FILE_INFO", FALSE), sizeof(GPtrArray*), copy_files->str, copy_files->len);
+}
+
+void cxp_right_pane_clipboard_clear (GtkClipboard * clipboard,
+			       gpointer user_data_or_owner)
+{
+	GString *copy_files = user_data_or_owner;
+	
+	g_string_free (copy_files, TRUE);
+}
+
+void cxp_right_pane_clipboard_received (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data)
+{
+	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (data);
+	gchar *copy_files;
+	gchar **copy_file;
+	guint index;
+
+	/* ToDo: nautilusのfm-directory-view.cを参考に*/
+	gchar *cur_dir;
+	gchar *error_msg;
+	gchar *cmd;
+	gchar *standard_error;
+	gint exit_status;
+	GtkWidget *dialog;
+
+	if (selection_data->type == gdk_atom_intern ("_CXP_FILE_INFO", FALSE))
+	{
+		copy_files = selection_data->data;
+		copy_file = g_strsplit (copy_files, "\n", 0);
+		for(index=0; copy_file[index] != NULL; index++)
+		{
+			if (g_file_test (copy_file[index], G_FILE_TEST_IS_REGULAR))
+			{
+				cmd = g_strdup_printf ("cp --backup=t '%s' '%s'", copy_file[index],
+						priv->cur_dir);
+				g_spawn_command_line_sync (cmd, NULL, &standard_error,
+						&exit_status, NULL);
+				if (exit_status == 0)
+				{
+					cur_dir = g_strdup (priv->cur_dir);
+					cxp_right_pane_change_directory (CXP_RIGHT_PANE(data),
+							cur_dir);
+					g_free (cur_dir);
+				}
+				else
+				{
+					error_msg =
+						g_locale_to_utf8 (standard_error, -1,
+								NULL, NULL, NULL);
+					dialog = gtk_message_dialog_new (NULL,
+							GTK_DIALOG_DESTROY_WITH_PARENT,
+							GTK_MESSAGE_ERROR,
+							GTK_BUTTONS_CLOSE,
+							"%s",
+							error_msg);
+					gtk_dialog_run (GTK_DIALOG (dialog));
+					gtk_widget_destroy (dialog);
+					g_free (error_msg);
+				}
+				g_free (cmd);
+			}
+		}
+	}
+}
Index: cxplorer/src/cxp-right-pane.h
diff -u cxplorer/src/cxp-right-pane.h:1.16 cxplorer/src/cxp-right-pane.h:1.17
--- cxplorer/src/cxp-right-pane.h:1.16	Mon May 16 21:22:27 2005
+++ cxplorer/src/cxp-right-pane.h	Fri Sep 23 00:02:49 2005
@@ -54,6 +54,7 @@
 gchar *cxp_right_pane_get_active_file_name (CxpRightPane *right_pane);
 void cxp_right_pane_make_file (CxpRightPane *right_pane, const gchar *base_name);
 void cxp_right_pane_delete_selected_files (CxpRightPane *right_pane);
+void cxp_right_pane_copy_to_clipboard (CxpRightPane *right_pane);
 void cxp_right_pane_paste_from_clipboard (CxpRightPane *right_pane);
 void cxp_right_pane_rename_file_request (CxpRightPane *right_pane);
 void cxp_right_pane_send_file_to_command (CxpRightPane *right_pane, const gchar *cmd);
Index: cxplorer/src/cxplorer-window.c
diff -u cxplorer/src/cxplorer-window.c:1.62 cxplorer/src/cxplorer-window.c:1.63
--- cxplorer/src/cxplorer-window.c:1.62	Tue Sep  6 20:45:11 2005
+++ cxplorer/src/cxplorer-window.c	Fri Sep 23 00:02:49 2005
@@ -779,15 +779,8 @@
 static void cxplorer_window_copy_action (GtkWidget * widget, gpointer user_data)
 {
 	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data);
-	gchar *fullpath;
-	GtkClipboard *clipboard;
 
-	if ((fullpath = cxp_right_pane_get_active_file_name (CXP_RIGHT_PANE (private->right_pane))) != NULL)
-	{
-		clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
-		gtk_clipboard_set_text (clipboard, fullpath, -1);
-		g_free (fullpath);
-	}
+	cxp_right_pane_copy_to_clipboard (CXP_RIGHT_PANE(private->right_pane));
 }
 
 /**


Cxplorer-cvs メーリングリストの案内
Zurück zum Archiv-Index