comparison src/view_file_icon.c @ 1202:8bf3fff49ddd

Allow to drag keywords on files in list or icon view. Dragged text is appended to keywords list of the destination file.
author zas_
date Mon, 15 Dec 2008 18:04:42 +0000
parents 3692efcbd325
children d79305a42a9b
comparison
equal deleted inserted replaced
1201:c55a935b5e36 1202:8bf3fff49ddd
11 */ 11 */
12 12
13 #include "main.h" 13 #include "main.h"
14 #include "view_file_icon.h" 14 #include "view_file_icon.h"
15 15
16 #include "bar_info.h"
16 #include "cellrenderericon.h" 17 #include "cellrenderericon.h"
17 #include "collect.h" 18 #include "collect.h"
18 #include "collect-io.h" 19 #include "collect-io.h"
19 #include "collect-table.h" 20 #include "collect-table.h"
20 #include "dnd.h" 21 #include "dnd.h"
23 #include "info.h" 24 #include "info.h"
24 #include "filedata.h" 25 #include "filedata.h"
25 #include "layout.h" 26 #include "layout.h"
26 #include "layout_image.h" 27 #include "layout_image.h"
27 #include "menu.h" 28 #include "menu.h"
29 #include "metadata.h"
28 #include "thumb.h" 30 #include "thumb.h"
29 #include "utilops.h" 31 #include "utilops.h"
30 #include "ui_fileops.h" 32 #include "ui_fileops.h"
31 #include "ui_menu.h" 33 #include "ui_menu.h"
32 #include "ui_tree_edit.h" 34 #include "ui_tree_edit.h"
549 gtk_selection_data_set(selection_data, selection_data->target, 551 gtk_selection_data_set(selection_data, selection_data->target,
550 8, (guchar *)uri_text, total); 552 8, (guchar *)uri_text, total);
551 g_free(uri_text); 553 g_free(uri_text);
552 } 554 }
553 555
556 static void vficon_drag_data_received(GtkWidget *entry_widget, GdkDragContext *context,
557 int x, int y, GtkSelectionData *selection,
558 guint info, guint time, gpointer data)
559 {
560 ViewFile *vf = data;
561
562 if (info == TARGET_TEXT_PLAIN) {
563 IconData *id = vficon_find_data_by_coord(vf, x, y, NULL);
564
565 if (id && id->fd) {
566 /* Add keywords to file */
567 FileData *fd = id->fd;
568 gchar *str = g_strndup(selection->data, selection->length);
569 GList *kw_list = string_to_keywords_list(str);
570
571 metadata_set(fd, kw_list, NULL, TRUE);
572 string_list_free(kw_list);
573 g_free(str);
574 if (vf->layout && vf->layout->bar_info) {
575 bar_info_set(vf->layout->bar_info, id->fd);
576 }
577 }
578 }
579 }
580
554 static void vficon_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) 581 static void vficon_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
555 { 582 {
556 ViewFile *vf = data; 583 ViewFile *vf = data;
557 584
558 tip_unschedule(vf); 585 tip_unschedule(vf);
587 void vficon_dnd_init(ViewFile *vf) 614 void vficon_dnd_init(ViewFile *vf)
588 { 615 {
589 gtk_drag_source_set(vf->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, 616 gtk_drag_source_set(vf->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
590 dnd_file_drag_types, dnd_file_drag_types_count, 617 dnd_file_drag_types, dnd_file_drag_types_count,
591 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); 618 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
619 gtk_drag_dest_set(vf->listview, GTK_DEST_DEFAULT_ALL,
620 dnd_file_drag_types, dnd_file_drag_types_count,
621 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
622
592 g_signal_connect(G_OBJECT(vf->listview), "drag_data_get", 623 g_signal_connect(G_OBJECT(vf->listview), "drag_data_get",
593 G_CALLBACK(vficon_dnd_get), vf); 624 G_CALLBACK(vficon_dnd_get), vf);
594 g_signal_connect(G_OBJECT(vf->listview), "drag_begin", 625 g_signal_connect(G_OBJECT(vf->listview), "drag_begin",
595 G_CALLBACK(vficon_dnd_begin), vf); 626 G_CALLBACK(vficon_dnd_begin), vf);
596 g_signal_connect(G_OBJECT(vf->listview), "drag_end", 627 g_signal_connect(G_OBJECT(vf->listview), "drag_end",
597 G_CALLBACK(vficon_dnd_end), vf); 628 G_CALLBACK(vficon_dnd_end), vf);
629 g_signal_connect(G_OBJECT(vf->listview), "drag_data_received",
630 G_CALLBACK(vficon_drag_data_received), vf);
598 } 631 }
599 632
600 /* 633 /*
601 *------------------------------------------------------------------- 634 *-------------------------------------------------------------------
602 * cell updates 635 * cell updates