annotate src/ui_bookmark.c @ 669:dd5d7fe9458f

Improve editors a bit: - allow whitespaces before and after %v, %V, %w - allow % escaping using %% (mandatory to use shell commands than contain % characters) - display a dialog on execution if a syntax error is detected (only for generic editors) - update README editors section
author zas_
date Fri, 16 May 2008 08:37:07 +0000
parents 905688aa2317
children 8268cbe682f1
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
475
48c8e49b571c updated copyright in source files
nadvornik
parents: 448
diff changeset
4 * Copyright (C) 2008 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 #ifdef HAVE_CONFIG_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 # include "config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include <stdio.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include <string.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include <gtk/gtk.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include <gdk/gdkkeysyms.h> /* for key values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 254
diff changeset
26 #include "main.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 521
diff changeset
27 #include "filedata.h"
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
28
514
f4410db9c934 Use sizeof().
zas_
parents: 475
diff changeset
29 #include "debug.h"
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
30 #include "secure_save.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 #include "ui_tabcomp.h"
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 /*
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 * history lists
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 #define HISTORY_DEFAULT_KEY_COUNT 16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 typedef struct _HistoryData HistoryData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 struct _HistoryData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 static GList *history_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 static gchar *quoted_from_text(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 const gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 gint c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 gint l = strlen(text);
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 if (l == 0) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 while (c < l && text[c] !='"') c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 if (text[c] == '"')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 gint e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 ptr = text + c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 e = c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 while (e < l && text[e] !='"') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 if (text[e] == '"')
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 if (e - c > 0)
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 return g_strndup(ptr, e - c);
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 }
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 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 }
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 gint history_list_load(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 gchar *key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 gchar s_buf[1024];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 f = fopen(pathl, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 /* first line must start with History comment */
514
f4410db9c934 Use sizeof().
zas_
parents: 475
diff changeset
98 if (!fgets(s_buf, sizeof(s_buf), f) ||
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 strncmp(s_buf, "#History", 8) != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104
514
f4410db9c934 Use sizeof().
zas_
parents: 475
diff changeset
105 while (fgets(s_buf, sizeof(s_buf), f))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 if (s_buf[0]=='#') continue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 if (s_buf[0]=='[')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 gint c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 ptr = s_buf + 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 c = 0;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
115 while (ptr[c] != ']' && ptr[c] != '\n' && ptr[c] != '\0') c++;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 key = g_strndup(ptr, c);
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 else
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 gchar *value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 value = quoted_from_text(s_buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 if (value && key)
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 history_list_add_to_key(key, value, 0);
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 g_free(value);
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 }
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 fclose(f);
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 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 gint history_list_save(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 {
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
142 SecureSaveInfo *ssi;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 pathl = path_from_utf8(path);
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
147 ssi = secure_open(pathl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 g_free(pathl);
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
149 if (!ssi)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 {
403
2649a28d31b6 Introduce printf_term() macro and use it.
zas_
parents: 315
diff changeset
151 printf_term(_("Unable to write history lists to: %s\n"), path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154
515
adc45cd3f08b Use only one secure_fprintf() call instead of two.
zas_
parents: 514
diff changeset
155 secure_fprintf(ssi, "#History lists\n\n");
9
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 list = g_list_last(history_list);
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
158 while (list && secsave_errno == SS_ERR_NONE)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 hd = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 list = list->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
166 secure_fprintf(ssi, "[%s]\n", hd->key);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 /* save them inverted (oldest to newest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 * so that when reading they are added correctly
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 work = g_list_last(hd->list);
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
172 while (work && secsave_errno == SS_ERR_NONE)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 {
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
174 secure_fprintf(ssi, "\"%s\"\n", (gchar *)work->data);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 }
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
177 secure_fputc(ssi, '\n');
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
180 secure_fprintf(ssi, "#end\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
182 return (secure_close(ssi) == 0);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 static void history_list_free(HistoryData *hd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 if (!hd) return;
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 work = hd->list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
192 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 g_free(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 work = work->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 g_free(hd->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 g_free(hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 static HistoryData *history_list_find_by_key(const gchar* key)
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 GList *work = history_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 if (!key) return NULL;
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 while (work)
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 HistoryData *hd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 if (strcmp(hd->key, key) == 0) return hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 work = work->next;
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 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 const gchar *history_list_find_last_path_by_key(const gchar* key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 if (!hd || !hd->list) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 return hd->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 }
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 void history_list_free_key(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 if (!hd) return;
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 history_list = g_list_remove(history_list, hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 history_list_free(hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 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
238 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 GList *work;
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 if (!key || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 if (!hd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 hd = g_new(HistoryData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 hd->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 hd->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 history_list = g_list_prepend(history_list, hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 /* if already in the list, simply move it to the top */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 work = hd->list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
255 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 if (strcmp(buf, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 hd->list = g_list_prepend(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 hd->list = g_list_prepend(hd->list, g_strdup(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 if (max == -1) max = HISTORY_DEFAULT_KEY_COUNT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 if (max > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 {
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
272 while (hd->list && g_list_length(hd->list) > max)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 GList *work = g_list_last(hd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 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
283 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 GList *work;
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 if (!oldpath) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 work = hd->list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
292 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 if (strcmp(buf, oldpath) == 0)
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 if (newpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 work->data = g_strdup(newpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 else
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 hd->list = g_list_remove(hd->list, buf);
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 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 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
313 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 gint p = 0;
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 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 if (strcmp(buf, path) == 0)
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 p += direction;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 if (p < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 hd->list = g_list_insert(hd->list, buf, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 return;
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 void history_list_item_remove(const gchar *key, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 history_list_item_change(key, path, NULL);
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 GList *history_list_get_by_key(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 if (!hd) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 return hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 }
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 * bookmarks
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 #define BOOKMARK_DATA_KEY "bookmarkdata"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 #define MARKER_PATH "[path]"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 #define MARKER_ICON "[icon]"
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 typedef struct _BookMarkData BookMarkData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 typedef struct _BookButtonData BookButtonData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 typedef struct _BookPropData BookPropData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 struct _BookMarkData
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 GtkWidget *widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 gchar *key;
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 void (*select_func)(const gchar *path, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 gpointer select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 gint no_defaults;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 gint editable;
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
379 gint only_directories;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 BookButtonData *active_button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 struct _BookButtonData
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 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 GtkWidget *image;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 gchar *parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 struct _BookPropData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 GtkWidget *name_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 GtkWidget *path_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 GtkWidget *icon_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 BookButtonData *bb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 TARGET_URI_LIST,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 TARGET_X_URL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 TARGET_TEXT_PLAIN
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 static GtkTargetEntry bookmark_drop_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 { "x-url/http", 0, TARGET_X_URL },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 { "_NETSCAPE_URL", 0, TARGET_X_URL }
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 #define bookmark_drop_types_n 3
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 static GtkTargetEntry bookmark_drag_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 { "text/plain", 0, TARGET_TEXT_PLAIN }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 #define bookmark_drag_types_n 2
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 static GList *bookmark_widget_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 static GList *bookmark_default_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 static void bookmark_populate_all(const gchar *key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 static BookButtonData *bookmark_from_string(const gchar *text)
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 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 const gchar *path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 const gchar *icon_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 b = g_new0(BookButtonData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 if (!text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 b->name = g_strdup(_("New Bookmark"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 b->path = g_strdup(homedir());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 b->key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 return b;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 b->key = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 path_ptr = strstr(text, MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 icon_ptr = strstr(text, MARKER_ICON);
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 if (path_ptr && icon_ptr && icon_ptr < path_ptr)
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 printf("warning, bookmark icon must be after path\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 if (path_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 gint l;
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 l = path_ptr - text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 b->name = g_strndup(text, l);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 path_ptr += strlen(MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 if (icon_ptr)
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 = icon_ptr - path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 b->path = g_strndup(path_ptr, l);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 else
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 b->path = g_strdup(path_ptr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 }
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->name = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 b->path = g_strdup("");
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 if (icon_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 icon_ptr += strlen(MARKER_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 b->icon = g_strdup(icon_ptr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 return b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 static void bookmark_free(BookButtonData *b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 if (!b) return;
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 g_free(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 g_free(b->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 g_free(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 g_free(b->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 g_free(b->parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 g_free(b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 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
505 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 if (!name) name = _("New Bookmark");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 if (icon && strncmp(icon, "/", 1) != 0) icon = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 if (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 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
512 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
513
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 return g_strdup_printf("%s"MARKER_PATH"%s", name, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 static void bookmark_select_cb(GtkWidget *button, gpointer data)
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 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 BookButtonData *b;
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 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 if (bm->select_func) bm->select_func(b->path, bm->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 static void bookmark_edit_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 BookPropData *p = 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 bookmark_free(p->bb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 g_free(p);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 static void bookmark_edit_cancel_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 static void bookmark_edit_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 BookPropData *p = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 const gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 gchar *new;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 name = gtk_entry_get_text(GTK_ENTRY(p->name_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 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
550 icon = gtk_entry_get_text(GTK_ENTRY(p->icon_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 new = bookmark_string(name, path, icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 if (p->bb->key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 history_list_item_change(p->bb->parent, p->bb->key, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 history_list_add_to_key(p->bb->parent, new, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 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
564 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
565
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 g_free(new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 bookmark_populate_all(p->bb->parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 /* 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
573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 static void bookmark_edit(const gchar *key, const gchar *text, GtkWidget *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 BookPropData *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 const gchar *icon;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
581
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 if (!key) key = "bookmarks";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 p = g_new0(BookPropData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 p->bb = bookmark_from_string(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 p->bb->parent = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 138
diff changeset
589 gd = generic_dialog_new(_("Edit Bookmark"), GQ_WMCLASS, "bookmark_edit",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 parent, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 bookmark_edit_cancel_cb, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 g_signal_connect(G_OBJECT(gd->dialog), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 G_CALLBACK(bookmark_edit_destroy_cb), p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 generic_dialog_add_message(gd, NULL, _("Edit Bookmark"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 bookmark_edit_ok_cb, TRUE);
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 table = pref_table_new(gd->vbox, 3, 2, FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 pref_table_label(table, 0, 0, _("Name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 p->name_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 gtk_widget_set_size_request(p->name_entry, 300, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 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
606 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
607 generic_dialog_attach_default(gd, p->name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 gtk_widget_show(p->name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 pref_table_label(table, 0, 1, _("Path:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 label = tab_completion_new_with_history(&p->path_entry, p->bb->path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 "bookmark_path", -1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 tab_completion_add_select_button(p->path_entry, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 generic_dialog_attach_default(gd, p->path_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 pref_table_label(table, 0, 2, _("Icon:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 icon = p->bb->icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 if (!icon) icon = "";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 label = tab_completion_new_with_history(&p->icon_entry, icon,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
624 "bookmark_icons", -1, NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 tab_completion_add_select_button(p->icon_entry, _("Select icon"), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 generic_dialog_attach_default(gd, p->icon_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 static void bookmark_move(BookMarkData *bm, GtkWidget *button, gint direction)
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 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 gint p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 gchar *key_holder;
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 if (!bm->editable) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 list = gtk_container_get_children(GTK_CONTAINER(bm->box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 p = g_list_index(list, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 if (p < 0 || p + direction < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 key_holder = bm->key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 bm->key = "_TEMPHOLDER";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 history_list_item_move(key_holder, b->key, -direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 bookmark_populate_all(key_holder);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 bm->key = key_holder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 gtk_box_reorder_child(GTK_BOX(bm->box), button, p + direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 static void bookmark_menu_prop_cb(GtkWidget *widget, gpointer data)
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 BookMarkData *bm = data;
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 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 bookmark_edit(bm->key, bm->active_button->key, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 }
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 static void bookmark_menu_move(BookMarkData *bm, gint direction)
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 if (!bm->active_button) return;
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 bookmark_move(bm, bm->active_button->button, direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 static void bookmark_menu_up_cb(GtkWidget *widget, gpointer data)
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_menu_move(data, -1);
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_down_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_remove_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 BookMarkData *bm = data;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
689
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 history_list_item_remove(bm->key, bm->active_button->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 bookmark_populate_all(bm->key);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 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
697 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 GtkWidget *button = data;
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 gdk_window_get_origin(button->window, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 *y += button->allocation.y + button->allocation.height;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 static void bookmark_menu_popup(BookMarkData *bm, GtkWidget *button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 gint button_n, guint32 time, gint local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 bm->active_button = 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 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 menu_item_add_stock_sensitive(menu, _("_Properties..."), GTK_STOCK_PROPERTIES, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 G_CALLBACK(bookmark_menu_prop_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 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
719 G_CALLBACK(bookmark_menu_up_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 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
721 G_CALLBACK(bookmark_menu_down_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 menu_item_add_stock_sensitive(menu, _("_Remove"), GTK_STOCK_REMOVE, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 G_CALLBACK(bookmark_menu_remove_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 if (local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 bookmark_menu_position_cb, button, button_n, time);
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 else
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, NULL, NULL, button_n, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 static gint bookmark_press_cb(GtkWidget *button, GdkEventButton *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
740 if (event->button != MOUSE_BUTTON_RIGHT) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 bookmark_menu_popup(bm, button, event->button, event->time, FALSE);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
743
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 static gint bookmark_keypress_cb(GtkWidget *button, GdkEventKey *event, gpointer data)
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 BookMarkData *bm = data;
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 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 case GDK_F10:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 if (!(event->state & GDK_CONTROL_MASK)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 bookmark_menu_popup(bm, button, 0, event->time, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 case GDK_Up:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 bookmark_move(bm, button, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 case GDK_Down:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 bookmark_move(bm, button, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 static void bookmark_drag_set_data(GtkWidget *button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 GdkDragContext *context, GtkSelectionData *selection_data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780 guint info, guint time, gpointer data)
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 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 if (context->dest_window == bm->widget->window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 if (!b) return;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
792
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 list = g_list_append(list, b->path);
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 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 uri_text = uri_text_from_list(list, &length, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 uri_text = uri_text_from_list(list, &length, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 if (!uri_text) return;
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 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
810 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 GdkModifierType mask;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
821 button->allocation.width, button->allocation.height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 gdk_pixbuf_get_from_drawable(pixbuf, button->window, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 button->allocation.x, button->allocation.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 0, 0, button->allocation.width, button->allocation.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 gdk_window_get_pointer(button->window, &x, &y, &mask);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 gtk_drag_set_icon_pixbuf(context, pixbuf,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
829 x - button->allocation.x, y - button->allocation.y);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 static void bookmark_populate(BookMarkData *bm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 GtkBox *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 GList *children;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
838
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 box = GTK_BOX(bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 children = gtk_container_get_children(GTK_CONTAINER(box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 work = children;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 while (work)
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 GtkWidget *widget = GTK_WIDGET(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 gtk_widget_destroy(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 if (!bm->no_defaults && !history_list_get_by_key(bm->key))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 gchar *path;
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 (!bookmark_default_list)
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 buf = bookmark_string(_("Home"), homedir(), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 path = concat_dir_and_file(homedir(), "Desktop");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 if (isname(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 buf = bookmark_string(_("Desktop"), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 work = bookmark_default_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 while (work && work->next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 gchar *name;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
874
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 work = work->next;
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 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 work = history_list_get_by_key(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 work = g_list_last(work);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 while (work)
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 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 b = bookmark_from_string(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 if (b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 GtkWidget *box;
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->button = gtk_button_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 gtk_button_set_relief(GTK_BUTTON(b->button), GTK_RELIEF_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 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
900 gtk_widget_show(b->button);
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 g_object_set_data_full(G_OBJECT(b->button), "bookbuttondata",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 b, (GDestroyNotify)bookmark_free);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 box = gtk_hbox_new(FALSE, PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 gtk_container_add(GTK_CONTAINER(b->button), box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 if (b->icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 gchar *iconl;
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 iconl = path_from_utf8(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 pixbuf = gdk_pixbuf_new_from_file(iconl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 g_free(iconl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 if (pixbuf)
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 GdkPixbuf *scaled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 w = h = 16;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 scaled = gdk_pixbuf_scale_simple(pixbuf, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 GDK_INTERP_BILINEAR);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 b->image = gtk_image_new_from_pixbuf(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 g_object_unref(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 b->image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
934 GTK_ICON_SIZE_BUTTON);
9
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 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
940 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 gtk_box_pack_start(GTK_BOX(box), b->image, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 gtk_widget_show(b->image);
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->label = gtk_label_new(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 gtk_box_pack_start(GTK_BOX(box), b->label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 gtk_widget_show(b->label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 g_signal_connect(G_OBJECT(b->button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 G_CALLBACK(bookmark_select_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 g_signal_connect(G_OBJECT(b->button), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 G_CALLBACK(bookmark_press_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 g_signal_connect(G_OBJECT(b->button), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 G_CALLBACK(bookmark_keypress_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 gtk_drag_source_set(b->button, GDK_BUTTON1_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 bookmark_drag_types, bookmark_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 g_signal_connect(G_OBJECT(b->button), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 G_CALLBACK(bookmark_drag_set_data), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 g_signal_connect(G_OBJECT(b->button), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 G_CALLBACK(bookmark_drag_begin), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 static void bookmark_populate_all(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 GList *work;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
971
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 if (!key) return;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
973
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 work = bookmark_widget_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 while (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 BookMarkData *bm;
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 bm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 work = work->next;
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 if (strcmp(bm->key, key) == 0)
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 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 }
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 }
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 static void bookmark_dnd_get_data(GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 GdkDragContext *context, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 guint time, gpointer data)
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 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 if (!bm->editable) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 case TARGET_X_URL:
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1004 list = uri_list_from_text((gchar *)selection_data->data, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1014 work = work->next;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1015
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1016 if (bm->only_directories && !isdir(path)) continue;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 buf = bookmark_string(filename_from_path(path), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1022 string_list_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 static void bookmark_list_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 bookmark_widget_list = g_list_remove(bookmark_widget_list, bm);
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 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 g_free(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 }
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 GtkWidget *bookmark_list_new(const gchar *key,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 void (*select_func)(const gchar *path, gpointer data), gpointer select_data)
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 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 BookMarkData *bm;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
1042
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 if (!key) key = "bookmarks";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 bm = g_new0(BookMarkData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 bm->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 bm->select_func = select_func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 bm->select_data = select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 bm->no_defaults = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 bm->editable = TRUE;
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1053 bm->only_directories = FALSE;
9
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 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 bm->box = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 gtk_widget_show(bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 g_signal_connect(G_OBJECT(bm->box), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 G_CALLBACK(bookmark_list_destroy), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 g_object_set_data(G_OBJECT(bm->box), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 g_object_set_data(G_OBJECT(scrolled), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 bm->widget = scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 gtk_drag_dest_set(scrolled,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 bookmark_drop_types, bookmark_drop_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 g_signal_connect(G_OBJECT(scrolled), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 G_CALLBACK(bookmark_dnd_get_data), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 bookmark_widget_list = g_list_append(bookmark_widget_list, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 return scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 void bookmark_list_set_key(GtkWidget *list, const gchar *key)
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 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 if (!list || !key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 if (!bm) 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 if (bm->key && strcmp(bm->key, key) == 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 bm->key = g_strdup(key);
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 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 }
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 void bookmark_list_set_no_defaults(GtkWidget *list, gint no_defaults)
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 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105 if (!bm) return;
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->no_defaults = no_defaults;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 void bookmark_list_set_editable(GtkWidget *list, gint editable)
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 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 if (!bm) return;
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->editable = editable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1120 void bookmark_list_set_only_directories(GtkWidget *list, gint only_directories)
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1121 {
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1122 BookMarkData *bm;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1123
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1124 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1125 if (!bm) return;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1126
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1127 bm->only_directories = only_directories;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1128 }
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1129
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 void bookmark_list_add(GtkWidget *list, const gchar *name, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 gchar *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 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 if (!bm) return;
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 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 bookmark_populate_all(bm->key);
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 void bookmark_add_default(const gchar *name, const gchar *path)
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 if (!name || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(path));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 /*
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 * combo with history key
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 typedef struct _HistoryComboData HistoryComboData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 struct _HistoryComboData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 gchar *history_key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 gint history_levels;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 static void history_combo_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 HistoryComboData *hc = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 g_free(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 g_free(data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 /* if text is NULL, entry is set to the most recent item */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 GtkWidget *history_combo_new(GtkWidget **entry, const gchar *text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 const gchar *history_key, gint max_levels)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 hc = g_new0(HistoryComboData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 hc->history_key = g_strdup(history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 hc->history_levels = max_levels;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 hc->combo = gtk_combo_box_entry_new_text();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 gtk_combo_set_case_sensitive(GTK_COMBO(hc->combo), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 gtk_combo_set_use_arrows(GTK_COMBO(hc->combo), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 #endif
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 hc->entry = GTK_BIN(hc->combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 g_object_set_data(G_OBJECT(hc->combo), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 g_object_set_data(G_OBJECT(hc->entry), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 g_signal_connect(G_OBJECT(hc->combo), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 G_CALLBACK(history_combo_destroy), hc);
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 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 while (work)
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_combo_box_append_text(GTK_COMBO_BOX(hc->combo), (gchar *)work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 if (text)
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 gtk_entry_set_text(GTK_ENTRY(hc->entry), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 else if (n > 0)
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 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 if (entry) *entry = hc->entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 return hc->combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 /* if text is NULL, current entry text is used
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 * widget can be the combo or entry widget
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 void history_combo_append_history(GtkWidget *widget, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 gchar *new_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 hc = g_object_get_data(G_OBJECT(widget), "history_combo_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 if (!hc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 printf("widget is not a history combo\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 if (text)
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 new_text = g_strdup(text);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 new_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(hc->entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 if (new_text && strlen(new_text) > 0)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 GList *work;
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 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
1251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 store = gtk_combo_box_get_model(GTK_COMBO_BOX(hc->combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255 gtk_list_store_clear(GTK_LIST_STORE(store));
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 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 while (work)
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 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
1261 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 g_free(new_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 /*
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 * drag and drop uri utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 /* the following characters are allowed to be unencoded for pathnames:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 * $ & + , / : = @
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 static gint escape_char_list[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0 */
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
1279 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 10 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 /* spc ! " # $ % & ' */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, /* 30 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 /* ( ) * + , - . / 0 1 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 /* 2 3 4 5 6 7 8 9 : ; */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 50 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 /* < = > ? @ A B C D E */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, /* 60 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 /* Z [ \ ] ^ _ ` a b c */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, /* 90 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 100 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 110 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 /* x y z { | } ~ del */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 0, 0, 0, 1, 1, 1, 0, 0 /* 120, 127 is end */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299 static gchar *hex_char = "0123456789ABCDEF";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1301 static gint escape_test(guchar c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303 if (c < 32 || c > 127) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 return (escape_char_list[c] != 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307 static const gchar *escape_code(guchar c)
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 static gchar text[4];
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 text[0] = '%';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 text[1] = hex_char[c>>4];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 text[2] = hex_char[c%16];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 text[3] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 return text;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319 gchar *uri_text_escape(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 GString *string;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 gchar *result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1324
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1325 if (!text) return NULL;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
1326
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327 string = g_string_new("");
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 p = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 while (*p != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 if (escape_test(*p))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1333 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 g_string_append(string, escape_code(*p));
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 g_string_append_c(string, *p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 p++;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343 result = string->str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 g_string_free(string, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 /* dropped filenames are expected to be utf-8 compatible */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347 if (!g_utf8_validate(result, -1, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349 gchar *tmp;
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 tmp = g_locale_to_utf8(result, -1, NULL, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 if (tmp)
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 g_free(result);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355 result = tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 return result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362 /* this operates on the passed string, decoding escaped characters */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 void uri_text_decode(gchar *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 if (strchr(text, '%'))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367 gchar *w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 gchar *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370 w = r = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
1372 while (*r != '\0')
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 if (*r == '%' && *(r + 1) != '\0' && *(r + 2) != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376 gchar t[3];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 t[0] = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382 t[1] = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383 t[2] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 n = (gint)strtol(t, NULL, 16);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 if (n > 0 && n < 256)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 *w = (gchar)n;
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
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 /* invalid number, rewind and ignore this escape */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 r -= 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 *w = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 }
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 else if (w != r)
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 *w = *r;
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 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401 w++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403 if (*w != '\0') *w = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 static void uri_list_parse_encoded_chars(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411 while (work)
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 gchar *text = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1414
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1415 uri_text_decode(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417 work = work->next;
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 }
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 GList *uri_list_from_text(gchar *data, gint files_only)
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 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 gint b, e;
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 b = e = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 while (data[b] != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1430 while (data[e] != '\r' && data[e] != '\n' && data[e] != '\0') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1431 if (strncmp(data + b, "file:", 5) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 b += 5;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435 while (data[b] == '/' && data[b+1] == '/') b++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436 path = g_strndup(data + b, e - b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 list = g_list_append(list, path_to_utf8(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1438 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 else if (!files_only && strncmp(data + b, "http:", 5) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442 list = g_list_append(list, g_strndup(data + b, e - b));
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 else if (!files_only && strncmp(data + b, "ftp:", 3) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446 list = g_list_append(list, g_strndup(data + b, e - b));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 while (data[e] == '\r' || data[e] == '\n') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1449 b = e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1450 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1451
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1452 uri_list_parse_encoded_chars(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1453
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1454 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1455 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1456
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1457 GList *uri_filelist_from_text(gchar *data, gint files_only)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1458 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1459 GList *path_list = uri_list_from_text(data, files_only);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1460 GList *filelist = filelist_from_path_list(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1461 string_list_free(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1462 return filelist;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1463 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1464
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 gchar *uri_text_from_list(GList *list, gint *len, gint plain_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468 GString *string;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471 if (!list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 if (len) *len = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475 }
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 string = g_string_new("");
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 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482 const gchar *name8; /* dnd filenames are in utf-8 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484 name8 = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 if (!plain_text)
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 gchar *escaped;
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 escaped = uri_text_escape(name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 g_string_append(string, "file:");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492 g_string_append(string, escaped);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493 g_free(escaped);
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 g_string_append(string, "\r\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 else
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 g_string_append(string, name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 if (work->next) g_string_append(string, "\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 }
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 work = work->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 uri_text = string->str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1507 if (len) *len = string->len;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1508 g_string_free(string, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1509
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1510 return uri_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1511 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1512
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1513 gchar *uri_text_from_filelist(GList *list, gint *len, gint plain_text)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1514 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1515 GList *path_list = filelist_to_path_list(list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1516 gchar *ret = uri_text_from_list(path_list, len, plain_text);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1517 string_list_free(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1518 return ret;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1519 }