annotate src/ui_bookmark.c @ 151:344d4ab0e20a

improved drawing of frame around selected image
author nadvornik
date Sun, 09 Dec 2007 00:11:40 +0000
parents 71e1ebee420e
children 9faf34f047b1
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
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
25 #include "gqview.h"
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
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #include "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 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 FILE *f;
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);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 f = fopen(pathl, "w");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 if (!f)
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 fprintf(f, "#History lists\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 fprintf(f, "\n");
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);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 while(list)
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 fprintf(f, "[%s]\n", hd->key);
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);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 fprintf(f, "\"%s\"\n", (gchar *)work->data);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 fprintf(f, "\n");
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 fprintf(f, "#end\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 fclose(f);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 static void history_list_free(HistoryData *hd)
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 GList *work;
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 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 g_free(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 g_free(hd->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 g_free(hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 static HistoryData *history_list_find_by_key(const gchar* key)
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 GList *work = history_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 if (!key) return NULL;
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 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 HistoryData *hd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 if (strcmp(hd->key, key) == 0) return hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 work = work->next;
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 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 }
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 const gchar *history_list_find_last_path_by_key(const gchar* key)
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 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 if (!hd || !hd->list) return NULL;
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 return hd->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 void history_list_free_key(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 history_list = g_list_remove(history_list, hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 history_list_free(hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 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
244 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 if (!key || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 if (!hd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 hd = g_new(HistoryData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 hd->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 hd->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 history_list = g_list_prepend(history_list, hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 /* if already in the list, simply move it to the top */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 if (strcmp(buf, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 hd->list = g_list_prepend(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 hd->list = g_list_prepend(hd->list, g_strdup(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 if (max == -1) max = HISTORY_DEFAULT_KEY_COUNT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 if (max > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 while(hd->list && g_list_length(hd->list) > max)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 GList *work = g_list_last(hd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 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
289 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 if (!oldpath) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 if (strcmp(buf, oldpath) == 0)
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 if (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 work->data = g_strdup(newpath);
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 else
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 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 return;
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 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
319 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 gint p = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 if (strcmp(buf, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 p += direction;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 if (p < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 hd->list = g_list_insert(hd->list, buf, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 p++;
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 }
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 void history_list_item_remove(const gchar *key, const gchar *path)
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 history_list_item_change(key, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 GList *history_list_get_by_key(const gchar *key)
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 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 if (!hd) return NULL;
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 return hd->list;
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 /*
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 * bookmarks
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 #define BOOKMARK_DATA_KEY "bookmarkdata"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 #define MARKER_PATH "[path]"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 #define MARKER_ICON "[icon]"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 typedef struct _BookMarkData BookMarkData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 typedef struct _BookButtonData BookButtonData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 typedef struct _BookPropData BookPropData;
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 struct _BookMarkData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 GtkWidget *widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 void (*select_func)(const gchar *path, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 gpointer select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 gint no_defaults;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 gint editable;
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 BookButtonData *active_button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 struct _BookButtonData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 GtkWidget *image;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 gchar *parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 struct _BookPropData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 GtkWidget *name_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 GtkWidget *path_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 GtkWidget *icon_entry;
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 BookButtonData *bb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 TARGET_URI_LIST,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 TARGET_X_URL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 TARGET_TEXT_PLAIN
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 static GtkTargetEntry bookmark_drop_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 { "x-url/http", 0, TARGET_X_URL },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 { "_NETSCAPE_URL", 0, TARGET_X_URL }
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 #define bookmark_drop_types_n 3
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 static GtkTargetEntry bookmark_drag_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 { "text/plain", 0, TARGET_TEXT_PLAIN }
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 #define bookmark_drag_types_n 2
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 static GList *bookmark_widget_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 static GList *bookmark_default_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 static void bookmark_populate_all(const gchar *key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 static BookButtonData *bookmark_from_string(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 const gchar *path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 const gchar *icon_ptr;
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 b = g_new0(BookButtonData, 1);
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 if (!text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 b->name = g_strdup(_("New Bookmark"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 b->path = g_strdup(homedir());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 b->key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 return b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 b->key = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 path_ptr = strstr(text, MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 icon_ptr = strstr(text, MARKER_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 if (path_ptr && icon_ptr && icon_ptr < path_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 printf("warning, bookmark icon must be after path\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 if (path_ptr)
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 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 l = path_ptr - text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 b->name = g_strndup(text, l);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 path_ptr += strlen(MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 if (icon_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 l = icon_ptr - path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 b->path = g_strndup(path_ptr, l);
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 else
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 b->path = g_strdup(path_ptr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 b->name = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 b->path = g_strdup("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 if (icon_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 icon_ptr += strlen(MARKER_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 b->icon = g_strdup(icon_ptr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 return b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 static void bookmark_free(BookButtonData *b)
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 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 g_free(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 g_free(b->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 g_free(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 g_free(b->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 g_free(b->parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 g_free(b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 static gchar *bookmark_string(const gchar *name, const gchar *path, const gchar *icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 if (!name) name = _("New Bookmark");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 if (icon && strncmp(icon, "/", 1) != 0) icon = NULL;
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 if (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 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
517 }
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 return g_strdup_printf("%s"MARKER_PATH"%s", name, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 static void bookmark_select_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 if (bm->select_func) bm->select_func(b->path, bm->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 static void bookmark_edit_destroy_cb(GtkWidget *widget, gpointer 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 BookPropData *p = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 bookmark_free(p->bb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 g_free(p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 static void bookmark_edit_cancel_cb(GenericDialog *gd, gpointer data)
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 }
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 static void bookmark_edit_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 BookPropData *p = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 const gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 gchar *new;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 name = gtk_entry_get_text(GTK_ENTRY(p->name_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 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
555 icon = gtk_entry_get_text(GTK_ENTRY(p->icon_entry));
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 new = bookmark_string(name, path, icon);
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 if (p->bb->key)
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 history_list_item_change(p->bb->parent, p->bb->key, new);
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 else
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 history_list_add_to_key(p->bb->parent, new, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 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
569 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
570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 g_free(new);
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 bookmark_populate_all(p->bb->parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 /* 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
578
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 static void bookmark_edit(const gchar *key, const gchar *text, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 BookPropData *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 const gchar *icon;
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 if (!key) key = "bookmarks";
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 = g_new0(BookPropData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 p->bb = bookmark_from_string(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 p->bb->parent = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 gd = generic_dialog_new(_("Edit Bookmark"), PACKAGE, "bookmark_edit",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 parent, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 bookmark_edit_cancel_cb, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 g_signal_connect(G_OBJECT(gd->dialog), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 G_CALLBACK(bookmark_edit_destroy_cb), p);
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_message(gd, NULL, _("Edit Bookmark"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 bookmark_edit_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 table = pref_table_new(gd->vbox, 3, 2, FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 pref_table_label(table, 0, 0, _("Name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 p->name_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 gtk_widget_set_size_request(p->name_entry, 300, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 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
611 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
612 generic_dialog_attach_default(gd, p->name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 gtk_widget_show(p->name_entry);
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 pref_table_label(table, 0, 1, _("Path:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 label = tab_completion_new_with_history(&p->path_entry, p->bb->path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 "bookmark_path", -1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 tab_completion_add_select_button(p->path_entry, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 generic_dialog_attach_default(gd, p->path_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 gtk_widget_show(label);
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 pref_table_label(table, 0, 2, _("Icon:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 icon = p->bb->icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 if (!icon) icon = "";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 label = tab_completion_new_with_history(&p->icon_entry, icon,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 "bookmark_icons", -1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 tab_completion_add_select_button(p->icon_entry, _("Select icon"), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 generic_dialog_attach_default(gd, p->icon_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 gtk_widget_show(label);
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 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 }
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 static void bookmark_move(BookMarkData *bm, GtkWidget *button, gint direction)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 gint p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 gchar *key_holder;
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 if (!bm->editable) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 list = gtk_container_get_children(GTK_CONTAINER(bm->box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 p = g_list_index(list, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 g_list_free(list);
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 if (p < 0 || p + direction < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 key_holder = bm->key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 bm->key = "_TEMPHOLDER";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 history_list_item_move(key_holder, b->key, -direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 bookmark_populate_all(key_holder);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 bm->key = key_holder;
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 gtk_box_reorder_child(GTK_BOX(bm->box), button, p + direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 static void bookmark_menu_prop_cb(GtkWidget *widget, gpointer 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 BookMarkData *bm = data;
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 if (!bm->active_button) return;
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 bookmark_edit(bm->key, bm->active_button->key, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 static void bookmark_menu_move(BookMarkData *bm, gint direction)
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 if (!bm->active_button) return;
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 bookmark_move(bm, bm->active_button->button, direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 static void bookmark_menu_up_cb(GtkWidget *widget, gpointer data)
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 bookmark_menu_move(data, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 static void bookmark_menu_down_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 bookmark_menu_move(data, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 static void bookmark_menu_remove_cb(GtkWidget *widget, gpointer 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 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 history_list_item_remove(bm->key, bm->active_button->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 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
702 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 GtkWidget *button = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 gdk_window_get_origin(button->window, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 *y += button->allocation.y + button->allocation.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 static void bookmark_menu_popup(BookMarkData *bm, GtkWidget *button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 gint button_n, guint32 time, gint local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 if (!b) return;
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 bm->active_button = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 menu_item_add_stock_sensitive(menu, _("_Properties..."), GTK_STOCK_PROPERTIES, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 G_CALLBACK(bookmark_menu_prop_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 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
724 G_CALLBACK(bookmark_menu_up_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 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
726 G_CALLBACK(bookmark_menu_down_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 menu_item_add_stock_sensitive(menu, _("_Remove"), GTK_STOCK_REMOVE, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 G_CALLBACK(bookmark_menu_remove_cb), bm);
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 if (local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 bookmark_menu_position_cb, button, button_n, time);
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 else
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 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
738 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 static gint bookmark_press_cb(GtkWidget *button, GdkEventButton *event, gpointer 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 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 if (event->button != 3) return 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 bookmark_menu_popup(bm, button, event->button, event->time, FALSE);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 static gint bookmark_keypress_cb(GtkWidget *button, GdkEventKey *event, gpointer 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 BookMarkData *bm = data;
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 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 case GDK_F10:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 if (!(event->state & GDK_CONTROL_MASK)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 bookmark_menu_popup(bm, button, 0, event->time, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 case GDK_Up:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 bookmark_move(bm, button, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 case GDK_Down:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 bookmark_move(bm, button, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 return TRUE;
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 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 static void bookmark_drag_set_data(GtkWidget *button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 GdkDragContext *context, GtkSelectionData *selection_data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 guint info, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 if (context->dest_window == bm->widget->window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 if (!b) return;
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 list = g_list_append(list, b->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 uri_text = uri_text_from_list(list, &length, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 uri_text = uri_text_from_list(list, &length, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 g_list_free(list);
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 if (!uri_text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 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
815 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 GdkModifierType mask;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 button->allocation.width, button->allocation.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 gdk_pixbuf_get_from_drawable(pixbuf, button->window, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 button->allocation.x, button->allocation.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 0, 0, button->allocation.width, button->allocation.height);
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 gdk_window_get_pointer(button->window, &x, &y, &mask);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 gtk_drag_set_icon_pixbuf(context, pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 x - button->allocation.x, y - button->allocation.y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 static void bookmark_populate(BookMarkData *bm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 GtkBox *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 GList *children;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 box = GTK_BOX(bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 children = gtk_container_get_children(GTK_CONTAINER(box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 work = children;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 GtkWidget *widget = GTK_WIDGET(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 gtk_widget_destroy(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 if (!bm->no_defaults && !history_list_get_by_key(bm->key))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 gchar *path;
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 if (!bookmark_default_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 buf = bookmark_string(_("Home"), homedir(), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 path = concat_dir_and_file(homedir(), "Desktop");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 if (isname(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 buf = bookmark_string(_("Desktop"), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 g_free(buf);
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 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 work = bookmark_default_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 while (work && work->next)
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 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 name = 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 path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 work = history_list_get_by_key(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 work = g_list_last(work);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 while (work)
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 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 b = bookmark_from_string(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 if (b)
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 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 b->button = gtk_button_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 gtk_button_set_relief(GTK_BUTTON(b->button), GTK_RELIEF_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 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
905 gtk_widget_show(b->button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 g_object_set_data_full(G_OBJECT(b->button), "bookbuttondata",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 b, (GDestroyNotify)bookmark_free);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 box = gtk_hbox_new(FALSE, PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 gtk_container_add(GTK_CONTAINER(b->button), box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 if (b->icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 gchar *iconl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 iconl = path_from_utf8(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 pixbuf = gdk_pixbuf_new_from_file(iconl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 g_free(iconl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 GdkPixbuf *scaled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 w = h = 16;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 scaled = gdk_pixbuf_scale_simple(pixbuf, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 GDK_INTERP_BILINEAR);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 b->image = gtk_image_new_from_pixbuf(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 g_object_unref(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 g_object_unref(pixbuf);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 b->image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 GTK_ICON_SIZE_BUTTON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 else
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 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
945 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 gtk_box_pack_start(GTK_BOX(box), b->image, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 gtk_widget_show(b->image);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 b->label = gtk_label_new(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 gtk_box_pack_start(GTK_BOX(box), b->label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 gtk_widget_show(b->label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 g_signal_connect(G_OBJECT(b->button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 G_CALLBACK(bookmark_select_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 g_signal_connect(G_OBJECT(b->button), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 G_CALLBACK(bookmark_press_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 g_signal_connect(G_OBJECT(b->button), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 G_CALLBACK(bookmark_keypress_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 gtk_drag_source_set(b->button, GDK_BUTTON1_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 bookmark_drag_types, bookmark_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 g_signal_connect(G_OBJECT(b->button), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 G_CALLBACK(bookmark_drag_set_data), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 g_signal_connect(G_OBJECT(b->button), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 G_CALLBACK(bookmark_drag_begin), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 static void bookmark_populate_all(const gchar *key)
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 GList *work;
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 if (!key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 work = bookmark_widget_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 while (work)
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 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 bm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 work = work->next;
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 if (strcmp(bm->key, key) == 0)
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 bookmark_populate(bm);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 static void bookmark_dnd_get_data(GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 GdkDragContext *context, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 GList *work;
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 if (!bm->editable) return;
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 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 case TARGET_X_URL:
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1009 list = uri_list_from_text((gchar *)selection_data->data, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 buf = bookmark_string(filename_from_path(path), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 g_free(buf);
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1026 string_list_free(list);
9
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 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 }
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 static void bookmark_list_destroy(GtkWidget *widget, gpointer 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 BookMarkData *bm = data;
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 bookmark_widget_list = g_list_remove(bookmark_widget_list, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 g_free(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 GtkWidget *bookmark_list_new(const gchar *key,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 void (*select_func)(const gchar *path, gpointer data), gpointer select_data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 BookMarkData *bm;
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 if (!key) key = "bookmarks";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 bm = g_new0(BookMarkData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 bm->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 bm->select_func = select_func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 bm->select_data = select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 bm->no_defaults = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 bm->editable = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 bm->box = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 gtk_widget_show(bm->box);
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 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 g_signal_connect(G_OBJECT(bm->box), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 G_CALLBACK(bookmark_list_destroy), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 g_object_set_data(G_OBJECT(bm->box), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 g_object_set_data(G_OBJECT(scrolled), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 bm->widget = scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 gtk_drag_dest_set(scrolled,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 bookmark_drop_types, bookmark_drop_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 g_signal_connect(G_OBJECT(scrolled), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 G_CALLBACK(bookmark_dnd_get_data), 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 bookmark_widget_list = g_list_append(bookmark_widget_list, bm);
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 return scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 void bookmark_list_set_key(GtkWidget *list, const gchar *key)
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 BookMarkData *bm;
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 if (!list || !key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 if (!bm) 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 if (bm->key && strcmp(bm->key, key) == 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 bm->key = g_strdup(key);
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 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 void bookmark_list_set_no_defaults(GtkWidget *list, gint no_defaults)
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 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 if (!bm) return;
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 bm->no_defaults = no_defaults;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 }
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 void bookmark_list_set_editable(GtkWidget *list, gint editable)
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 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 if (!bm) return;
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 bm->editable = editable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123 void bookmark_list_add(GtkWidget *list, const gchar *name, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 g_free(buf);
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 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 }
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 void bookmark_add_default(const gchar *name, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 if (!name || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(path));
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 /*
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 * combo with history key
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 typedef struct _HistoryComboData HistoryComboData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 struct _HistoryComboData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 gchar *history_key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 gint history_levels;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 static void history_combo_destroy(GtkWidget *widget, gpointer 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 HistoryComboData *hc = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 g_free(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 g_free(data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 /* if text is NULL, entry is set to the most recent item */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 GtkWidget *history_combo_new(GtkWidget **entry, const gchar *text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 const gchar *history_key, gint max_levels)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 hc = g_new0(HistoryComboData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 hc->history_key = g_strdup(history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 hc->history_levels = max_levels;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 hc->combo = gtk_combo_box_entry_new_text();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 gtk_combo_set_case_sensitive(GTK_COMBO(hc->combo), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 gtk_combo_set_use_arrows(GTK_COMBO(hc->combo), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 #endif
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 hc->entry = GTK_BIN(hc->combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 g_object_set_data(G_OBJECT(hc->combo), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 g_object_set_data(G_OBJECT(hc->entry), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 g_signal_connect(G_OBJECT(hc->combo), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 G_CALLBACK(history_combo_destroy), hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 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
1197 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 if (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 gtk_entry_set_text(GTK_ENTRY(hc->entry), text);
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 else if (n > 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 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 if (entry) *entry = hc->entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 return hc->combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 /* if text is NULL, current entry text is used
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 * widget can be the combo or entry widget
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 void history_combo_append_history(GtkWidget *widget, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 gchar *new_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 hc = g_object_get_data(G_OBJECT(widget), "history_combo_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 if (!hc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 printf("widget is not a history combo\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 if (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 new_text = g_strdup(text);
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 else
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 new_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(hc->entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 if (new_text && strlen(new_text) > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 GList *work;
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 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
1244
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 store = gtk_combo_box_get_model(GTK_COMBO_BOX(hc->combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 gtk_list_store_clear(GTK_LIST_STORE(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 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
1254 work = work->next;
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 }
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 g_free(new_text);
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 /*
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 * drag and drop uri utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 /* the following characters are allowed to be unencoded for pathnames:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 * $ & + , / : = @
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 static gint escape_char_list[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 10 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 /* spc ! " # $ % & ' */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, /* 30 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276 /* ( ) * + , - . / 0 1 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 /* 2 3 4 5 6 7 8 9 : ; */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 50 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 /* < = > ? @ A B C D E */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, /* 60 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 /* Z [ \ ] ^ _ ` a b c */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, /* 90 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 100 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 110 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 /* x y z { | } ~ del */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 0, 0, 0, 1, 1, 1, 0, 0 /* 120, 127 is end */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 static gchar *hex_char = "0123456789ABCDEF";
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 static gint escape_test(guchar c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 if (c < 32 || c > 127) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 return (escape_char_list[c] != 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300 static const gchar *escape_code(guchar c)
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 static gchar text[4];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 text[0] = '%';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305 text[1] = hex_char[c>>4];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306 text[2] = hex_char[c%16];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307 text[3] = '\0';
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 return text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310 }
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 gchar *uri_text_escape(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 GString *string;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315 gchar *result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 const gchar *p;
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 if (!text) return NULL;
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 string = g_string_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 p = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323 while (*p != '\0')
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 if (escape_test(*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 g_string_append(string, escape_code(*p));
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 else
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 g_string_append_c(string, *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 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336 result = string->str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 g_string_free(string, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 /* dropped filenames are expected to be utf-8 compatible */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 if (!g_utf8_validate(result, -1, NULL))
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 gchar *tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 tmp = g_locale_to_utf8(result, -1, NULL, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 if (tmp)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347 g_free(result);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 result = tmp;
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 }
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 return result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355 /* this operates on the passed string, decoding escaped characters */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 void uri_text_decode(gchar *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 if (strchr(text, '%'))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360 gchar *w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361 gchar *r;
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 w = r = text;
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 while(*r != '\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 if (*r == '%' && *(r + 1) != '\0' && *(r + 2) != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369 gchar t[3];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371
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[0] = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 t[1] = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376 t[2] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377 n = (gint)strtol(t, NULL, 16);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378 if (n > 0 && n < 256)
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 *w = (gchar)n;
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 /* invalid number, rewind and ignore this escape */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 r -= 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386 *w = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 }
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 else if (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 *w = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 w++;
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 if (*w != '\0') *w = '\0';
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 }
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 static void uri_list_parse_encoded_chars(GList *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 GList *work = list;
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 while (work)
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 gchar *text = work->data;
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 uri_text_decode(text);
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 work = work->next;
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 }
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 *uri_list_from_text(gchar *data, gint files_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1415 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417 gint b, e;
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 b = e = 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[b] != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423 while (data[e] != '\r' && data[e] != '\n' && data[e] != '\0') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 if (strncmp(data + b, "file:", 5) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427 b += 5;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 while (data[b] == '/' && data[b+1] == '/') b++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 path = g_strndup(data + b, e - b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1430 list = g_list_append(list, path_to_utf8(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1431 g_free(path);
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 else if (!files_only && strncmp(data + b, "http:", 5) == 0)
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 list = g_list_append(list, g_strndup(data + b, e - b));
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 else if (!files_only && strncmp(data + b, "ftp:", 3) == 0)
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 list = g_list_append(list, g_strndup(data + b, e - b));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441 while (data[e] == '\r' || data[e] == '\n') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442 b = e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 }
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 uri_list_parse_encoded_chars(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 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1449
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1450 GList *uri_filelist_from_text(gchar *data, gint files_only)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1451 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1452 GList *path_list = uri_list_from_text(data, files_only);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1453 GList *filelist = filelist_from_path_list(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1454 string_list_free(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1455 return filelist;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1456 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1457
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1458 gchar *uri_text_from_list(GList *list, gint *len, gint plain_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1460 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1461 GString *string;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1462 GList *work;
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 (!list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466 if (len) *len = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468 }
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 string = g_string_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 while (work)
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 const gchar *name8; /* dnd filenames are in utf-8 */
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 name8 = work->data;
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 if (!plain_text)
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 gchar *escaped;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483 escaped = uri_text_escape(name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484 g_string_append(string, "file:");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485 g_string_append(string, escaped);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 g_free(escaped);
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 g_string_append(string, "\r\n");
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492 g_string_append(string, name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493 if (work->next) g_string_append(string, "\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 }
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 uri_text = string->str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 if (len) *len = string->len;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 g_string_free(string, FALSE);
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 return uri_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1504 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1505
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1506 gchar *uri_text_from_filelist(GList *list, gint *len, gint plain_text)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1507 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1508 GList *path_list = filelist_to_path_list(list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1509 gchar *ret = uri_text_from_list(path_list, len, plain_text);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1510 string_list_free(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1511 return ret;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1512 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1513