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

Back to archive index

Yasumichi Akahoshi yasum****@users*****
2005年 10月 9日 (日) 01:59:19 JST


Index: cxplorer/src/cxp-right-pane.c
diff -u cxplorer/src/cxp-right-pane.c:1.84 cxplorer/src/cxp-right-pane.c:1.85
--- cxplorer/src/cxp-right-pane.c:1.84	Sat Oct  8 01:33:26 2005
+++ cxplorer/src/cxp-right-pane.c	Sun Oct  9 01:59:19 2005
@@ -134,6 +134,8 @@
 							 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_received (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data);
 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);
@@ -1248,15 +1250,12 @@
 	gchar *fullpath;
 	GtkClipboard *clipboard;
 
-	selection =
-		gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_list));
+	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 (GDK_SELECTION_PRIMARY);
-
 	cur = list;
 	copy_files = g_string_new ("");
 	while (cur != NULL)
@@ -1272,73 +1271,20 @@
 	g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
 	g_list_free (list);
 
-	gtk_clipboard_set_text (clipboard, copy_files->str, copy_files->len);
-	g_string_free (copy_files, TRUE);
+	clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+
+	gtk_clipboard_set_with_data (clipboard, cxp_target_types, G_N_ELEMENTS(cxp_target_types), cxp_right_pane_clipboard_get, NULL, copy_files->str);
+
+	g_string_free (copy_files, FALSE);
 }
 
 void cxp_right_pane_paste_from_clipboard (CxpRightPane * right_pane)
 {
 	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (right_pane);
 	GtkClipboard *clipboard;
-	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;
 
 	clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
-	if (gtk_clipboard_wait_is_text_available (clipboard))
-	{
-		copy_files = gtk_clipboard_wait_for_text (clipboard);
-		copy_file = g_strsplit (copy_files, "\n", 0);
-		for(index=0; copy_file[index] != NULL; index++)
-		{
-			cmd = NULL;
-			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);
-			}
-			else if (g_file_test (copy_file[index], G_FILE_TEST_IS_DIR))
-			{
-				cmd = g_strdup_printf ("cp -R --backup=t '%s' '%s'", copy_file[index],
-						priv->cur_dir);
-			}
-
-			if(cmd != NULL)
-			{
-				g_spawn_command_line_sync (cmd, NULL, &standard_error,
-						&exit_status, NULL);
-				if (exit_status != 0)
-				{
-					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);
-			}
-		}
-		cur_dir = g_strdup (priv->cur_dir);
-		cxp_right_pane_change_directory (right_pane,
-				cur_dir);
-		g_free (cur_dir);
-		g_strfreev (copy_file);
-	}
+	gtk_clipboard_request_contents (clipboard, GDK_TARGET_STRING, cxp_right_pane_clipboard_received, right_pane);
 }
 
 void cxp_right_pane_rename_file_request (CxpRightPane * right_pane)
@@ -1473,6 +1419,69 @@
 				  priv->popup_menu);
 }
 
+/*
+ * Virtually sets the contents of the specified
+ */
+void cxp_right_pane_clipboard_get (GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, gpointer data)
+{
+	gtk_selection_data_set (selection_data, GDK_TARGET_STRING, 8, data, strlen(data)); 
+}
+
+void cxp_right_pane_clipboard_received (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data)
+{
+	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (data);
+	GtkWidget *dialog;
+	gchar *cmd;
+	gchar *cur_dir;
+	gchar *copy_files;
+	gchar **copy_file;
+	gchar *serr;
+	gchar *error_msg;
+	guint index;
+	gint exit_status;
+
+	copy_files = selection_data->data;
+	if (copy_files == NULL)
+	{
+		g_warning ("faild get text from clipboard\n");
+		return;
+	}
+	copy_file = g_strsplit (copy_files, "\n", 0);
+	for(index=0; copy_file[index] != NULL; index++)
+	{
+		cmd = NULL;
+		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);
+		}
+		else if (g_file_test (copy_file[index], G_FILE_TEST_IS_DIR))
+		{
+			cmd = g_strdup_printf ("cp -R --backup=t '%s' '%s'", copy_file[index],
+					priv->cur_dir);
+		}
+
+		if(cmd != NULL)
+		{
+			g_spawn_command_line_sync (cmd, NULL, &serr,
+					&exit_status, NULL);
+			if (exit_status != 0)
+			{
+				error_msg = g_locale_to_utf8 (serr, -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);
+		}
+	}
+	cur_dir = g_strdup (priv->cur_dir);
+	cxp_right_pane_change_directory (CXP_RIGHT_PANE(data), cur_dir);
+	g_free (cur_dir);
+	g_strfreev (copy_file);
+}
+
 void cxp_right_pane_drag_data_get(GtkWidget *widget, GdkDragContext *dc, GtkSelectionData *selection_data, guint info, guint t, gpointer data)
 {
 	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (data);


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