annotate src/ui_pathsel.c @ 546:f852eb277913

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