comparison src/gtk/bookmarks.c @ 7:5551ab2301fe

* Fixed a DND crash * When running a SSH bookmark, make sure need_userpass is enabled for that connection * moved anonymous ftp stuff from gtk port to rfc959.c * call bind_textdomain_codeset in gtk+ port * translation fixes for menus (from Owen Taylor <otaylor@redhat.com>)
author masneyb
date Fri, 23 Aug 2002 12:40:44 +0000
parents 8b1883341c6f
children 3b2dcdefc7e9
comparison
equal deleted inserted replaced
6:5678b5179c35 7:5551ab2301fe
121 } 121 }
122 122
123 if (!gftp_protocols[i].name) 123 if (!gftp_protocols[i].name)
124 gftp_protocols[0].init (current_wdata->request); 124 gftp_protocols[0].init (current_wdata->request);
125 125
126 /* If we're using one of the SSH protocols, override the value of
127 ssh_need_userpass in the config file */
128 if (strncmp (tempentry->protocol, "SSH", 3) == 0)
129 current_wdata->request->need_userpass = 1;
130
126 ftp_connect (current_wdata, current_wdata->request, 1); 131 ftp_connect (current_wdata, current_wdata->request, 1);
127 } 132 }
128 133
129 void 134 void
130 add_bookmark (gpointer data) 135 add_bookmark (gpointer data)
200 205
201 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (current_wdata->combo)->entry)); 206 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (current_wdata->combo)->entry));
202 tempentry->remote_dir = g_malloc (strlen (edttxt) + 1); 207 tempentry->remote_dir = g_malloc (strlen (edttxt) + 1);
203 strcpy (tempentry->remote_dir, edttxt); 208 strcpy (tempentry->remote_dir, edttxt);
204 209
205 if ((edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry))) == NULL) 210 if ((edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry))) != NULL)
206 {
207 tempentry->user = g_malloc (10);
208 strcpy (tempentry->user, "anonymous");
209
210 tempentry->pass = g_malloc (strlen (emailaddr) + 1);
211 strcpy (tempentry->pass, emailaddr);
212 }
213 else
214 { 211 {
215 tempentry->user = g_malloc (strlen (edttxt) + 1); 212 tempentry->user = g_malloc (strlen (edttxt) + 1);
216 strcpy (tempentry->user, edttxt); 213 strcpy (tempentry->user, edttxt);
217 214
218 edttxt = gtk_entry_get_text (GTK_ENTRY (passedit)); 215 edttxt = gtk_entry_get_text (GTK_ENTRY (passedit));
221 tempentry->save_password = GTK_TOGGLE_BUTTON (data->checkbox)->active; 218 tempentry->save_password = GTK_TOGGLE_BUTTON (data->checkbox)->active;
222 } 219 }
223 220
224 add_to_bookmark (tempentry); 221 add_to_bookmark (tempentry);
225 222
226 test.path = g_strconcat (_("/Bookmarks/"), tempentry->path, NULL); 223 test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL);
227 gtk_item_factory_create_item (factory, &test, (gpointer) tempentry->path, 224 gtk_item_factory_create_item (factory, &test, (gpointer) tempentry->path,
228 1); 225 1);
229 g_free (test.path); 226 g_free (test.path);
230 gftp_write_config_file (); 227 gftp_write_config_file ();
231 } 228 }
238 gftp_bookmarks * tempentry; 235 gftp_bookmarks * tempentry;
239 236
240 tempentry = bookmarks->children; 237 tempentry = bookmarks->children;
241 while (tempentry != NULL) 238 while (tempentry != NULL)
242 { 239 {
243 test.path = g_strconcat (_("/Bookmarks/"), tempentry->path, NULL); 240 test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL);
244 if (tempentry->isfolder) 241 if (tempentry->isfolder)
245 { 242 {
246 test.item_type = "<Branch>"; 243 test.item_type = "<Branch>";
247 test.callback = NULL; 244 test.callback = NULL;
248 } 245 }
270 void 267 void
271 edit_bookmarks (gpointer data) 268 edit_bookmarks (gpointer data)
272 { 269 {
273 GtkWidget * dialog, * scroll, * tempwid; 270 GtkWidget * dialog, * scroll, * tempwid;
274 GtkItemFactory * ifactory; 271 GtkItemFactory * ifactory;
275 GtkItemFactoryEntry dummy_item, menu_items[] = { 272 GtkItemFactoryEntry menu_items[] = {
276 {N_("/_File"), NULL, 0, 0, "<Branch>"}, 273 {N_("/_File"), NULL, 0, 0, "<Branch>"},
277 {N_("/File/tearoff"), NULL, 0, 0, "<Tearoff>"}, 274 {N_("/File/tearoff"), NULL, 0, 0, "<Tearoff>"},
278 {N_("/File/New Folder..."), NULL, new_folder_entry, 0}, 275 {N_("/File/New Folder..."), NULL, new_folder_entry, 0},
279 {N_("/File/New Item..."), NULL, new_item_entry, 0}, 276 {N_("/File/New Item..."), NULL, new_item_entry, 0},
280 {N_("/File/Delete"), NULL, delete_entry, 0}, 277 {N_("/File/Delete"), NULL, delete_entry, 0},
281 {N_("/File/Properties..."), NULL, edit_entry, 0}, 278 {N_("/File/Properties..."), NULL, edit_entry, 0},
282 {N_("/File/sep"), NULL, 0, 0, "<Separator>"}, 279 {N_("/File/sep"), NULL, 0, 0, "<Separator>"},
283 {N_("/File/Close"), NULL, gtk_widget_destroy, 0} 280 {N_("/File/Close"), NULL, gtk_widget_destroy, 0}
284 }; 281 };
285 int i;
286 282
287 new_bookmarks = copy_bookmarks (bookmarks); 283 new_bookmarks = copy_bookmarks (bookmarks);
288 new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks); 284 new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks);
289 285
290 dialog = gtk_dialog_new (); 286 dialog = gtk_dialog_new ();
291 gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Bookmarks")); 287 gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Bookmarks"));
292 gtk_window_set_wmclass (GTK_WINDOW(dialog), "Edit Bookmarks", "gFTP"); 288 gtk_window_set_wmclass (GTK_WINDOW(dialog), "Edit Bookmarks", "gFTP");
293 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); 289 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15);
294 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); 290 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
295 291
296 ifactory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<bookmarks>", NULL); 292 ifactory = item_factory_new (GTK_TYPE_MENU_BAR, "<bookmarks>", NULL, NULL);
297 create_item_factory (ifactory, 7, menu_items, NULL); 293 create_item_factory (ifactory, 7, menu_items, NULL);
298 create_item_factory (ifactory, 1, menu_items + 7, dialog); 294 create_item_factory (ifactory, 1, menu_items + 7, dialog);
299 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), ifactory->widget, 295 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), ifactory->widget,
300 FALSE, FALSE, 0); 296 FALSE, FALSE, 0);
301 gtk_widget_show (ifactory->widget); 297 gtk_widget_show (ifactory->widget);
308 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scroll, TRUE, TRUE, 304 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scroll, TRUE, TRUE,
309 0); 305 0);
310 gtk_container_border_width (GTK_CONTAINER (scroll), 3); 306 gtk_container_border_width (GTK_CONTAINER (scroll), 3);
311 gtk_widget_show (scroll); 307 gtk_widget_show (scroll);
312 308
313 edit_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<edit_bookmark>", NULL); 309 edit_factory = item_factory_new (GTK_TYPE_MENU, "<edit_bookmark>", NULL, "/File");
314 for (i = 2; i < 8; i++) 310
315 { 311 create_item_factory (edit_factory, 6, menu_items + 2, dialog);
316 memcpy (&dummy_item, menu_items + i, sizeof (dummy_item));
317 dummy_item.path = strrchr (_(dummy_item.path), '/');
318 gtk_item_factory_create_item (edit_factory, &dummy_item, dialog, 1);
319 }
320 312
321 tree = gtk_ctree_new (1, 0); 313 tree = gtk_ctree_new (1, 0);
322 gtk_clist_set_selection_mode (GTK_CLIST (tree), GTK_SELECTION_BROWSE); 314 gtk_clist_set_selection_mode (GTK_CLIST (tree), GTK_SELECTION_BROWSE);
323 gtk_clist_set_reorderable (GTK_CLIST (tree), 1); 315 gtk_clist_set_reorderable (GTK_CLIST (tree), 1);
324 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), tree); 316 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), tree);
374 tempentry = bookmarks->children; 366 tempentry = bookmarks->children;
375 while (tempentry != NULL) 367 while (tempentry != NULL)
376 { 368 {
377 if (tempentry->path && !tempentry->isfolder) 369 if (tempentry->path && !tempentry->isfolder)
378 { 370 {
379 tempstr = g_strdup_printf (_("/Bookmarks/%s"), tempentry->path); 371 tempstr = g_strdup_printf ("/Bookmarks/%s", tempentry->path);
380 gtk_widget_destroy (gtk_item_factory_get_item (factory, tempstr)); 372 gtk_widget_destroy (gtk_item_factory_get_item (factory, tempstr));
381 g_free (tempentry->path); 373 g_free (tempentry->path);
382 g_free (tempstr); 374 g_free (tempstr);
383 } 375 }
384 if (tempentry->hostname) 376 if (tempentry->hostname)
406 { 398 {
407 delentry = tempentry; 399 delentry = tempentry;
408 tempentry = tempentry->prev; 400 tempentry = tempentry->prev;
409 if (delentry->isfolder) 401 if (delentry->isfolder)
410 { 402 {
411 tempstr = g_strdup_printf (_("/Bookmarks/%s"), 403 tempstr = g_strdup_printf ("/Bookmarks/%s",
412 delentry->path); 404 delentry->path);
413 gtk_widget_destroy (gtk_item_factory_get_item (factory, 405 gtk_widget_destroy (gtk_item_factory_get_item (factory,
414 tempstr)); 406 tempstr));
415 g_free (tempstr); 407 g_free (tempstr);
416 g_free (delentry->path); 408 g_free (delentry->path);
419 } 411 }
420 delentry = tempentry; 412 delentry = tempentry;
421 tempentry = tempentry->next; 413 tempentry = tempentry->next;
422 if (delentry->isfolder && tempentry != NULL) 414 if (delentry->isfolder && tempentry != NULL)
423 { 415 {
424 tempstr = g_strdup_printf (_("/Bookmarks/%s"), 416 tempstr = g_strdup_printf ("/Bookmarks/%s",
425 delentry->path); 417 delentry->path);
426 gtk_widget_destroy (gtk_item_factory_get_item (factory, 418 gtk_widget_destroy (gtk_item_factory_get_item (factory,
427 tempstr)); 419 tempstr));
428 g_free (delentry->path); 420 g_free (delentry->path);
429 g_free (tempstr); 421 g_free (tempstr);