annotate src/ui_bookmark.c @ 387:de6060230ec5

fixed compiler warnings
author nadvornik
date Wed, 16 Apr 2008 20:32:44 +0000
parents d5a3bcc6a694
children 2649a28d31b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2 * (SLIK) SimpLIstic sKin functions
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12 #ifdef HAVE_CONFIG_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 # include "config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include <stdio.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include <string.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include <gtk/gtk.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include <gdk/gdkkeysyms.h> /* for key values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 254
diff changeset
25 #include "main.h"
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
26 #include "filelist.h"
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
27
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
28 #include "secure_save.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 * history lists
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 #define HISTORY_DEFAULT_KEY_COUNT 16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 typedef struct _HistoryData HistoryData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 struct _HistoryData
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 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 static GList *history_list = NULL;
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 static gchar *quoted_from_text(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 const gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 gint c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 gint l = strlen(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 if (l == 0) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 while (c < l && text[c] !='"') c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 if (text[c] == '"')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 gint e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 ptr = text + c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 e = c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 while (e < l && text[e] !='"') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 if (text[e] == '"')
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 if (e - c > 0)
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 return g_strndup(ptr, e - c);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 gint history_list_load(const gchar *path)
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 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 gchar *key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 gchar s_buf[1024];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 gchar *pathl;
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 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 f = fopen(pathl, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 if (!f) return FALSE;
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 /* first line must start with History comment */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 if (!fgets(s_buf,1024,f) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 strncmp(s_buf, "#History", 8) != 0)
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 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 while (fgets(s_buf,1024,f))
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 if (s_buf[0]=='#') continue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 if (s_buf[0]=='[')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 gint c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 gchar *ptr;
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 ptr = s_buf + 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 while(ptr[c] != ']' && ptr[c] != '\n' && ptr[c] != '\0') c++;
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 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 key = g_strndup(ptr, c);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 gchar *value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 value = quoted_from_text(s_buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 if (value && key)
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 history_list_add_to_key(key, value, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 g_free(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 g_free(key);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 gint history_list_save(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 {
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
140 SecureSaveInfo *ssi;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 pathl = path_from_utf8(path);
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
145 ssi = secure_open(pathl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 g_free(pathl);
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
147 if (!ssi)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 gchar *buf;
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 buf = g_strdup_printf(_("Unable to write history lists to: %s\n"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 print_term(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
158 secure_fprintf(ssi, "#History lists\n");
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
159 secure_fprintf(ssi, "\n");
9
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 list = g_list_last(history_list);
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
162 while(list && secsave_errno == SS_ERR_NONE)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 hd = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 list = list->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
170 secure_fprintf(ssi, "[%s]\n", hd->key);
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 /* save them inverted (oldest to newest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 * so that when reading they are added correctly
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 work = g_list_last(hd->list);
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
176 while(work && secsave_errno == SS_ERR_NONE)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 {
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
178 secure_fprintf(ssi, "\"%s\"\n", (gchar *)work->data);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 }
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
181 secure_fputc(ssi, '\n');
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
184 secure_fprintf(ssi, "#end\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
186 return (secure_close(ssi) == 0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 static void history_list_free(HistoryData *hd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 while(work)
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 g_free(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 work = work->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 g_free(hd->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 g_free(hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 static HistoryData *history_list_find_by_key(const gchar* key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 GList *work = history_list;
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 if (!key) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 HistoryData *hd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 if (strcmp(hd->key, key) == 0) return hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 }
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 const gchar *history_list_find_last_path_by_key(const gchar* key)
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 HistoryData *hd;
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 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 if (!hd || !hd->list) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 return hd->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 }
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 void history_list_free_key(const gchar *key)
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 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 history_list = g_list_remove(history_list, hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 history_list_free(hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 void history_list_add_to_key(const gchar *key, const gchar *path, gint max)
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 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 GList *work;
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 (!key || !path) return;
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 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 if (!hd)
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 hd = g_new(HistoryData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 hd->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 hd->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 history_list = g_list_prepend(history_list, hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 /* if already in the list, simply move it to the top */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 if (strcmp(buf, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 hd->list = g_list_prepend(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 return;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 hd->list = g_list_prepend(hd->list, 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 if (max == -1) max = HISTORY_DEFAULT_KEY_COUNT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 if (max > 0)
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 while(hd->list && g_list_length(hd->list) > max)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 GList *work = g_list_last(hd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 void history_list_item_change(const gchar *key, const gchar *oldpath, const gchar *newpath)
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 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 if (!oldpath) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 if (!hd) return;
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 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 while(work)
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 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 if (strcmp(buf, oldpath) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 if (newpath)
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 work->data = g_strdup(newpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 hd->list = g_list_remove(hd->list, buf);
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 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 return;
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 work = work->next;
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 void history_list_item_move(const gchar *key, const gchar *path, gint direction)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 gint p = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 if (strcmp(buf, path) == 0)
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 p += direction;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 if (p < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 hd->list = g_list_insert(hd->list, buf, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 }
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 void history_list_item_remove(const gchar *key, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 history_list_item_change(key, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 GList *history_list_get_by_key(const gchar *key)
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 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 if (!hd) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 return hd->list;
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 /*
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 * bookmarks
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 #define BOOKMARK_DATA_KEY "bookmarkdata"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 #define MARKER_PATH "[path]"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 #define MARKER_ICON "[icon]"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 typedef struct _BookMarkData BookMarkData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 typedef struct _BookButtonData BookButtonData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 typedef struct _BookPropData BookPropData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 struct _BookMarkData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 GtkWidget *widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 void (*select_func)(const gchar *path, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 gpointer select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 gint no_defaults;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 gint editable;
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 BookButtonData *active_button;
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 struct _BookButtonData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 GtkWidget *image;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 gchar *parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 struct _BookPropData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 GtkWidget *name_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 GtkWidget *path_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 GtkWidget *icon_entry;
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 BookButtonData *bb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 TARGET_URI_LIST,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 TARGET_X_URL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 TARGET_TEXT_PLAIN
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 static GtkTargetEntry bookmark_drop_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 { "x-url/http", 0, TARGET_X_URL },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 { "_NETSCAPE_URL", 0, TARGET_X_URL }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 #define bookmark_drop_types_n 3
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 static GtkTargetEntry bookmark_drag_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 { "text/plain", 0, TARGET_TEXT_PLAIN }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 #define bookmark_drag_types_n 2
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 static GList *bookmark_widget_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 static GList *bookmark_default_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 static void bookmark_populate_all(const gchar *key);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 static BookButtonData *bookmark_from_string(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 const gchar *path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 const gchar *icon_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 b = g_new0(BookButtonData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 if (!text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 b->name = g_strdup(_("New Bookmark"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 b->path = g_strdup(homedir());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 b->key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 return b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 b->key = g_strdup(text);
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 path_ptr = strstr(text, MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 icon_ptr = strstr(text, MARKER_ICON);
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 if (path_ptr && icon_ptr && icon_ptr < path_ptr)
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 printf("warning, bookmark icon must be after path\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 if (path_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 l = path_ptr - text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 b->name = g_strndup(text, l);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 path_ptr += strlen(MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 if (icon_ptr)
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 l = icon_ptr - path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 b->path = g_strndup(path_ptr, l);
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 else
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 b->path = g_strdup(path_ptr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 else
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 b->name = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 b->path = g_strdup("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 if (icon_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 icon_ptr += strlen(MARKER_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 b->icon = g_strdup(icon_ptr);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 return b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 static void bookmark_free(BookButtonData *b)
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 if (!b) return;
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 g_free(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 g_free(b->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 g_free(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 g_free(b->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 g_free(b->parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 g_free(b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 static gchar *bookmark_string(const gchar *name, const gchar *path, const gchar *icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 if (!name) name = _("New Bookmark");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 if (icon && strncmp(icon, "/", 1) != 0) icon = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 if (icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 return g_strdup_printf("%s"MARKER_PATH"%s"MARKER_ICON"%s", name, path, icon);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 return g_strdup_printf("%s"MARKER_PATH"%s", name, path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 static void bookmark_select_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 BookButtonData *b;
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 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 if (bm->select_func) bm->select_func(b->path, bm->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 static void bookmark_edit_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 BookPropData *p = data;
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 bookmark_free(p->bb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 g_free(p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 static void bookmark_edit_cancel_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 static void bookmark_edit_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 BookPropData *p = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 const gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 gchar *new;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 name = gtk_entry_get_text(GTK_ENTRY(p->name_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 path = remove_trailing_slash(gtk_entry_get_text(GTK_ENTRY(p->path_entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 icon = gtk_entry_get_text(GTK_ENTRY(p->icon_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 new = bookmark_string(name, path, icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 if (p->bb->key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 history_list_item_change(p->bb->parent, p->bb->key, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 history_list_add_to_key(p->bb->parent, new, 0);
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 if (path && strlen(path) > 0) tab_completion_append_to_history(p->path_entry, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 if (icon && strlen(icon) > 0) tab_completion_append_to_history(p->icon_entry, icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 g_free(new);
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 bookmark_populate_all(p->bb->parent);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 /* simply pass NULL for text to turn this into a 'new bookmark' dialog */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 static void bookmark_edit(const gchar *key, const gchar *text, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 BookPropData *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 const gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 if (!key) key = "bookmarks";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 p = g_new0(BookPropData, 1);
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 p->bb = bookmark_from_string(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 p->bb->parent = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 138
diff changeset
592 gd = generic_dialog_new(_("Edit Bookmark"), GQ_WMCLASS, "bookmark_edit",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 parent, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 bookmark_edit_cancel_cb, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 g_signal_connect(G_OBJECT(gd->dialog), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 G_CALLBACK(bookmark_edit_destroy_cb), p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 generic_dialog_add_message(gd, NULL, _("Edit Bookmark"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 bookmark_edit_ok_cb, TRUE);
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 table = pref_table_new(gd->vbox, 3, 2, FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 pref_table_label(table, 0, 0, _("Name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 p->name_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 gtk_widget_set_size_request(p->name_entry, 300, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 if (p->bb->name) gtk_entry_set_text(GTK_ENTRY(p->name_entry), p->bb->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 gtk_table_attach_defaults(GTK_TABLE(table), p->name_entry, 1, 2, 0, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 generic_dialog_attach_default(gd, p->name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 gtk_widget_show(p->name_entry);
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 pref_table_label(table, 0, 1, _("Path:"), 1.0);
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 label = tab_completion_new_with_history(&p->path_entry, p->bb->path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 "bookmark_path", -1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 tab_completion_add_select_button(p->path_entry, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 generic_dialog_attach_default(gd, p->path_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 pref_table_label(table, 0, 2, _("Icon:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 icon = p->bb->icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 if (!icon) icon = "";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 label = tab_completion_new_with_history(&p->icon_entry, icon,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 "bookmark_icons", -1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 tab_completion_add_select_button(p->icon_entry, _("Select icon"), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 generic_dialog_attach_default(gd, p->icon_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 static void bookmark_move(BookMarkData *bm, GtkWidget *button, gint direction)
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 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 gint p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 gchar *key_holder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 if (!bm->editable) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 if (!b) return;
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 list = gtk_container_get_children(GTK_CONTAINER(bm->box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 p = g_list_index(list, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 if (p < 0 || p + direction < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 key_holder = bm->key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 bm->key = "_TEMPHOLDER";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 history_list_item_move(key_holder, b->key, -direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 bookmark_populate_all(key_holder);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 bm->key = key_holder;
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 gtk_box_reorder_child(GTK_BOX(bm->box), button, p + direction);
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 void bookmark_menu_prop_cb(GtkWidget *widget, 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 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 bookmark_edit(bm->key, bm->active_button->key, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 static void bookmark_menu_move(BookMarkData *bm, gint direction)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 bookmark_move(bm, bm->active_button->button, direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 static void bookmark_menu_up_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 bookmark_menu_move(data, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 static void bookmark_menu_down_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 bookmark_menu_move(data, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 static void bookmark_menu_remove_cb(GtkWidget *widget, gpointer data)
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 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 history_list_item_remove(bm->key, bm->active_button->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 bookmark_populate_all(bm->key);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 static void bookmark_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gint *pushed_in, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 GtkWidget *button = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 gdk_window_get_origin(button->window, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 *y += button->allocation.y + button->allocation.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 static void bookmark_menu_popup(BookMarkData *bm, GtkWidget *button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 gint button_n, guint32 time, gint local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 bm->active_button = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 menu_item_add_stock_sensitive(menu, _("_Properties..."), GTK_STOCK_PROPERTIES, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 G_CALLBACK(bookmark_menu_prop_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 menu_item_add_stock_sensitive(menu, _("Move _up"), GTK_STOCK_GO_UP, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 G_CALLBACK(bookmark_menu_up_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 menu_item_add_stock_sensitive(menu, _("Move _down"), GTK_STOCK_GO_DOWN, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 G_CALLBACK(bookmark_menu_down_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 menu_item_add_stock_sensitive(menu, _("_Remove"), GTK_STOCK_REMOVE, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 G_CALLBACK(bookmark_menu_remove_cb), bm);
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 if (local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 bookmark_menu_position_cb, button, button_n, time);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button_n, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 }
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 static gint bookmark_press_cb(GtkWidget *button, GdkEventButton *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 if (event->button != 3) return FALSE;
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 bookmark_menu_popup(bm, button, event->button, event->time, FALSE);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 static gint bookmark_keypress_cb(GtkWidget *button, GdkEventKey *event, gpointer data)
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 BookMarkData *bm = data;
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 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 case GDK_F10:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 if (!(event->state & GDK_CONTROL_MASK)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 bookmark_menu_popup(bm, button, 0, event->time, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 case GDK_Up:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 bookmark_move(bm, button, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 case GDK_Down:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 bookmark_move(bm, button, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 static void bookmark_drag_set_data(GtkWidget *button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 GdkDragContext *context, GtkSelectionData *selection_data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 guint info, guint time, gpointer data)
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 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 if (context->dest_window == bm->widget->window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 list = g_list_append(list, b->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 switch (info)
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 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 uri_text = uri_text_from_list(list, &length, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 uri_text = uri_text_from_list(list, &length, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 g_list_free(list);
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 if (!uri_text) return;
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_selection_data_set(selection_data, selection_data->target,
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
813 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 GdkModifierType mask;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 button->allocation.width, button->allocation.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 gdk_pixbuf_get_from_drawable(pixbuf, button->window, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 button->allocation.x, button->allocation.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 0, 0, button->allocation.width, button->allocation.height);
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 gdk_window_get_pointer(button->window, &x, &y, &mask);
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 gtk_drag_set_icon_pixbuf(context, pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 x - button->allocation.x, y - button->allocation.y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 static void bookmark_populate(BookMarkData *bm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 GtkBox *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 GList *children;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 box = GTK_BOX(bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 children = gtk_container_get_children(GTK_CONTAINER(box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 work = children;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 GtkWidget *widget = GTK_WIDGET(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 gtk_widget_destroy(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 if (!bm->no_defaults && !history_list_get_by_key(bm->key))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 if (!bookmark_default_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 buf = bookmark_string(_("Home"), homedir(), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 path = concat_dir_and_file(homedir(), "Desktop");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 if (isname(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 buf = bookmark_string(_("Desktop"), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 g_free(path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 work = bookmark_default_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 while (work && work->next)
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 *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 work = work->next;
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 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 g_free(buf);
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 }
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 work = history_list_get_by_key(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 work = g_list_last(work);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 b = bookmark_from_string(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 if (b)
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 GtkWidget *box;
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 b->button = gtk_button_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 gtk_button_set_relief(GTK_BUTTON(b->button), GTK_RELIEF_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 gtk_box_pack_start(GTK_BOX(bm->box), b->button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 gtk_widget_show(b->button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 g_object_set_data_full(G_OBJECT(b->button), "bookbuttondata",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 b, (GDestroyNotify)bookmark_free);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 box = gtk_hbox_new(FALSE, PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 gtk_container_add(GTK_CONTAINER(b->button), box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 if (b->icon)
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 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 gchar *iconl;
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 iconl = path_from_utf8(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918 pixbuf = gdk_pixbuf_new_from_file(iconl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 g_free(iconl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 GdkPixbuf *scaled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 gint w, h;
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 w = h = 16;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 scaled = gdk_pixbuf_scale_simple(pixbuf, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 GDK_INTERP_BILINEAR);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 b->image = gtk_image_new_from_pixbuf(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 g_object_unref(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 b->image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 GTK_ICON_SIZE_BUTTON);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 b->image = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
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 gtk_box_pack_start(GTK_BOX(box), b->image, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 gtk_widget_show(b->image);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 b->label = gtk_label_new(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 gtk_box_pack_start(GTK_BOX(box), b->label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 gtk_widget_show(b->label);
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 g_signal_connect(G_OBJECT(b->button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 G_CALLBACK(bookmark_select_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 g_signal_connect(G_OBJECT(b->button), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 G_CALLBACK(bookmark_press_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 g_signal_connect(G_OBJECT(b->button), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 G_CALLBACK(bookmark_keypress_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 gtk_drag_source_set(b->button, GDK_BUTTON1_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 bookmark_drag_types, bookmark_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 g_signal_connect(G_OBJECT(b->button), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 G_CALLBACK(bookmark_drag_set_data), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 g_signal_connect(G_OBJECT(b->button), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 G_CALLBACK(bookmark_drag_begin), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 }
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 bookmark_populate_all(const gchar *key)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 if (!key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 work = bookmark_widget_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 BookMarkData *bm;
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 bm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 if (strcmp(bm->key, key) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 bookmark_populate(bm);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 }
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 static void bookmark_dnd_get_data(GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 GdkDragContext *context, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 GList *work;
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 if (!bm->editable) return;
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 switch (info)
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 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 case TARGET_X_URL:
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1007 list = uri_list_from_text((gchar *)selection_data->data, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 while (work)
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 gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 gchar *buf;
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 buf = bookmark_string(filename_from_path(path), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 g_free(buf);
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1024 string_list_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 static void bookmark_list_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 bookmark_widget_list = g_list_remove(bookmark_widget_list, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 g_free(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 GtkWidget *bookmark_list_new(const gchar *key,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 void (*select_func)(const gchar *path, gpointer data), gpointer select_data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 BookMarkData *bm;
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 if (!key) key = "bookmarks";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 bm = g_new0(BookMarkData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 bm->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 bm->select_func = select_func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 bm->select_data = select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 bm->no_defaults = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 bm->editable = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 bm->box = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 gtk_widget_show(bm->box);
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 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 g_signal_connect(G_OBJECT(bm->box), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 G_CALLBACK(bookmark_list_destroy), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 g_object_set_data(G_OBJECT(bm->box), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 g_object_set_data(G_OBJECT(scrolled), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 bm->widget = scrolled;
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 gtk_drag_dest_set(scrolled,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 bookmark_drop_types, bookmark_drop_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 g_signal_connect(G_OBJECT(scrolled), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 G_CALLBACK(bookmark_dnd_get_data), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 bookmark_widget_list = g_list_append(bookmark_widget_list, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 return 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 void bookmark_list_set_key(GtkWidget *list, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 if (!list || !key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 if (bm->key && strcmp(bm->key, key) == 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 bm->key = g_strdup(key);
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 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 }
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 void bookmark_list_set_no_defaults(GtkWidget *list, gint no_defaults)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 BookMarkData *bm;
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 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 bm->no_defaults = no_defaults;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 }
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 void bookmark_list_set_editable(GtkWidget *list, gint editable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 bm->editable = editable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 }
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 void bookmark_list_add(GtkWidget *list, const gchar *name, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 void bookmark_add_default(const gchar *name, const gchar *path)
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 if (!name || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 }
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 * combo with history key
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 typedef struct _HistoryComboData HistoryComboData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 struct _HistoryComboData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 gchar *history_key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 gint history_levels;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 static void history_combo_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 HistoryComboData *hc = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 g_free(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 g_free(data);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 /* if text is NULL, entry is set to the most recent item */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 GtkWidget *history_combo_new(GtkWidget **entry, const gchar *text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 const gchar *history_key, gint max_levels)
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 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 hc = g_new0(HistoryComboData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 hc->history_key = g_strdup(history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 hc->history_levels = max_levels;
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 hc->combo = gtk_combo_box_entry_new_text();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 gtk_combo_set_case_sensitive(GTK_COMBO(hc->combo), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 gtk_combo_set_use_arrows(GTK_COMBO(hc->combo), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 hc->entry = GTK_BIN(hc->combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 g_object_set_data(G_OBJECT(hc->combo), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 g_object_set_data(G_OBJECT(hc->entry), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 g_signal_connect(G_OBJECT(hc->combo), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 G_CALLBACK(history_combo_destroy), hc);
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 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 gtk_combo_box_append_text(GTK_COMBO_BOX(hc->combo), (gchar *)work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 gtk_entry_set_text(GTK_ENTRY(hc->entry), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203 else if (n > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), 0);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 if (entry) *entry = hc->entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 return hc->combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 /* if text is NULL, current entry text is used
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 * widget can be the combo or entry widget
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 void history_combo_append_history(GtkWidget *widget, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 gchar *new_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 hc = g_object_get_data(G_OBJECT(widget), "history_combo_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 if (!hc)
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 printf("widget is not a history combo\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 if (text)
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 new_text = g_strdup(text);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 new_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(hc->entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 if (new_text && strlen(new_text) > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 history_list_add_to_key(hc->history_key, new_text, hc->history_levels);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), -1);
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 store = gtk_combo_box_get_model(GTK_COMBO_BOX(hc->combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246 gtk_list_store_clear(GTK_LIST_STORE(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 gtk_combo_box_append_text(GTK_COMBO_BOX(hc->combo), (gchar *)work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 g_free(new_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 * drag and drop uri utils
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 */
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 /* the following characters are allowed to be unencoded for pathnames:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 * $ & + , / : = @
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 static gint escape_char_list[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 10 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 /* spc ! " # $ % & ' */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, /* 30 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 /* ( ) * + , - . / 0 1 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276 /* 2 3 4 5 6 7 8 9 : ; */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 50 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 /* < = > ? @ A B C D E */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, /* 60 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 /* Z [ \ ] ^ _ ` a b c */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, /* 90 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 100 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 110 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286 /* x y z { | } ~ del */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 0, 0, 0, 1, 1, 1, 0, 0 /* 120, 127 is end */
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 static gchar *hex_char = "0123456789ABCDEF";
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 static gint escape_test(guchar c)
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 if (c < 32 || c > 127) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 return (escape_char_list[c] != 0);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298 static const gchar *escape_code(guchar c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300 static gchar text[4];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1301
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302 text[0] = '%';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303 text[1] = hex_char[c>>4];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 text[2] = hex_char[c%16];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305 text[3] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307 return text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1309
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310 gchar *uri_text_escape(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 GString *string;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 gchar *result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 if (!text) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318 string = g_string_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 p = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 while (*p != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323 if (escape_test(*p))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1324 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1325 g_string_append(string, escape_code(*p));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1328 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1329 g_string_append_c(string, *p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1333
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 result = string->str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 g_string_free(string, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 /* dropped filenames are expected to be utf-8 compatible */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 if (!g_utf8_validate(result, -1, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 gchar *tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1341
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1342 tmp = g_locale_to_utf8(result, -1, NULL, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343 if (tmp)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 g_free(result);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 result = tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350 return result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353 /* this operates on the passed string, decoding escaped characters */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 void uri_text_decode(gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 if (strchr(text, '%'))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358 gchar *w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 gchar *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361 w = r = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 while(*r != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365 if (*r == '%' && *(r + 1) != '\0' && *(r + 2) != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367 gchar t[3];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371 t[0] = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1372 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 t[1] = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 t[2] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 n = (gint)strtol(t, NULL, 16);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376 if (n > 0 && n < 256)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378 *w = (gchar)n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382 /* invalid number, rewind and ignore this escape */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383 r -= 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 *w = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 else if (w != r)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1388 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389 *w = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1390 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 w++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 if (*w != '\0') *w = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398 static void uri_list_parse_encoded_chars(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1399 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1400 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 gchar *text = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406 uri_text_decode(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412 GList *uri_list_from_text(gchar *data, gint files_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1414 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1415 gint b, e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417 b = e = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1419 while (data[b] != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1420 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421 while (data[e] != '\r' && data[e] != '\n' && data[e] != '\0') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422 if (strncmp(data + b, "file:", 5) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425 b += 5;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426 while (data[b] == '/' && data[b+1] == '/') b++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427 path = g_strndup(data + b, e - b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 list = g_list_append(list, path_to_utf8(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1430 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1431 else if (!files_only && strncmp(data + b, "http:", 5) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433 list = g_list_append(list, g_strndup(data + b, e - b));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435 else if (!files_only && strncmp(data + b, "ftp:", 3) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 list = g_list_append(list, g_strndup(data + b, e - b));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1438 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439 while (data[e] == '\r' || data[e] == '\n') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 b = e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 uri_list_parse_encoded_chars(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1448 GList *uri_filelist_from_text(gchar *data, gint files_only)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1449 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1450 GList *path_list = uri_list_from_text(data, files_only);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1451 GList *filelist = filelist_from_path_list(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1452 string_list_free(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1453 return filelist;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1454 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1455
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1456 gchar *uri_text_from_list(GList *list, gint *len, gint plain_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1457 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1458 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 GString *string;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1460 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1461
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1462 if (!list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1463 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1464 if (len) *len = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468 string = g_string_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 const gchar *name8; /* dnd filenames are in utf-8 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475 name8 = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 if (!plain_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479 gchar *escaped;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481 escaped = uri_text_escape(name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482 g_string_append(string, "file:");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483 g_string_append(string, escaped);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484 g_free(escaped);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 g_string_append(string, "\r\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490 g_string_append(string, name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 if (work->next) g_string_append(string, "\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1495 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 uri_text = string->str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498 if (len) *len = string->len;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 g_string_free(string, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 return uri_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1502 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1503
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1504 gchar *uri_text_from_filelist(GList *list, gint *len, gint plain_text)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1505 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1506 GList *path_list = filelist_to_path_list(list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1507 gchar *ret = uri_text_from_list(path_list, len, plain_text);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1508 string_list_free(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1509 return ret;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1510 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1511