annotate src/ui_pathsel.c @ 1367:fe4da037be21

When g_new0() is used, drop redundant initializations to NULL, FALSE or 0, second pass.
author zas_
date Sun, 01 Mar 2009 23:14:19 +0000
parents 249bf204004a
children a3d3208b0c50
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
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1174
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * 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
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 #ifdef HAVE_CONFIG_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 # include "config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include <stdio.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include <string.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include <dirent.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include <fcntl.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include <unistd.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include <sys/types.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include <sys/stat.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include <gtk/gtk.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #include <gdk/gdkkeysyms.h> /* for key values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 254
diff changeset
32 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #include "ui_pathsel.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 #include "ui_tree_edit.h"
904
1698baa37871 Move uri_*() functions to separate files: uri_utils.[ch]
zas_
parents: 726
diff changeset
42 #include "uri_utils.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43
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 DEST_WIDTH 250
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 #define DEST_HEIGHT 210
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 #define RENAME_PRESS_DELAY 333 /* 1/3 second, to allow double clicks */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 #define PATH_SEL_USE_HEADINGS FALSE
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 FILTER_COLUMN_NAME = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 FILTER_COLUMN_FILTER
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 };
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 typedef struct _Dest_Data Dest_Data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 struct _Dest_Data
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 GtkWidget *d_view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 GtkWidget *f_view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 gchar *filter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 GList *filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 GList *filter_text_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 GtkWidget *filter_combo;
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 gint show_hidden;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 GtkWidget *hidden_button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 GtkWidget *bookmark_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 GtkTreePath *right_click_path;
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 void (*select_func)(const gchar *path, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 gpointer select_data;
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 GenericDialog *gd; /* any open confirm dialogs ? */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 };
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 typedef struct _DestDel_Data DestDel_Data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 struct _DestDel_Data
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 Dest_Data *dd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 };
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 static void dest_view_delete_dlg_cancel(GenericDialog *gd, gpointer data);
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
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 * (private)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 *-----------------------------------------------------------------------------
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
98 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 static void dest_free_data(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 if (dd->gd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 GenericDialog *gd = dd->gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 dest_view_delete_dlg_cancel(dd->gd, dd->gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 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
111
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 g_free(dd->filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 g_free(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 g_free(dd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 static gint dest_check_filter(const gchar *filter, const gchar *file)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 const gchar *f_ptr = filter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 const gchar *strt_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 l = strlen(file);
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 if (filter[0] == '*') return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 while (f_ptr < filter + strlen(filter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 strt_ptr = f_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 i=0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 while (*f_ptr != ';' && *f_ptr != '\0')
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 f_ptr++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 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
137 f_ptr++;
605
651ae2be1031 Use g_ascii_strncasecmp() instead of strncasecmp() where applicable.
zas_
parents: 576
diff changeset
138 /* FIXME: utf8 */
1307
e8f21b91885d Glibification again.
zas_
parents: 1284
diff changeset
139 if (l >= i && g_ascii_strncasecmp(file + l - i, strt_ptr, i) == 0) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 }
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 #ifndef CASE_SORT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 #define CASE_SORT strcmp
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147
1002
3096a47232ec Use gpointer instead of void *.
zas_
parents: 989
diff changeset
148 static gint dest_sort_cb(gpointer a, gpointer b)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 return CASE_SORT((gchar *)a, (gchar *)b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 static gint is_hidden(const gchar *name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 if (name[0] != '.') return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 if (name[1] == '\0') return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 if (name[1] == '.' && name[2] == '\0') return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 static void dest_populate(Dest_Data *dd, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 DIR *dp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 struct dirent *dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 struct stat ent_sbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 GList *path_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 GList *file_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
172 if (!path) return;
9
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 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 dp = opendir(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 if (!dp)
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 /* dir not found */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 return;
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 while ((dir = readdir(dp)) != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 {
373
61a3c8b05b24 Add a new option in Preferences > Filtering to allow the
zas_
parents: 281
diff changeset
184 if (!options->file_filter.show_dot_directory
61a3c8b05b24 Add a new option in Preferences > Filtering to allow the
zas_
parents: 281
diff changeset
185 && dir->d_name[0] == '.' && dir->d_name[1] == '\0')
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
186 continue;
373
61a3c8b05b24 Add a new option in Preferences > Filtering to allow the
zas_
parents: 281
diff changeset
187 if (dir->d_name[0] == '.' && dir->d_name[1] == '.' && dir->d_name[2] == '\0'
726
a1dcef8cd1ae Use G_DIR_SEPARATOR where applicable.
zas_
parents: 725
diff changeset
188 && pathl[0] == G_DIR_SEPARATOR && pathl[1] == '\0')
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
189 continue; /* no .. for root directory */
69
31759d770628 Fri Oct 13 10:27:22 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
190 if (dd->show_hidden || !is_hidden(dir->d_name))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 gchar *name = dir->d_name;
717
aae956e84de4 Use g_build_filename().
zas_
parents: 702
diff changeset
193 gchar *filepath = g_build_filename(pathl, name, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 if (stat(filepath, &ent_sbuf) >= 0 && S_ISDIR(ent_sbuf.st_mode))
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 path_list = g_list_prepend(path_list, path_to_utf8(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 else if (dd->f_view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 if (!dd->filter || (dd->filter && dest_check_filter(dd->filter, name)))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 file_list = g_list_prepend(file_list, path_to_utf8(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 g_free(filepath);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 closedir(dp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 path_list = g_list_sort(path_list, (GCompareFunc) dest_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 file_list = g_list_sort(file_list, (GCompareFunc) dest_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 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
213 gtk_list_store_clear(store);
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 list = path_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 gchar *filepath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 if (strcmp(list->data, ".") == 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 filepath = g_strdup(path);
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 else if (strcmp(list->data, "..") == 0)
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 gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 filepath = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 p = (gchar *)filename_from_path(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 if (p - 1 != filepath) p--;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 p[0] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 {
702
e07895754e65 Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents: 605
diff changeset
235 filepath = g_build_filename(path, list->data, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
237
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 gtk_list_store_set(store, &iter, 0, list->data, 1, filepath, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 g_free(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 list = list->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 513
diff changeset
245 string_list_free(path_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 if (dd->f_view)
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 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
251 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 list = file_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 while (list)
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
255 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 gchar *filepath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 const gchar *name = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259
702
e07895754e65 Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents: 605
diff changeset
260 filepath = g_build_filename(path, name, NULL);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
261
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 gtk_list_store_set(store, &iter, 0, name, 1, filepath, -1);
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 g_free(filepath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 list = list->next;
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
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 513
diff changeset
269 string_list_free(file_list);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 g_free(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 dd->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 }
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 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
277 {
719
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
278 const gchar *old_name = NULL;
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
279 gchar *full_path;
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
280 gchar *new_directory;
9
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 if (retain_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 const gchar *buf = gtk_entry_get_text(GTK_ENTRY(dd->entry));
719
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
285
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
286 if (!isdir(buf)) old_name = filename_from_path(buf);
9
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
719
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
289 full_path = g_build_filename(path, old_name, NULL);
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
290 if (old_name)
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
291 new_directory = g_path_get_dirname(full_path);
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
292 else
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
293 new_directory = g_strdup(full_path);
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
294
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
295 gtk_entry_set_text(GTK_ENTRY(dd->entry), full_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296
719
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
297 dest_populate(dd, new_directory);
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
298 g_free(new_directory);
9
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 if (old_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 {
719
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
302 gchar *basename = g_path_get_basename(full_path);
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
303
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
304 gtk_editable_select_region(GTK_EDITABLE(dd->entry), strlen(full_path) - strlen(basename), strlen(full_path));
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
305 g_free(basename);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 }
719
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
307
ab4162fa9209 dest_change_dir(): rewrite to use g_build_filename(), g_path_get_dirname() and g_path_get_basename().
zas_
parents: 717
diff changeset
308 g_free(full_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310
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 * drag and drop
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 */
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 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 TARGET_URI_LIST,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 TARGET_TEXT_PLAIN
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 static GtkTargetEntry dest_drag_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 { "text/plain", 0, TARGET_TEXT_PLAIN }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 #define dest_drag_types_n 2
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 static void dest_dnd_set_data(GtkWidget *view,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 GdkDragContext *context, GtkSelectionData *selection_data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 guint info, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 gchar *path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 if (!gtk_tree_selection_get_selected(selection, &model, &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 gtk_tree_model_get(model, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 list = g_list_append(list, path);
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 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 uri_text = uri_text_from_list(list, &length, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 uri_text = uri_text_from_list(list, &length, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 break;
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
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 513
diff changeset
359 string_list_free(list);
9
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 if (!uri_text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 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
364 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 g_free(uri_text);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 static void dest_dnd_init(Dest_Data *dd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(dd->d_view), GDK_BUTTON1_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 dest_drag_types, dest_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 g_signal_connect(G_OBJECT(dd->d_view), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 G_CALLBACK(dest_dnd_set_data), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 if (dd->f_view)
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 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
379 dest_drag_types, dest_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 g_signal_connect(G_OBJECT(dd->f_view), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 G_CALLBACK(dest_dnd_set_data), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 * destination widget file management utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 */
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 static void dest_view_store_selection(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 GtkTreeIter iter;
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 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
400 dd->right_click_path = NULL;
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 selection = gtk_tree_view_get_selection(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 if (!gtk_tree_selection_get_selected(selection, &model, &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 dd->right_click_path = gtk_tree_model_get_path(model, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 }
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 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
412 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 gchar *old_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 gchar *new_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 model = gtk_tree_view_get_model(GTK_TREE_VIEW(ted->tree));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 gtk_tree_model_get_iter(model, &iter, dd->right_click_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 gtk_tree_model_get(model, &iter, 1, &old_path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 if (!old_path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 buf = remove_level_from_path(old_path);
702
e07895754e65 Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents: 605
diff changeset
427 new_path = g_build_filename(buf, new, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 if (isname(new_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 buf = g_strdup_printf(_("A file with name %s already exists."), new);
989
50e1f5e54c1a Fix untranslated messages. French translation and POTFILES.in were updated.
zas_
parents: 904
diff changeset
433 warning_dialog(_("Rename failed"), buf, GTK_STOCK_DIALOG_INFO, dd->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 else if (!rename_file(old_path, new_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 buf = g_strdup_printf(_("Failed to rename %s to %s."), old, new);
989
50e1f5e54c1a Fix untranslated messages. French translation and POTFILES.in were updated.
zas_
parents: 904
diff changeset
439 warning_dialog(_("Rename failed"), buf, GTK_STOCK_DIALOG_ERROR, dd->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 g_free(buf);
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 else
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 const gchar *text;
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 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
447
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 text = gtk_entry_get_text(GTK_ENTRY(dd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 if (text && old_path && strcmp(text, old_path) == 0)
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 gtk_entry_set_text(GTK_ENTRY(dd->entry), new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 g_free(new_path);
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 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 static void dest_view_rename(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 gchar *text;
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 if (!dd->right_click_path) return;
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 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 gtk_tree_model_get(model, &iter, 0, &text, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 tree_edit_by_path(view, dd->right_click_path, 0, text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 dest_view_rename_cb, dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 g_free(text);
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_cancel(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 dl->dd->gd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 g_free(dl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 g_free(dl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 static void dest_view_delete_dlg_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 DestDel_Data *dl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 if (!unlink_file(dl->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 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
495 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
496 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 else if (dl->dd->path)
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 /* refresh list */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 gchar *path = g_strdup(dl->dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 dest_populate(dl->dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 dest_view_delete_dlg_cancel(gd, data);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 static void dest_view_delete(Dest_Data *dd, GtkTreeView *view)
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 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 DestDel_Data *dl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 GtkTreeIter iter;
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 if (view != GTK_TREE_VIEW(dd->f_view)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 if (!dd->right_click_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 gtk_tree_model_get(model, &iter, 1, &path, -1);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
523
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 dl = g_new(DestDel_Data, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 dl->dd = dd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 dl->path = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 if (dd->gd)
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 GenericDialog *gd = dd->gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 dest_view_delete_dlg_cancel(dd->gd, dd->gd->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1055
diff changeset
537 dd->gd = generic_dialog_new(_("Delete file"), "dlg_confirm",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 dd->entry, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 dest_view_delete_dlg_cancel, dl);
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 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
542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 text = g_strdup_printf(_("About to delete the file:\n %s"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 generic_dialog_add_message(dd->gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 _("Delete file"), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 g_free(text);
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 gtk_widget_show(dd->gd->dialog);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 static void dest_view_bookmark(Dest_Data *dd, GtkTreeView *view)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 gchar *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 if (!dd->right_click_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 gtk_tree_model_get(model, &iter, 1, &path, -1);
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 bookmark_list_add(dd->bookmark_list, filename_from_path(path), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 g_free(path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 static void dest_popup_dir_rename_cb(GtkWidget *widget, gpointer data)
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 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 dest_view_rename(dd, GTK_TREE_VIEW(dd->d_view));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 static void dest_popup_dir_bookmark_cb(GtkWidget *widget, gpointer data)
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 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 dest_view_bookmark(dd, GTK_TREE_VIEW(dd->d_view));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 static void dest_popup_file_rename_cb(GtkWidget *widget, gpointer data)
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 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 dest_view_rename(dd, GTK_TREE_VIEW(dd->f_view));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 static void dest_popup_file_delete_cb(GtkWidget *widget, gpointer data)
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 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 dest_view_delete(dd, GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 }
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 static void dest_popup_file_bookmark_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 dest_view_bookmark(dd, GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 static void dest_popup_position_cb(GtkMenu *menu, gint *x, gint *y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 gboolean *push_in, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 GtkTreeView *view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 gint cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 view = g_object_get_data(G_OBJECT(menu), "active_view");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 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
607 *y += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 popup_menu_position_clamp(menu, x, y, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 static gint dest_popup_menu(Dest_Data *dd, GtkTreeView *view,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 gint button, guint32 time, gint local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 GtkWidget *menu;
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 if (!dd->right_click_path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 if (view == GTK_TREE_VIEW(dd->d_view))
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 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 gint normal_dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 model = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 gtk_tree_model_get_iter(model, &iter, dd->right_click_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 gtk_tree_model_get(model, &iter, 0, &text, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 if (!text) return FALSE;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
630
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 normal_dir = (strcmp(text, ".") == 0 || strcmp(text, "..") == 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 menu_item_add_sensitive(menu, _("_Rename"), !normal_dir,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 G_CALLBACK(dest_popup_dir_rename_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 menu_item_add_stock(menu, _("Add _Bookmark"), GTK_STOCK_JUMP_TO,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 G_CALLBACK(dest_popup_dir_bookmark_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 else
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 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 menu_item_add(menu, _("_Rename"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 G_CALLBACK(dest_popup_file_rename_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 menu_item_add_stock(menu, _("_Delete"), GTK_STOCK_DELETE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 G_CALLBACK(dest_popup_file_delete_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 menu_item_add_stock(menu, _("Add _Bookmark"), GTK_STOCK_JUMP_TO,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 G_CALLBACK(dest_popup_file_bookmark_cb), dd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 if (local)
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 g_object_set_data(G_OBJECT(menu), "active_view", view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 dest_popup_position_cb, dd, button, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 static gint dest_press_cb(GtkWidget *view, GdkEventButton *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 gint cell_x, cell_y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 GtkTreeModel *model;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
674 if (event->button != MOUSE_BUTTON_RIGHT ||
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 !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
676 &tpath, &column, &cell_x, &cell_y))
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 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 }
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 model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 gtk_tree_model_get_iter(model, &iter, tpath);
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 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 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
688 dd->right_click_path = tpath;
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 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
691 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 static gboolean dest_keypress_cb(GtkWidget *view, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 case GDK_F10:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 if (!(event->state & GDK_CONTROL_MASK)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 dest_popup_menu(dd, GTK_TREE_VIEW(view), 0, event->time, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 case 'R': case 'r':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 if (event->state & GDK_CONTROL_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 dest_view_rename(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 return TRUE;
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 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 case GDK_Delete:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 dest_view_delete(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 case 'B' : case 'b':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 if (event->state & GDK_CONTROL_MASK)
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 dest_view_store_selection(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 dest_view_bookmark(dd, GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
731
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 static void dest_new_dir_cb(GtkWidget *widget, gpointer data)
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 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 const gchar *tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 gint from_text = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 tmp = gtk_entry_get_text(GTK_ENTRY(dd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 if (!isname(tmp))
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 path = g_strdup(tmp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 from_text = TRUE;
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 {
702
e07895754e65 Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents: 605
diff changeset
748 buf = g_build_filename(dd->path, _("New folder"), NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 path = unique_filename(buf, NULL, " ", FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 }
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 if (!mkdir_utf8(path, 0755))
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 /* failed */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 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
759 warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, dd->entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 const gchar *text;
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 (from_text) gtk_entry_set_text(GTK_ENTRY(dd->entry), dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 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
771
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 text = filename_from_path(path);
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 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 gtk_list_store_set(store, &iter, 0, text, 1, path, -1);
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 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
778 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
779
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780 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
781 dest_view_rename_cb, dd);
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 g_free(path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 * destination widget file selection, traversal, view options
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 *-----------------------------------------------------------------------------
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
791 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 static void dest_select_cb(GtkTreeSelection *selection, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 GtkTreeView *view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 view = gtk_tree_selection_get_tree_view(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 store = gtk_tree_view_get_model(view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 gtk_tree_model_get(store, &iter, 1, &path, -1);
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 if (view == GTK_TREE_VIEW(dd->d_view))
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 dest_change_dir(dd, path, (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 gtk_entry_set_text(GTK_ENTRY(dd->entry), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 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
820 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 store = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 gtk_tree_model_get(store, &iter, 1, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 if (view == dd->d_view)
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 dest_change_dir(dd, path, (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 else
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 if (dd->select_func)
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 dd->select_func(path, dd->select_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 }
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 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 static void dest_home_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 dest_change_dir(dd, homedir(), (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 static void dest_show_hidden_cb(GtkWidget *widget, gpointer data)
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 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 gchar *buf;
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 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
858
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 buf = g_strdup(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 }
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 static void dest_entry_changed_cb(GtkEditable *editable, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 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
871 if (dd->path && strcmp(path, dd->path) == 0) return;
9
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 buf = remove_level_from_path(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
875 if (buf && (!dd->path || strcmp(buf, dd->path) != 0))
9
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 gchar *tmp = remove_trailing_slash(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 if (isdir(tmp))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 dest_populate(dd, tmp);
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 else if (isdir(buf))
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 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 g_free(tmp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 g_free(buf);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 static void dest_filter_list_sync(Dest_Data *dd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 gchar *old_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 GList *fwork;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 GList *twork;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 if (!dd->filter_list || !dd->filter_combo) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 entry = GTK_BIN(dd->filter_combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 old_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 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
905 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 fwork = dd->filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 twork = dd->filter_text_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 while (fwork && twork)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 gchar *filter;
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 name = twork->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 filter = fwork->data;
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 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 gtk_list_store_set(store, &iter, FILTER_COLUMN_NAME, name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 FILTER_COLUMN_FILTER, filter, -1);
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 if (strcmp(old_text, filter) == 0)
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 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
925 }
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 fwork = fwork->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 twork = twork->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 }
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 g_free(old_text);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 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
935 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 gint c = 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 (!filter) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 work = dd->filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 gchar *f = work->data;
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 if (strcmp(f, filter) == 0)
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 (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
950 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 c++;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 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
957
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 if (description)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 buf = g_strdup_printf("%s ( %s )", description, filter);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 buf = g_strdup_printf("( %s )", filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 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
967
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 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
969 dest_filter_list_sync(dd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 static void dest_filter_clear(Dest_Data *dd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 513
diff changeset
974 string_list_free(dd->filter_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 dd->filter_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 513
diff changeset
977 string_list_free(dd->filter_text_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 dd->filter_text_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 dest_filter_add(dd, "*", _("All Files"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 static void dest_filter_changed_cb(GtkEditable *editable, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 Dest_Data *dd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 const gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 entry = GTK_BIN(dd->filter_combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 buf = gtk_entry_get_text(GTK_ENTRY(entry));
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 g_free(dd->filter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 dd->filter = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 if (strlen(buf) > 0) dd->filter = g_strdup(buf);
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 path = g_strdup(dd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 dest_populate(dd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 g_free(path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 static void dest_bookmark_select_cb(const gchar *path, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 Dest_Data *dd = data;
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 if (isdir(path))
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 dest_change_dir(dd, path, (dd->f_view != NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 else if (isfile(path) && dd->f_view)
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 gtk_entry_set_text(GTK_ENTRY(dd->entry), path);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
1013 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 }
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 * destination widget setup routines (public)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 *-----------------------------------------------------------------------------
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
1020 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 GtkWidget *path_selection_new_with_files(GtkWidget *entry, const gchar *path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 const gchar *filter, const gchar *filter_desc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 GtkWidget *hbox2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 Dest_Data *dd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 GtkWidget *paned;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 dd = g_new0(Dest_Data, 1);
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 table = gtk_table_new(4, (filter != NULL) ? 3 : 1, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 gtk_table_set_col_spacings(GTK_TABLE(table), PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 gtk_table_set_row_spacing(GTK_TABLE(table), 0, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 gtk_widget_show(table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 dd->entry = entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 g_object_set_data(G_OBJECT(dd->entry), "destination_data", dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 hbox2 = pref_table_box(table, 0, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 gtk_box_set_spacing(GTK_BOX(hbox2), PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 pref_button_new(hbox2, NULL, _("Home"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 G_CALLBACK(dest_home_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 pref_button_new(hbox2, NULL, _("New folder"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 G_CALLBACK(dest_new_dir_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 dd->hidden_button = gtk_check_button_new_with_label(_("Show hidden"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 g_signal_connect(G_OBJECT(dd->hidden_button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 G_CALLBACK(dest_show_hidden_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 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
1056 gtk_widget_show(dd->hidden_button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 hbox2 = gtk_hbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 if (filter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 paned = gtk_hpaned_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 gtk_table_attach(GTK_TABLE(table), paned, 0, 3, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 gtk_widget_show(paned);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 gtk_paned_add1(GTK_PANED(paned), hbox2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 paned = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 gtk_widget_show(hbox2);
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 /* bookmarks */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 scrolled = bookmark_list_new(NULL, dest_bookmark_select_cb, dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 gtk_box_pack_start(GTK_BOX(hbox2), scrolled, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 dd->bookmark_list = scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
1084 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 475
diff changeset
1085 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 gtk_box_pack_start(GTK_BOX(hbox2), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 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
1091 g_object_unref(store);
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 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
1094
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dd->d_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 gtk_tree_view_column_set_title(column, _("Folders"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 gtk_tree_view_append_column(GTK_TREE_VIEW(dd->d_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 /* only for debugging */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 gtk_tree_view_column_set_title(column, _("Path"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 gtk_tree_view_column_add_attribute(column, renderer, "text", 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 gtk_tree_view_append_column(GTK_TREE_VIEW(dd->d_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 gtk_widget_set_size_request(dd->d_view, DEST_WIDTH, DEST_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 gtk_container_add(GTK_CONTAINER(scrolled), dd->d_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120 gtk_widget_show(dd->d_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 g_signal_connect(G_OBJECT(dd->d_view), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123 G_CALLBACK(dest_press_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 g_signal_connect(G_OBJECT(dd->d_view), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 G_CALLBACK(dest_keypress_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 g_signal_connect(G_OBJECT(dd->d_view), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 G_CALLBACK(dest_activate_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 g_signal_connect(G_OBJECT(dd->d_view), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 G_CALLBACK(dest_free_data), dd);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
1130
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 if (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 GtkListStore *store;
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 hbox2 = pref_table_box(table, 2, 0, GTK_ORIENTATION_HORIZONTAL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 pref_label_new(hbox2, _("Filter:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 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
1141 FILTER_COLUMN_FILTER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 gtk_cell_layout_clear(GTK_CELL_LAYOUT(dd->filter_combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 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
1146 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dd->filter_combo), renderer,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 "text", FILTER_COLUMN_NAME, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 gtk_combo_set_case_sensitive(GTK_COMBO(dd->filter_combo), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 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
1152 gtk_widget_show(dd->filter_combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
1156 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 475
diff changeset
1157 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 if (paned)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 gtk_paned_add2(GTK_PANED(paned), scrolled);
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 else
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 gtk_table_attach(GTK_TABLE(table), scrolled, 2, 3, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 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
1171 g_object_unref(store);
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 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
1174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dd->f_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 gtk_tree_view_column_set_title(column, _("Files"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 gtk_tree_view_append_column(GTK_TREE_VIEW(dd->f_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 gtk_widget_set_size_request(dd->f_view, DEST_WIDTH, DEST_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 gtk_container_add(GTK_CONTAINER(scrolled), dd->f_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 gtk_widget_show(dd->f_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 g_signal_connect(G_OBJECT(dd->f_view), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 G_CALLBACK(dest_press_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 g_signal_connect(G_OBJECT(dd->f_view), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 G_CALLBACK(dest_keypress_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 g_signal_connect(G_OBJECT(dd->f_view), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 G_CALLBACK(dest_activate_cb), dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 g_signal_connect(selection, "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 G_CALLBACK(dest_select_cb), dd);
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 dest_filter_clear(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 dest_filter_add(dd, filter, filter_desc, TRUE);
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 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
1205 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206
726
a1dcef8cd1ae Use G_DIR_SEPARATOR where applicable.
zas_
parents: 725
diff changeset
1207 if (path && path[0] == G_DIR_SEPARATOR && isdir(path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 dest_populate(dd, path);
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 else
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 gchar *buf = remove_level_from_path(path);
725
eda074e91ddd Use G_DIR_SEPARATOR_S where applicable.
zas_
parents: 719
diff changeset
1214 if (buf && buf[0] == G_DIR_SEPARATOR && isdir(buf))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 gint pos = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 dest_populate(dd, (gchar *)homedir());
725
eda074e91ddd Use G_DIR_SEPARATOR_S where applicable.
zas_
parents: 719
diff changeset
1223 if (path) gtk_editable_insert_text(GTK_EDITABLE(dd->entry), G_DIR_SEPARATOR_S, -1, &pos);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 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
1225 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 }
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 if (dd->filter_combo)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 g_signal_connect(G_OBJECT(GTK_BIN(dd->filter_combo)->child), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 G_CALLBACK(dest_filter_changed_cb), 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 g_signal_connect(G_OBJECT(dd->entry), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 G_CALLBACK(dest_entry_changed_cb), dd);
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 dest_dnd_init(dd);
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 table;
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 GtkWidget *path_selection_new(const gchar *path, 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 return path_selection_new_with_files(entry, path, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 }
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 void path_selection_sync_to_entry(GtkWidget *entry)
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 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 path = gtk_entry_get_text(GTK_ENTRY(entry));
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 373
diff changeset
1255
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1256 if (isdir(path) && (!dd->path || strcmp(path, dd->path) != 0))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 dest_populate(dd, path);
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 else
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 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
1263 if (isdir(buf) && (!dd->path || strcmp(buf, dd->path) != 0))
9
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 dest_populate(dd, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 g_free(buf);
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 }
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 void path_selection_add_select_func(GtkWidget *entry,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 void (*func)(const gchar *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_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 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 dd->select_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 dd->select_data = 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 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
1283 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
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 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 if (!filter) return;
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_filter_add(dd, filter, description, set);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 void path_selection_clear_filter(GtkWidget *entry)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 Dest_Data *dd = g_object_get_data(G_OBJECT(entry), "destination_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 if (!dd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298 dest_filter_clear(dd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1002
diff changeset
1300 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */