annotate src/ui_pathsel.c @ 115:53b2bfdcff69

Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net> * color-man.[ch]: Allow color manager to work with GdkPixbufs not linked to an ImageWindow. Fix missing embedded dummy function when compiling without color profile support. * image.c: When embedded color profiles is enabled and EXIF ColorSpace is set to 1 use sRGB color profile for the image. Also fixed order of starting the image read-ahead when color profiles are in use. * typedefs.h (ImageWindow): Use gpointer definition correctly so that cm is a pointer and not a pointer to a pointer. * utilops.c: Pass 0 to vertical fill arg of gtk_table_attach() instead of FALSE.
author gqview
date Tue, 28 Nov 2006 17:06:47 +0000
parents 31759d770628
children 71e1ebee420e
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
69
31759d770628 Fri Oct 13 10:27:22 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
3 * (C) 2006 John Ellis
9
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
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
168 if (!path) return;
9
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 {
69
31759d770628 Fri Oct 13 10:27:22 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
180 if (dd->show_hidden || !is_hidden(dir->d_name))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 gchar *name = dir->d_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 gchar *filepath = g_strconcat(pathl, "/", name, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 if (stat(filepath, &ent_sbuf) >= 0 && S_ISDIR(ent_sbuf.st_mode))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 path_list = g_list_prepend(path_list, path_to_utf8(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 else if (dd->f_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 if (!dd->filter || (dd->filter && dest_check_filter(dd->filter, name)))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 file_list = g_list_prepend(file_list, path_to_utf8(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 g_free(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 }
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 closedir(dp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 path_list = g_list_sort(path_list, (GCompareFunc) dest_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 file_list = g_list_sort(file_list, (GCompareFunc) dest_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 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
203 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 list = path_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 gchar *filepath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 if (strcmp(list->data, ".") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 filepath = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 else if (strcmp(list->data, "..") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 filepath = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 p = (gchar *)filename_from_path(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 if (p - 1 != filepath) p--;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 p[0] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 filepath = concat_dir_and_file(path, list->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 }
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 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 gtk_list_store_set(store, &iter, 0, list->data, 1, filepath, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 g_free(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 list = list->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 }
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 path_list_free(path_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236
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 if (dd->f_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 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
241 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 list = file_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 gchar *filepath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 const gchar *name = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 filepath = concat_dir_and_file(path, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 gtk_list_store_set(store, &iter, 0, name, 1, filepath, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 g_free(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 list = list->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 }
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 path_list_free(file_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 }
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 g_free(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 dd->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 }
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 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
267 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 gchar *old_name = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 gint s = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 if (retain_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 const gchar *buf = gtk_entry_get_text(GTK_ENTRY(dd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 if (!isdir(buf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 if (path && strcmp(path, "/") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 old_name = g_strdup(filename_from_path(buf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 old_name = g_strconcat("/", filename_from_path(buf), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 s = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 }
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 gtk_entry_set_text(GTK_ENTRY(dd->entry), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 dest_populate(dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 /* remember filename */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 if (old_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 gint pos = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 gtk_editable_insert_text(GTK_EDITABLE(dd->entry), old_name, -1, &pos);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 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
298 g_free(old_name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 }
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 * drag and drop
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 *-----------------------------------------------------------------------------
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 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 TARGET_URI_LIST,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 TARGET_TEXT_PLAIN
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 };
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 static GtkTargetEntry dest_drag_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 { "text/plain", 0, TARGET_TEXT_PLAIN }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 #define dest_drag_types_n 2
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318
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 static void dest_dnd_set_data(GtkWidget *view,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 GdkDragContext *context, GtkSelectionData *selection_data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 guint info, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 gchar *path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 if (!gtk_tree_selection_get_selected(selection, &model, &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 gtk_tree_model_get(model, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 list = g_list_append(list, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 uri_text = uri_text_from_list(list, &length, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 uri_text = uri_text_from_list(list, &length, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 }
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 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 if (!uri_text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 gtk_selection_data_set(selection_data, selection_data->target,
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
355 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 }
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 static void dest_dnd_init(Dest_Data *dd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 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
362 dest_drag_types, dest_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 g_signal_connect(G_OBJECT(dd->d_view), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 G_CALLBACK(dest_dnd_set_data), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 if (dd->f_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 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
370 dest_drag_types, dest_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 g_signal_connect(G_OBJECT(dd->f_view), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 G_CALLBACK(dest_dnd_set_data), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 }
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 * destination widget file management utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 *-----------------------------------------------------------------------------
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 static void dest_view_store_selection(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 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
391 dd->right_click_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 selection = gtk_tree_view_get_selection(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 if (!gtk_tree_selection_get_selected(selection, &model, &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 }
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 dd->right_click_path = gtk_tree_model_get_path(model, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 }
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 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
403 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 gchar *old_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 gchar *new_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 model = gtk_tree_view_get_model(GTK_TREE_VIEW(ted->tree));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 gtk_tree_model_get(model, &iter, 1, &old_path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 if (!old_path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 buf = remove_level_from_path(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 new_path = concat_dir_and_file(buf, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 if (isname(new_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 buf = g_strdup_printf(_("A file with name %s already exists."), new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 warning_dialog("Rename failed", buf, GTK_STOCK_DIALOG_INFO, dd->entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 else if (!rename_file(old_path, new_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 buf = g_strdup_printf(_("Failed to rename %s to %s."), old, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 warning_dialog("Rename failed", buf, GTK_STOCK_DIALOG_ERROR, dd->entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 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
438
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 text = gtk_entry_get_text(GTK_ENTRY(dd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 if (text && old_path && strcmp(text, old_path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 gtk_entry_set_text(GTK_ENTRY(dd->entry), new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 }
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 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 g_free(new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 }
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 static void dest_view_rename(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 if (!dd->right_click_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 gtk_tree_model_get(model, &iter, 0, &text, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 tree_edit_by_path(view, dd->right_click_path, 0, text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 dest_view_rename_cb, dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 }
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 static void dest_view_delete_dlg_cancel(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 DestDel_Data *dl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 dl->dd->gd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 g_free(dl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 g_free(dl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 }
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 static void dest_view_delete_dlg_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 DestDel_Data *dl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 if (!unlink_file(dl->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 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
486 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
487 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 else if (dl->dd->path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 /* refresh list */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 gchar *path = g_strdup(dl->dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 dest_populate(dl->dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 }
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 dest_view_delete_dlg_cancel(gd, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 }
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 static void dest_view_delete(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 DestDel_Data *dl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 if (view != GTK_TREE_VIEW(dd->f_view)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 if (!dd->right_click_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 gtk_tree_model_get(model, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 dl = g_new(DestDel_Data, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 dl->dd = dd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 dl->path = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 if (dd->gd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 GenericDialog *gd = dd->gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 dest_view_delete_dlg_cancel(dd->gd, dd->gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 }
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 dd->gd = generic_dialog_new(_("Delete file"), PACKAGE, "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 dd->entry, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 dest_view_delete_dlg_cancel, dl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 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
533
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 text = g_strdup_printf(_("About to delete the file:\n %s"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 generic_dialog_add_message(dd->gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 _("Delete file"), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 gtk_widget_show(dd->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 }
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 static void dest_view_bookmark(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 if (!dd->right_click_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 gtk_tree_model_get(model, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 bookmark_list_add(dd->bookmark_list, filename_from_path(path), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 }
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 static void dest_popup_dir_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 dest_view_rename(dd, GTK_TREE_VIEW(dd->d_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 }
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 static void dest_popup_dir_bookmark_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 dest_view_bookmark(dd, GTK_TREE_VIEW(dd->d_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 }
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 static void dest_popup_file_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 dest_view_rename(dd, GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 }
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 static void dest_popup_file_delete_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 dest_view_delete(dd, GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 }
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 static void dest_popup_file_bookmark_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 dest_view_bookmark(dd, GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 }
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 static void dest_popup_position_cb(GtkMenu *menu, gint *x, gint *y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 gboolean *push_in, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 GtkTreeView *view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 gint cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 view = g_object_get_data(G_OBJECT(menu), "active_view");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 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
598 *y += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 popup_menu_position_clamp(menu, x, y, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 }
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 static gint dest_popup_menu(Dest_Data *dd, GtkTreeView *view,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 gint button, guint32 time, gint local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 if (!dd->right_click_path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 if (view == GTK_TREE_VIEW(dd->d_view))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 gint normal_dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 gtk_tree_model_get(model, &iter, 0, &text, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 if (!text) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 normal_dir = (strcmp(text, ".") == 0 || strcmp(text, "..") == 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 menu_item_add_sensitive(menu, _("_Rename"), !normal_dir,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 G_CALLBACK(dest_popup_dir_rename_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 menu_item_add_stock(menu, _("Add _Bookmark"), GTK_STOCK_JUMP_TO,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 G_CALLBACK(dest_popup_dir_bookmark_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 menu_item_add(menu, _("_Rename"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 G_CALLBACK(dest_popup_file_rename_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 menu_item_add_stock(menu, _("_Delete"), GTK_STOCK_DELETE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 G_CALLBACK(dest_popup_file_delete_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 menu_item_add_stock(menu, _("Add _Bookmark"), GTK_STOCK_JUMP_TO,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 G_CALLBACK(dest_popup_file_bookmark_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 }
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 if (local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 g_object_set_data(G_OBJECT(menu), "active_view", view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 dest_popup_position_cb, dd, button, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 }
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 }
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 static gint dest_press_cb(GtkWidget *view, GdkEventButton *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 gint cell_x, cell_y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 if (event->button != 3 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 !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
667 &tpath, &column, &cell_x, &cell_y))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 }
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 model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 gtk_tree_model_get_iter(model, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 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
679 dd->right_click_path = tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 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
682 }
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 static gboolean dest_keypress_cb(GtkWidget *view, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 case GDK_F10:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 if (!(event->state & GDK_CONTROL_MASK)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 dest_popup_menu(dd, GTK_TREE_VIEW(view), 0, event->time, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 case 'R': case 'r':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 if (event->state & GDK_CONTROL_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 dest_view_rename(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 case GDK_Delete:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 dest_view_delete(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 case 'B' : case 'b':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 if (event->state & GDK_CONTROL_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 dest_view_bookmark(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 }
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 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 }
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 static void dest_new_dir_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 const gchar *tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 gint from_text = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 tmp = gtk_entry_get_text(GTK_ENTRY(dd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 if (!isname(tmp))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 path = g_strdup(tmp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 from_text = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 buf = concat_dir_and_file(dd->path, _("New folder"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 path = unique_filename(buf, NULL, " ", FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 }
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 if (!mkdir_utf8(path, 0755))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 /* failed */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 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
750 warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, dd->entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 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
760
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 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
762
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 text = filename_from_path(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 gtk_list_store_set(store, &iter, 0, text, 1, path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 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
769 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
770
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 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
772 dest_view_rename_cb, dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 }
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 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 }
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 * destination widget file selection, traversal, view options
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 *-----------------------------------------------------------------------------
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 static void dest_select_cb(GtkTreeSelection *selection, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 GtkTreeView *view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 view = gtk_tree_selection_get_tree_view(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 store = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 gtk_tree_model_get(store, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 if (view == GTK_TREE_VIEW(dd->d_view))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 dest_change_dir(dd, path, (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 gtk_entry_set_text(GTK_ENTRY(dd->entry), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 }
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 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 }
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 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
811 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 store = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 gtk_tree_model_get(store, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 if (view == dd->d_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 dest_change_dir(dd, path, (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 if (dd->select_func)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 dd->select_func(path, dd->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 }
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 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 }
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 static void dest_home_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 dest_change_dir(dd, homedir(), (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 }
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 static void dest_show_hidden_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 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
849
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 buf = g_strdup(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 }
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 static void dest_entry_changed_cb(GtkEditable *editable, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 path = gtk_entry_get_text(GTK_ENTRY(dd->entry));
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
862 if (dd->path && strcmp(path, dd->path) == 0) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 buf = remove_level_from_path(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
866 if (buf && (!dd->path || strcmp(buf, dd->path) != 0))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 gchar *tmp = remove_trailing_slash(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 if (isdir(tmp))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 dest_populate(dd, tmp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 else if (isdir(buf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 g_free(tmp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 }
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 static void dest_filter_list_sync(Dest_Data *dd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 gchar *old_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 GList *fwork;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 GList *twork;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 if (!dd->filter_list || !dd->filter_combo) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 entry = GTK_BIN(dd->filter_combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 old_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 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
896 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 fwork = dd->filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 twork = dd->filter_text_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 while (fwork && twork)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 gchar *filter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 name = twork->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 filter = fwork->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 gtk_list_store_set(store, &iter, FILTER_COLUMN_NAME, name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 FILTER_COLUMN_FILTER, filter, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 if (strcmp(old_text, filter) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 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
916 }
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 fwork = fwork->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 twork = twork->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 }
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 g_free(old_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 }
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 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
926 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 gint c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 if (!filter) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 work = dd->filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 gchar *f = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 if (strcmp(f, filter) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 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
941 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 }
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 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
948
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 if (description)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 buf = g_strdup_printf("%s ( %s )", description, filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 buf = g_strdup_printf("( %s )", filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 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
958
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 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
960 dest_filter_list_sync(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 }
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 static void dest_filter_clear(Dest_Data *dd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 path_list_free(dd->filter_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 dd->filter_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 path_list_free(dd->filter_text_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 dd->filter_text_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 dest_filter_add(dd, "*", _("All Files"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 }
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 static void dest_filter_changed_cb(GtkEditable *editable, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 const gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 entry = GTK_BIN(dd->filter_combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 buf = gtk_entry_get_text(GTK_ENTRY(entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 g_free(dd->filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 dd->filter = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 if (strlen(buf) > 0) dd->filter = g_strdup(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 path = g_strdup(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 dest_populate(dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 }
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 static void dest_bookmark_select_cb(const gchar *path, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 if (isdir(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 dest_change_dir(dd, path, (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 else if (isfile(path) && dd->f_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 gtk_entry_set_text(GTK_ENTRY(dd->entry), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 }
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 * destination widget setup routines (public)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 *-----------------------------------------------------------------------------
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 GtkWidget *path_selection_new_with_files(GtkWidget *entry, const gchar *path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 const gchar *filter, const gchar *filter_desc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 GtkWidget *hbox2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 Dest_Data *dd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 GtkWidget *paned;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 dd = g_new0(Dest_Data, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 dd->show_hidden = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 dd->select_func = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 dd->select_data = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 dd->gd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 table = gtk_table_new(4, (filter != NULL) ? 3 : 1, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 gtk_table_set_col_spacings(GTK_TABLE(table), PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 gtk_table_set_row_spacing(GTK_TABLE(table), 0, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 gtk_widget_show(table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 dd->entry = entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 g_object_set_data(G_OBJECT(dd->entry), "destination_data", dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 hbox2 = pref_table_box(table, 0, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 gtk_box_set_spacing(GTK_BOX(hbox2), PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 pref_button_new(hbox2, NULL, _("Home"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 G_CALLBACK(dest_home_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 pref_button_new(hbox2, NULL, _("New folder"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 G_CALLBACK(dest_new_dir_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 dd->hidden_button = gtk_check_button_new_with_label(_("Show hidden"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 g_signal_connect(G_OBJECT(dd->hidden_button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 G_CALLBACK(dest_show_hidden_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 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
1051 gtk_widget_show(dd->hidden_button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 hbox2 = gtk_hbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 if (filter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 paned = gtk_hpaned_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 gtk_table_attach(GTK_TABLE(table), paned, 0, 3, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 gtk_widget_show(paned);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 gtk_paned_add1(GTK_PANED(paned), hbox2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 paned = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 gtk_widget_show(hbox2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 /* bookmarks */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 scrolled = bookmark_list_new(NULL, dest_bookmark_select_cb, dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 gtk_box_pack_start(GTK_BOX(hbox2), scrolled, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 dd->bookmark_list = scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 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
1079 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 gtk_box_pack_start(GTK_BOX(hbox2), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 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
1086 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 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
1089
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dd->d_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 gtk_tree_view_column_set_title(column, _("Folders"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 gtk_tree_view_append_column(GTK_TREE_VIEW(dd->d_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 /* only for debugging */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 gtk_tree_view_column_set_title(column, _("Path"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 gtk_tree_view_column_add_attribute(column, renderer, "text", 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 gtk_tree_view_append_column(GTK_TREE_VIEW(dd->d_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 gtk_widget_set_size_request(dd->d_view, DEST_WIDTH, DEST_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 gtk_container_add(GTK_CONTAINER(scrolled), dd->d_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 gtk_widget_show(dd->d_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 g_signal_connect(G_OBJECT(dd->d_view), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 G_CALLBACK(dest_press_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 g_signal_connect(G_OBJECT(dd->d_view), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120 G_CALLBACK(dest_keypress_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 g_signal_connect(G_OBJECT(dd->d_view), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 G_CALLBACK(dest_activate_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123 g_signal_connect(G_OBJECT(dd->d_view), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 G_CALLBACK(dest_free_data), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 if (filter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 hbox2 = pref_table_box(table, 2, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 pref_label_new(hbox2, _("Filter:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135 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
1136 FILTER_COLUMN_FILTER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 gtk_cell_layout_clear(GTK_CELL_LAYOUT(dd->filter_combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 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
1141 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dd->filter_combo), renderer,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 "text", FILTER_COLUMN_NAME, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 gtk_combo_set_case_sensitive(GTK_COMBO(dd->filter_combo), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 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
1147 gtk_widget_show(dd->filter_combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 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
1151 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 if (paned)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 gtk_paned_add2(GTK_PANED(paned), scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 gtk_table_attach(GTK_TABLE(table), scrolled, 2, 3, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 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
1166 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 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
1169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 gtk_tree_view_column_set_title(column, _("Files"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 gtk_tree_view_append_column(GTK_TREE_VIEW(dd->f_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 gtk_widget_set_size_request(dd->f_view, DEST_WIDTH, DEST_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 gtk_container_add(GTK_CONTAINER(scrolled), dd->f_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 gtk_widget_show(dd->f_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 g_signal_connect(G_OBJECT(dd->f_view), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 G_CALLBACK(dest_press_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 g_signal_connect(G_OBJECT(dd->f_view), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 G_CALLBACK(dest_keypress_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 g_signal_connect(G_OBJECT(dd->f_view), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 G_CALLBACK(dest_activate_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 g_signal_connect(selection, "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 G_CALLBACK(dest_select_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 dest_filter_clear(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 dest_filter_add(dd, filter, filter_desc, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 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
1200 }
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 if (path && path[0] == '/' && isdir(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 dest_populate(dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 gchar *buf = remove_level_from_path(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 if (buf && buf[0] == '/' && isdir(buf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 gint pos = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 dest_populate(dd, (gchar *)homedir());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 if (path) gtk_editable_insert_text(GTK_EDITABLE(dd->entry), "/", -1, &pos);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 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
1220 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 }
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 if (dd->filter_combo)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 g_signal_connect(G_OBJECT(GTK_BIN(dd->filter_combo)->child), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 G_CALLBACK(dest_filter_changed_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 g_signal_connect(G_OBJECT(dd->entry), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 G_CALLBACK(dest_entry_changed_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 dest_dnd_init(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 return table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 }
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 GtkWidget *path_selection_new(const gchar *path, GtkWidget *entry)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 return path_selection_new_with_files(entry, path, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 }
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 void path_selection_sync_to_entry(GtkWidget *entry)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 path = gtk_entry_get_text(GTK_ENTRY(entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1251 if (isdir(path) && (!dd->path || strcmp(path, dd->path) != 0))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 dest_populate(dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 gchar *buf = remove_level_from_path(path);
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1258 if (isdir(buf) && (!dd->path || strcmp(buf, dd->path) != 0))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 }
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 void path_selection_add_select_func(GtkWidget *entry,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 void (*func)(const gchar *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273 dd->select_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 dd->select_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 }
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 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
1278 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 if (!filter) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 dest_filter_add(dd, filter, description, set);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 }
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 void path_selection_clear_filter(GtkWidget *entry)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 dest_filter_clear(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295