annotate src/ui_bookmark.c @ 708:444705451f3a

Use G_DIR_SEPARATOR_S instead of hardcoded "/".
author zas_
date Tue, 20 May 2008 23:11:47 +0000
parents e07895754e65
children eda074e91ddd
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
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
29 #include "secure_save.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 * history lists
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 #define HISTORY_DEFAULT_KEY_COUNT 16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 typedef struct _HistoryData HistoryData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 struct _HistoryData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 static GList *history_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 static gchar *quoted_from_text(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 const gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 gint c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 gint l = strlen(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 if (l == 0) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 while (c < l && text[c] !='"') c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 if (text[c] == '"')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 gint e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 ptr = text + c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 e = c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 while (e < l && text[e] !='"') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 if (text[e] == '"')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 if (e - c > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 return g_strndup(ptr, e - c);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 gint history_list_load(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 gchar *key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 gchar s_buf[1024];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 f = fopen(pathl, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 /* first line must start with History comment */
514
f4410db9c934 Use sizeof().
zas_
parents: 475
diff changeset
97 if (!fgets(s_buf, sizeof(s_buf), f) ||
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 strncmp(s_buf, "#History", 8) != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103
514
f4410db9c934 Use sizeof().
zas_
parents: 475
diff changeset
104 while (fgets(s_buf, sizeof(s_buf), f))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 if (s_buf[0]=='#') continue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 if (s_buf[0]=='[')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 gint c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 ptr = s_buf + 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 c = 0;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
114 while (ptr[c] != ']' && ptr[c] != '\n' && ptr[c] != '\0') c++;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 key = g_strndup(ptr, c);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 gchar *value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 value = quoted_from_text(s_buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 if (value && key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 history_list_add_to_key(key, value, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 g_free(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 gint history_list_save(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 {
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
141 SecureSaveInfo *ssi;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 pathl = path_from_utf8(path);
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
146 ssi = secure_open(pathl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 g_free(pathl);
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
148 if (!ssi)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 {
694
a3218946bd2d Sort out log_printf() vs printf_term() mix up.
zas_
parents: 673
diff changeset
150 log_printf(_("Unable to write history lists to: %s\n"), path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153
515
adc45cd3f08b Use only one secure_fprintf() call instead of two.
zas_
parents: 514
diff changeset
154 secure_fprintf(ssi, "#History lists\n\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 list = g_list_last(history_list);
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
157 while (list && secsave_errno == SS_ERR_NONE)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 hd = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 list = list->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
165 secure_fprintf(ssi, "[%s]\n", hd->key);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 /* save them inverted (oldest to newest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 * so that when reading they are added correctly
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 work = g_list_last(hd->list);
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
171 while (work && secsave_errno == SS_ERR_NONE)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 {
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
173 secure_fprintf(ssi, "\"%s\"\n", (gchar *)work->data);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 }
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
176 secure_fputc(ssi, '\n');
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
179 secure_fprintf(ssi, "#end\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180
315
d5a3bcc6a694 Use secure save in history_list_save().
zas_
parents: 281
diff changeset
181 return (secure_close(ssi) == 0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 static void history_list_free(HistoryData *hd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 work = hd->list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
191 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 g_free(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 g_free(hd->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 g_free(hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 static HistoryData *history_list_find_by_key(const gchar* key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 GList *work = history_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 if (!key) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 HistoryData *hd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 if (strcmp(hd->key, key) == 0) return hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 const gchar *history_list_find_last_path_by_key(const gchar* key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 if (!hd || !hd->list) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 return hd->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 void history_list_free_key(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 history_list = g_list_remove(history_list, hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 history_list_free(hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 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
237 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 if (!key || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 if (!hd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 hd = g_new(HistoryData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 hd->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 hd->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 history_list = g_list_prepend(history_list, hd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 /* if already in the list, simply move it to the top */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 work = hd->list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
254 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 if (strcmp(buf, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 hd->list = g_list_prepend(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 }
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 hd->list = g_list_prepend(hd->list, g_strdup(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 if (max == -1) max = HISTORY_DEFAULT_KEY_COUNT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 if (max > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 {
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
271 while (hd->list && g_list_length(hd->list) > max)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 GList *work = g_list_last(hd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 }
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 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
282 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 if (!oldpath) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 work = hd->list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
291 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 if (strcmp(buf, oldpath) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 if (newpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 work->data = g_strdup(newpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 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
312 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 gint p = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 if (!hd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 work = hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 gchar *buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 if (strcmp(buf, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 p += direction;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 if (p < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 hd->list = g_list_remove(hd->list, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 hd->list = g_list_insert(hd->list, buf, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 }
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 void history_list_item_remove(const gchar *key, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 history_list_item_change(key, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 GList *history_list_get_by_key(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 HistoryData *hd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 hd = history_list_find_by_key(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 if (!hd) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 return hd->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352
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 * bookmarks
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 #define BOOKMARK_DATA_KEY "bookmarkdata"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 #define MARKER_PATH "[path]"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 #define MARKER_ICON "[icon]"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 typedef struct _BookMarkData BookMarkData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 typedef struct _BookButtonData BookButtonData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 typedef struct _BookPropData BookPropData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 struct _BookMarkData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 GtkWidget *widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 void (*select_func)(const gchar *path, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 gpointer select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 gint no_defaults;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 gint editable;
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
378 gint only_directories;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 BookButtonData *active_button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 };
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 struct _BookButtonData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 GtkWidget *image;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 gchar *parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 struct _BookPropData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 GtkWidget *name_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 GtkWidget *path_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 GtkWidget *icon_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 BookButtonData *bb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 TARGET_URI_LIST,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 TARGET_X_URL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 TARGET_TEXT_PLAIN
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 static GtkTargetEntry bookmark_drop_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 { "x-url/http", 0, TARGET_X_URL },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 { "_NETSCAPE_URL", 0, TARGET_X_URL }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 #define bookmark_drop_types_n 3
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 static GtkTargetEntry bookmark_drag_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 { "text/plain", 0, TARGET_TEXT_PLAIN }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 #define bookmark_drag_types_n 2
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 static GList *bookmark_widget_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 static GList *bookmark_default_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 static void bookmark_populate_all(const gchar *key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 static BookButtonData *bookmark_from_string(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 const gchar *path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 const gchar *icon_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 b = g_new0(BookButtonData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 if (!text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 b->name = g_strdup(_("New Bookmark"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 b->path = g_strdup(homedir());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 b->key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 return b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 b->key = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 path_ptr = strstr(text, MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 icon_ptr = strstr(text, MARKER_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 if (path_ptr && icon_ptr && icon_ptr < path_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
455 log_printf("warning, bookmark icon must be after path\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 if (path_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 l = path_ptr - text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 b->name = g_strndup(text, l);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 path_ptr += strlen(MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 if (icon_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 l = icon_ptr - path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 b->path = g_strndup(path_ptr, l);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 b->path = g_strdup(path_ptr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 b->name = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 b->path = g_strdup("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 if (icon_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 icon_ptr += strlen(MARKER_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 b->icon = g_strdup(icon_ptr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 return b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 static void bookmark_free(BookButtonData *b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 g_free(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 g_free(b->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 g_free(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 g_free(b->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 g_free(b->parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 g_free(b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 }
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 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
504 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 if (!name) name = _("New Bookmark");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 if (icon && strncmp(icon, "/", 1) != 0) icon = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 if (icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 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
511 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
512
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 return g_strdup_printf("%s"MARKER_PATH"%s", name, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 }
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 static void bookmark_select_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 if (bm->select_func) bm->select_func(b->path, bm->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 static void bookmark_edit_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 BookPropData *p = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 bookmark_free(p->bb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 g_free(p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 }
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 static void bookmark_edit_cancel_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 static void bookmark_edit_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 BookPropData *p = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 const gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 gchar *new;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 name = gtk_entry_get_text(GTK_ENTRY(p->name_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 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
549 icon = gtk_entry_get_text(GTK_ENTRY(p->icon_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 new = bookmark_string(name, path, icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 if (p->bb->key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 history_list_item_change(p->bb->parent, p->bb->key, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 history_list_add_to_key(p->bb->parent, new, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 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
563 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
564
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 g_free(new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 bookmark_populate_all(p->bb->parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 }
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 /* 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
572
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 static void bookmark_edit(const gchar *key, const gchar *text, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 BookPropData *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 const gchar *icon;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
580
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 if (!key) key = "bookmarks";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 p = g_new0(BookPropData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 p->bb = bookmark_from_string(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 p->bb->parent = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 138
diff changeset
588 gd = generic_dialog_new(_("Edit Bookmark"), GQ_WMCLASS, "bookmark_edit",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 parent, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 bookmark_edit_cancel_cb, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 g_signal_connect(G_OBJECT(gd->dialog), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 G_CALLBACK(bookmark_edit_destroy_cb), p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 generic_dialog_add_message(gd, NULL, _("Edit Bookmark"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 bookmark_edit_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 table = pref_table_new(gd->vbox, 3, 2, FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 pref_table_label(table, 0, 0, _("Name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 p->name_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 gtk_widget_set_size_request(p->name_entry, 300, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 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
605 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
606 generic_dialog_attach_default(gd, p->name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 gtk_widget_show(p->name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 pref_table_label(table, 0, 1, _("Path:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 label = tab_completion_new_with_history(&p->path_entry, p->bb->path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 "bookmark_path", -1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 tab_completion_add_select_button(p->path_entry, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 generic_dialog_attach_default(gd, p->path_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 pref_table_label(table, 0, 2, _("Icon:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 icon = p->bb->icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 if (!icon) icon = "";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 label = tab_completion_new_with_history(&p->icon_entry, icon,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
623 "bookmark_icons", -1, NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 tab_completion_add_select_button(p->icon_entry, _("Select icon"), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 generic_dialog_attach_default(gd, p->icon_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 }
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 static void bookmark_move(BookMarkData *bm, GtkWidget *button, gint direction)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 gint p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 gchar *key_holder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 if (!bm->editable) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 list = gtk_container_get_children(GTK_CONTAINER(bm->box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 p = g_list_index(list, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 if (p < 0 || p + direction < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 key_holder = bm->key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 bm->key = "_TEMPHOLDER";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 history_list_item_move(key_holder, b->key, -direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 bookmark_populate_all(key_holder);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 bm->key = key_holder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 gtk_box_reorder_child(GTK_BOX(bm->box), button, p + direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 static void bookmark_menu_prop_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 bookmark_edit(bm->key, bm->active_button->key, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 static void bookmark_menu_move(BookMarkData *bm, gint direction)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 bookmark_move(bm, bm->active_button->button, direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 static void bookmark_menu_up_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 bookmark_menu_move(data, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 static void bookmark_menu_down_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 bookmark_menu_move(data, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 static void bookmark_menu_remove_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 BookMarkData *bm = data;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
688
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 history_list_item_remove(bm->key, bm->active_button->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 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
696 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 GtkWidget *button = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 gdk_window_get_origin(button->window, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 *y += button->allocation.y + button->allocation.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 }
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 static void bookmark_menu_popup(BookMarkData *bm, GtkWidget *button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 gint button_n, guint32 time, gint local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 bm->active_button = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 menu_item_add_stock_sensitive(menu, _("_Properties..."), GTK_STOCK_PROPERTIES, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 G_CALLBACK(bookmark_menu_prop_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 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
718 G_CALLBACK(bookmark_menu_up_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 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
720 G_CALLBACK(bookmark_menu_down_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 menu_item_add_stock_sensitive(menu, _("_Remove"), GTK_STOCK_REMOVE, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 G_CALLBACK(bookmark_menu_remove_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 if (local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 bookmark_menu_position_cb, button, button_n, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 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
732 }
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 static gint bookmark_press_cb(GtkWidget *button, GdkEventButton *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
739 if (event->button != MOUSE_BUTTON_RIGHT) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 bookmark_menu_popup(bm, button, event->button, event->time, FALSE);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
742
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 static gint bookmark_keypress_cb(GtkWidget *button, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 case GDK_F10:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 if (!(event->state & GDK_CONTROL_MASK)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 bookmark_menu_popup(bm, button, 0, event->time, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 case GDK_Up:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 bookmark_move(bm, button, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 case GDK_Down:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 bookmark_move(bm, button, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 static void bookmark_drag_set_data(GtkWidget *button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 GdkDragContext *context, GtkSelectionData *selection_data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 guint info, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 if (context->dest_window == bm->widget->window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 if (!b) return;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
791
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 list = g_list_append(list, b->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 uri_text = uri_text_from_list(list, &length, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 uri_text = uri_text_from_list(list, &length, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 if (!uri_text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 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
809 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 GdkModifierType mask;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
820 button->allocation.width, button->allocation.height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 gdk_pixbuf_get_from_drawable(pixbuf, button->window, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 button->allocation.x, button->allocation.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 0, 0, button->allocation.width, button->allocation.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 gdk_window_get_pointer(button->window, &x, &y, &mask);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 gtk_drag_set_icon_pixbuf(context, pixbuf,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
828 x - button->allocation.x, y - button->allocation.y);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 static void bookmark_populate(BookMarkData *bm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 GtkBox *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 GList *children;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
837
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 box = GTK_BOX(bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 children = gtk_container_get_children(GTK_CONTAINER(box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 work = children;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 GtkWidget *widget = GTK_WIDGET(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 gtk_widget_destroy(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 if (!bm->no_defaults && !history_list_get_by_key(bm->key))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 if (!bookmark_default_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 buf = bookmark_string(_("Home"), homedir(), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858
702
e07895754e65 Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents: 694
diff changeset
859 path = g_build_filename(homedir(), "Desktop", NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 if (isname(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 buf = bookmark_string(_("Desktop"), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 work = bookmark_default_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 while (work && work->next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 gchar *name;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
873
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 }
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 work = history_list_get_by_key(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 work = g_list_last(work);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 b = bookmark_from_string(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 if (b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 b->button = gtk_button_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 gtk_button_set_relief(GTK_BUTTON(b->button), GTK_RELIEF_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 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
899 gtk_widget_show(b->button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 g_object_set_data_full(G_OBJECT(b->button), "bookbuttondata",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 b, (GDestroyNotify)bookmark_free);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 box = gtk_hbox_new(FALSE, PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 gtk_container_add(GTK_CONTAINER(b->button), box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 if (b->icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 gchar *iconl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 iconl = path_from_utf8(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 pixbuf = gdk_pixbuf_new_from_file(iconl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 g_free(iconl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918 GdkPixbuf *scaled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 w = h = 16;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 scaled = gdk_pixbuf_scale_simple(pixbuf, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 GDK_INTERP_BILINEAR);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 b->image = gtk_image_new_from_pixbuf(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 g_object_unref(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 b->image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
933 GTK_ICON_SIZE_BUTTON);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 b->image = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 gtk_box_pack_start(GTK_BOX(box), b->image, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 gtk_widget_show(b->image);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 b->label = gtk_label_new(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 gtk_box_pack_start(GTK_BOX(box), b->label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 gtk_widget_show(b->label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 g_signal_connect(G_OBJECT(b->button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 G_CALLBACK(bookmark_select_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 g_signal_connect(G_OBJECT(b->button), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 G_CALLBACK(bookmark_press_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 g_signal_connect(G_OBJECT(b->button), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 G_CALLBACK(bookmark_keypress_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 gtk_drag_source_set(b->button, GDK_BUTTON1_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 bookmark_drag_types, bookmark_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 g_signal_connect(G_OBJECT(b->button), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 G_CALLBACK(bookmark_drag_set_data), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 g_signal_connect(G_OBJECT(b->button), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 G_CALLBACK(bookmark_drag_begin), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 }
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 static void bookmark_populate_all(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 GList *work;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
970
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 if (!key) return;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
972
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 work = bookmark_widget_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 bm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 if (strcmp(bm->key, key) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 }
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 static void bookmark_dnd_get_data(GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 GdkDragContext *context, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 if (!bm->editable) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 case TARGET_X_URL:
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1003 list = uri_list_from_text((gchar *)selection_data->data, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1013 work = work->next;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1014
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1015 if (bm->only_directories && !isdir(path)) continue;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 buf = bookmark_string(filename_from_path(path), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1021 string_list_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 static void bookmark_list_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 bookmark_widget_list = g_list_remove(bookmark_widget_list, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 g_free(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 GtkWidget *bookmark_list_new(const gchar *key,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 void (*select_func)(const gchar *path, gpointer data), gpointer select_data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 BookMarkData *bm;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
1041
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 if (!key) key = "bookmarks";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 bm = g_new0(BookMarkData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 bm->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 bm->select_func = select_func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 bm->select_data = select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 bm->no_defaults = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 bm->editable = TRUE;
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1052 bm->only_directories = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 bm->box = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 gtk_widget_show(bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 g_signal_connect(G_OBJECT(bm->box), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 G_CALLBACK(bookmark_list_destroy), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 g_object_set_data(G_OBJECT(bm->box), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 g_object_set_data(G_OBJECT(scrolled), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 bm->widget = scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 gtk_drag_dest_set(scrolled,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 bookmark_drop_types, bookmark_drop_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 g_signal_connect(G_OBJECT(scrolled), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 G_CALLBACK(bookmark_dnd_get_data), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 bookmark_widget_list = g_list_append(bookmark_widget_list, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 return scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 void bookmark_list_set_key(GtkWidget *list, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 if (!list || !key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 if (bm->key && strcmp(bm->key, key) == 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 bm->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 void bookmark_list_set_no_defaults(GtkWidget *list, gint no_defaults)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 bm->no_defaults = no_defaults;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 void bookmark_list_set_editable(GtkWidget *list, gint editable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 bm->editable = editable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1119 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
1120 {
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1121 BookMarkData *bm;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1122
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1123 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
1124 if (!bm) return;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1125
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1126 bm->only_directories = only_directories;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1127 }
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
1128
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 void bookmark_list_add(GtkWidget *list, const gchar *name, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 void bookmark_add_default(const gchar *name, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 if (!name || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 /*
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 * combo with history key
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 *-----------------------------------------------------------------------------
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 typedef struct _HistoryComboData HistoryComboData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 struct _HistoryComboData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 gchar *history_key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 gint history_levels;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 static void history_combo_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 HistoryComboData *hc = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 g_free(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 g_free(data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 /* if text is NULL, entry is set to the most recent item */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 GtkWidget *history_combo_new(GtkWidget **entry, const gchar *text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 const gchar *history_key, gint max_levels)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 hc = g_new0(HistoryComboData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 hc->history_key = g_strdup(history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 hc->history_levels = max_levels;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 hc->combo = gtk_combo_box_entry_new_text();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 gtk_combo_set_case_sensitive(GTK_COMBO(hc->combo), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 gtk_combo_set_use_arrows(GTK_COMBO(hc->combo), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 hc->entry = GTK_BIN(hc->combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 g_object_set_data(G_OBJECT(hc->combo), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 g_object_set_data(G_OBJECT(hc->entry), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 g_signal_connect(G_OBJECT(hc->combo), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 G_CALLBACK(history_combo_destroy), hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 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
1203 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 gtk_entry_set_text(GTK_ENTRY(hc->entry), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 else if (n > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 if (entry) *entry = hc->entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 return hc->combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 /* if text is NULL, current entry text is used
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 * widget can be the combo or entry widget
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 void history_combo_append_history(GtkWidget *widget, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 gchar *new_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 hc = g_object_get_data(G_OBJECT(widget), "history_combo_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 if (!hc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
1231 log_printf("widget is not a history combo\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 new_text = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 new_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(hc->entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 if (new_text && strlen(new_text) > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 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
1250
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 store = gtk_combo_box_get_model(GTK_COMBO_BOX(hc->combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 gtk_list_store_clear(GTK_LIST_STORE(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 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
1260 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 g_free(new_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 /*
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 * drag and drop uri utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 */
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 /* the following characters are allowed to be unencoded for pathnames:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 * $ & + , / : = @
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 static gint escape_char_list[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0 */
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
1278 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 10 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 /* spc ! " # $ % & ' */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, /* 30 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 /* ( ) * + , - . / 0 1 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 /* 2 3 4 5 6 7 8 9 : ; */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 50 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286 /* < = > ? @ A B C D E */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, /* 60 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 /* Z [ \ ] ^ _ ` a b c */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, /* 90 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 100 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 110 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 /* x y z { | } ~ del */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 0, 0, 0, 1, 1, 1, 0, 0 /* 120, 127 is end */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298 static gchar *hex_char = "0123456789ABCDEF";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300 static gint escape_test(guchar c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302 if (c < 32 || c > 127) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303 return (escape_char_list[c] != 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 }
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 static const gchar *escape_code(guchar c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308 static gchar text[4];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1309
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310 text[0] = '%';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311 text[1] = hex_char[c>>4];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 text[2] = hex_char[c%16];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 text[3] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315 return text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 }
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 gchar *uri_text_escape(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 GString *string;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 gchar *result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1324 if (!text) return NULL;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
1325
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326 string = g_string_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1328 p = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1329 while (*p != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331 if (escape_test(*p))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1333 g_string_append(string, escape_code(*p));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 g_string_append_c(string, *p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 }
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 result = string->str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343 g_string_free(string, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 /* dropped filenames are expected to be utf-8 compatible */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 if (!g_utf8_validate(result, -1, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 gchar *tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350 tmp = g_locale_to_utf8(result, -1, NULL, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351 if (tmp)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353 g_free(result);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 result = tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 }
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 return result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361 /* this operates on the passed string, decoding escaped characters */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362 void uri_text_decode(gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364 if (strchr(text, '%'))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 gchar *w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367 gchar *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369 w = r = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 515
diff changeset
1371 while (*r != '\0')
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1372 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 if (*r == '%' && *(r + 1) != '\0' && *(r + 2) != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 gchar t[3];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 t[0] = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 t[1] = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382 t[2] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383 n = (gint)strtol(t, NULL, 16);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 if (n > 0 && n < 256)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386 *w = (gchar)n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1388 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1390 /* invalid number, rewind and ignore this escape */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 r -= 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 *w = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 else if (w != r)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397 *w = *r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1399 r++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1400 w++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 if (*w != '\0') *w = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 }
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 static void uri_list_parse_encoded_chars(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412 gchar *text = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1414 uri_text_decode(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1415
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417 }
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 GList *uri_list_from_text(gchar *data, gint files_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423 gint b, e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425 b = e = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427 while (data[b] != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 while (data[e] != '\r' && data[e] != '\n' && data[e] != '\0') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1430 if (strncmp(data + b, "file:", 5) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1431 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433 b += 5;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 while (data[b] == '/' && data[b+1] == '/') b++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435 path = g_strndup(data + b, e - b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436 list = g_list_append(list, path_to_utf8(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1438 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439 else if (!files_only && strncmp(data + b, "http:", 5) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441 list = g_list_append(list, g_strndup(data + b, e - b));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 else if (!files_only && strncmp(data + b, "ftp:", 3) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 list = g_list_append(list, g_strndup(data + b, e - b));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447 while (data[e] == '\r' || data[e] == '\n') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 b = e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1449 }
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 uri_list_parse_encoded_chars(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1452
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1453 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1454 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1455
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1456 GList *uri_filelist_from_text(gchar *data, gint files_only)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1457 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1458 GList *path_list = uri_list_from_text(data, files_only);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1459 GList *filelist = filelist_from_path_list(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1460 string_list_free(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1461 return filelist;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1462 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1463
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1464 gchar *uri_text_from_list(GList *list, gint *len, gint plain_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467 GString *string;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470 if (!list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472 if (len) *len = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476 string = g_string_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481 const gchar *name8; /* dnd filenames are in utf-8 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483 name8 = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485 if (!plain_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487 gchar *escaped;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489 escaped = uri_text_escape(name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490 g_string_append(string, "file:");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 g_string_append(string, escaped);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492 g_free(escaped);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 g_string_append(string, "\r\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1495 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498 g_string_append(string, name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 if (work->next) g_string_append(string, "\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1502 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1503 }
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 uri_text = string->str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 if (len) *len = string->len;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1507 g_string_free(string, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1508
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1509 return uri_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1510 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1511
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1512 gchar *uri_text_from_filelist(GList *list, gint *len, gint plain_text)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1513 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1514 GList *path_list = filelist_to_path_list(list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1515 gchar *ret = uri_text_from_list(path_list, len, plain_text);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1516 string_list_free(path_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1517 return ret;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
1518 }