Mercurial > gftp.yaz
comparison src/gtk/bookmarks.c @ 129:fe0b21c006f6
2003-4-13 Brian Masney <masneyb@gftp.org>
* lib/config_file.c - implemented gftp_set_global_option()
* lib/gftp.h lib/misc.c - added gftp_tdata_new()
* src/text/gftp-text.c src/gtk/transfer.c - use gftp_tdata_new()
* src/gtk/bookmarks.c - In run_bookmark(), use gftp_parse_bookmark()
function. Renamed all instances of gftp_bookmarks to
gftp_bookmarks_var
* src/gtk/gftp-gtk.[ch] - added global variables viewedit_processes
and viewedit_processes_done. These used to be declared in
lib/options.h
* src/gtk/gftp-gtk.h (struct gftp_window_data) - removed sortcol and
sortasds variables. Added prefix_col_str variable. This will either be
local or remote
* src/gtk/misc-gtk.c - removed r_gethostbyname() and r_getservbyname()
* src/gtk/transfer.c - removed gftp_gtk_calc_kbs(), get_status() and
parse_attribs(). These are in the lib/ directory now. Also, use
g_static_mutex_*() functions from glib instead of pthread_mutex_*()
* src/gtk/bookmark.c src/gtk/dnd.c src/gtk/menu-items.c
src/gtk/transfer.c - use g_strdup() instead of g_malloc()/strcpy()
* src/gtk/options_dialog.c - commented out large parts of this file.
This file is busted at the moment
* src/gtk/*.[ch] - Use new configuration interface in all source
files. Updated copyright dates on all source files
author | masneyb |
---|---|
date | Sun, 13 Apr 2003 15:21:13 +0000 |
parents | c226809c03c8 |
children | c505d9ba9d53 |
comparison
equal
deleted
inserted
replaced
128:7616ab674d4e | 129:fe0b21c006f6 |
---|---|
22 | 22 |
23 static GtkWidget * bm_hostedit, * bm_portedit, * bm_localdiredit, | 23 static GtkWidget * bm_hostedit, * bm_portedit, * bm_localdiredit, |
24 * bm_remotediredit, * bm_useredit, * bm_passedit, * bm_acctedit, * anon_chk, | 24 * bm_remotediredit, * bm_useredit, * bm_passedit, * bm_acctedit, * anon_chk, |
25 * bm_pathedit, * bm_protocol, * tree, *bm_sftppath; | 25 * bm_pathedit, * bm_protocol, * tree, *bm_sftppath; |
26 static GHashTable * new_bookmarks_htable; | 26 static GHashTable * new_bookmarks_htable; |
27 static gftp_bookmarks * new_bookmarks; | 27 static gftp_bookmarks_var * new_bookmarks; |
28 static GtkItemFactory * edit_factory; | 28 static GtkItemFactory * edit_factory; |
29 | 29 |
30 | 30 |
31 void | 31 void |
32 run_bookmark (gpointer data) | 32 run_bookmark (gpointer data) |
33 { | 33 { |
34 gftp_bookmarks * tempentry; | |
35 int i; | |
36 | |
37 if (window1.request->stopable || window2.request->stopable) | 34 if (window1.request->stopable || window2.request->stopable) |
38 { | 35 { |
39 ftp_log (gftp_logging_misc, NULL, | 36 ftp_log (gftp_logging_misc, NULL, |
40 _("%s: Please hit the stop button first to do anything else\n"), | 37 _("%s: Please hit the stop button first to do anything else\n"), |
41 _("Run Bookmark")); | 38 _("Run Bookmark")); |
42 return; | 39 return; |
43 } | 40 } |
44 | 41 |
45 if ((tempentry = g_hash_table_lookup (bookmarks_htable, (char *) data)) == NULL) | 42 if (gftp_parse_bookmark (current_wdata->request, (char *) data) < 0) |
46 { | 43 return; |
47 ftp_log (gftp_logging_misc, NULL, | |
48 _("Internal gFTP Error: Could not look up bookmark entry. This is definately a bug. Please email masneyb@gftp.org about it. Please be sure to include the version number and how you can reproduce it\n")); | |
49 return; | |
50 } | |
51 else if (tempentry->hostname == NULL || *tempentry->hostname == '\0' || | |
52 tempentry->user == NULL || *tempentry->user == '\0') | |
53 { | |
54 ftp_log (gftp_logging_misc, NULL, _("Bookmarks Error: There are some missing entries in this bookmark. Make sure you have a hostname and username\n")); | |
55 return; | |
56 } | |
57 | 44 |
58 if (GFTP_IS_CONNECTED (current_wdata->request)) | 45 if (GFTP_IS_CONNECTED (current_wdata->request)) |
59 disconnect (current_wdata); | 46 disconnect (current_wdata); |
60 | 47 |
61 if (tempentry->local_dir && *tempentry->local_dir != '\0') | |
62 { | |
63 gftp_set_directory (other_wdata->request, tempentry->local_dir); | |
64 gtk_clist_freeze (GTK_CLIST (other_wdata->listbox)); | |
65 remove_files_window (other_wdata); | |
66 ftp_list_files (other_wdata, 1); | |
67 gtk_clist_thaw (GTK_CLIST (other_wdata->listbox)); | |
68 } | |
69 | |
70 gftp_set_username (current_wdata->request, tempentry->user); | |
71 if (strncmp (tempentry->pass, "@EMAIL@", 7) == 0) | |
72 gftp_set_password (current_wdata->request, emailaddr); | |
73 else | |
74 gftp_set_password (current_wdata->request, tempentry->pass); | |
75 if (tempentry->acct != NULL) | |
76 gftp_set_account (current_wdata->request, tempentry->acct); | |
77 gftp_set_hostname (current_wdata->request, tempentry->hostname); | |
78 gftp_set_directory (current_wdata->request, tempentry->remote_dir); | |
79 gftp_set_port (current_wdata->request, tempentry->port); | |
80 gftp_set_sftpserv_path (current_wdata->request, tempentry->sftpserv_path); | |
81 | |
82 for (i = 0; gftp_protocols[i].name; i++) | |
83 { | |
84 if (strcmp (gftp_protocols[i].name, tempentry->protocol) == 0) | |
85 { | |
86 gftp_protocols[i].init (current_wdata->request); | |
87 break; | |
88 } | |
89 } | |
90 | |
91 if (!gftp_protocols[i].name) | |
92 gftp_protocols[0].init (current_wdata->request); | |
93 | |
94 ftp_connect (current_wdata, current_wdata->request, 1); | 48 ftp_connect (current_wdata, current_wdata->request, 1); |
95 } | 49 } |
96 | 50 |
97 | 51 |
98 static void | 52 static void |
99 doadd_bookmark (gpointer * data, gftp_dialog_data * ddata) | 53 doadd_bookmark (gpointer * data, gftp_dialog_data * ddata) |
100 { | 54 { |
101 GtkItemFactoryEntry test = { NULL, NULL, run_bookmark, 0 }; | 55 GtkItemFactoryEntry test = { NULL, NULL, run_bookmark, 0 }; |
102 const char *edttxt, *spos; | 56 const char *edttxt, *spos; |
103 gftp_bookmarks * tempentry; | 57 gftp_bookmarks_var * tempentry; |
104 char *dpos; | 58 char *dpos, *proto; |
105 | 59 |
106 edttxt = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); | 60 edttxt = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); |
107 if (*edttxt == '\0') | 61 if (*edttxt == '\0') |
108 { | 62 { |
109 ftp_log (gftp_logging_error, NULL, | 63 ftp_log (gftp_logging_error, NULL, |
110 _("Add Bookmark: You must enter a name for the bookmark\n")); | 64 _("Add Bookmark: You must enter a name for the bookmark\n")); |
111 return; | 65 return; |
112 } | 66 } |
113 | 67 |
114 if (g_hash_table_lookup (bookmarks_htable, edttxt) != NULL) | 68 if (g_hash_table_lookup (gftp_bookmarks_htable, edttxt) != NULL) |
115 { | 69 { |
116 ftp_log (gftp_logging_error, NULL, | 70 ftp_log (gftp_logging_error, NULL, |
117 _("Add Bookmark: Cannot add bookmark %s because that name already exists\n"), edttxt); | 71 _("Add Bookmark: Cannot add bookmark %s because that name already exists\n"), edttxt); |
118 return; | 72 return; |
119 } | 73 } |
131 } | 85 } |
132 } | 86 } |
133 *dpos = '\0'; | 87 *dpos = '\0'; |
134 | 88 |
135 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry)); | 89 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry)); |
136 tempentry->hostname = g_malloc (strlen (edttxt) + 1); | 90 tempentry->hostname = g_strdup (edttxt); |
137 strcpy (tempentry->hostname, edttxt); | |
138 | 91 |
139 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (portedit)->entry)); | 92 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (portedit)->entry)); |
140 tempentry->port = strtol (edttxt, NULL, 10); | 93 tempentry->port = strtol (edttxt, NULL, 10); |
141 | 94 |
142 tempentry->protocol = | 95 proto = gftp_protocols[current_wdata->request->protonum].name; |
143 g_malloc (strlen (GFTP_GET_PROTOCOL_NAME (current_wdata->request)) + 1); | 96 tempentry->protocol = g_strdup (proto); |
144 strcpy (tempentry->protocol, GFTP_GET_PROTOCOL_NAME (current_wdata->request)); | |
145 | 97 |
146 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (other_wdata->combo)->entry)); | 98 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (other_wdata->combo)->entry)); |
147 tempentry->local_dir = g_malloc (strlen (edttxt) + 1); | 99 tempentry->local_dir = g_strdup (edttxt); |
148 strcpy (tempentry->local_dir, edttxt); | |
149 | 100 |
150 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (current_wdata->combo)->entry)); | 101 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (current_wdata->combo)->entry)); |
151 tempentry->remote_dir = g_malloc (strlen (edttxt) + 1); | 102 tempentry->remote_dir = g_strdup (edttxt); |
152 strcpy (tempentry->remote_dir, edttxt); | |
153 | 103 |
154 if ((edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry))) != NULL) | 104 if ((edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry))) != NULL) |
155 { | 105 { |
156 tempentry->user = g_malloc (strlen (edttxt) + 1); | 106 tempentry->user = g_strdup (edttxt); |
157 strcpy (tempentry->user, edttxt); | |
158 | 107 |
159 edttxt = gtk_entry_get_text (GTK_ENTRY (passedit)); | 108 edttxt = gtk_entry_get_text (GTK_ENTRY (passedit)); |
160 tempentry->pass = g_malloc (strlen (edttxt) + 1); | 109 tempentry->pass = g_strdup (edttxt); |
161 strcpy (tempentry->pass, edttxt); | |
162 tempentry->save_password = GTK_TOGGLE_BUTTON (ddata->checkbox)->active; | 110 tempentry->save_password = GTK_TOGGLE_BUTTON (ddata->checkbox)->active; |
163 } | 111 } |
164 | 112 |
165 add_to_bookmark (tempentry); | 113 gftp_add_bookmark (tempentry); |
166 | 114 |
167 test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL); | 115 test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL); |
168 gtk_item_factory_create_item (factory, &test, (gpointer) tempentry->path, | 116 gtk_item_factory_create_item (factory, &test, (gpointer) tempentry->path, |
169 1); | 117 1); |
170 g_free (test.path); | 118 g_free (test.path); |
194 | 142 |
195 void | 143 void |
196 build_bookmarks_menu (void) | 144 build_bookmarks_menu (void) |
197 { | 145 { |
198 GtkItemFactoryEntry test = { NULL, NULL, NULL, 0 }; | 146 GtkItemFactoryEntry test = { NULL, NULL, NULL, 0 }; |
199 gftp_bookmarks * tempentry; | 147 gftp_bookmarks_var * tempentry; |
200 | 148 |
201 tempentry = bookmarks->children; | 149 tempentry = gftp_bookmarks->children; |
202 while (tempentry != NULL) | 150 while (tempentry != NULL) |
203 { | 151 { |
204 test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL); | 152 test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL); |
205 if (tempentry->isfolder) | 153 if (tempentry->isfolder) |
206 { | 154 { |
227 } | 175 } |
228 } | 176 } |
229 | 177 |
230 | 178 |
231 static void | 179 static void |
232 free_bookmark_entry_items (gftp_bookmarks * entry) | 180 free_bookmark_entry_items (gftp_bookmarks_var * entry) |
233 { | 181 { |
234 if (entry->hostname) | 182 if (entry->hostname) |
235 g_free (entry->hostname); | 183 g_free (entry->hostname); |
236 if (entry->remote_dir) | 184 if (entry->remote_dir) |
237 g_free (entry->remote_dir); | 185 g_free (entry->remote_dir); |
246 if (entry->protocol) | 194 if (entry->protocol) |
247 g_free (entry->protocol); | 195 g_free (entry->protocol); |
248 } | 196 } |
249 | 197 |
250 | 198 |
251 static gftp_bookmarks * | 199 static gftp_bookmarks_var * |
252 copy_bookmarks (gftp_bookmarks * bookmarks) | 200 copy_bookmarks (gftp_bookmarks_var * bookmarks) |
253 { | 201 { |
254 gftp_bookmarks * new_bm, * preventry, * tempentry, * sibling, * newentry, | 202 gftp_bookmarks_var * new_bm, * preventry, * tempentry, * sibling, * newentry, |
255 * tentry; | 203 * tentry; |
256 | 204 |
257 new_bm = g_malloc0 (sizeof (*new_bm)); | 205 new_bm = g_malloc0 (sizeof (*new_bm)); |
258 /* FIXME - memory leak */ | 206 /* FIXME - memory leak */ |
259 new_bm->path = g_malloc0 (1); | 207 new_bm->path = g_malloc0 (1); |
266 newentry = g_malloc0 (sizeof (*newentry)); | 214 newentry = g_malloc0 (sizeof (*newentry)); |
267 newentry->isfolder = tempentry->isfolder; | 215 newentry->isfolder = tempentry->isfolder; |
268 newentry->save_password = tempentry->save_password; | 216 newentry->save_password = tempentry->save_password; |
269 newentry->cnode = tempentry->cnode; | 217 newentry->cnode = tempentry->cnode; |
270 if (tempentry->path) | 218 if (tempentry->path) |
271 { | 219 newentry->path = g_strdup (tempentry->path); |
272 newentry->path = g_malloc (strlen (tempentry->path) + 1); | 220 |
273 strcpy (newentry->path, tempentry->path); | |
274 } | |
275 if (tempentry->hostname) | 221 if (tempentry->hostname) |
276 { | 222 newentry->hostname = g_strdup (tempentry->hostname); |
277 newentry->hostname = g_malloc (strlen (tempentry->hostname) + 1); | 223 |
278 strcpy (newentry->hostname, tempentry->hostname); | |
279 } | |
280 if (tempentry->protocol) | 224 if (tempentry->protocol) |
281 { | 225 newentry->protocol = g_strdup (tempentry->protocol); |
282 newentry->protocol = g_malloc (strlen (tempentry->protocol) + 1); | 226 |
283 strcpy (newentry->protocol, tempentry->protocol); | |
284 } | |
285 if (tempentry->local_dir) | 227 if (tempentry->local_dir) |
286 { | 228 newentry->local_dir = g_strdup (tempentry->local_dir); |
287 newentry->local_dir = g_malloc (strlen (tempentry->local_dir) + 1); | 229 |
288 strcpy (newentry->local_dir, tempentry->local_dir); | |
289 } | |
290 if (tempentry->remote_dir) | 230 if (tempentry->remote_dir) |
291 { | 231 newentry->remote_dir = g_strdup (tempentry->remote_dir); |
292 newentry->remote_dir = | 232 |
293 g_malloc (strlen (tempentry->remote_dir) + 1); | |
294 strcpy (newentry->remote_dir, tempentry->remote_dir); | |
295 } | |
296 if (tempentry->user) | 233 if (tempentry->user) |
297 { | 234 newentry->user = g_strdup (tempentry->user); |
298 newentry->user = g_malloc (strlen (tempentry->user) + 1); | 235 |
299 strcpy (newentry->user, tempentry->user); | |
300 } | |
301 if (tempentry->pass) | 236 if (tempentry->pass) |
302 { | 237 newentry->pass = g_strdup (tempentry->pass); |
303 newentry->pass = g_malloc (strlen (tempentry->pass) + 1); | 238 |
304 strcpy (newentry->pass, tempentry->pass); | |
305 } | |
306 if (tempentry->acct) | 239 if (tempentry->acct) |
307 { | 240 newentry->acct = g_strdup (tempentry->acct); |
308 newentry->acct = g_malloc (strlen (tempentry->acct) + 1); | 241 |
309 strcpy (newentry->acct, tempentry->acct); | |
310 } | |
311 if (tempentry->sftpserv_path) | |
312 { | |
313 newentry->sftpserv_path = g_malloc (strlen (tempentry->sftpserv_path) + 1); | |
314 strcpy (newentry->sftpserv_path, tempentry->sftpserv_path); | |
315 } | |
316 newentry->port = tempentry->port; | 242 newentry->port = tempentry->port; |
317 | 243 |
318 if (sibling == NULL) | 244 if (sibling == NULL) |
319 { | 245 { |
320 if (preventry->children == NULL) | 246 if (preventry->children == NULL) |
361 | 287 |
362 | 288 |
363 static void | 289 static void |
364 bm_apply_changes (GtkWidget * widget, gpointer backup_data) | 290 bm_apply_changes (GtkWidget * widget, gpointer backup_data) |
365 { | 291 { |
366 gftp_bookmarks * tempentry, * delentry; | 292 gftp_bookmarks_var * tempentry, * delentry; |
367 char *tempstr; | 293 char *tempstr; |
368 | 294 |
369 tempentry = bookmarks->children; | 295 tempentry = gftp_bookmarks->children; |
370 while (tempentry != NULL) | 296 while (tempentry != NULL) |
371 { | 297 { |
372 if (tempentry->path && !tempentry->isfolder) | 298 if (tempentry->path && !tempentry->isfolder) |
373 { | 299 { |
374 tempstr = g_strdup_printf ("/Bookmarks/%s", tempentry->path); | 300 tempstr = g_strdup_printf ("/Bookmarks/%s", tempentry->path); |
419 tempentry = tempentry->next; | 345 tempentry = tempentry->next; |
420 g_free (delentry); | 346 g_free (delentry); |
421 } | 347 } |
422 } | 348 } |
423 } | 349 } |
424 g_free (bookmarks); | 350 g_free (gftp_bookmarks); |
425 g_hash_table_destroy (bookmarks_htable); | 351 g_hash_table_destroy (gftp_bookmarks_htable); |
426 | 352 |
427 bookmarks = new_bookmarks; | 353 gftp_bookmarks = new_bookmarks; |
428 bookmarks_htable = new_bookmarks_htable; | 354 gftp_bookmarks_htable = new_bookmarks_htable; |
429 if (backup_data) | 355 if (backup_data) |
430 { | 356 { |
431 new_bookmarks = copy_bookmarks (bookmarks); | 357 new_bookmarks = copy_bookmarks (gftp_bookmarks); |
432 new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks); | 358 new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks); |
433 } | 359 } |
434 else | 360 else |
435 { | 361 { |
436 new_bookmarks = NULL; | 362 new_bookmarks = NULL; |
442 | 368 |
443 | 369 |
444 static void | 370 static void |
445 bm_close_dialog (GtkWidget * widget, GtkWidget * dialog) | 371 bm_close_dialog (GtkWidget * widget, GtkWidget * dialog) |
446 { | 372 { |
447 gftp_bookmarks * tempentry, * delentry; | 373 gftp_bookmarks_var * tempentry, * delentry; |
448 | 374 |
449 if (new_bookmarks_htable) | 375 if (new_bookmarks_htable) |
450 g_hash_table_destroy (new_bookmarks_htable); | 376 g_hash_table_destroy (new_bookmarks_htable); |
451 | 377 |
452 tempentry = new_bookmarks; | 378 tempentry = new_bookmarks; |
498 static void | 424 static void |
499 do_make_new (gpointer data, gftp_dialog_data * ddata) | 425 do_make_new (gpointer data, gftp_dialog_data * ddata) |
500 { | 426 { |
501 GdkPixmap * closedir_pixmap, * opendir_pixmap; | 427 GdkPixmap * closedir_pixmap, * opendir_pixmap; |
502 GdkBitmap * closedir_bitmap, * opendir_bitmap; | 428 GdkBitmap * closedir_bitmap, * opendir_bitmap; |
503 gftp_bookmarks * tempentry, * newentry; | 429 gftp_bookmarks_var * tempentry, * newentry; |
504 GtkCTreeNode * sibling; | 430 GtkCTreeNode * sibling; |
505 char *pos, *text[2]; | 431 char *pos, *text[2]; |
506 const char *str; | 432 const char *str; |
507 #if GTK_MAJOR_VERSION > 1 | 433 #if GTK_MAJOR_VERSION > 1 |
508 gsize bread, bwrite; | 434 gsize bread, bwrite; |
585 do_make_new, NULL, NULL, NULL); | 511 do_make_new, NULL, NULL, NULL); |
586 } | 512 } |
587 | 513 |
588 | 514 |
589 static void | 515 static void |
590 do_delete_entry (gftp_bookmarks * entry, gftp_dialog_data * ddata) | 516 do_delete_entry (gftp_bookmarks_var * entry, gftp_dialog_data * ddata) |
591 { | 517 { |
592 gftp_bookmarks * tempentry, * delentry; | 518 gftp_bookmarks_var * tempentry, * delentry; |
593 | 519 |
594 g_hash_table_remove (new_bookmarks_htable, entry->path); | 520 g_hash_table_remove (new_bookmarks_htable, entry->path); |
595 gtk_ctree_remove_node (GTK_CTREE (tree), entry->cnode); | 521 gtk_ctree_remove_node (GTK_CTREE (tree), entry->cnode); |
596 if (entry->prev->children == entry) | 522 if (entry->prev->children == entry) |
597 entry->prev->children = entry->prev->children->next; | 523 entry->prev->children = entry->prev->children->next; |
642 | 568 |
643 | 569 |
644 static void | 570 static void |
645 delete_entry (gpointer data) | 571 delete_entry (gpointer data) |
646 { | 572 { |
647 gftp_bookmarks * entry; | 573 gftp_bookmarks_var * entry; |
648 char *tempstr, *pos; | 574 char *tempstr, *pos; |
649 | 575 |
650 if (GTK_CLIST (tree)->selection == NULL) | 576 if (GTK_CLIST (tree)->selection == NULL) |
651 return; | 577 return; |
652 entry = | 578 entry = |
684 static void | 610 static void |
685 build_bookmarks_tree (void) | 611 build_bookmarks_tree (void) |
686 { | 612 { |
687 GdkPixmap * closedir_pixmap, * opendir_pixmap; | 613 GdkPixmap * closedir_pixmap, * opendir_pixmap; |
688 GdkBitmap * closedir_bitmap, * opendir_bitmap; | 614 GdkBitmap * closedir_bitmap, * opendir_bitmap; |
689 gftp_bookmarks * tempentry, * preventry; | 615 gftp_bookmarks_var * tempentry, * preventry; |
690 char *pos, *prevpos, *text[2], *str; | 616 char *pos, *prevpos, *text[2], *str; |
691 GtkCTreeNode * parent; | 617 GtkCTreeNode * parent; |
692 | 618 |
693 gftp_get_pixmap (tree, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap); | 619 gftp_get_pixmap (tree, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap); |
694 gftp_get_pixmap (tree, "dir.xpm", &closedir_pixmap, &closedir_bitmap); | 620 gftp_get_pixmap (tree, "dir.xpm", &closedir_pixmap, &closedir_bitmap); |
712 { | 638 { |
713 pos = tempentry->path; | 639 pos = tempentry->path; |
714 while ((pos = strchr (pos, '/')) != NULL) | 640 while ((pos = strchr (pos, '/')) != NULL) |
715 { | 641 { |
716 *pos = '\0'; | 642 *pos = '\0'; |
717 str = g_malloc (strlen (tempentry->path) + 1); | 643 str = g_strdup (tempentry->path); |
718 strcpy (str, tempentry->path); | |
719 *pos = '/'; | 644 *pos = '/'; |
720 preventry = g_hash_table_lookup (new_bookmarks_htable, str); | 645 preventry = g_hash_table_lookup (new_bookmarks_htable, str); |
721 if (preventry->cnode == NULL) | 646 if (preventry->cnode == NULL) |
722 { | 647 { |
723 if ((prevpos = strrchr (str, '/')) == NULL) | 648 if ((prevpos = strrchr (str, '/')) == NULL) |
759 | 684 |
760 | 685 |
761 static void | 686 static void |
762 clear_bookmarks_tree (void) | 687 clear_bookmarks_tree (void) |
763 { | 688 { |
764 gftp_bookmarks * tempentry; | 689 gftp_bookmarks_var * tempentry; |
765 | 690 |
766 tempentry = new_bookmarks->children; | 691 tempentry = new_bookmarks->children; |
767 while (tempentry != NULL) | 692 while (tempentry != NULL) |
768 { | 693 { |
769 if (tempentry->children != NULL) | 694 if (tempentry->children != NULL) |
783 } | 708 } |
784 } | 709 } |
785 | 710 |
786 | 711 |
787 static void | 712 static void |
788 entry_apply_changes (GtkWidget * widget, gftp_bookmarks * entry) | 713 entry_apply_changes (GtkWidget * widget, gftp_bookmarks_var * entry) |
789 { | 714 { |
790 char *pos, *newpath, tempchar, *tempstr, *origpath; | 715 char *pos, *newpath, tempchar, *tempstr, *origpath; |
791 gftp_bookmarks * tempentry, * nextentry; | 716 gftp_bookmarks_var * tempentry, * nextentry; |
792 GtkWidget * tempwid; | 717 GtkWidget * tempwid; |
793 const char *str; | 718 const char *str; |
794 int oldpathlen; | 719 int oldpathlen; |
795 | 720 |
796 oldpathlen = strlen (entry->path); | 721 oldpathlen = strlen (entry->path); |
812 *pos = tempchar; | 737 *pos = tempchar; |
813 | 738 |
814 str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit)); | 739 str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit)); |
815 if (entry->hostname) | 740 if (entry->hostname) |
816 g_free (entry->hostname); | 741 g_free (entry->hostname); |
817 entry->hostname = g_malloc (strlen (str) + 1); | 742 entry->hostname = g_strdup (str); |
818 strcpy (entry->hostname, str); | |
819 | 743 |
820 str = gtk_entry_get_text (GTK_ENTRY (bm_portedit)); | 744 str = gtk_entry_get_text (GTK_ENTRY (bm_portedit)); |
821 entry->port = strtol (str, NULL, 10); | 745 entry->port = strtol (str, NULL, 10); |
822 | 746 |
823 tempwid = gtk_menu_get_active (GTK_MENU (bm_protocol)); | 747 tempwid = gtk_menu_get_active (GTK_MENU (bm_protocol)); |
824 str = gtk_object_get_user_data (GTK_OBJECT (tempwid)); | 748 str = gtk_object_get_user_data (GTK_OBJECT (tempwid)); |
825 if (entry->protocol) | 749 if (entry->protocol) |
826 g_free (entry->protocol); | 750 g_free (entry->protocol); |
827 entry->protocol = g_malloc (strlen (str) + 1); | 751 entry->protocol = g_strdup (str); |
828 strcpy (entry->protocol, str); | |
829 | 752 |
830 str = gtk_entry_get_text (GTK_ENTRY (bm_remotediredit)); | 753 str = gtk_entry_get_text (GTK_ENTRY (bm_remotediredit)); |
831 if (entry->remote_dir) | 754 if (entry->remote_dir) |
832 g_free (entry->remote_dir); | 755 g_free (entry->remote_dir); |
833 entry->remote_dir = g_malloc (strlen (str) + 1); | 756 entry->remote_dir = g_strdup (str); |
834 strcpy (entry->remote_dir, str); | |
835 | 757 |
836 str = gtk_entry_get_text (GTK_ENTRY (bm_localdiredit)); | 758 str = gtk_entry_get_text (GTK_ENTRY (bm_localdiredit)); |
837 if (entry->local_dir) | 759 if (entry->local_dir) |
838 g_free (entry->local_dir); | 760 g_free (entry->local_dir); |
839 entry->local_dir = g_malloc (strlen (str) + 1); | 761 entry->local_dir = g_strdup (str); |
840 strcpy (entry->local_dir, str); | |
841 | |
842 str = gtk_entry_get_text (GTK_ENTRY (bm_sftppath)); | |
843 if (entry->sftpserv_path) | |
844 g_free (entry->sftpserv_path); | |
845 if (strlen (str) > 0) | |
846 { | |
847 entry->sftpserv_path = g_malloc (strlen (str) + 1); | |
848 strcpy (entry->sftpserv_path, str); | |
849 } | |
850 else | |
851 entry->sftpserv_path = NULL; | |
852 | 762 |
853 if (GTK_TOGGLE_BUTTON (anon_chk)->active) | 763 if (GTK_TOGGLE_BUTTON (anon_chk)->active) |
854 str = "anonymous"; | 764 str = "anonymous"; |
855 else | 765 else |
856 str = gtk_entry_get_text (GTK_ENTRY (bm_useredit)); | 766 str = gtk_entry_get_text (GTK_ENTRY (bm_useredit)); |
857 if (entry->user) | 767 if (entry->user) |
858 g_free (entry->user); | 768 g_free (entry->user); |
859 entry->user = g_malloc (strlen (str) + 1); | 769 entry->user = g_strdup (str); |
860 strcpy (entry->user, str); | |
861 | 770 |
862 if (GTK_TOGGLE_BUTTON (anon_chk)->active) | 771 if (GTK_TOGGLE_BUTTON (anon_chk)->active) |
863 str = "@EMAIL@"; | 772 str = "@EMAIL@"; |
864 else | 773 else |
865 str = gtk_entry_get_text (GTK_ENTRY (bm_passedit)); | 774 str = gtk_entry_get_text (GTK_ENTRY (bm_passedit)); |
866 if (entry->pass) | 775 if (entry->pass) |
867 g_free (entry->pass); | 776 g_free (entry->pass); |
868 entry->pass = g_malloc (strlen (str) + 1); | 777 entry->pass = g_strdup (str); |
869 strcpy (entry->pass, str); | |
870 entry->save_password = *entry->pass != '\0'; | 778 entry->save_password = *entry->pass != '\0'; |
871 | 779 |
872 if (GTK_TOGGLE_BUTTON (anon_chk)->active) | 780 if (GTK_TOGGLE_BUTTON (anon_chk)->active) |
873 str = ""; | 781 str = ""; |
874 else | 782 else |
875 str = gtk_entry_get_text (GTK_ENTRY (bm_acctedit)); | 783 str = gtk_entry_get_text (GTK_ENTRY (bm_acctedit)); |
876 if (entry->acct) | 784 if (entry->acct) |
877 g_free (entry->acct); | 785 g_free (entry->acct); |
878 entry->acct = g_malloc (strlen (str) + 1); | 786 entry->acct = g_strdup (str); |
879 strcpy (entry->acct, str); | |
880 | 787 |
881 if (strcmp (entry->path, newpath) != 0) | 788 if (strcmp (entry->path, newpath) != 0) |
882 { | 789 { |
883 tempentry = entry; | 790 tempentry = entry; |
884 nextentry = entry->next; | 791 nextentry = entry->next; |
934 | 841 |
935 static void | 842 static void |
936 edit_entry (gpointer data) | 843 edit_entry (gpointer data) |
937 { | 844 { |
938 GtkWidget * table, * tempwid, * dialog, * menu; | 845 GtkWidget * table, * tempwid, * dialog, * menu; |
939 gftp_bookmarks * entry; | 846 gftp_bookmarks_var * entry; |
940 int i, num; | 847 int i, num; |
941 char *pos; | 848 char *pos; |
942 | 849 |
943 if (GTK_CLIST (tree)->selection == NULL) | 850 if (GTK_CLIST (tree)->selection == NULL) |
944 return; | 851 return; |
1216 static void | 1123 static void |
1217 after_move (GtkCTree * ctree, GtkCTreeNode * child, GtkCTreeNode * parent, | 1124 after_move (GtkCTree * ctree, GtkCTreeNode * child, GtkCTreeNode * parent, |
1218 GtkCTreeNode * sibling, gpointer data) | 1125 GtkCTreeNode * sibling, gpointer data) |
1219 { | 1126 { |
1220 | 1127 |
1221 gftp_bookmarks * childentry, * siblingentry, * parententry, * tempentry; | 1128 gftp_bookmarks_var * childentry, * siblingentry, * parententry, * tempentry; |
1222 char *tempstr, *pos, *stpos; | 1129 char *tempstr, *pos, *stpos; |
1223 | 1130 |
1224 childentry = gtk_ctree_node_get_row_data (ctree, child); | 1131 childentry = gtk_ctree_node_get_row_data (ctree, child); |
1225 parententry = gtk_ctree_node_get_row_data (ctree, parent); | 1132 parententry = gtk_ctree_node_get_row_data (ctree, parent); |
1226 siblingentry = gtk_ctree_node_get_row_data (ctree, sibling); | 1133 siblingentry = gtk_ctree_node_get_row_data (ctree, sibling); |
1267 else | 1174 else |
1268 pos++; | 1175 pos++; |
1269 tempstr = g_strdup_printf ("%s/%s", tempentry->prev->path, pos); | 1176 tempstr = g_strdup_printf ("%s/%s", tempentry->prev->path, pos); |
1270 for (stpos = tempstr; *stpos == '/'; stpos++); | 1177 for (stpos = tempstr; *stpos == '/'; stpos++); |
1271 g_free (tempentry->path); | 1178 g_free (tempentry->path); |
1272 tempentry->path = g_malloc (strlen (stpos) + 1); | 1179 tempentry->path = g_strdup (stpos); |
1273 strcpy (tempentry->path, stpos); | |
1274 g_free (tempstr); | 1180 g_free (tempstr); |
1275 g_hash_table_insert (new_bookmarks_htable, tempentry->path, | 1181 g_hash_table_insert (new_bookmarks_htable, tempentry->path, |
1276 tempentry); | 1182 tempentry); |
1277 if (tempentry->children != NULL) | 1183 if (tempentry->children != NULL) |
1278 tempentry = tempentry->children; | 1184 tempentry = tempentry->children; |
1328 }; | 1234 }; |
1329 #if GTK_MAJOR_VERSION == 1 | 1235 #if GTK_MAJOR_VERSION == 1 |
1330 GtkWidget * tempwid; | 1236 GtkWidget * tempwid; |
1331 #endif | 1237 #endif |
1332 | 1238 |
1333 new_bookmarks = copy_bookmarks (bookmarks); | 1239 new_bookmarks = copy_bookmarks (gftp_bookmarks); |
1334 new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks); | 1240 new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks); |
1335 | 1241 |
1336 #if GTK_MAJOR_VERSION == 1 | 1242 #if GTK_MAJOR_VERSION == 1 |
1337 dialog = gtk_dialog_new (); | 1243 dialog = gtk_dialog_new (); |
1338 gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Bookmarks")); | 1244 gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Bookmarks")); |