annotate src/ui_bookmark.c @ 1774:a7f7b9c0050c

build documentation with gnome-doc-tool in makefile
author nadvornik
date Fri, 27 Nov 2009 23:27:35 +0000
parents a6f9ba6fd751
children 956aab097ea7
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
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1174
diff changeset
4 * Copyright (C) 2008 - 2009 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"
902
c414002a1f27 Move history_list_*() functions to separate files:
zas_
parents: 898
diff changeset
27
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 521
diff changeset
28 #include "filedata.h"
902
c414002a1f27 Move history_list_*() functions to separate files:
zas_
parents: 898
diff changeset
29 #include "history_list.h"
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
30
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 #include "ui_tabcomp.h"
904
1698baa37871 Move uri_*() functions to separate files: uri_utils.[ch]
zas_
parents: 902
diff changeset
37 #include "uri_utils.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 /*
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 * bookmarks
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 #define BOOKMARK_DATA_KEY "bookmarkdata"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 #define MARKER_PATH "[path]"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 #define MARKER_ICON "[icon]"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 typedef struct _BookMarkData BookMarkData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 typedef struct _BookButtonData BookButtonData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 typedef struct _BookPropData BookPropData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 struct _BookMarkData
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 GtkWidget *widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 void (*select_func)(const gchar *path, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 gpointer select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63
1446
a6f9ba6fd751 gint -> gboolean.
zas_
parents: 1284
diff changeset
64 gboolean no_defaults;
a6f9ba6fd751 gint -> gboolean.
zas_
parents: 1284
diff changeset
65 gboolean editable;
a6f9ba6fd751 gint -> gboolean.
zas_
parents: 1284
diff changeset
66 gboolean only_directories;
9
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 BookButtonData *active_button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 struct _BookButtonData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 GtkWidget *image;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 GtkWidget *label;
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 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 gchar *parent;
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 struct _BookPropData
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 GtkWidget *name_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 GtkWidget *path_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 GtkWidget *icon_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 BookButtonData *bb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 TARGET_URI_LIST,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 TARGET_X_URL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 TARGET_TEXT_PLAIN
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 static GtkTargetEntry bookmark_drop_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 { "x-url/http", 0, TARGET_X_URL },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 { "_NETSCAPE_URL", 0, TARGET_X_URL }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 #define bookmark_drop_types_n 3
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 static GtkTargetEntry bookmark_drag_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 { "text/plain", 0, TARGET_TEXT_PLAIN }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 #define bookmark_drag_types_n 2
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 static GList *bookmark_widget_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 static GList *bookmark_default_list = NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 static void bookmark_populate_all(const gchar *key);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 static BookButtonData *bookmark_from_string(const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 const gchar *path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 const gchar *icon_ptr;
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 b = g_new0(BookButtonData, 1);
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 if (!text)
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 b->name = g_strdup(_("New Bookmark"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 b->path = g_strdup(homedir());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 b->key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 return b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 b->key = g_strdup(text);
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 path_ptr = strstr(text, MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 icon_ptr = strstr(text, MARKER_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 if (path_ptr && icon_ptr && icon_ptr < path_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
143 log_printf("warning, bookmark icon must be after path\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 if (path_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 l = path_ptr - text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 b->name = g_strndup(text, l);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 path_ptr += strlen(MARKER_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 if (icon_ptr)
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 l = icon_ptr - path_ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 b->path = g_strndup(path_ptr, l);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 b->path = g_strdup(path_ptr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 b->name = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 b->path = g_strdup("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 }
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 if (icon_ptr)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 icon_ptr += strlen(MARKER_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 b->icon = g_strdup(icon_ptr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 return b;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 static void bookmark_free(BookButtonData *b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 if (!b) return;
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 g_free(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 g_free(b->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 g_free(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 g_free(b->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 g_free(b->parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 g_free(b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 static gchar *bookmark_string(const gchar *name, const gchar *path, const gchar *icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 if (!name) name = _("New Bookmark");
725
eda074e91ddd Use G_DIR_SEPARATOR_S where applicable.
zas_
parents: 702
diff changeset
194 if (icon && strncmp(icon, G_DIR_SEPARATOR_S, 1) != 0) icon = NULL;
9
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 if (icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 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
199 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
200
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 return g_strdup_printf("%s"MARKER_PATH"%s", name, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 static void bookmark_select_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 BookButtonData *b;
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 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 if (bm->select_func) bm->select_func(b->path, bm->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 static void bookmark_edit_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 BookPropData *p = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 bookmark_free(p->bb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 g_free(p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 static void bookmark_edit_cancel_cb(GenericDialog *gd, gpointer 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 static void bookmark_edit_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 BookPropData *p = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 const gchar *icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 gchar *new;
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 name = gtk_entry_get_text(GTK_ENTRY(p->name_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 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
237 icon = gtk_entry_get_text(GTK_ENTRY(p->icon_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 new = bookmark_string(name, path, icon);
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 (p->bb->key)
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 history_list_item_change(p->bb->parent, p->bb->key, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 history_list_add_to_key(p->bb->parent, new, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 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
251 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
252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 g_free(new);
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 bookmark_populate_all(p->bb->parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 /* 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
260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 static void bookmark_edit(const gchar *key, const gchar *text, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 BookPropData *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 const gchar *icon;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
268
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 if (!key) key = "bookmarks";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 p = g_new0(BookPropData, 1);
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 p->bb = bookmark_from_string(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 p->bb->parent = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1055
diff changeset
276 gd = generic_dialog_new(_("Edit Bookmark"), "bookmark_edit",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 parent, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 bookmark_edit_cancel_cb, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 g_signal_connect(G_OBJECT(gd->dialog), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 G_CALLBACK(bookmark_edit_destroy_cb), p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 generic_dialog_add_message(gd, NULL, _("Edit Bookmark"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 bookmark_edit_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 table = pref_table_new(gd->vbox, 3, 2, FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 pref_table_label(table, 0, 0, _("Name:"), 1.0);
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 p->name_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 gtk_widget_set_size_request(p->name_entry, 300, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 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
293 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
294 generic_dialog_attach_default(gd, p->name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 gtk_widget_show(p->name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 pref_table_label(table, 0, 1, _("Path:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 label = tab_completion_new_with_history(&p->path_entry, p->bb->path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 "bookmark_path", -1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 tab_completion_add_select_button(p->path_entry, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 generic_dialog_attach_default(gd, p->path_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 pref_table_label(table, 0, 2, _("Icon:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 icon = p->bb->icon;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 if (!icon) icon = "";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 label = tab_completion_new_with_history(&p->icon_entry, icon,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
311 "bookmark_icons", -1, NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 tab_completion_add_select_button(p->icon_entry, _("Select icon"), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 generic_dialog_attach_default(gd, p->icon_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 gtk_widget_show(label);
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 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 static void bookmark_move(BookMarkData *bm, GtkWidget *button, gint direction)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 gint p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 gchar *key_holder;
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 if (!bm->editable) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 list = gtk_container_get_children(GTK_CONTAINER(bm->box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 p = g_list_index(list, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 g_list_free(list);
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 if (p < 0 || p + direction < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 key_holder = bm->key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 bm->key = "_TEMPHOLDER";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 history_list_item_move(key_holder, b->key, -direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 bookmark_populate_all(key_holder);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 bm->key = key_holder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 gtk_box_reorder_child(GTK_BOX(bm->box), button, p + direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 static void bookmark_menu_prop_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 if (!bm->active_button) return;
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 bookmark_edit(bm->key, bm->active_button->key, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 static void bookmark_menu_move(BookMarkData *bm, gint direction)
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 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 bookmark_move(bm, bm->active_button->button, direction);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 static void bookmark_menu_up_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 bookmark_menu_move(data, -1);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 static void bookmark_menu_down_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 bookmark_menu_move(data, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 static void bookmark_menu_remove_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 BookMarkData *bm = data;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
376
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 if (!bm->active_button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 history_list_item_remove(bm->key, bm->active_button->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 bookmark_populate_all(bm->key);
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 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
384 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 GtkWidget *button = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 gdk_window_get_origin(button->window, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 *y += button->allocation.y + button->allocation.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 static void bookmark_menu_popup(BookMarkData *bm, GtkWidget *button,
1446
a6f9ba6fd751 gint -> gboolean.
zas_
parents: 1284
diff changeset
392 gint button_n, guint32 time, gboolean local)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 if (!b) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 bm->active_button = b;
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 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 menu_item_add_stock_sensitive(menu, _("_Properties..."), GTK_STOCK_PROPERTIES, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 G_CALLBACK(bookmark_menu_prop_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 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
406 G_CALLBACK(bookmark_menu_up_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 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
408 G_CALLBACK(bookmark_menu_down_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 menu_item_add_stock_sensitive(menu, _("_Remove"), GTK_STOCK_REMOVE, bm->editable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 G_CALLBACK(bookmark_menu_remove_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 if (local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 bookmark_menu_position_cb, button, button_n, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 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
420 }
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
1446
a6f9ba6fd751 gint -> gboolean.
zas_
parents: 1284
diff changeset
423 static gboolean bookmark_press_cb(GtkWidget *button, GdkEventButton *event, gpointer data)
9
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 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
427 if (event->button != MOUSE_BUTTON_RIGHT) return FALSE;
9
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 bookmark_menu_popup(bm, button, event->button, event->time, FALSE);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
430
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433
1446
a6f9ba6fd751 gint -> gboolean.
zas_
parents: 1284
diff changeset
434 static gboolean bookmark_keypress_cb(GtkWidget *button, GdkEventKey *event, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 BookMarkData *bm = data;
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 switch (event->keyval)
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 case GDK_F10:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 if (!(event->state & GDK_CONTROL_MASK)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 bookmark_menu_popup(bm, button, 0, event->time, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 case GDK_Up:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 bookmark_move(bm, button, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 case GDK_Down:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 bookmark_move(bm, button, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 break;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 static void bookmark_drag_set_data(GtkWidget *button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 GdkDragContext *context, GtkSelectionData *selection_data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 guint info, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 GList *list = NULL;
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 if (context->dest_window == bm->widget->window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 b = g_object_get_data(G_OBJECT(button), "bookbuttondata");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 if (!b) return;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
479
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 list = g_list_append(list, b->path);
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 switch (info)
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 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 uri_text = uri_text_from_list(list, &length, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 uri_text = uri_text_from_list(list, &length, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 if (!uri_text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 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
497 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpointer data)
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 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 GdkModifierType mask;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
508 button->allocation.width, button->allocation.height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 gdk_pixbuf_get_from_drawable(pixbuf, button->window, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 button->allocation.x, button->allocation.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 0, 0, button->allocation.width, button->allocation.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 gdk_window_get_pointer(button->window, &x, &y, &mask);
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 gtk_drag_set_icon_pixbuf(context, pixbuf,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
516 x - button->allocation.x, y - button->allocation.y);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 static void bookmark_populate(BookMarkData *bm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 GtkBox *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 GList *children;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
525
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 box = GTK_BOX(bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 children = gtk_container_get_children(GTK_CONTAINER(box));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 work = children;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 while (work)
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 GtkWidget *widget = GTK_WIDGET(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 gtk_widget_destroy(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 if (!bm->no_defaults && !history_list_get_by_key(bm->key))
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 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 gchar *path;
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 if (!bookmark_default_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 buf = bookmark_string(_("Home"), homedir(), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546
702
e07895754e65 Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents: 694
diff changeset
547 path = g_build_filename(homedir(), "Desktop", NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 if (isname(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 buf = bookmark_string(_("Desktop"), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 work = bookmark_default_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 while (work && work->next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 gchar *name;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
561
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 work = history_list_get_by_key(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 work = g_list_last(work);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 BookButtonData *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 b = bookmark_from_string(work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 if (b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 b->button = gtk_button_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 gtk_button_set_relief(GTK_BUTTON(b->button), GTK_RELIEF_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 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
587 gtk_widget_show(b->button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 g_object_set_data_full(G_OBJECT(b->button), "bookbuttondata",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 b, (GDestroyNotify)bookmark_free);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 box = gtk_hbox_new(FALSE, PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 gtk_container_add(GTK_CONTAINER(b->button), box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 gtk_widget_show(box);
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 if (b->icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 gchar *iconl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 iconl = path_from_utf8(b->icon);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 pixbuf = gdk_pixbuf_new_from_file(iconl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 g_free(iconl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 GdkPixbuf *scaled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 gint w, h;
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 w = h = 16;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 scaled = gdk_pixbuf_scale_simple(pixbuf, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 GDK_INTERP_BILINEAR);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 b->image = gtk_image_new_from_pixbuf(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 g_object_unref(scaled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 g_object_unref(pixbuf);
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 else
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 b->image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
621 GTK_ICON_SIZE_BUTTON);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 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
627 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 gtk_box_pack_start(GTK_BOX(box), b->image, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 gtk_widget_show(b->image);
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 b->label = gtk_label_new(b->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 gtk_box_pack_start(GTK_BOX(box), b->label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 gtk_widget_show(b->label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 g_signal_connect(G_OBJECT(b->button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 G_CALLBACK(bookmark_select_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 g_signal_connect(G_OBJECT(b->button), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 G_CALLBACK(bookmark_press_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 g_signal_connect(G_OBJECT(b->button), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 G_CALLBACK(bookmark_keypress_cb), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 gtk_drag_source_set(b->button, GDK_BUTTON1_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 bookmark_drag_types, bookmark_drag_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 g_signal_connect(G_OBJECT(b->button), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 G_CALLBACK(bookmark_drag_set_data), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 g_signal_connect(G_OBJECT(b->button), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 G_CALLBACK(bookmark_drag_begin), bm);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 static void bookmark_populate_all(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 GList *work;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
658
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 if (!key) return;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
660
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 work = bookmark_widget_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 bm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 if (strcmp(bm->key, key) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 static void bookmark_dnd_get_data(GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 GdkDragContext *context, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 GList *work;
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 if (!bm->editable) return;
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 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 case TARGET_X_URL:
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
691 list = uri_list_from_text((gchar *)selection_data->data, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 break;
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 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
701 work = work->next;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
702
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
703 if (bm->only_directories && !isdir(path)) continue;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 buf = bookmark_string(filename_from_path(path), path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 64
diff changeset
709 string_list_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 bookmark_populate_all(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 static void bookmark_list_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 BookMarkData *bm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 bookmark_widget_list = g_list_remove(bookmark_widget_list, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 g_free(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 }
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 GtkWidget *bookmark_list_new(const gchar *key,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 void (*select_func)(const gchar *path, gpointer data), gpointer select_data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 BookMarkData *bm;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 403
diff changeset
729
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 if (!key) key = "bookmarks";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 bm = g_new0(BookMarkData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 bm->key = g_strdup(key);
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 bm->select_func = select_func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 bm->select_data = select_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 bm->no_defaults = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 bm->editable = TRUE;
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
740 bm->only_directories = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
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 bm->box = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), bm->box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 gtk_widget_show(bm->box);
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 bookmark_populate(bm);
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 g_signal_connect(G_OBJECT(bm->box), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 G_CALLBACK(bookmark_list_destroy), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 g_object_set_data(G_OBJECT(bm->box), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 g_object_set_data(G_OBJECT(scrolled), BOOKMARK_DATA_KEY, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 bm->widget = scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 gtk_drag_dest_set(scrolled,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 bookmark_drop_types, bookmark_drop_types_n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 g_signal_connect(G_OBJECT(scrolled), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 G_CALLBACK(bookmark_dnd_get_data), bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 bookmark_widget_list = g_list_append(bookmark_widget_list, bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 return scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 void bookmark_list_set_key(GtkWidget *list, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 BookMarkData *bm;
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 if (!list || !key) return;
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 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 if (!bm) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 if (bm->key && strcmp(bm->key, key) == 0) return;
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 g_free(bm->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 bm->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 bookmark_populate(bm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786
1446
a6f9ba6fd751 gint -> gboolean.
zas_
parents: 1284
diff changeset
787 void bookmark_list_set_no_defaults(GtkWidget *list, gboolean no_defaults)
9
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 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 if (!bm) return;
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 bm->no_defaults = no_defaults;
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
1446
a6f9ba6fd751 gint -> gboolean.
zas_
parents: 1284
diff changeset
797 void bookmark_list_set_editable(GtkWidget *list, gboolean editable)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 if (!bm) return;
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 bm->editable = editable;
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
1446
a6f9ba6fd751 gint -> gboolean.
zas_
parents: 1284
diff changeset
807 void bookmark_list_set_only_directories(GtkWidget *list, gboolean only_directories)
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
808 {
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
809 BookMarkData *bm;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
810
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
811 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
812 if (!bm) return;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
813
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
814 bm->only_directories = only_directories;
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
815 }
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 516
diff changeset
816
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 void bookmark_list_add(GtkWidget *list, const gchar *name, const gchar *path)
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 BookMarkData *bm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 if (!bm) return;
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 buf = bookmark_string(name, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 history_list_add_to_key(bm->key, buf, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 bookmark_populate_all(bm->key);
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 void bookmark_add_default(const gchar *name, const gchar *path)
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 if (!name || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 bookmark_default_list = g_list_append(bookmark_default_list, g_strdup(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 * combo with history key
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 typedef struct _HistoryComboData HistoryComboData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 struct _HistoryComboData
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 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 gchar *history_key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 gint history_levels;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 static void history_combo_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 HistoryComboData *hc = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 g_free(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 g_free(data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 /* if text is NULL, entry is set to the most recent item */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 GtkWidget *history_combo_new(GtkWidget **entry, const gchar *text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 const gchar *history_key, gint max_levels)
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 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 hc = g_new0(HistoryComboData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 hc->history_key = g_strdup(history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 hc->history_levels = max_levels;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 hc->combo = gtk_combo_box_entry_new_text();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 gtk_combo_set_case_sensitive(GTK_COMBO(hc->combo), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 gtk_combo_set_use_arrows(GTK_COMBO(hc->combo), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 hc->entry = GTK_BIN(hc->combo)->child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 g_object_set_data(G_OBJECT(hc->combo), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 g_object_set_data(G_OBJECT(hc->entry), "history_combo_data", hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 g_signal_connect(G_OBJECT(hc->combo), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 G_CALLBACK(history_combo_destroy), hc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 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
891 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 n++;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 gtk_entry_set_text(GTK_ENTRY(hc->entry), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 else if (n > 0)
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 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 if (entry) *entry = hc->entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 return hc->combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 /* if text is NULL, current entry text is used
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 * widget can be the combo or entry widget
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 void history_combo_append_history(GtkWidget *widget, const gchar *text)
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 HistoryComboData *hc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 gchar *new_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 hc = g_object_get_data(G_OBJECT(widget), "history_combo_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 if (!hc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
919 log_printf("widget is not a history combo\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 new_text = g_strdup(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 new_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(hc->entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 if (new_text && strlen(new_text) > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 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
938
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 gtk_combo_box_set_active(GTK_COMBO_BOX(hc->combo), -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 store = gtk_combo_box_get_model(GTK_COMBO_BOX(hc->combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 gtk_list_store_clear(GTK_LIST_STORE(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 work = history_list_get_by_key(hc->history_key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 while (work)
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 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
948 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 g_free(new_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 904
diff changeset
954 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */