Yasumichi Akahoshi
yasum****@users*****
2005年 10月 10日 (月) 23:05:56 JST
Index: cxplorer/src/cxp-right-pane.c diff -u cxplorer/src/cxp-right-pane.c:1.86 cxplorer/src/cxp-right-pane.c:1.87 --- cxplorer/src/cxp-right-pane.c:1.86 Sun Oct 9 02:13:44 2005 +++ cxplorer/src/cxp-right-pane.c Mon Oct 10 23:05:56 2005 @@ -134,6 +134,7 @@ GtkTreePath * path, GtkTreeIter * iter, gpointer userdata); +static gchar *cxp_right_pane_selection_to_string (CxpRightPane *obj); static void cxp_right_pane_clipboard_get (GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, gpointer user_data_or_owner); static void cxp_right_pane_clipboard_received (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data); static void cxp_right_pane_drag_data_get(GtkWidget *widget, GdkDragContext *dc, GtkSelectionData *selection_data, guint info, guint t, gpointer data); @@ -1241,46 +1242,17 @@ void cxp_right_pane_copy_to_clipboard (CxpRightPane *right_pane) { - CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (right_pane); - GList *list, *cur; - GtkTreeIter iter; - GtkTreeModel *model; - GtkTreeSelection *selection; - GString *copy_files; - gchar *fullpath; GtkClipboard *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); - - cur = list; - copy_files = g_string_new (""); - while (cur != NULL) - { - 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, (GFunc)gtk_tree_path_free, NULL); - g_list_free (list); + gchar *copy_files; 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); + copy_files = cxp_right_pane_selection_to_string (right_pane); + gtk_clipboard_set_with_data (clipboard, cxp_target_types, G_N_ELEMENTS(cxp_target_types), cxp_right_pane_clipboard_get, NULL, 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 (GDK_SELECTION_PRIMARY); @@ -1419,6 +1391,45 @@ priv->popup_menu); } +/** + * convert GtkTreeSelection to string + */ +static gchar *cxp_right_pane_selection_to_string (CxpRightPane *obj) +{ + CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (obj); + GList *list, *cur; + GString *select_files; + GtkTreeIter iter; + GtkTreeModel *model; + GtkTreeSelection *selection; + gchar *fullpath; + gchar *result; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_list)); + + list = gtk_tree_selection_get_selected_rows (selection, &model); + + g_return_val_if_fail (list != NULL, ""); + + select_files = g_string_new (""); + cur = list; + while (cur != NULL) + { + gtk_tree_model_get_iter (model, &iter, cur->data); + gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH, &fullpath, -1); + g_string_append (select_files, fullpath); + g_string_append_c (select_files, '\n'); + g_free (fullpath); + cur = g_list_next (cur); + } + g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL); + g_list_free (list); + + result = g_string_free (select_files, FALSE); + + return result; +} + /* * Virtually sets the contents of the specified */ @@ -1484,42 +1495,10 @@ static 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); - GList *list, *cur; - GtkTreeIter iter; - GtkTreeModel *model; - GtkTreeSelection *selection; - GString *move_files; - gchar *fullpath; - GtkClipboard *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 (GDK_SELECTION_PRIMARY); - - cur = list; - move_files = g_string_new (""); - while (cur != NULL) - { - gtk_tree_model_get_iter (model, &iter, cur->data); - gtk_tree_model_get (model, &iter, FILE_LIST_COL_FULLPATH, - &fullpath, -1); - g_string_append (move_files, fullpath); - g_string_append_c (move_files, '\n'); - g_free (fullpath); - cur = g_list_next (cur); - } - g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL); - g_list_free (list); + gchar *move_files; - gtk_selection_data_set (selection_data, GDK_TARGET_STRING, 8, move_files->str, move_files->len); - //gtk_clipboard_set_text (clipboard, copy_files->str, copy_files->len); - g_string_free (move_files, TRUE); + move_files = cxp_right_pane_selection_to_string (CXP_RIGHT_PANE(data)); + gtk_selection_data_set (selection_data, GDK_TARGET_STRING, 8, move_files, strlen(move_files)); } static void cxp_right_pane_drag_data_delete (GtkWidget *widget, GdkDragContext *dc, gpointer data)