Mercurial > geeqie.yaz
comparison src/view_dir.c @ 383:499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
to view_dir.c.
author | zas_ |
---|---|
date | Wed, 16 Apr 2008 16:05:12 +0000 |
parents | 5afe77bb563a |
children | 392dd6541d51 |
comparison
equal
deleted
inserted
replaced
382:eceeced4cbb9 | 383:499d7ba62261 |
---|---|
10 */ | 10 */ |
11 | 11 |
12 #include "main.h" | 12 #include "main.h" |
13 #include "view_dir.h" | 13 #include "view_dir.h" |
14 | 14 |
15 #include "filelist.h" | |
16 #include "ui_menu.h" | |
17 #include "utilops.h" | |
15 #include "view_dir_list.h" | 18 #include "view_dir_list.h" |
16 #include "view_dir_tree.h" | 19 #include "view_dir_tree.h" |
17 | 20 |
18 GtkRadioActionEntry menu_view_dir_radio_entries[] = { | 21 GtkRadioActionEntry menu_view_dir_radio_entries[] = { |
19 { "FolderList", NULL, N_("List"), "<meta>L", NULL, DIRVIEW_LIST }, | 22 { "FolderList", NULL, N_("List"), "<meta>L", NULL, DIRVIEW_LIST }, |
78 } | 81 } |
79 | 82 |
80 return ret; | 83 return ret; |
81 } | 84 } |
82 | 85 |
86 void vd_color_set(ViewDir *vd, FileData *fd, gint color_set) | |
87 { | |
88 GtkTreeModel *store; | |
89 GtkTreeIter iter; | |
90 | |
91 switch(vd->type) | |
92 { | |
93 case DIRVIEW_LIST: | |
94 { | |
95 if (vdlist_find_row(vd, fd, &iter) < 0) return; | |
96 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); | |
97 gtk_list_store_set(GTK_LIST_STORE(store), &iter, DIR_COLUMN_COLOR, color_set, -1); | |
98 } | |
99 break; | |
100 case DIRVIEW_TREE: | |
101 { | |
102 if (vdtree_find_row(vd, fd, &iter, NULL) < 0) return; | |
103 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); | |
104 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, DIR_COLUMN_COLOR, color_set, -1); | |
105 } | |
106 break; | |
107 } | |
108 } | |
109 | |
110 void vd_popup_destroy_cb(GtkWidget *widget, gpointer data) | |
111 { | |
112 ViewDir *vd = data; | |
113 | |
114 vd_color_set(vd, vd->click_fd, FALSE); | |
115 vd->click_fd = NULL; | |
116 vd->popup = NULL; | |
117 | |
118 vd_color_set(vd, vd->drop_fd, FALSE); | |
119 filelist_free(vd->drop_list); | |
120 vd->drop_list = NULL; | |
121 vd->drop_fd = NULL; | |
122 } | |
123 | |
124 /* | |
125 *----------------------------------------------------------------------------- | |
126 * drop menu (from dnd) | |
127 *----------------------------------------------------------------------------- | |
128 */ | |
129 | |
130 static void vd_drop_menu_copy_cb(GtkWidget *widget, gpointer data) | |
131 { | |
132 ViewDir *vd = data; | |
133 const gchar *path; | |
134 GList *list; | |
135 | |
136 if (!vd->drop_fd) return; | |
137 | |
138 path = vd->drop_fd->path; | |
139 list = vd->drop_list; | |
140 vd->drop_list = NULL; | |
141 | |
142 file_util_copy_simple(list, path); | |
143 } | |
144 | |
145 static void vd_drop_menu_move_cb(GtkWidget *widget, gpointer data) | |
146 { | |
147 ViewDir *vd = data; | |
148 const gchar *path; | |
149 GList *list; | |
150 | |
151 if (!vd->drop_fd) return; | |
152 | |
153 path = vd->drop_fd->path; | |
154 list = vd->drop_list; | |
155 | |
156 vd->drop_list = NULL; | |
157 | |
158 file_util_move_simple(list, path); | |
159 } | |
160 | |
161 GtkWidget *vd_drop_menu(ViewDir *vd, gint active) | |
162 { | |
163 GtkWidget *menu; | |
164 | |
165 menu = popup_menu_short_lived(); | |
166 g_signal_connect(G_OBJECT(menu), "destroy", | |
167 G_CALLBACK(vd_popup_destroy_cb), vd); | |
168 | |
169 menu_item_add_stock_sensitive(menu, _("_Copy"), GTK_STOCK_COPY, active, | |
170 G_CALLBACK(vd_drop_menu_copy_cb), vd); | |
171 menu_item_add_sensitive(menu, _("_Move"), active, G_CALLBACK(vd_drop_menu_move_cb), vd); | |
172 | |
173 menu_item_add_divider(menu); | |
174 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, NULL, vd); | |
175 | |
176 return menu; | |
177 } | |
178 |