annotate src/gtk/bookmarks.c @ 514:e55d8b35d809

2004-7-25 Brian Masney <masneyb@gftp.org> * src/gtk/bookmarks.c src/gtk/gftp-gtk.c src/gtk/gtkui.c src/gtk/transfer.c src/text/textui.c src/uicommon/gftpui.c src/uicommon/gftpui.h - added clear_cache argument to gftpui_refresh() Don't clear the cache when changing directories * src/uicommon/gftpuicallbacks.c (_gftpui_common_rm_list) - return 0 on success * src/gtk/delete_dialog.c - refresh the directory listing after the operation was successful
author masneyb
date Sun, 25 Jul 2004 15:48:25 +0000
parents 037e904642e8
children 648bf2825ea9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2 /* bookmarks.c - routines for the bookmarks */
255
2ad324cf4930 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
20 #include "gftp-gtk.h"
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 26
diff changeset
21 static const char cvsid[] = "$Id$";
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
22
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
23 static GtkWidget * bm_dialog = NULL, * bm_hostedit, * bm_portedit,
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
24 * bm_localdiredit, * bm_remotediredit, * bm_useredit,
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
25 * bm_passedit, * bm_acctedit, * anon_chk, * bm_pathedit,
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
26 * bm_protocol, * tree, * edit_bookmarks_dialog;
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
27 static GHashTable * new_bookmarks_htable = NULL;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
28 static gftp_bookmarks_var * new_bookmarks = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
29 static GtkItemFactory * edit_factory;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
30
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
31
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
32 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
33 run_bookmark (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
34 {
275
5810b0f97eee 2003-9-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
35 int refresh_local;
5810b0f97eee 2003-9-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
36
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
37 if (window1.request->stopable || window2.request->stopable)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
38 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
39 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
40 _("%s: Please hit the stop button first to do anything else\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
41 _("Run Bookmark"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
42 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
43 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
44
285
470759f49ba2 2003-10-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 275
diff changeset
45 if (GFTP_IS_CONNECTED (current_wdata->request))
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 366
diff changeset
46 gftpui_disconnect (current_wdata);
285
470759f49ba2 2003-10-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 275
diff changeset
47
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
48 if (gftp_parse_bookmark (current_wdata->request, other_wdata->request,
275
5810b0f97eee 2003-9-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
49 (char *) data, &refresh_local) < 0)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
50 return;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
51
275
5810b0f97eee 2003-9-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
52 if (refresh_local)
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 452
diff changeset
53 gftpui_refresh (other_wdata, 0);
275
5810b0f97eee 2003-9-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
54
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
55 ftp_connect (current_wdata, current_wdata->request, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
56 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
57
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
58
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
59 static void
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
60 doadd_bookmark (gpointer * data, gftp_dialog_data * ddata)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
61 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
62 GtkItemFactoryEntry test = { NULL, NULL, run_bookmark, 0 };
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
63 const char *edttxt, *spos;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
64 gftp_bookmarks_var * tempentry;
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
65 char *dpos, *proto;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
66
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
67 edttxt = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
68 if (*edttxt == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
69 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
70 ftp_log (gftp_logging_error, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
71 _("Add Bookmark: You must enter a name for the bookmark\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
72 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
73 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
74
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
75 if (g_hash_table_lookup (gftp_bookmarks_htable, edttxt) != NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
76 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 ftp_log (gftp_logging_error, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
78 _("Add Bookmark: Cannot add bookmark %s because that name already exists\n"), edttxt);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
79 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
80 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
81
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
82 tempentry = g_malloc0 (sizeof (*tempentry));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
83
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
84 dpos = tempentry->path = g_malloc (strlen (edttxt) + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
85 for (spos = edttxt; *spos != '\0';)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
86 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
87 *dpos++ = *spos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
88 if (*spos == '/')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
89 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
90 *dpos++ = '/';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
91 for (; *spos == '/'; spos++);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
92 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
93 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
94 *dpos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
95
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
96 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry));
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
97 tempentry->hostname = g_strdup (edttxt);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
98
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
99 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (portedit)->entry));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
100 tempentry->port = strtol (edttxt, NULL, 10);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
101
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
102 proto = gftp_protocols[current_wdata->request->protonum].name;
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
103 tempentry->protocol = g_strdup (proto);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (other_wdata->combo)->entry));
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
106 tempentry->local_dir = g_strdup (edttxt);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
108 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (current_wdata->combo)->entry));
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
109 tempentry->remote_dir = g_strdup (edttxt);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
110
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
111 if ((edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry))) != NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
113 tempentry->user = g_strdup (edttxt);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 edttxt = gtk_entry_get_text (GTK_ENTRY (passedit));
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
116 tempentry->pass = g_strdup (edttxt);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
117 tempentry->save_password = GTK_TOGGLE_BUTTON (ddata->checkbox)->active;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
120 gftp_add_bookmark (tempentry);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
122 test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123 gtk_item_factory_create_item (factory, &test, (gpointer) tempentry->path,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 g_free (test.path);
26
d74bfa342116 2002-09-24 gettextize <bug-gnu-gettext@gnu.org>
masneyb
parents: 23
diff changeset
126 gftp_write_bookmarks_file ();
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
130 void
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
131 add_bookmark (gpointer data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
132 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
133 const char *edttxt;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
134
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
135 if (!check_status (_("Add Bookmark"), current_wdata, 0, 0, 0, 1))
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
136 return;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
137
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
138 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
139 if (*edttxt == '\0')
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
140 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
141 ftp_log (gftp_logging_error, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
142 _("Add Bookmark: You must enter a hostname\n"));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
143 return;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
144 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
145
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
146 MakeEditDialog (_("Add Bookmark"), _("Enter the name of the bookmark you want to add\nYou can separate items by a / to put it into a submenu\n(ex: Linux Sites/Debian)"), NULL, 1, _("Remember password"), gftp_dialog_button_create, doadd_bookmark, data, NULL, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
147 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
148
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
149
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
150 void
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
151 build_bookmarks_menu (void)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 GtkItemFactoryEntry test = { NULL, NULL, NULL, 0 };
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
154 gftp_bookmarks_var * tempentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
155
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
156 tempentry = gftp_bookmarks->children;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
157 while (tempentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158 {
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
159 test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160 if (tempentry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
161 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 test.item_type = "<Branch>";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163 test.callback = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
165 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
167 test.item_type = "";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 test.callback = run_bookmark;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
170 gtk_item_factory_create_item (factory, &test,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
171 (gpointer) tempentry->path, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
172 g_free (test.path);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 if (tempentry->children != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175 tempentry = tempentry->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 while (tempentry->next == NULL && tempentry->prev != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 tempentry = tempentry->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
183 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
186 static gftp_bookmarks_var *
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
187 copy_bookmarks (gftp_bookmarks_var * bookmarks)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
189 gftp_bookmarks_var * new_bm, * preventry, * tempentry, * sibling, * newentry,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 * tentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 new_bm = g_malloc0 (sizeof (*new_bm));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 new_bm->path = g_malloc0 (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194 new_bm->isfolder = bookmarks->isfolder;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
195 preventry = new_bm;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 tempentry = bookmarks->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 sibling = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 while (tempentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 newentry = g_malloc0 (sizeof (*newentry));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 newentry->isfolder = tempentry->isfolder;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202 newentry->save_password = tempentry->save_password;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 newentry->cnode = tempentry->cnode;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 if (tempentry->path)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
205 newentry->path = g_strdup (tempentry->path);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
206
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 if (tempentry->hostname)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
208 newentry->hostname = g_strdup (tempentry->hostname);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
209
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 if (tempentry->protocol)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
211 newentry->protocol = g_strdup (tempentry->protocol);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
212
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 if (tempentry->local_dir)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
214 newentry->local_dir = g_strdup (tempentry->local_dir);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
215
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 if (tempentry->remote_dir)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
217 newentry->remote_dir = g_strdup (tempentry->remote_dir);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
218
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219 if (tempentry->user)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
220 newentry->user = g_strdup (tempentry->user);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
221
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222 if (tempentry->pass)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
223 newentry->pass = g_strdup (tempentry->pass);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
224
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
225 if (tempentry->acct)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
226 newentry->acct = g_strdup (tempentry->acct);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
227
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 newentry->port = tempentry->port;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
229
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
230 gftp_copy_local_options (&newentry->local_options_vars,
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
231 &newentry->local_options_hash,
429
1d45758e5cf5 2004-3-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 422
diff changeset
232 &newentry->num_local_options_vars,
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
233 tempentry->local_options_vars,
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
234 tempentry->num_local_options_vars);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
235 newentry->num_local_options_vars = tempentry->num_local_options_vars;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
236
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 if (sibling == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 if (preventry->children == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 preventry->children = newentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 tentry = preventry->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244 while (tentry->next != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 tentry = tentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246 tentry->next = newentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 sibling->next = newentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 newentry->prev = preventry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 if (tempentry->children != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
254 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255 preventry = newentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
256 sibling = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 tempentry = tempentry->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
261 if (tempentry->next == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
262 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
263 sibling = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
264 while (tempentry->next == NULL && tempentry->prev != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
265 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
266 tempentry = tempentry->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267 preventry = preventry->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
268 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
270 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
271 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
272 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
273 sibling = newentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
274 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
275 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277 }
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
278
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
279 return (new_bm);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
280 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
281
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
282
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
283 static void
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
284 bm_apply_changes (GtkWidget * widget, gpointer backup_data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
285 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
286 gftp_bookmarks_var * tempentry, * delentry;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
287 char *tempstr;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
288
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
289 tempentry = gftp_bookmarks->children;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
290 while (tempentry != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
291 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
292 if (tempentry->path && !tempentry->isfolder)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
293 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
294 tempstr = g_strdup_printf ("/Bookmarks/%s", tempentry->path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
295 gtk_widget_destroy (gtk_item_factory_get_item (factory, tempstr));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
296 g_free (tempentry->path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
297 g_free (tempstr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
298 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
299
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
300 gftp_free_bookmark (tempentry);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
301
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
302 if (tempentry->children != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
303 tempentry = tempentry->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
304 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
305 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
306 if (tempentry->next == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
307 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
308 while (tempentry->next == NULL && tempentry->prev != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
309 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
310 delentry = tempentry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
311 tempentry = tempentry->prev;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
312 if (delentry->isfolder)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
313 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
314 tempstr = g_strdup_printf ("/Bookmarks/%s",
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
315 delentry->path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
316 gtk_widget_destroy (gtk_item_factory_get_item (factory,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
317 tempstr));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
318 g_free (tempstr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
319 g_free (delentry->path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
320 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
321 g_free (delentry);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
322 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
323 delentry = tempentry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
324 tempentry = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
325 if (delentry->isfolder && tempentry != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
326 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
327 tempstr = g_strdup_printf ("/Bookmarks/%s",
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
328 delentry->path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
329 gtk_widget_destroy (gtk_item_factory_get_item (factory,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
330 tempstr));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
331 g_free (delentry->path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
332 g_free (tempstr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
333 g_free (delentry);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
334 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
335 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
336 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
337 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
338 delentry = tempentry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
339 tempentry = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
340 g_free (delentry);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
341 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
342 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
343 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
344 g_free (gftp_bookmarks);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
345 g_hash_table_destroy (gftp_bookmarks_htable);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
346
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
347 gftp_bookmarks = new_bookmarks;
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
348 gftp_bookmarks_htable = new_bookmarks_htable;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
349 if (backup_data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
350 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
351 new_bookmarks = copy_bookmarks (gftp_bookmarks);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
352 new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
353 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
354 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
355 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
356 new_bookmarks = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
357 new_bookmarks_htable = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
358 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
359 build_bookmarks_menu ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
360 gftp_write_bookmarks_file ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
361 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
362
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
363
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
364 static void
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365 bm_close_dialog (GtkWidget * widget, GtkWidget * dialog)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
366 {
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
367 if (new_bookmarks_htable != NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368 {
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
369 g_hash_table_destroy (new_bookmarks_htable);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
370 new_bookmarks_htable = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
371 }
23
e19785b088d7 2002-09-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
372
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
373 if (new_bookmarks != NULL)
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
374 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
375 gftp_bookmarks_destroy (new_bookmarks);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
376 new_bookmarks = NULL;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
377 }
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
378
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
379 gtk_widget_destroy (edit_bookmarks_dialog);
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
380 edit_bookmarks_dialog = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
381 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
382
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
383
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
384 #if GTK_MAJOR_VERSION > 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385 static void
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
386 editbm_action (GtkWidget * widget, gint response, gpointer user_data)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
388 switch (response)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
390 case GTK_RESPONSE_OK:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
391 bm_apply_changes (widget, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
392 /* no break */
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
393 default:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
394 bm_close_dialog (NULL, widget);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
395 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396 }
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
397 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
398
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
399
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400 static void
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
401 do_make_new (gpointer data, gftp_dialog_data * ddata)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
402 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
403 GdkPixmap * closedir_pixmap, * opendir_pixmap;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
404 GdkBitmap * closedir_bitmap, * opendir_bitmap;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
405 gftp_bookmarks_var * tempentry, * newentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
406 GtkCTreeNode * sibling;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
407 char *pos, *text[2];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
408 const char *str;
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
409 #if GTK_MAJOR_VERSION > 1
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
410 gsize bread, bwrite;
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
411 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
412
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
413 gftp_get_pixmap (tree, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
414 gftp_get_pixmap (tree, "dir.xpm", &closedir_pixmap, &closedir_bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
415
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
416 str = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
417
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
418 newentry = g_malloc0 (sizeof (*newentry));
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
419 #if GTK_MAJOR_VERSION == 1
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
420 newentry->path = g_strdup (str);
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
421
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
422 while ((pos = strchr (str, '/')) != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
423 *pos++ = ' ';
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
424 #else
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
425 if (g_utf8_validate (str, -1, NULL))
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
426 newentry->path = g_strdup (str);
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
427 else
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
428 newentry->path = g_locale_to_utf8 (str, -1, &bread, &bwrite, NULL);
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
429
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
430 while ((pos = g_utf8_strchr (str, -1, '/')) != NULL)
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
431 *pos++ = ' ';
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
432 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
433
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
434 newentry->prev = new_bookmarks;
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
435 if (data)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
436 newentry->isfolder = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
437
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
438 if (new_bookmarks->children == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
439 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
440 new_bookmarks->children = newentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
441 sibling = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
442 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
443 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
444 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
445 tempentry = new_bookmarks->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
446 while (tempentry->next != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
447 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
448 tempentry->next = newentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
449 sibling = tempentry->cnode;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
450 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
451
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
452 text[0] = text[1] = newentry->path;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
453
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
454 if (newentry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
455 newentry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
456 new_bookmarks->cnode, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
457 text, 5, closedir_pixmap,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
458 closedir_bitmap, opendir_pixmap,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
459 opendir_bitmap, FALSE, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
460 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
461 newentry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
462 new_bookmarks->cnode, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
463 text, 5, NULL, NULL, NULL, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
464 FALSE, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
465
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
466 gtk_ctree_node_set_row_data (GTK_CTREE (tree), newentry->cnode, newentry);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
467 g_hash_table_insert (new_bookmarks_htable, newentry->path, newentry);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
468 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
469
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
470
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
471 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
472 new_folder_entry (gpointer data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
473 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
474 MakeEditDialog (_("New Folder"),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
475 _("Enter the name of the new folder to create"), NULL, 1,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
476 NULL, gftp_dialog_button_create,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
477 do_make_new, (gpointer) 0x1, NULL, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
478 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
479
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
480
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
481 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
482 new_item_entry (gpointer data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
483 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
484 MakeEditDialog (_("New Folder"),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
485 _("Enter the name of the new item to create"), NULL, 1,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
486 NULL, gftp_dialog_button_create,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
487 do_make_new, NULL, NULL, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
488 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
489
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
490
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
491 static void
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
492 do_delete_entry (gftp_bookmarks_var * entry, gftp_dialog_data * ddata)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
493 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
494 gftp_bookmarks_var * tempentry, * delentry;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
495
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
496 g_hash_table_remove (new_bookmarks_htable, entry->path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
497 gtk_ctree_remove_node (GTK_CTREE (tree), entry->cnode);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
498 if (entry->prev->children == entry)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
499 entry->prev->children = entry->prev->children->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
500 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
501 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
502 tempentry = entry->prev->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
503 while (tempentry->next != entry)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
504 tempentry = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
505 tempentry->next = entry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
506 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
507
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
508 entry->prev = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
509 entry->next = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
510 tempentry = entry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
511 while (tempentry != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
512 {
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
513 gftp_free_bookmark (tempentry);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
514
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
515 if (tempentry->children != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
516 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
517 tempentry = tempentry->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
518 continue;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
519 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
520 else if (tempentry->next == NULL && tempentry->prev != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
521 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
522 delentry = tempentry->prev;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
523 g_free (tempentry);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
524 tempentry = delentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
525 if (delentry != entry)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
526 g_free (delentry);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
527 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
528 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
529 tempentry = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
530 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
531 g_free (entry);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
532 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
533
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
534
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
535 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
536 delete_entry (gpointer data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
537 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
538 gftp_bookmarks_var * entry;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
539 char *tempstr, *pos;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
540
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
541 if (GTK_CLIST (tree)->selection == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
542 return;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
543 entry =
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
544 gtk_ctree_node_get_row_data (GTK_CTREE (tree),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
545 GTK_CLIST (tree)->selection->data);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
546 if (entry == NULL || entry->prev == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
547 return;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
548
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
549 if (!entry->isfolder)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
550 do_delete_entry (entry, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
551 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
552 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
553 if ((pos = strrchr (entry->path, '/')) == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
554 pos = entry->path;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
555 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
556 pos++;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
557
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
558 tempstr = g_strdup_printf (_("Are you sure you want to erase the bookmark\n%s and all it's children?"), pos);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
559 MakeYesNoDialog (_("Delete Bookmark"), tempstr, do_delete_entry, entry,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
560 NULL, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
561 g_free (tempstr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
562 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
563 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
564
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
565
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
566 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
567 set_userpass_visible (GtkWidget * checkbutton, GtkWidget * entry)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
568 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
569 gtk_widget_set_sensitive (bm_useredit, !GTK_TOGGLE_BUTTON (anon_chk)->active);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
570 gtk_widget_set_sensitive (bm_passedit, !GTK_TOGGLE_BUTTON (anon_chk)->active);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
571 gtk_widget_set_sensitive (bm_acctedit, !GTK_TOGGLE_BUTTON (anon_chk)->active);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
572 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
573
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
574
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
575 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
576 build_bookmarks_tree (void)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
577 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
578 GdkPixmap * closedir_pixmap, * opendir_pixmap;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
579 GdkBitmap * closedir_bitmap, * opendir_bitmap;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
580 gftp_bookmarks_var * tempentry, * preventry;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
581 char *pos, *prevpos, *text[2], *str;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
582 GtkCTreeNode * parent;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
583
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
584 gftp_get_pixmap (tree, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
585 gftp_get_pixmap (tree, "dir.xpm", &closedir_pixmap, &closedir_bitmap);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
586 text[0] = text[1] = _("Bookmarks");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
587 parent = gtk_ctree_insert_node (GTK_CTREE (tree), NULL, NULL, text, 5,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
588 closedir_pixmap, closedir_bitmap,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
589 opendir_pixmap, opendir_bitmap, FALSE, TRUE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
590 gtk_ctree_node_set_row_data (GTK_CTREE (tree), parent, new_bookmarks);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
591 new_bookmarks->cnode = parent;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
592
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
593 tempentry = new_bookmarks->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
594 while (tempentry != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
595 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
596 tempentry->cnode = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
597 if (tempentry->children != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
598 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
599 tempentry = tempentry->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
600 continue;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
601 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
602 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
603 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
604 pos = tempentry->path;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
605 while ((pos = strchr (pos, '/')) != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
606 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
607 *pos = '\0';
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
608 str = g_strdup (tempentry->path);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
609 *pos = '/';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
610 preventry = g_hash_table_lookup (new_bookmarks_htable, str);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
611 if (preventry->cnode == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
612 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
613 if ((prevpos = strrchr (str, '/')) == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
614 prevpos = str;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
615 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
616 prevpos++;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
617 text[0] = text[1] = prevpos;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
618 preventry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
619 preventry->prev->cnode, NULL, text,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
620 5, closedir_pixmap, closedir_bitmap,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
621 opendir_pixmap, opendir_bitmap,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
622 FALSE, FALSE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
623 gtk_ctree_node_set_row_data (GTK_CTREE (tree),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
624 preventry->cnode, preventry);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
625 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
626
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
627 g_free (str);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
628 pos++;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
629 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
630 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
631
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
632 if ((pos = strrchr (tempentry->path, '/')) == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
633 pos = tempentry->path;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
634 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
635 pos++;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
636
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
637 text[0] = text[1] = pos;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
638 tempentry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
639 tempentry->prev->cnode, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
640 text, 5, NULL, NULL, NULL, NULL, FALSE, FALSE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
641 gtk_ctree_node_set_row_data (GTK_CTREE (tree), tempentry->cnode,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
642 tempentry);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
643
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
644 while (tempentry->next == NULL && tempentry->prev != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
645 tempentry = tempentry->prev;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
646 tempentry = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
647 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
648 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
649
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
650
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
651 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
652 clear_bookmarks_tree (void)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
653 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
654 gftp_bookmarks_var * tempentry;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
655
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
656 tempentry = new_bookmarks->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
657 while (tempentry != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
658 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
659 if (tempentry->children != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
660 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
661 tempentry = tempentry->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
662 continue;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
663 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
664 while (tempentry->next == NULL && tempentry->prev != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
665 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
666 gtk_ctree_remove_node (GTK_CTREE (tree), tempentry->cnode);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
667 tempentry->cnode = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
668 tempentry = tempentry->prev;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
669 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
670 gtk_ctree_remove_node (GTK_CTREE (tree), tempentry->cnode);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
671 tempentry->cnode = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
672 tempentry = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
673 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
674 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
675
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
676
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
677 static void
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
678 entry_apply_changes (GtkWidget * widget, gftp_bookmarks_var * entry)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
679 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
680 char *pos, *newpath, tempchar, *tempstr, *origpath;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
681 gftp_bookmarks_var * tempentry, * nextentry;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
682 GtkWidget * tempwid;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
683 const char *str;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
684 int oldpathlen;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
685
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
686 oldpathlen = strlen (entry->path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
687 if ((pos = strrchr (entry->path, '/')) == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
688 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
689 pos = entry->path;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
690 tempchar = *entry->path;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
691 *entry->path = '\0';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
692 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
693 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
694 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
695 tempchar = *pos;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
696 *pos = '\0';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
697 }
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 285
diff changeset
698
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 285
diff changeset
699 origpath = newpath = gftp_build_path (entry->path, gtk_entry_get_text (GTK_ENTRY (bm_pathedit)), NULL);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
700 *pos = tempchar;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
701
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
702 str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
703 if (entry->hostname)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
704 g_free (entry->hostname);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
705 entry->hostname = g_strdup (str);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
706
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
707 str = gtk_entry_get_text (GTK_ENTRY (bm_portedit));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
708 entry->port = strtol (str, NULL, 10);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
709
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
710 tempwid = gtk_menu_get_active (GTK_MENU (bm_protocol));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
711 str = gtk_object_get_user_data (GTK_OBJECT (tempwid));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
712 if (entry->protocol)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
713 g_free (entry->protocol);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
714 entry->protocol = g_strdup (str);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
715
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
716 str = gtk_entry_get_text (GTK_ENTRY (bm_remotediredit));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
717 if (entry->remote_dir)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
718 g_free (entry->remote_dir);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
719 entry->remote_dir = g_strdup (str);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
720
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
721 str = gtk_entry_get_text (GTK_ENTRY (bm_localdiredit));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
722 if (entry->local_dir)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
723 g_free (entry->local_dir);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
724 entry->local_dir = g_strdup (str);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
725
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
726 if (GTK_TOGGLE_BUTTON (anon_chk)->active)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
727 str = "anonymous";
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
728 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
729 str = gtk_entry_get_text (GTK_ENTRY (bm_useredit));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
730 if (entry->user)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
731 g_free (entry->user);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
732 entry->user = g_strdup (str);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
733
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
734 if (GTK_TOGGLE_BUTTON (anon_chk)->active)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
735 str = "@EMAIL@";
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
736 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
737 str = gtk_entry_get_text (GTK_ENTRY (bm_passedit));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
738 if (entry->pass)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
739 g_free (entry->pass);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
740 entry->pass = g_strdup (str);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
741 entry->save_password = *entry->pass != '\0';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
742
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
743 if (GTK_TOGGLE_BUTTON (anon_chk)->active)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
744 str = "";
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
745 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
746 str = gtk_entry_get_text (GTK_ENTRY (bm_acctedit));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
747 if (entry->acct)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
748 g_free (entry->acct);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
749 entry->acct = g_strdup (str);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
750
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
751 gftp_gtk_save_bookmark_options (entry);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
752
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
753 if (strcmp (entry->path, newpath) != 0)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
754 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
755 tempentry = entry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
756 nextentry = entry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
757 entry->next = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
758 while (tempentry != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
759 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
760 g_hash_table_remove (new_bookmarks_htable, tempentry->path);
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
761
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
762 if (tempentry->path + oldpathlen == '\0')
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
763 tempstr = g_strdup (newpath);
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
764 else
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
765 tempstr = gftp_build_path (newpath, tempentry->path + oldpathlen, NULL);
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
766
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
767 g_free (tempentry->path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
768 tempentry->path = tempstr;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
769 g_hash_table_insert (new_bookmarks_htable, tempentry->path,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
770 tempentry);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
771 if (tempentry->children != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
772 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
773 tempentry = tempentry->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
774 continue;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
775 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
776 while (tempentry->next == NULL && tempentry != entry &&
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
777 tempentry->prev != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
778 tempentry = tempentry->prev;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
779
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
780 tempentry = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
781 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
782 entry->next = nextentry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
783 clear_bookmarks_tree ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
784 build_bookmarks_tree ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
785 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
786
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
787 g_free (origpath);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
788 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
789
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
790
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
791 #if GTK_MAJOR_VERSION == 1
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
792
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
793 static void
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
794 entry_close_dialog (void * data)
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
795 {
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
796 gtk_widget_destroy (bm_dialog);
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
797 bm_dialog = NULL;
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
798 }
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
799
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
800
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
801 #else
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
802
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
803 static void
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
804 bmedit_action (GtkWidget * widget, gint response, gpointer user_data)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
805 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
806 switch (response)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
807 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
808 case GTK_RESPONSE_APPLY:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
809 entry_apply_changes (widget, user_data);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
810 break;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
811 case GTK_RESPONSE_OK:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
812 entry_apply_changes (widget, user_data);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
813 /* no break */
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
814 default:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
815 gtk_widget_destroy (widget);
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
816 bm_dialog = NULL;
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
817 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
818 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
819 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
820
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
821
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
822 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
823 edit_entry (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
824 {
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
825 GtkWidget * table, * tempwid, * menu, * notebook;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
826 gftp_bookmarks_var * entry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
827 int i, num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
828 char *pos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
829
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
830 if (bm_dialog != NULL)
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
831 {
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
832 gtk_widget_grab_focus (bm_dialog);
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
833 return;
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
834 }
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
835
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
836 if (GTK_CLIST (tree)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
837 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
838
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
839 entry = gtk_ctree_node_get_row_data (GTK_CTREE (tree),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
840 GTK_CLIST (tree)->selection->data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
841
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
842 if (entry == NULL || entry == new_bookmarks)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
843 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
844
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
845 #if GTK_MAJOR_VERSION == 1
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
846 bm_dialog = gtk_dialog_new ();
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
847 gtk_window_set_title (GTK_WINDOW (bm_dialog), _("Edit Entry"));
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
848 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (bm_dialog)->action_area), 15);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
849 #else
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
850 bm_dialog = gtk_dialog_new_with_buttons (_("Edit Entry"), NULL, 0,
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
851 GTK_STOCK_SAVE,
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
852 GTK_RESPONSE_OK,
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
853 GTK_STOCK_CANCEL,
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
854 GTK_RESPONSE_CANCEL,
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
855 GTK_STOCK_APPLY,
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
856 GTK_RESPONSE_APPLY,
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
857 NULL);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
858 #endif
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
859 gtk_window_set_wmclass (GTK_WINDOW (bm_dialog), "Edit Bookmark Entry",
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
860 "gFTP");
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
861 gtk_window_set_position (GTK_WINDOW (bm_dialog), GTK_WIN_POS_MOUSE);
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
862 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (bm_dialog)->vbox), 10);
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
863 gtk_widget_realize (bm_dialog);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
864
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
865 if (gftp_icon != NULL)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
866 {
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
867 gdk_window_set_icon (bm_dialog->window, NULL, gftp_icon->pixmap,
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
868 gftp_icon->bitmap);
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
869 gdk_window_set_icon_name (bm_dialog->window, gftp_version);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
870 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
871
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
872 notebook = gtk_notebook_new ();
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
873 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bm_dialog)->vbox), notebook, TRUE,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
874 TRUE, 0);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
875 gtk_widget_show (notebook);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
876
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
877 table = gtk_table_new (11, 2, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
878 gtk_container_border_width (GTK_CONTAINER (table), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
879 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
880 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
881 gtk_widget_show (table);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
882
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
883 tempwid = gtk_label_new (_("Bookmark"));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
884 gtk_widget_show (tempwid);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
885
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
886 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, tempwid);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
887
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
888 tempwid = gtk_label_new (_("Description:"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
889 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
890 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 0, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
891 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
892
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
893 bm_pathedit = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
894 gtk_table_attach_defaults (GTK_TABLE (table), bm_pathedit, 1, 2, 0, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
895 if ((pos = strrchr (entry->path, '/')) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
896 pos = entry->path;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
897 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
898 pos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
899 if (pos)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
900 gtk_entry_set_text (GTK_ENTRY (bm_pathedit), pos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
901 gtk_widget_show (bm_pathedit);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
902
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
903 tempwid = gtk_label_new (_("Hostname:"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
904 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
905 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 1, 2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
906 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
907
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
908 bm_hostedit = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
909 gtk_table_attach_defaults (GTK_TABLE (table), bm_hostedit, 1, 2, 1, 2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
910 if (entry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
911 gtk_widget_set_sensitive (bm_hostedit, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
912 else if (entry->hostname)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
913 gtk_entry_set_text (GTK_ENTRY (bm_hostedit), entry->hostname);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
914 gtk_widget_show (bm_hostedit);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
915
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
916 tempwid = gtk_label_new (_("Port:"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
917 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
918 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 2, 3);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
919 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
920
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
921 bm_portedit = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
922 gtk_table_attach_defaults (GTK_TABLE (table), bm_portedit, 1, 2, 2, 3);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
923 if (entry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
924 gtk_widget_set_sensitive (bm_portedit, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
925 else if (entry->port)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
926 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
927 pos = g_strdup_printf ("%d", entry->port);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
928 gtk_entry_set_text (GTK_ENTRY (bm_portedit), pos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
929 g_free (pos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
930 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
931 gtk_widget_show (bm_portedit);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
932
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
933 tempwid = gtk_label_new (_("Protocol:"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
934 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
935 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 3, 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
936 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
937
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
938 menu = gtk_option_menu_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
939 gtk_table_attach_defaults (GTK_TABLE (table), menu, 1, 2, 3, 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
940 gtk_widget_show (menu);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
941
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
942 num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
943 bm_protocol = gtk_menu_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
944 for (i = 0; gftp_protocols[i].name; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
945 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
946 tempwid = gtk_menu_item_new_with_label (gftp_protocols[i].name);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
947 gtk_object_set_user_data (GTK_OBJECT (tempwid), gftp_protocols[i].name);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
948 gtk_menu_append (GTK_MENU (bm_protocol), tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
949 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
950 if (entry->protocol &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
951 strcmp (gftp_protocols[i].name, entry->protocol) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
952 num = i;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
953 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
954 gtk_option_menu_set_menu (GTK_OPTION_MENU (menu), bm_protocol);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
955 gtk_option_menu_set_history (GTK_OPTION_MENU (menu), num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
956
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
957 tempwid = gtk_label_new (_("Remote Directory:"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
958 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
959 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 4, 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
960 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
961
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
962 bm_remotediredit = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
963 gtk_table_attach_defaults (GTK_TABLE (table), bm_remotediredit, 1, 2, 4, 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
964 if (entry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
965 gtk_widget_set_sensitive (bm_remotediredit, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
966 else if (entry->remote_dir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
967 gtk_entry_set_text (GTK_ENTRY (bm_remotediredit), entry->remote_dir);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
968 gtk_widget_show (bm_remotediredit);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
969
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
970 tempwid = gtk_label_new (_("Local Directory:"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
971 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
972 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 5, 6);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
973 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
974
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
975 bm_localdiredit = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
976 gtk_table_attach_defaults (GTK_TABLE (table), bm_localdiredit, 1, 2, 5, 6);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
977 if (entry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
978 gtk_widget_set_sensitive (bm_localdiredit, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
979 else if (entry->local_dir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
980 gtk_entry_set_text (GTK_ENTRY (bm_localdiredit), entry->local_dir);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
981 gtk_widget_show (bm_localdiredit);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
982
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
983 tempwid = gtk_hseparator_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
984 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 2, 7, 8);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
985 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
986
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
987 tempwid = gtk_label_new (_("Username:"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
988 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
989 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 8, 9);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
990 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
991
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
992 bm_useredit = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
993 gtk_table_attach_defaults (GTK_TABLE (table), bm_useredit, 1, 2, 8, 9);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
994 if (entry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
995 gtk_widget_set_sensitive (bm_useredit, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
996 else if (entry->user)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
997 gtk_entry_set_text (GTK_ENTRY (bm_useredit), entry->user);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
998 gtk_widget_show (bm_useredit);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
999
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1000 tempwid = gtk_label_new (_("Password:"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1001 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1002 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 9, 10);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1003 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1004
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1005 bm_passedit = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1006 gtk_table_attach_defaults (GTK_TABLE (table), bm_passedit, 1, 2, 9, 10);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1007 gtk_entry_set_visibility (GTK_ENTRY (bm_passedit), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1008 if (entry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1009 gtk_widget_set_sensitive (bm_passedit, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1010 else if (entry->pass)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1011 gtk_entry_set_text (GTK_ENTRY (bm_passedit), entry->pass);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1012 gtk_widget_show (bm_passedit);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1013
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1014 tempwid = gtk_label_new (_("Account:"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1015 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1016 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 10, 11);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1017 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1018
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1019 bm_acctedit = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1020 gtk_table_attach_defaults (GTK_TABLE (table), bm_acctedit, 1, 2, 10, 11);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1021 gtk_entry_set_visibility (GTK_ENTRY (bm_acctedit), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1022 if (entry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1023 gtk_widget_set_sensitive (bm_acctedit, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1024 else if (entry->acct)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1025 gtk_entry_set_text (GTK_ENTRY (bm_acctedit), entry->acct);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1026 gtk_widget_show (bm_acctedit);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1027
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1028 anon_chk = gtk_check_button_new_with_label (_("Log in as ANONYMOUS"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1029 gtk_table_attach_defaults (GTK_TABLE (table), anon_chk, 0, 2, 11, 12);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1030 if (entry->isfolder)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1031 gtk_widget_set_sensitive (anon_chk, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1032 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1033 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1034 gtk_signal_connect (GTK_OBJECT (anon_chk), "toggled",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1035 GTK_SIGNAL_FUNC (set_userpass_visible), NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1036 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (anon_chk), entry->user
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1037 && strcmp (entry->user, "anonymous") == 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1038 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1039 gtk_widget_show (anon_chk);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1040
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
1041 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1042 tempwid = gtk_button_new_with_label (_("OK"));
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
1043 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bm_dialog)->action_area), tempwid,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1044 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1045 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1046 GTK_SIGNAL_FUNC (entry_apply_changes),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1047 (gpointer) entry);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1048 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
1049 GTK_SIGNAL_FUNC (entry_close_dialog), NULL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1050 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1051 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1052
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1053 tempwid = gtk_button_new_with_label (_(" Cancel "));
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
1054 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bm_dialog)->action_area), tempwid,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1055 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1056 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1057 GTK_SIGNAL_FUNC (gtk_widget_destroy),
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
1058 GTK_OBJECT (bm_dialog));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1059 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1060 gtk_widget_grab_focus (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1061 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1062
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1063 tempwid = gtk_button_new_with_label (_("Apply"));
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
1064 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bm_dialog)->action_area), tempwid,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1065 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1066 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1067 GTK_SIGNAL_FUNC (entry_apply_changes),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1068 (gpointer) entry);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1069 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1070 gtk_widget_show (tempwid);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
1071 #else
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
1072 g_signal_connect (GTK_OBJECT (bm_dialog), "response",
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
1073 G_CALLBACK (bmedit_action), (gpointer) entry);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 7
diff changeset
1074 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1075
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1076 gftp_gtk_setup_bookmark_options (notebook, entry);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1077
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
1078 gtk_widget_show (bm_dialog);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1079 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1080
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1081
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1082 static gint
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1083 bm_enter (GtkWidget * widget, GdkEventKey * event, gpointer data)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1084 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1085 if (event->type == GDK_KEY_PRESS)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1086 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1087 if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1088 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1089 edit_entry (NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1090 return (FALSE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1091 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1092 else if (event->keyval == GDK_KP_Delete || event->keyval == GDK_Delete)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1093 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1094 delete_entry (NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1095 return (FALSE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1096 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1097 }
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1098 return (TRUE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1099 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1100
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1101
366
2e408d9918d4 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1102 static inline gboolean
2e408d9918d4 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1103 move_possible (GtkCTree *ctree, GtkCTreeNode *child, GtkCTreeNode *parent,
2e408d9918d4 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1104 GtkCTreeNode *sibling)
2e408d9918d4 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1105 {
2e408d9918d4 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1106 return (parent != NULL && sibling != NULL);
2e408d9918d4 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1107 }
2e408d9918d4 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1108
2e408d9918d4 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1109
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1110 static void
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1111 after_move (GtkCTree * ctree, GtkCTreeNode * child, GtkCTreeNode * parent,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1112 GtkCTreeNode * sibling, gpointer data)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1113 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1114
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
1115 gftp_bookmarks_var * childentry, * siblingentry, * parententry, * tempentry;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1116 char *tempstr, *pos, *stpos;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1117
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1118 childentry = gtk_ctree_node_get_row_data (ctree, child);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1119 parententry = gtk_ctree_node_get_row_data (ctree, parent);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1120 siblingentry = gtk_ctree_node_get_row_data (ctree, sibling);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1121
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1122 tempentry = childentry->prev->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1123 if (tempentry == childentry)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1124 childentry->prev->children = childentry->prev->children->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1125 else
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1126 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1127 while (tempentry->next != childentry)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1128 tempentry = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1129 tempentry->next = childentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1130 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1131 childentry->prev = parententry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1132 if (!parententry->isfolder)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1133 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1134 childentry->next = parententry->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1135 parententry->children = childentry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1136 gtk_ctree_move (ctree, child, parententry->prev->cnode,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1137 parententry->cnode);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1138 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1139 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1140 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1141 if (siblingentry == NULL || parententry->children == siblingentry)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1142 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1143 childentry->next = parententry->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1144 parententry->children = childentry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1145 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1146 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1147 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1148 tempentry = parententry->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1149 while (tempentry->next != siblingentry)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1150 tempentry = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1151 childentry->next = tempentry->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1152 tempentry->next = childentry;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1153 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1154
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1155 tempentry = childentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1156 while (tempentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1157 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1158 g_hash_table_remove (new_bookmarks_htable, tempentry->path);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1159 if ((pos = strrchr (tempentry->path, '/')) == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1160 pos = tempentry->path;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1161 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1162 pos++;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1163 tempstr = g_strdup_printf ("%s/%s", tempentry->prev->path, pos);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1164 for (stpos = tempstr; *stpos == '/'; stpos++);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1165 g_free (tempentry->path);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
1166 tempentry->path = g_strdup (stpos);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1167 g_free (tempstr);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1168 g_hash_table_insert (new_bookmarks_htable, tempentry->path,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1169 tempentry);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1170 if (tempentry->children != NULL)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1171 tempentry = tempentry->children;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1172 else
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1173 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1174 if (tempentry->next == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1175 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1176 if (tempentry->prev == childentry)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1177 break;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1178 else
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1179 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1180 while (tempentry->next == NULL
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1181 && tempentry->prev != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1182 tempentry = tempentry->prev;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1183 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1184 }
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1185 tempentry = tempentry->next;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1186 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1187 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1188 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1189 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1190
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1191
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1192 static gint
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1193 bm_dblclick (GtkWidget * widget, GdkEventButton * event, gpointer data)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1194 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1195 if (event->button == 3)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1196 gtk_item_factory_popup (edit_factory, (guint) event->x_root,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1197 (guint) event->y_root, 1, 0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1198 else if (event->type == GDK_2BUTTON_PRESS)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1199 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1200 edit_entry (NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1201 return (FALSE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1202 }
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1203 return (TRUE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1204 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1205
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1206
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1207 void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1208 edit_bookmarks (gpointer data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1209 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1210 GtkItemFactory * ifactory;
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1211 GtkWidget * scroll;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1212 GtkItemFactoryEntry menu_items[] = {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1213 {N_("/_File"), NULL, 0, 0, "<Branch>"},
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1214 {N_("/File/tearoff"), NULL, 0, 0, "<Tearoff>"},
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1215 {N_("/File/New Folder..."), NULL, new_folder_entry, 0, MN_(NULL)},
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1216 {N_("/File/New Item..."), NULL, new_item_entry, 0, MS_(GTK_STOCK_NEW)},
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1217 {N_("/File/Delete"), NULL, delete_entry, 0, MS_(GTK_STOCK_DELETE)},
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1218 {N_("/File/Properties..."), NULL, edit_entry, 0, MS_(GTK_STOCK_PROPERTIES)},
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1219 {N_("/File/sep"), NULL, 0, 0, "<Separator>"},
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1220 {N_("/File/Close"), NULL, gtk_widget_destroy, 0, MS_(GTK_STOCK_CLOSE)}
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1221 };
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1222 #if GTK_MAJOR_VERSION == 1
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1223 GtkWidget * tempwid;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1224 #endif
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1225
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1226 if (edit_bookmarks_dialog != NULL)
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1227 {
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1228 gtk_widget_grab_focus (edit_bookmarks_dialog);
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1229 return;
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1230 }
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1231
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 73
diff changeset
1232 new_bookmarks = copy_bookmarks (gftp_bookmarks);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1233 new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1234
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1235 #if GTK_MAJOR_VERSION == 1
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1236 edit_bookmarks_dialog = gtk_dialog_new ();
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1237 gtk_window_set_title (GTK_WINDOW (edit_bookmarks_dialog),
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1238 _("Edit Bookmarks"));
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1239 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (edit_bookmarks_dialog)->action_area), 15);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1240 #else
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1241 edit_bookmarks_dialog = gtk_dialog_new_with_buttons (_("Edit Bookmarks"),
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1242 NULL, 0, GTK_STOCK_SAVE,
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1243 GTK_RESPONSE_OK,
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1244 GTK_STOCK_CANCEL,
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1245 GTK_RESPONSE_CANCEL,
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1246 NULL);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1247 #endif
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1248 gtk_window_set_wmclass (GTK_WINDOW(edit_bookmarks_dialog), "Edit Bookmarks",
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1249 "gFTP");
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1250 gtk_window_set_position (GTK_WINDOW (edit_bookmarks_dialog),
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1251 GTK_WIN_POS_MOUSE);
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1252 gtk_widget_realize (edit_bookmarks_dialog);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1253
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1254 if (gftp_icon != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1255 {
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1256 gdk_window_set_icon (edit_bookmarks_dialog->window, NULL,
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1257 gftp_icon->pixmap, gftp_icon->bitmap);
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1258 gdk_window_set_icon_name (edit_bookmarks_dialog->window, gftp_version);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1259 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1260
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1261 ifactory = item_factory_new (GTK_TYPE_MENU_BAR, "<bookmarks>", NULL, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1262 create_item_factory (ifactory, 7, menu_items, NULL);
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1263 create_item_factory (ifactory, 1, menu_items + 7, edit_bookmarks_dialog);
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1264 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (edit_bookmarks_dialog)->vbox),
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1265 ifactory->widget, FALSE, FALSE, 0);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1266 gtk_widget_show (ifactory->widget);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1267
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1268 scroll = gtk_scrolled_window_new (NULL, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1269 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1270 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1271 gtk_widget_set_size_request (scroll, 150, 200);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1272
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1273 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (edit_bookmarks_dialog)->vbox),
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1274 scroll, TRUE, TRUE, 0);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1275 gtk_container_border_width (GTK_CONTAINER (scroll), 3);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1276 gtk_widget_show (scroll);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1277
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1278 edit_factory = item_factory_new (GTK_TYPE_MENU, "<edit_bookmark>", NULL, "/File");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1279
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1280 create_item_factory (edit_factory, 6, menu_items + 2, edit_bookmarks_dialog);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1281
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1282 tree = gtk_ctree_new (1, 0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1283 gtk_clist_set_selection_mode (GTK_CLIST (tree), GTK_SELECTION_BROWSE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1284 gtk_clist_set_reorderable (GTK_CLIST (tree), 1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1285 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), tree);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1286 gtk_signal_connect_after (GTK_OBJECT (tree), "key_press_event",
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1287 GTK_SIGNAL_FUNC (bm_enter), (gpointer) tree);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1288 gtk_signal_connect_after (GTK_OBJECT (tree), "tree_move",
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1289 GTK_SIGNAL_FUNC (after_move), NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1290 gtk_signal_connect_after (GTK_OBJECT (tree), "button_press_event",
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1291 GTK_SIGNAL_FUNC (bm_dblclick), (gpointer) tree);
366
2e408d9918d4 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1292 gtk_ctree_set_drag_compare_func (GTK_CTREE(tree), &move_possible);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1293 gtk_widget_show (tree);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1294
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1295 #if GTK_MAJOR_VERSION == 1
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1296 tempwid = gtk_button_new_with_label (_("OK"));
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1297 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (edit_bookmarks_dialog)->action_area),
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1298 tempwid, TRUE, TRUE, 0);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1299 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1300 GTK_SIGNAL_FUNC (bm_apply_changes), NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1301 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1302 GTK_SIGNAL_FUNC (bm_close_dialog),
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1303 (gpointer) edit_bookmarks_dialog);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1304 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1305 gtk_widget_show (tempwid);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1306
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1307 tempwid = gtk_button_new_with_label (_(" Cancel "));
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1308 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (edit_bookmarks_dialog)->action_area),
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1309 tempwid, TRUE, TRUE, 0);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1310 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1311 GTK_SIGNAL_FUNC (bm_close_dialog),
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1312 (gpointer) edit_bookmarks_dialog);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1313 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1314 gtk_widget_grab_focus (tempwid);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1315 gtk_widget_show (tempwid);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1316 #else
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1317 g_signal_connect (GTK_OBJECT (edit_bookmarks_dialog), "response",
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1318 G_CALLBACK (editbm_action), NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1319 #endif
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1320
452
037e904642e8 2004-3-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
1321 gtk_widget_show (edit_bookmarks_dialog);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1322
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1323 build_bookmarks_tree ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1324 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
1325