gtkfilechooser: track cut files for visual feedback
This commit is contained in:
parent
3961ed8f46
commit
9436bc7ce0
2 changed files with 59 additions and 4 deletions
|
|
@ -1517,6 +1517,12 @@ gtk_file_chooser_default_finalize (GObject *object)
|
|||
|
||||
thumbnail_queue_clear (impl);
|
||||
|
||||
if (impl->file_clipboard_cut_files)
|
||||
{
|
||||
g_hash_table_destroy (impl->file_clipboard_cut_files);
|
||||
impl->file_clipboard_cut_files = NULL;
|
||||
}
|
||||
|
||||
if (impl->icon_tooltip_path)
|
||||
{
|
||||
gtk_tree_path_free (impl->icon_tooltip_path);
|
||||
|
|
@ -5036,6 +5042,7 @@ struct file_clipboard_closure
|
|||
GString *gnome_copied_files;
|
||||
GString *uri_list;
|
||||
GString *plain_text;
|
||||
GHashTable *cut_files;
|
||||
gboolean first;
|
||||
};
|
||||
|
||||
|
|
@ -5054,6 +5061,25 @@ static const GtkTargetEntry file_clipboard_targets[] = {
|
|||
{ "application/x-tdeio-metadata", 0, FILE_CLIPBOARD_TARGET_EMPTY }
|
||||
};
|
||||
|
||||
static void
|
||||
file_clipboard_queue_draw_current_view (GtkFileChooserDefault *impl)
|
||||
{
|
||||
if (impl->browse_files_current_view)
|
||||
gtk_widget_queue_draw (impl->browse_files_current_view);
|
||||
}
|
||||
|
||||
static void
|
||||
file_clipboard_cut_files_clear (GtkFileChooserDefault *impl)
|
||||
{
|
||||
if (!impl->file_clipboard_cut_files)
|
||||
return;
|
||||
|
||||
g_hash_table_destroy (impl->file_clipboard_cut_files);
|
||||
impl->file_clipboard_cut_files = NULL;
|
||||
|
||||
file_clipboard_queue_draw_current_view (impl);
|
||||
}
|
||||
|
||||
static void
|
||||
file_clipboard_data_free (struct file_clipboard_data *data)
|
||||
{
|
||||
|
|
@ -5147,6 +5173,11 @@ file_clipboard_foreach_cb (GtkTreeModel *model,
|
|||
|
||||
g_string_append (closure->plain_text, uri);
|
||||
closure->first = FALSE;
|
||||
|
||||
if (closure->cut_files)
|
||||
g_hash_table_insert (closure->cut_files,
|
||||
g_object_ref (file),
|
||||
GUINT_TO_POINTER (1));
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
|
|
@ -5164,6 +5195,10 @@ copy_or_cut_files_to_clipboard (GtkFileChooserDefault *impl,
|
|||
closure.gnome_copied_files = g_string_new (cut ? "cut\n" : "copy\n");
|
||||
closure.uri_list = g_string_new (NULL);
|
||||
closure.plain_text = g_string_new (NULL);
|
||||
closure.cut_files = cut ? g_hash_table_new_full ((GHashFunc) g_file_hash,
|
||||
(GEqualFunc) g_file_equal,
|
||||
g_object_unref,
|
||||
NULL) : NULL;
|
||||
closure.first = TRUE;
|
||||
|
||||
current_selection_selected_foreach (impl,
|
||||
|
|
@ -5175,6 +5210,8 @@ copy_or_cut_files_to_clipboard (GtkFileChooserDefault *impl,
|
|||
g_string_free (closure.gnome_copied_files, TRUE);
|
||||
g_string_free (closure.uri_list, TRUE);
|
||||
g_string_free (closure.plain_text, TRUE);
|
||||
if (closure.cut_files)
|
||||
g_hash_table_destroy (closure.cut_files);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -5198,11 +5235,28 @@ copy_or_cut_files_to_clipboard (GtkFileChooserDefault *impl,
|
|||
file_clipboard_get_cb,
|
||||
file_clipboard_clear_cb,
|
||||
data))
|
||||
gtk_clipboard_set_can_store (clipboard,
|
||||
file_clipboard_targets,
|
||||
G_N_ELEMENTS (file_clipboard_targets));
|
||||
{
|
||||
file_clipboard_cut_files_clear (impl);
|
||||
|
||||
if (cut)
|
||||
{
|
||||
impl->file_clipboard_cut_files = closure.cut_files;
|
||||
closure.cut_files = NULL;
|
||||
}
|
||||
|
||||
file_clipboard_queue_draw_current_view (impl);
|
||||
|
||||
gtk_clipboard_set_can_store (clipboard,
|
||||
file_clipboard_targets,
|
||||
G_N_ELEMENTS (file_clipboard_targets));
|
||||
}
|
||||
else
|
||||
file_clipboard_data_free (data);
|
||||
{
|
||||
file_clipboard_data_free (data);
|
||||
}
|
||||
|
||||
if (closure.cut_files)
|
||||
g_hash_table_destroy (closure.cut_files);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -275,6 +275,7 @@ struct _GtkFileChooserDefault
|
|||
*/
|
||||
GSList *thumbnail_queue;
|
||||
GHashTable *thumbnail_queued_files;
|
||||
GHashTable *file_clipboard_cut_files;
|
||||
GCancellable *thumbnail_cancellable;
|
||||
guint thumbnail_queue_idle_id;
|
||||
guint thumbnail_generation_serial;
|
||||
|
|
|
|||
Loading…
Reference in a new issue