annotate src/ui_pathsel.c @ 33:a41ecbb26a96

Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net> * pan-view.c: Move pixbuf drawing into pixbuf_util.c. * pixbuf-renderer.c: Rename util_clip_region to pr_clip_region to fix namespace conflict with util in pixbuf_util.h. * pixbuf_util.[ch]: Moved pixbuf drawing utils here from pan-view.c ##### Note: GQview CVS on sourceforge is not always up to date, please use ##### ##### an offical release when making enhancements and translation updates. #####
author gqview
date Wed, 06 Apr 2005 10:45:36 +0000
parents d907d608745f
children 606fcf461a68
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2 * (SLIK) SimpLIstic sKin functions
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12 #ifdef HAVE_CONFIG_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 # include "config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include <stdio.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include <string.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include <dirent.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include <fcntl.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include <unistd.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include <sys/types.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include <sys/stat.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include <gtk/gtk.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 #include <gdk/gdkkeysyms.h> /* for key values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include "ui_pathsel.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 #include "ui_tree_edit.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 #define DEST_WIDTH 250
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 #define DEST_HEIGHT 210
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 #define RENAME_PRESS_DELAY 333 /* 1/3 second, to allow double clicks */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 #define PATH_SEL_USE_HEADINGS FALSE
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 FILTER_COLUMN_NAME = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 FILTER_COLUMN_FILTER
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 typedef struct _Dest_Data Dest_Data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 struct _Dest_Data
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 GtkWidget *d_view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 GtkWidget *f_view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 gchar *filter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 GList *filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 GList *filter_text_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 GtkWidget *filter_combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 gint show_hidden;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 GtkWidget *hidden_button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 GtkWidget *bookmark_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 GtkTreePath *right_click_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 void (*select_func)(const gchar *path, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 gpointer select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 GenericDialog *gd; /* any open confirm dialogs ? */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 typedef struct _DestDel_Data DestDel_Data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 struct _DestDel_Data
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 Dest_Data *dd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 static void dest_view_delete_dlg_cancel(GenericDialog *gd, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 * (private)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 static void dest_free_data(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 if (dd->gd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 GenericDialog *gd = dd->gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 dest_view_delete_dlg_cancel(dd->gd, dd->gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 if (dd->right_click_path) gtk_tree_path_free(dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 g_free(dd->filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 g_free(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 g_free(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 static gint dest_check_filter(const gchar *filter, const gchar *file)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 const gchar *f_ptr = filter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 const gchar *strt_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 l = strlen(file);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 if (filter[0] == '*') return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 while (f_ptr < filter + strlen(filter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 strt_ptr = f_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 i=0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 while (*f_ptr != ';' && *f_ptr != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 f_ptr++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 if (*f_ptr != '\0' && f_ptr[1] == ' ') f_ptr++; /* skip space immediately after separator */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 f_ptr++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 if (l >= i && strncasecmp(file + l - i, strt_ptr, i) == 0) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 #ifndef CASE_SORT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 #define CASE_SORT strcmp
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 static gint dest_sort_cb(void *a, void *b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 return CASE_SORT((gchar *)a, (gchar *)b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 static gint is_hidden(const gchar *name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 if (name[0] != '.') return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 if (name[1] == '\0') return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 if (name[1] == '.' && name[2] == '\0') return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 static void dest_populate(Dest_Data *dd, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 DIR *dp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 struct dirent *dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 struct stat ent_sbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 GList *path_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 GList *file_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 if(!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 dp = opendir(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 if (!dp)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 /* dir not found */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 while ((dir = readdir(dp)) != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 /* skips removed files */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 if (dir->d_ino > 0 && (dd->show_hidden || !is_hidden(dir->d_name)) )
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 gchar *name = dir->d_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 gchar *filepath = g_strconcat(pathl, "/", name, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 if (stat(filepath, &ent_sbuf) >= 0 && S_ISDIR(ent_sbuf.st_mode))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 path_list = g_list_prepend(path_list, path_to_utf8(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 else if (dd->f_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 if (!dd->filter || (dd->filter && dest_check_filter(dd->filter, name)))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 file_list = g_list_prepend(file_list, path_to_utf8(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 g_free(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 closedir(dp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 path_list = g_list_sort(path_list, (GCompareFunc) dest_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 file_list = g_list_sort(file_list, (GCompareFunc) dest_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dd->d_view)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 list = path_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 gchar *filepath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 if (strcmp(list->data, ".") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 filepath = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 else if (strcmp(list->data, "..") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 filepath = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 p = (gchar *)filename_from_path(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 if (p - 1 != filepath) p--;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 p[0] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 filepath = concat_dir_and_file(path, list->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 gtk_list_store_set(store, &iter, 0, list->data, 1, filepath, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 g_free(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 list = list->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 path_list_free(path_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 if (dd->f_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dd->f_view)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 list = file_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 gchar *filepath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 const gchar *name = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 filepath = concat_dir_and_file(path, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 gtk_list_store_set(store, &iter, 0, name, 1, filepath, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 g_free(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 list = list->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 path_list_free(file_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 g_free(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 dd->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 static void dest_change_dir(Dest_Data *dd, const gchar *path, gint retain_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 gchar *old_name = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 gint s = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 if (retain_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 const gchar *buf = gtk_entry_get_text(GTK_ENTRY(dd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 if (!isdir(buf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 if (path && strcmp(path, "/") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 old_name = g_strdup(filename_from_path(buf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 old_name = g_strconcat("/", filename_from_path(buf), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 s = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 gtk_entry_set_text(GTK_ENTRY(dd->entry), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 dest_populate(dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 /* remember filename */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 if (old_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 gint pos = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 gtk_editable_insert_text(GTK_EDITABLE(dd->entry), old_name, -1, &pos);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 gtk_editable_select_region(GTK_EDITABLE(dd->entry), strlen(path) + s, strlen(path) + strlen(old_name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 g_free(old_name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 * drag and drop
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 TARGET_URI_LIST,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 TARGET_TEXT_PLAIN
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 static GtkTargetEntry dest_drag_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 { "text/plain", 0, TARGET_TEXT_PLAIN }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 #define dest_drag_types_n 2
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 static void dest_dnd_set_data(GtkWidget *view,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 GdkDragContext *context, GtkSelectionData *selection_data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 guint info, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 gchar *path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 if (!gtk_tree_selection_get_selected(selection, &model, &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 gtk_tree_model_get(model, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 list = g_list_append(list, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 uri_text = uri_text_from_list(list, &length, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 uri_text = uri_text_from_list(list, &length, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 if (!uri_text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 gtk_selection_data_set(selection_data, selection_data->target,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 8, uri_text, length);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 static void dest_dnd_init(Dest_Data *dd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(dd->d_view), GDK_BUTTON1_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 dest_drag_types, dest_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 g_signal_connect(G_OBJECT(dd->d_view), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 G_CALLBACK(dest_dnd_set_data), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 if (dd->f_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(dd->f_view), GDK_BUTTON1_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 dest_drag_types, dest_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 g_signal_connect(G_OBJECT(dd->f_view), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 G_CALLBACK(dest_dnd_set_data), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 * destination widget file management utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 static void dest_view_store_selection(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 if (dd->right_click_path) gtk_tree_path_free(dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 dd->right_click_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 selection = gtk_tree_view_get_selection(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 if (!gtk_tree_selection_get_selected(selection, &model, &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 dd->right_click_path = gtk_tree_model_get_path(model, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 static gint dest_view_rename_cb(TreeEditData *ted, const gchar *old, const gchar *new, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 gchar *old_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 gchar *new_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 model = gtk_tree_view_get_model(GTK_TREE_VIEW(ted->tree));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 gtk_tree_model_get(model, &iter, 1, &old_path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 if (!old_path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 buf = remove_level_from_path(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 new_path = concat_dir_and_file(buf, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 if (isname(new_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 buf = g_strdup_printf(_("A file with name %s already exists."), new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 warning_dialog("Rename failed", buf, GTK_STOCK_DIALOG_INFO, dd->entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 else if (!rename_file(old_path, new_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 buf = g_strdup_printf(_("Failed to rename %s to %s."), old, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 warning_dialog("Rename failed", buf, GTK_STOCK_DIALOG_ERROR, dd->entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, new, 1, new_path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 text = gtk_entry_get_text(GTK_ENTRY(dd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 if (text && old_path && strcmp(text, old_path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 gtk_entry_set_text(GTK_ENTRY(dd->entry), new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 g_free(new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 static void dest_view_rename(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 if (!dd->right_click_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 gtk_tree_model_get(model, &iter, 0, &text, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 tree_edit_by_path(view, dd->right_click_path, 0, text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 dest_view_rename_cb, dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 static void dest_view_delete_dlg_cancel(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 DestDel_Data *dl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 dl->dd->gd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 g_free(dl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 g_free(dl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 static void dest_view_delete_dlg_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 DestDel_Data *dl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 if (!unlink_file(dl->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 gchar *text = g_strdup_printf(_("Unable to delete file:\n%s"), dl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_WARNING, dl->dd->entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 else if (dl->dd->path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 /* refresh list */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 gchar *path = g_strdup(dl->dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 dest_populate(dl->dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 dest_view_delete_dlg_cancel(gd, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 static void dest_view_delete(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 DestDel_Data *dl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 if (view != GTK_TREE_VIEW(dd->f_view)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 if (!dd->right_click_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 gtk_tree_model_get(model, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 dl = g_new(DestDel_Data, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 dl->dd = dd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 dl->path = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 if (dd->gd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 GenericDialog *gd = dd->gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 dest_view_delete_dlg_cancel(dd->gd, dd->gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 dd->gd = generic_dialog_new(_("Delete file"), PACKAGE, "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 dd->entry, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 dest_view_delete_dlg_cancel, dl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 generic_dialog_add_button(dd->gd, GTK_STOCK_DELETE, NULL, dest_view_delete_dlg_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 text = g_strdup_printf(_("About to delete the file:\n %s"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 generic_dialog_add_message(dd->gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 _("Delete file"), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 gtk_widget_show(dd->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 static void dest_view_bookmark(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 if (!dd->right_click_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 gtk_tree_model_get(model, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 bookmark_list_add(dd->bookmark_list, filename_from_path(path), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 static void dest_popup_dir_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 dest_view_rename(dd, GTK_TREE_VIEW(dd->d_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 static void dest_popup_dir_bookmark_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 dest_view_bookmark(dd, GTK_TREE_VIEW(dd->d_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 static void dest_popup_file_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 dest_view_rename(dd, GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 static void dest_popup_file_delete_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 dest_view_delete(dd, GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 static void dest_popup_file_bookmark_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 dest_view_bookmark(dd, GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 static void dest_popup_position_cb(GtkMenu *menu, gint *x, gint *y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 gboolean *push_in, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 GtkTreeView *view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 gint cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 view = g_object_get_data(G_OBJECT(menu), "active_view");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 tree_view_get_cell_clamped(view, dd->right_click_path, 0, TRUE, x, y, &cw, &ch);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 *y += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 popup_menu_position_clamp(menu, x, y, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 static gint dest_popup_menu(Dest_Data *dd, GtkTreeView *view,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 gint button, guint32 time, gint local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 if (!dd->right_click_path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 if (view == GTK_TREE_VIEW(dd->d_view))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 gint normal_dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 gtk_tree_model_get(model, &iter, 0, &text, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 if (!text) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 normal_dir = (strcmp(text, ".") == 0 || strcmp(text, "..") == 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 menu_item_add_sensitive(menu, _("_Rename"), !normal_dir,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 G_CALLBACK(dest_popup_dir_rename_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 menu_item_add_stock(menu, _("Add _Bookmark"), GTK_STOCK_JUMP_TO,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 G_CALLBACK(dest_popup_dir_bookmark_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 menu_item_add(menu, _("_Rename"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 G_CALLBACK(dest_popup_file_rename_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 menu_item_add_stock(menu, _("_Delete"), GTK_STOCK_DELETE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 G_CALLBACK(dest_popup_file_delete_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 menu_item_add_stock(menu, _("Add _Bookmark"), GTK_STOCK_JUMP_TO,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 G_CALLBACK(dest_popup_file_bookmark_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 if (local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 g_object_set_data(G_OBJECT(menu), "active_view", view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 dest_popup_position_cb, dd, button, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 static gint dest_press_cb(GtkWidget *view, GdkEventButton *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 gint cell_x, cell_y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 if (event->button != 3 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 !gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(view), event->x, event->y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 &tpath, &column, &cell_x, &cell_y))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 gtk_tree_model_get_iter(model, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 if (dd->right_click_path) gtk_tree_path_free(dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 dd->right_click_path = tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 return dest_popup_menu(dd, GTK_TREE_VIEW(view), 0, event->time, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 static gboolean dest_keypress_cb(GtkWidget *view, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 case GDK_F10:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 if (!(event->state & GDK_CONTROL_MASK)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 dest_popup_menu(dd, GTK_TREE_VIEW(view), 0, event->time, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 case 'R': case 'r':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 if (event->state & GDK_CONTROL_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 dest_view_rename(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 case GDK_Delete:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 dest_view_delete(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 case 'B' : case 'b':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 if (event->state & GDK_CONTROL_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 dest_view_bookmark(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 static void dest_new_dir_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 const gchar *tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 gint from_text = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 tmp = gtk_entry_get_text(GTK_ENTRY(dd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 if (!isname(tmp))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 path = g_strdup(tmp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 from_text = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 buf = concat_dir_and_file(dd->path, _("New folder"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 path = unique_filename(buf, NULL, " ", FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 if (!mkdir_utf8(path, 0755))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 /* failed */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 text = g_strdup_printf(_("Unable to create folder:\n%s"), filename_from_path(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, dd->entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 if (from_text) gtk_entry_set_text(GTK_ENTRY(dd->entry), dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dd->d_view)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 text = filename_from_path(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 gtk_list_store_set(store, &iter, 0, text, 1, path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 if (dd->right_click_path) gtk_tree_path_free(dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 dd->right_click_path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 tree_edit_by_path(GTK_TREE_VIEW(dd->d_view), dd->right_click_path, 0, text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 dest_view_rename_cb, dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 * destination widget file selection, traversal, view options
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 static void dest_select_cb(GtkTreeSelection *selection, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 GtkTreeView *view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 view = gtk_tree_selection_get_tree_view(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 store = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 gtk_tree_model_get(store, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 if (view == GTK_TREE_VIEW(dd->d_view))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 dest_change_dir(dd, path, (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 gtk_entry_set_text(GTK_ENTRY(dd->entry), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 static void dest_activate_cb(GtkWidget *view, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 store = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 gtk_tree_model_get(store, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 if (view == dd->d_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 dest_change_dir(dd, path, (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 if (dd->select_func)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 dd->select_func(path, dd->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 static void dest_home_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 dest_change_dir(dd, homedir(), (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 static void dest_show_hidden_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 dd->show_hidden = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dd->hidden_button));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 buf = g_strdup(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 static void dest_entry_changed_cb(GtkEditable *editable, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 path = gtk_entry_get_text(GTK_ENTRY(dd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 if (strcmp(path, dd->path) == 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 buf = remove_level_from_path(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 if (buf && strcmp(buf, dd->path) != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 gchar *tmp = remove_trailing_slash(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 if (isdir(tmp))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 dest_populate(dd, tmp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 else if (isdir(buf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 g_free(tmp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 static void dest_filter_list_sync(Dest_Data *dd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 gchar *old_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 GList *fwork;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 GList *twork;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 if (!dd->filter_list || !dd->filter_combo) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 entry = GTK_BIN(dd->filter_combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 old_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(dd->filter_combo)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 fwork = dd->filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 twork = dd->filter_text_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 while (fwork && twork)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 gchar *filter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 name = twork->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 filter = fwork->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 gtk_list_store_set(store, &iter, FILTER_COLUMN_NAME, name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 FILTER_COLUMN_FILTER, filter, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 if (strcmp(old_text, filter) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dd->filter_combo), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 fwork = fwork->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 twork = twork->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 g_free(old_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 static void dest_filter_add(Dest_Data *dd, const gchar *filter, const gchar *description, gint set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 gint c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 if (!filter) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 work = dd->filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 gchar *f = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 if (strcmp(f, filter) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 if (set) gtk_combo_box_set_active(GTK_COMBO_BOX(dd->filter_combo), c);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 dd->filter_list = uig_list_insert_link(dd->filter_list, g_list_last(dd->filter_list), g_strdup(filter));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 if (description)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 buf = g_strdup_printf("%s ( %s )", description, filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 buf = g_strdup_printf("( %s )", filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 dd->filter_text_list = uig_list_insert_link(dd->filter_text_list, g_list_last(dd->filter_text_list), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 if (set) gtk_entry_set_text(GTK_ENTRY(GTK_BIN(dd->filter_combo)->child), filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 dest_filter_list_sync(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 static void dest_filter_clear(Dest_Data *dd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 path_list_free(dd->filter_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 dd->filter_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 path_list_free(dd->filter_text_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 dd->filter_text_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 dest_filter_add(dd, "*", _("All Files"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 static void dest_filter_changed_cb(GtkEditable *editable, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 const gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 entry = GTK_BIN(dd->filter_combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 buf = gtk_entry_get_text(GTK_ENTRY(entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 g_free(dd->filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 dd->filter = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 if (strlen(buf) > 0) dd->filter = g_strdup(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 path = g_strdup(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 dest_populate(dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 static void dest_bookmark_select_cb(const gchar *path, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 if (isdir(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 dest_change_dir(dd, path, (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 else if (isfile(path) && dd->f_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 gtk_entry_set_text(GTK_ENTRY(dd->entry), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 * destination widget setup routines (public)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 GtkWidget *path_selection_new_with_files(GtkWidget *entry, const gchar *path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 const gchar *filter, const gchar *filter_desc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 GtkWidget *hbox2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 Dest_Data *dd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 GtkWidget *paned;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 dd = g_new0(Dest_Data, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 dd->show_hidden = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 dd->select_func = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 dd->select_data = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 dd->gd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 table = gtk_table_new(4, (filter != NULL) ? 3 : 1, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 gtk_table_set_col_spacings(GTK_TABLE(table), PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 gtk_table_set_row_spacing(GTK_TABLE(table), 0, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 gtk_widget_show(table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 dd->entry = entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 g_object_set_data(G_OBJECT(dd->entry), "destination_data", dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 hbox2 = pref_table_box(table, 0, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 gtk_box_set_spacing(GTK_BOX(hbox2), PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 pref_button_new(hbox2, NULL, _("Home"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 G_CALLBACK(dest_home_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 pref_button_new(hbox2, NULL, _("New folder"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 G_CALLBACK(dest_new_dir_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 dd->hidden_button = gtk_check_button_new_with_label(_("Show hidden"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 g_signal_connect(G_OBJECT(dd->hidden_button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 G_CALLBACK(dest_show_hidden_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 gtk_box_pack_end(GTK_BOX(hbox2), dd->hidden_button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 gtk_widget_show(dd->hidden_button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 hbox2 = gtk_hbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 if (filter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 paned = gtk_hpaned_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 gtk_table_attach(GTK_TABLE(table), paned, 0, 3, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 gtk_widget_show(paned);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 gtk_paned_add1(GTK_PANED(paned), hbox2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 paned = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 gtk_widget_show(hbox2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 /* bookmarks */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 scrolled = bookmark_list_new(NULL, dest_bookmark_select_cb, dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 gtk_box_pack_start(GTK_BOX(hbox2), scrolled, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 dd->bookmark_list = scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 gtk_box_pack_start(GTK_BOX(hbox2), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 dd->d_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(dd->d_view), PATH_SEL_USE_HEADINGS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dd->d_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 gtk_tree_view_column_set_title(column, _("Folders"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 gtk_tree_view_append_column(GTK_TREE_VIEW(dd->d_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105 /* only for debugging */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 gtk_tree_view_column_set_title(column, _("Path"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 gtk_tree_view_column_add_attribute(column, renderer, "text", 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 gtk_tree_view_append_column(GTK_TREE_VIEW(dd->d_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 gtk_widget_set_size_request(dd->d_view, DEST_WIDTH, DEST_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 gtk_container_add(GTK_CONTAINER(scrolled), dd->d_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 gtk_widget_show(dd->d_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 g_signal_connect(G_OBJECT(dd->d_view), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 G_CALLBACK(dest_press_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120 g_signal_connect(G_OBJECT(dd->d_view), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 G_CALLBACK(dest_keypress_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 g_signal_connect(G_OBJECT(dd->d_view), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123 G_CALLBACK(dest_activate_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 g_signal_connect(G_OBJECT(dd->d_view), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 G_CALLBACK(dest_free_data), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 if (filter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 hbox2 = pref_table_box(table, 2, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 pref_label_new(hbox2, _("Filter:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 dd->filter_combo = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(store),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 FILTER_COLUMN_FILTER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 gtk_cell_layout_clear(GTK_CELL_LAYOUT(dd->filter_combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dd->filter_combo), renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dd->filter_combo), renderer,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 "text", FILTER_COLUMN_NAME, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 gtk_combo_set_case_sensitive(GTK_COMBO(dd->filter_combo), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 gtk_box_pack_start(GTK_BOX(hbox2), dd->filter_combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 gtk_widget_show(dd->filter_combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 if (paned)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 gtk_paned_add2(GTK_PANED(paned), scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 gtk_table_attach(GTK_TABLE(table), scrolled, 2, 3, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 dd->f_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(dd->f_view), PATH_SEL_USE_HEADINGS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 gtk_tree_view_column_set_title(column, _("Files"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 gtk_tree_view_append_column(GTK_TREE_VIEW(dd->f_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 gtk_widget_set_size_request(dd->f_view, DEST_WIDTH, DEST_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 gtk_container_add(GTK_CONTAINER(scrolled), dd->f_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 gtk_widget_show(dd->f_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 g_signal_connect(G_OBJECT(dd->f_view), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 G_CALLBACK(dest_press_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 g_signal_connect(G_OBJECT(dd->f_view), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 G_CALLBACK(dest_keypress_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 g_signal_connect(G_OBJECT(dd->f_view), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 G_CALLBACK(dest_activate_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 g_signal_connect(selection, "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 G_CALLBACK(dest_select_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 dest_filter_clear(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 dest_filter_add(dd, filter, filter_desc, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200 dd->filter = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(dd->filter_combo)->child)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203 if (path && path[0] == '/' && isdir(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 dest_populate(dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 gchar *buf = remove_level_from_path(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 if (buf && buf[0] == '/' && isdir(buf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 gint pos = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 dest_populate(dd, (gchar *)homedir());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 if (path) gtk_editable_insert_text(GTK_EDITABLE(dd->entry), "/", -1, &pos);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 if (path) gtk_editable_insert_text(GTK_EDITABLE(dd->entry), path, -1, &pos);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 if (dd->filter_combo)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 g_signal_connect(G_OBJECT(GTK_BIN(dd->filter_combo)->child), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 G_CALLBACK(dest_filter_changed_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 g_signal_connect(G_OBJECT(dd->entry), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 G_CALLBACK(dest_entry_changed_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 dest_dnd_init(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 return table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 GtkWidget *path_selection_new(const gchar *path, GtkWidget *entry)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 return path_selection_new_with_files(entry, path, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243 void path_selection_sync_to_entry(GtkWidget *entry)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 path = gtk_entry_get_text(GTK_ENTRY(entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 if (isdir(path) && strcmp(path, dd->path) != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 dest_populate(dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 gchar *buf = remove_level_from_path(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 if (isdir(buf) && strcmp(buf, dd->path) != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 void path_selection_add_select_func(GtkWidget *entry,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 void (*func)(const gchar *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 dd->select_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 dd->select_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 void path_selection_add_filter(GtkWidget *entry, const gchar *filter, const gchar *description, gint set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 if (!filter) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 dest_filter_add(dd, filter, description, set);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 void path_selection_clear_filter(GtkWidget *entry)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 dest_filter_clear(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296