Mercurial > gftp.yaz
changeset 19:3b2dcdefc7e9
2002-09-15 Brian Masney <masneyb@gftp.org>
* lib/gftp.h (struct gftp_transfer) - changed the type of numfiles and
numdirs from unsigned long to long. This must be a signed field. This
is a bug I introduced a few days ago.
* lib/local.c (local_put_file) - remove the + off of the ab mode to
fdopen. This is also a bug I introduced a few days ago.
* src/gtk/transfer.c (gftp_gtk_calc_kbs) - make sure that the variable
difftime isn't a negative number when computing the KB/s
* src/gtk/menu-items.c (save_directory_listing) - remove casts to
GTK_OBJECT for the str variable
* src/gtk/gftp-gtk.c - use GTK_STOCK_* icons in place of left.xpm,
right.xpm, up.xpm, down.xpm and stop.xpm in GTK+ 2.0 port
* src/gtk/bookmarks.c - show GTK_STOCK_* icons on the popup menu
* src/gtk/bookmarks.c, src/gtk/chmod_dialog.c, src/gtk/menu-items.c,
src/gtk/misc-gtk.c, src/gtk/options_dialog.c and
src/gtk/view_dialog.c - use gtk_dialog_new_with_buttons in GTK+ 2.0
port to create the dialog. Also, associate gFTP icon with this dialog
* src/gtk/misc-gtk.c - changed the interface of MakeEditDialog and
MakeYesNoDialog. In the GTK+ 2.0 port, I now use stock icons in the
dialog buttons.
author | masneyb |
---|---|
date | Mon, 16 Sep 2002 12:27:50 +0000 |
parents | 6b2e606554aa |
children | 3d8380283d0c |
files | ChangeLog configure lib/gftp.h lib/local.c src/gtk/bookmarks.c src/gtk/chmod_dialog.c src/gtk/delete_dialog.c src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/mkdir_dialog.c src/gtk/options_dialog.c src/gtk/rename_dialog.c src/gtk/transfer.c src/gtk/view_dialog.c |
diffstat | 16 files changed, 847 insertions(+), 593 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Sep 11 10:26:13 2002 +0000 +++ b/ChangeLog Mon Sep 16 12:27:50 2002 +0000 @@ -1,4 +1,32 @@ -2002-09-11 Marius Andreiana <mandreiana@yahoo.com> +2002-09-15 Brian Masney <masneyb@gftp.org> + * lib/gftp.h (struct gftp_transfer) - changed the type of numfiles and + numdirs from unsigned long to long. This must be a signed field. This + is a bug I introduced a few days ago. + + * lib/local.c (local_put_file) - remove the + off of the ab mode to + fdopen. This is also a bug I introduced a few days ago. + + * src/gtk/transfer.c (gftp_gtk_calc_kbs) - make sure that the variable + difftime isn't a negative number when computing the KB/s + + * src/gtk/menu-items.c (save_directory_listing) - remove casts to + GTK_OBJECT for the str variable + + * src/gtk/gftp-gtk.c - use GTK_STOCK_* icons in place of left.xpm, + right.xpm, up.xpm, down.xpm and stop.xpm in GTK+ 2.0 port + + * src/gtk/bookmarks.c - show GTK_STOCK_* icons on the popup menu + + * src/gtk/bookmarks.c, src/gtk/chmod_dialog.c, src/gtk/menu-items.c, + src/gtk/misc-gtk.c, src/gtk/options_dialog.c and + src/gtk/view_dialog.c - use gtk_dialog_new_with_buttons in GTK+ 2.0 + port to create the dialog. Also, associate gFTP icon with this dialog + + * src/gtk/misc-gtk.c - changed the interface of MakeEditDialog and + MakeYesNoDialog. In the GTK+ 2.0 port, I now use stock icons in the + dialog buttons. + +2002-09-11 Marius Andreiana <mandreiana@yahoo.com> * configure.in: added 'ro' to ALL_LINGUAS @@ -14,25 +42,26 @@ * src/text/gftp-text.c, lib/protocols.c - more large file support 2002-09-04 Brian Masney <masneyb@gftp.org> - * lib/rfc959.c - FXP fixes (from Tobias Gruetzmacher <tobias@portfolio16.de>) + * lib/rfc959.c - FXP fixes (from Tobias Gruetzmacher + <tobias@portfolio16.de>) 2002-09-03 Brian Masney <masneyb@gftp.org> * lib/rfc2068.c - HTTP fixes when running under Solaris. Read from - request->sockfd and write to request->sockfd_write (Solaris doesn't like it - when you read/write to the same FILE structure) + request->sockfd and write to request->sockfd_write (Solaris doesn't + like it when you read/write to the same FILE structure) - * lib/local.c - encode major/minor numbers for a device in the file size. This - is probably still busted for other platforms + * lib/local.c - encode major/minor numbers for a device in the file + size. This is probably still busted for other platforms * lib/rfc2068.c, lib/rfc959.c, lib/ssh.c, lib/sshv2.c - Sanity - checking on the fdopen() calls. Also make sure that all of them have a + in - their open mode. Doesn't affect UNIX, but it does affect Windows + checking on the fdopen() calls. Also make sure that all of them have a + + in their open mode. Doesn't affect UNIX, but it does affect Windows * src/gtk/menu-items.c, src/gtk/gftp-gtk.c, src/gtk/misc-gtk.c - added function save_directory_listing. It's in the Local and Remote menus - * src/gtk/view_dialog.c - changed log message slightly. The new string should - already be in the po files translated + * src/gtk/view_dialog.c - changed log message slightly. The new string + should already be in the po files translated 2002-08-30 Brian Masney <masneyb@gftp.org> * lib/misc.c - don't allow passing a 0 to log10 @@ -73,7 +102,8 @@ (from Owen Taylor <otaylor@redhat.com>) 2002-08-23 <baddog@cvs.gnome.org> - * configure.in - (ALL_LINGUAS): zh_CN.GB2312 -> zh_CN, zh_TW.Big5 -> zh_TW + * configure.in - (ALL_LINGUAS): zh_CN.GB2312 -> zh_CN, zh_TW.Big5 -> + zh_TW 2002-08-23 Abel Cheung <maddog@linux.org.hk> * zh_TW.Big5.po renamed to zh_TW.po @@ -91,18 +121,20 @@ * po/de.po - Fixed German translation (charset, header) 2002-08-05 Brian Masney <masneyb@gftp.org> - * lib/protocols.c - When we connect to a remote server, don't change the - hostname to the PTR record of the hostname + * lib/protocols.c - When we connect to a remote server, don't change + the hostname to the PTR record of the hostname - * src/gtk/transfer.c - Fixed crash if you was already transfering a file, - and you started another transfer, and if you hit cancel at the + * src/gtk/transfer.c - Fixed crash if you was already transfering a + file, and you started another transfer, and if you hit cancel at the Overwrite/Resume/Skip dialog * docs/sample.gftp/gftprc - put the ext= lines back in the config file - * po/es.po - Spanish updates (from Gustavo D. Vranjes <gvranjes@softhome.net>) + * po/es.po - Spanish updates (from Gustavo D. Vranjes + <gvranjes@softhome.net>) - * po/nl.po - Dutch updates (from Myckel Habets <myckelhabets@netscape.net>) + * po/nl.po - Dutch updates (from Myckel Habets + <myckelhabets@netscape.net>) 2002-07-19 Brian Masney <masneyb@gftp.org> * gFTP 2.0.13 released
--- a/configure Wed Sep 11 10:26:13 2002 +0000 +++ b/configure Mon Sep 16 12:27:50 2002 +0000 @@ -950,7 +950,7 @@ -ALL_LINGUAS="bg cs da de es fi fr it ja ko nl no pl pt_BR ru sv tr zh_CN zh_TW" +ALL_LINGUAS="bg cs da de es fi fr it ja ko nl no pl pt_BR ro ru sv tr zh_CN zh_TW" cat >> confdefs.h <<\EOF #define _GNU_SOURCE 1
--- a/lib/gftp.h Wed Sep 11 10:26:13 2002 +0000 +++ b/lib/gftp.h Mon Sep 16 12:27:50 2002 +0000 @@ -311,10 +311,10 @@ * curfle, * updfle; - unsigned long numfiles, - numdirs, - current_file_number, - current_file_retries; + long numfiles, + numdirs, + current_file_number, + current_file_retries; off_t curtrans, /* Current transfered bytes for this file */ curresumed, /* Resumed bytes for this file */
--- a/lib/local.c Wed Sep 11 10:26:13 2002 +0000 +++ b/lib/local.c Mon Sep 16 12:27:50 2002 +0000 @@ -294,7 +294,7 @@ return (-2); } - if ((request->datafd = fdopen (sock, "ab+")) == NULL) + if ((request->datafd = fdopen (sock, "ab")) == NULL) { request->logging_function (gftp_logging_error, request->user_data, _("Cannot fdopen() socket for %s: %s\n"),
--- a/src/gtk/bookmarks.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/bookmarks.c Mon Sep 16 12:27:50 2002 +0000 @@ -19,8 +19,8 @@ #include "gftp-gtk.h" -static void doadd_bookmark ( GtkWidget * widget, - gftp_dialog_data * data); +static void doadd_bookmark ( gpointer * data, + gftp_dialog_data * ddata); static void bm_apply_changes ( GtkWidget * widget, gpointer backup_data ); static gftp_bookmarks * copy_bookmarks ( gftp_bookmarks * bookmarks ); @@ -38,13 +38,13 @@ GdkEventKey * event, gpointer data ); static void new_folder_entry ( gpointer data ); -static void do_make_new ( GtkWidget * widget, - gftp_dialog_data * data ); +static void do_make_new ( gpointer data, + gftp_dialog_data * ddata ); static void new_item_entry ( gpointer data ); static void edit_entry ( gpointer data ); static void delete_entry ( gpointer data ); -static void do_delete_entry ( GtkWidget * widget, - gftp_dialog_data * data ); +static void do_delete_entry ( gftp_bookmarks * entry, + gftp_dialog_data * ddata ); static void entry_apply_changes ( GtkWidget * widget, gftp_bookmarks * entry ); static void set_userpass_visible ( GtkWidget * checkbutton, @@ -147,19 +147,19 @@ return; } - 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, 1, _("Remember password"), _("Add"), doadd_bookmark, data, _(" Cancel "), NULL, NULL); + 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); } static void -doadd_bookmark (GtkWidget * widget, gftp_dialog_data * data) +doadd_bookmark (gpointer * data, gftp_dialog_data * ddata) { GtkItemFactoryEntry test = { NULL, NULL, run_bookmark, 0 }; const char *edttxt, *spos; gftp_bookmarks * tempentry; char *dpos; - edttxt = gtk_entry_get_text (GTK_ENTRY (data->edit)); + edttxt = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); if (*edttxt == '\0') { ftp_log (gftp_logging_error, NULL, @@ -215,7 +215,7 @@ edttxt = gtk_entry_get_text (GTK_ENTRY (passedit)); tempentry->pass = g_malloc (strlen (edttxt) + 1); strcpy (tempentry->pass, edttxt); - tempentry->save_password = GTK_TOGGLE_BUTTON (data->checkbox)->active; + tempentry->save_password = GTK_TOGGLE_BUTTON (ddata->checkbox)->active; } add_to_bookmark (tempentry); @@ -264,30 +264,67 @@ } +#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) +static void +editbm_action (GtkWidget * widget, gint response, gpointer user_data) +{ + switch (response) + { + case GTK_RESPONSE_OK: + bm_apply_changes (widget, NULL); + /* no break */ + default: + bm_close_dialog (NULL, widget); + } +} +#endif + + void edit_bookmarks (gpointer data) { - GtkWidget * dialog, * scroll, * tempwid; + GtkWidget * dialog, * scroll; GtkItemFactory * ifactory; GtkItemFactoryEntry menu_items[] = { {N_("/_File"), NULL, 0, 0, "<Branch>"}, {N_("/File/tearoff"), NULL, 0, 0, "<Tearoff>"}, - {N_("/File/New Folder..."), NULL, new_folder_entry, 0}, - {N_("/File/New Item..."), NULL, new_item_entry, 0}, - {N_("/File/Delete"), NULL, delete_entry, 0}, - {N_("/File/Properties..."), NULL, edit_entry, 0}, + {N_("/File/New Folder..."), NULL, new_folder_entry, 0, MN_(NULL)}, + {N_("/File/New Item..."), NULL, new_item_entry, 0, MS_(GTK_STOCK_NEW)}, + {N_("/File/Delete"), NULL, delete_entry, 0, MS_(GTK_STOCK_DELETE)}, + {N_("/File/Properties..."), NULL, edit_entry, 0, MS_(GTK_STOCK_PROPERTIES)}, {N_("/File/sep"), NULL, 0, 0, "<Separator>"}, - {N_("/File/Close"), NULL, gtk_widget_destroy, 0} + {N_("/File/Close"), NULL, gtk_widget_destroy, 0, MS_(GTK_STOCK_CLOSE)} }; +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 + GtkWidget * tempwid; +#endif new_bookmarks = copy_bookmarks (bookmarks); new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks); +/* FIXME - busted if you pull this up twice */ +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Bookmarks")); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); +#else + dialog = gtk_dialog_new_with_buttons (_("Edit Bookmarks"), NULL, 0, + GTK_STOCK_SAVE, + GTK_RESPONSE_OK, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + NULL); +#endif gtk_window_set_wmclass (GTK_WINDOW(dialog), "Edit Bookmarks", "gFTP"); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + gtk_widget_realize (dialog); + + if (gftp_icon != NULL) + { + gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, + gftp_icon->bitmap); + gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); + } ifactory = item_factory_new (GTK_TYPE_MENU_BAR, "<bookmarks>", NULL, NULL); create_item_factory (ifactory, 7, menu_items, NULL); @@ -322,6 +359,7 @@ GTK_SIGNAL_FUNC (bm_dblclick), (gpointer) tree); gtk_widget_show (tree); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 tempwid = gtk_button_new_with_label (_("OK")); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, TRUE, TRUE, 0); @@ -340,16 +378,10 @@ GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_widget_grab_focus (tempwid); gtk_widget_show (tempwid); - -/* FIXME - tempwid = gtk_button_new_with_label (_("Apply")); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, - TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (bm_apply_changes), (gpointer) 1); - GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); - gtk_widget_show (tempwid); -*/ +#else + g_signal_connect (GTK_OBJECT (dialog), "response", + G_CALLBACK (editbm_action), NULL); +#endif gtk_widget_show (dialog); @@ -709,9 +741,9 @@ new_folder_entry (gpointer data) { MakeEditDialog (_("New Folder"), - _("Enter the name of the new folder to create"), NULL, 1, 1, - NULL, _("Create"), do_make_new, (gpointer) 1, _(" Cancel "), - NULL, NULL); + _("Enter the name of the new folder to create"), NULL, 1, + NULL, gftp_dialog_button_create, + do_make_new, (gpointer) 0x1, NULL, NULL); } @@ -719,14 +751,14 @@ new_item_entry (gpointer data) { MakeEditDialog (_("New Folder"), - _("Enter the name of the new item to create"), NULL, 1, 1, - NULL, _("Create"), do_make_new, (gpointer) 0, _(" Cancel "), - NULL, NULL); + _("Enter the name of the new item to create"), NULL, 1, + NULL, gftp_dialog_button_create, + do_make_new, NULL, NULL, NULL); } static void -do_make_new (GtkWidget * widget, gftp_dialog_data * data) +do_make_new (gpointer data, gftp_dialog_data * ddata) { GdkPixmap * closedir_pixmap, * opendir_pixmap; GdkBitmap * closedir_bitmap, * opendir_bitmap; @@ -738,7 +770,7 @@ gftp_get_pixmap (tree, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap); gftp_get_pixmap (tree, "dir.xpm", &closedir_pixmap, &closedir_bitmap); - str = gtk_entry_get_text (GTK_ENTRY (data->edit)); + str = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); newentry = g_malloc0 (sizeof (*newentry)); newentry->path = g_malloc (strlen (str) + 1); @@ -747,7 +779,7 @@ *pos++ = ' '; newentry->prev = new_bookmarks; - if (data->data) + if (data) newentry->isfolder = 1; if (new_bookmarks->children == NULL) @@ -783,6 +815,25 @@ } +#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) +static void +bmedit_action (GtkWidget * widget, gint response, gpointer user_data) +{ + switch (response) + { + case GTK_RESPONSE_APPLY: + entry_apply_changes (widget, user_data); + break; + case GTK_RESPONSE_OK: + entry_apply_changes (widget, user_data); + /* no break */ + default: + gtk_widget_destroy (widget); + } +} +#endif + + static void edit_entry (gpointer data) { @@ -800,12 +851,31 @@ if (entry == NULL || entry == new_bookmarks) return; +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Entry")); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); +#else + dialog = gtk_dialog_new_with_buttons (_("Edit Entry"), NULL, 0, + GTK_STOCK_SAVE, + GTK_RESPONSE_OK, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_APPLY, + GTK_RESPONSE_APPLY, + NULL); +#endif gtk_window_set_wmclass (GTK_WINDOW (dialog), "Edit Bookmark Entry", "gFTP"); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); + gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); - gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + gtk_widget_realize (dialog); + + if (gftp_icon != NULL) + { + gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, + gftp_icon->bitmap); + gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); + } tempwid = gtk_frame_new (NULL); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), tempwid, TRUE, @@ -985,6 +1055,7 @@ } gtk_widget_show (anon_chk); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 tempwid = gtk_button_new_with_label (_("OK")); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, TRUE, TRUE, 0); @@ -1015,6 +1086,10 @@ (gpointer) entry); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_widget_show (tempwid); +#else + g_signal_connect (GTK_OBJECT (dialog), "response", + G_CALLBACK (bmedit_action), (gpointer) entry); +#endif gtk_widget_show (dialog); } @@ -1023,7 +1098,6 @@ static void delete_entry (gpointer data) { - gftp_dialog_data d_data; gftp_bookmarks * entry; char *tempstr, *pos; @@ -1035,9 +1109,8 @@ if (entry == NULL || entry->prev == NULL) return; - d_data.data = entry; if (!entry->isfolder) - do_delete_entry (NULL, &d_data); + do_delete_entry (entry, NULL); else { if ((pos = strrchr (entry->path, '/')) == NULL) @@ -1046,19 +1119,17 @@ pos++; tempstr = g_strdup_printf (_("Are you sure you want to erase the bookmark\n%s and all it's children?"), pos); - MakeYesNoDialog (_("Delete Bookmark"), tempstr, 1, 2, _("Yes"), - do_delete_entry, entry, _("No"), NULL, NULL); + MakeYesNoDialog (_("Delete Bookmark"), tempstr, do_delete_entry, entry, + NULL, NULL); g_free (tempstr); } } static void -do_delete_entry (GtkWidget * widget, gftp_dialog_data * data) +do_delete_entry (gftp_bookmarks * entry, gftp_dialog_data * ddata) { - gftp_bookmarks * entry, * tempentry, * delentry; - - entry = data->data; + gftp_bookmarks * tempentry, * delentry; g_hash_table_remove (new_bookmarks_htable, entry->path); gtk_ctree_remove_node (GTK_CTREE (tree), entry->cnode);
--- a/src/gtk/chmod_dialog.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/chmod_dialog.c Mon Sep 16 12:27:50 2002 +0000 @@ -30,6 +30,22 @@ static sigjmp_buf chmodenvir; static int mode; +#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) +static void +chmod_action (GtkWidget * widget, gint response, gpointer wdata) +{ + switch (response) + { + case GTK_RESPONSE_OK: + dochmod (widget, wdata); + /* no break */ + default: + gtk_widget_destroy (widget); + } +} +#endif + + void chmod_dialog (gpointer data) { @@ -44,18 +60,32 @@ wdata->request->chmod != NULL)) return; +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), _("Chmod")); - gtk_window_set_wmclass (GTK_WINDOW(dialog), "Chmod", "gFTP"); - gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); +#else + dialog = gtk_dialog_new_with_buttons (_("Chmod"), NULL, 0, + GTK_STOCK_OK, + GTK_RESPONSE_OK, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + NULL); +#endif + gtk_window_set_wmclass (GTK_WINDOW(dialog), "Chmod", "gFTP"); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - gtk_signal_connect_object (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (dialog)); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); + gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); + gtk_widget_realize (dialog); + + if (gftp_icon != NULL) + { + gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, + gftp_icon->bitmap); + gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); + } tempwid = gtk_label_new (_("You can now adjust the attributes of your file(s)\nNote: Not all ftp servers support the chmod feature")); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), tempwid, FALSE, @@ -147,7 +177,8 @@ gtk_box_pack_start (GTK_BOX (vbox), ox, FALSE, FALSE, 0); gtk_widget_show (ox); - tempwid = gtk_button_new_with_label (_("Change")); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 + tempwid = gtk_button_new_with_label (_("OK")); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, TRUE, TRUE, 0); @@ -167,6 +198,10 @@ GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (dialog)); gtk_widget_show (tempwid); +#else + g_signal_connect (GTK_OBJECT (dialog), "response", + G_CALLBACK (chmod_action), wdata); +#endif if (IS_ONE_SELECTED (wdata)) {
--- a/src/gtk/delete_dialog.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/delete_dialog.c Mon Sep 16 12:27:50 2002 +0000 @@ -20,9 +20,8 @@ #include "gftp-gtk.h" static void askdel ( gftp_transfer * transfer ); -static void yes_dialog_cb ( GtkWidget * widget, - gpointer data ); -static void yesCB ( gftp_transfer * transfer ); +static void yesCB ( gftp_transfer * transfer, + gftp_dialog_data * ddata ); static void * do_delete_thread ( void *data ); static void delete_purge_cache ( gpointer key, gpointer value, @@ -118,25 +117,14 @@ tempstr = g_strdup_printf (_("Are you sure you want to delete these %ld files and %ld directories"), transfer->numfiles, transfer->numdirs); - MakeYesNoDialog (_("Delete Files/Directories"), tempstr, 0, 2, _("Yes"), - yes_dialog_cb, transfer, _("No"), NULL, NULL); + MakeYesNoDialog (_("Delete Files/Directories"), tempstr, + yesCB, transfer, NULL, NULL); g_free (tempstr); } static void -yes_dialog_cb (GtkWidget * widget, gpointer data) -{ - gftp_dialog_data * dialog; - - dialog = data; - gtk_widget_destroy (dialog->dialog); - yesCB (dialog->data); -} - - -static void -yesCB (gftp_transfer * transfer) +yesCB (gftp_transfer * transfer, gftp_dialog_data * ddata) { gftp_window_data * wdata; void * ret;
--- a/src/gtk/gftp-gtk.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/gftp-gtk.c Mon Sep 16 12:27:50 2002 +0000 @@ -71,12 +71,12 @@ GtkItemFactory * factory = NULL; pthread_mutex_t transfer_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; +gftp_graphic * gftp_icon; int main (int argc, char **argv) { GtkWidget *window, *ui; - gftp_graphic * graphic; #ifdef HAVE_GETTEXT setlocale (LC_ALL, ""); @@ -108,11 +108,11 @@ gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE); gtk_widget_realize (window); - graphic = open_xpm (window, "gftp.xpm"); - if (graphic != NULL) + gftp_icon = open_xpm (window, "gftp.xpm"); + if (gftp_icon != NULL) { - gdk_window_set_icon (window->window, NULL, graphic->pixmap, - graphic->bitmap); + gdk_window_set_icon (window->window, NULL, gftp_icon->pixmap, + gftp_icon->bitmap); gdk_window_set_icon_name (window->window, _("gFTP Icon")); } @@ -150,10 +150,7 @@ doexit (NULL, NULL); else { - MakeYesNoDialog (_("Exit"), - _("There are file transfers in progress.\nAre you sure you want to exit?"), - 1, 2, _("Exit"), doexit, NULL, _("Don't Exit"), NULL, - NULL); + MakeYesNoDialog (_("Exit"), _("There are file transfers in progress.\nAre you sure you want to exit?"), doexit, NULL, NULL, NULL); return (TRUE); } return (FALSE); @@ -213,14 +210,26 @@ gtk_container_border_width (GTK_CONTAINER (dlbox), 5); gtk_box_pack_start (GTK_BOX (box), dlbox, FALSE, FALSE, 0); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 tempwid = toolbar_pixmap (ui, "right.xpm"); +#else + tempwid = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, + GTK_ICON_SIZE_SMALL_TOOLBAR); +#endif + button = gtk_button_new (); gtk_box_pack_start (GTK_BOX (dlbox), button, TRUE, FALSE, 0); gtk_signal_connect_object (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (put_files), NULL); gtk_container_add (GTK_CONTAINER (button), tempwid); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 tempwid = toolbar_pixmap (ui, "left.xpm"); +#else + tempwid = gtk_image_new_from_stock (GTK_STOCK_GO_BACK, + GTK_ICON_SIZE_SMALL_TOOLBAR); +#endif + button = gtk_button_new (); gtk_box_pack_start (GTK_BOX (dlbox), button, TRUE, FALSE, 0); gtk_signal_connect_object (GTK_OBJECT (button), "clicked", @@ -332,14 +341,6 @@ } -#if GTK_MAJOR_VERSION < 2 -#define MS_(a) NULL -#define MN_(a) a -#else -#define MS_(a) "<StockItem>",a -#define MN_(a) a,NULL -#endif - static GtkWidget * CreateMenus (GtkWidget * parent) { @@ -627,7 +628,13 @@ gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), protocol_menu); gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), num); - tempwid = toolbar_pixmap (parent, "stop.xpm"); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 + tempwid = toolbar_pixmap (ui, "stop.xpm"); +#else + tempwid = gtk_image_new_from_stock (GTK_STOCK_STOP, + GTK_ICON_SIZE_LARGE_TOOLBAR); +#endif + stop_btn = gtk_button_new (); gtk_container_add (GTK_CONTAINER (stop_btn), tempwid); gtk_widget_set_sensitive (stop_btn, 0); @@ -686,20 +693,6 @@ void init_gftp (int argc, char *argv[], GtkWidget * parent) { - GtkWidget *sort_wid; - - if (window1.sortasds) - sort_wid = toolbar_pixmap (parent, "down.xpm"); - else - sort_wid = toolbar_pixmap (parent, "up.xpm"); - gtk_clist_set_column_widget (GTK_CLIST (window1.listbox), 0, sort_wid); - - if (window2.sortasds) - sort_wid = toolbar_pixmap (parent, "down.xpm"); - else - sort_wid = toolbar_pixmap (parent, "up.xpm"); - gtk_clist_set_column_widget (GTK_CLIST (window2.listbox), 0, sort_wid); - if (argc == 2 && strncmp (argv[1], "--", 2) != 0) { if (gftp_parse_url (window2.request, argv[1]) == 0) @@ -1019,17 +1012,35 @@ gftp_window_data * wdata; GtkWidget * sort_wid; GList * templist; + int swap_col; wdata = data; if (column == 0 || (column == wdata->sortcol && wdata->sorted)) { wdata->sortasds = !wdata->sortasds; + swap_col = 1; + } + else + swap_col = 0; + + if (swap_col || !wdata->sorted) + { sort_wid = gtk_clist_get_column_widget (clist, 0); gtk_widget_destroy (sort_wid); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 if (wdata->sortasds) sort_wid = toolbar_pixmap (wdata->listbox, "down.xpm"); else sort_wid = toolbar_pixmap (wdata->listbox, "up.xpm"); +#else + if (wdata->sortasds) + sort_wid = gtk_image_new_from_stock (GTK_STOCK_SORT_ASCENDING, + GTK_ICON_SIZE_SMALL_TOOLBAR); + else + sort_wid = gtk_image_new_from_stock (GTK_STOCK_SORT_DESCENDING, + GTK_ICON_SIZE_SMALL_TOOLBAR); +#endif + gtk_clist_set_column_widget (clist, 0, sort_wid); } else
--- a/src/gtk/gftp-gtk.h Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/gftp-gtk.h Mon Sep 16 12:27:50 2002 +0000 @@ -33,6 +33,30 @@ gtk_widget_set_usize (widget, width, height) #endif +/* These 2 defines are for creating menu items with stock icons in GTK+ 2.0. + If we are using version 1.2, it will disable the stock items since it's not + supported */ + +#if GTK_MAJOR_VERSION < 2 +#define MS_(a) NULL +#define MN_(a) a +#else +#define MS_(a) "<StockItem>",a +#define MN_(a) a,NULL +#endif + +/* These are used for the MakeEditDialog function. I have these types to make + it easier for creating dialogs with GTK+ 1.2 and GTK+ 2.0 */ + +typedef enum gftp_dialog_button_tag +{ + gftp_dialog_button_create, + gftp_dialog_button_change, + gftp_dialog_button_connect, + gftp_dialog_button_rename, + gftp_dialog_button_ok +} gftp_dialog_button; + typedef struct gftp_window_data_tag { GtkWidget *combo, /* Entry widget/history for the user to enter @@ -65,11 +89,15 @@ typedef struct gftp_dialog_data_tag { - GtkWidget * dialog, /* Pointer to the dialog */ - * checkbox, /* Pointer to the checkbox widget */ - * edit; /* Pointer to the edit widget */ - GList * all_buttons; /* All the buttons of this dialog */ - gpointer data; /* Data pointer we'll pass to the function */ + GtkWidget * dialog, + * checkbox, + * edit; + + void (*yesfunc) (); + gpointer yespointer; + + void (*nofunc) (); + gpointer nopointer; } gftp_dialog_data; @@ -117,6 +145,7 @@ extern GtkItemFactoryEntry * menus; extern GtkItemFactory * factory; extern pthread_mutex_t transfer_mutex, log_mutex; +extern gftp_graphic * gftp_icon; /* bookmarks.c */ void run_bookmark ( gpointer data ); @@ -275,21 +304,20 @@ void MakeEditDialog ( char *diagtxt, char *infotxt, char *deftext, - int edit_shown, - int erase, - char *checktext, - char *oktxt, + int passwd_item, + char *checktext, + gftp_dialog_button okbutton, void (*okfunc) (), void *okptr, - char *canceltxt, void (*cancelfunc) (), void *cancelptr ); void MakeYesNoDialog ( char *diagtxt, char *infotxt, - int erase, - int num, - ... ); + void (*yesfunc) (), + gpointer yespointer, + void (*nofunc) (), + gpointer nopointer ); void update_directory_download_progress ( gftp_transfer * transfer );
--- a/src/gtk/menu-items.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/menu-items.c Mon Sep 16 12:27:50 2002 +0000 @@ -19,21 +19,9 @@ #include <gftp-gtk.h> -static void do_openurl ( GtkWidget * widget, - gftp_dialog_data * data ); -static void dochange_filespec ( GtkWidget * widget, - gftp_dialog_data * data ); -static void dosave_directory_listing ( GtkWidget * widget, - gftp_save_dir_struct * str ); -static void destroy_save_directory_listing ( gftp_save_dir_struct * str ); -static void dosite ( GtkWidget * widget, - gftp_dialog_data * data ); static int do_change_dir ( gftp_window_data * wdata, char * directory ); static void *do_change_dir_thread ( void * data ); -static void dosavelog ( GtkWidget * widget, - GtkFileSelection * fs ); - static RETSIGTYPE sig_chdirquit ( int signo ); static sigjmp_buf chdirenvir; @@ -96,22 +84,11 @@ } -void -openurl_dialog (gpointer data) +static void +do_openurl (gftp_window_data * wdata, gftp_dialog_data * ddata) { - MakeEditDialog (_("Connect via URL"), _("Enter ftp url to connect to"), - NULL, 1, 1, NULL, _("Connect"), do_openurl, data, - _(" Cancel "), NULL, NULL); -} - - -static void -do_openurl (GtkWidget * widget, gftp_dialog_data * data) -{ - gftp_window_data * wdata; const char *tempstr; - wdata = data->data; if (current_wdata->request->stopable) { ftp_log (gftp_logging_misc, NULL, @@ -120,7 +97,7 @@ return; } - tempstr = gtk_entry_get_text (GTK_ENTRY (data->edit)); + tempstr = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); if (*tempstr == '\0') { ftp_log (gftp_logging_misc, NULL, @@ -133,15 +110,24 @@ if (gftp_parse_url (wdata->request, tempstr) == 0) { - gtk_widget_destroy (data->dialog); + gtk_widget_destroy (ddata->dialog); ftp_connect (wdata, wdata->request, 1); } else { - gtk_widget_destroy (data->dialog); + gtk_widget_destroy (ddata->dialog); ftp_log (gftp_logging_misc, NULL, _("Could not parse URL %s\n"), tempstr); } - data->dialog = NULL; + ddata->dialog = NULL; +} + + +void +openurl_dialog (gpointer data) +{ + MakeEditDialog (_("Connect via URL"), _("Enter ftp url to connect to"), + NULL, 1, NULL, gftp_dialog_button_connect, do_openurl, data, + NULL, NULL); } @@ -157,34 +143,17 @@ } -void -change_filespec (gpointer data) -{ - gftp_window_data * wdata; - - wdata = data; - if (!check_status (_("Change Filespec"), wdata, 0, 0, 0, 1)) - return; - - MakeEditDialog (_("Change Filespec"), _("Enter the new file specification"), - wdata->filespec, 1, 1, NULL, _("Change"), dochange_filespec, - wdata, _(" Cancel "), NULL, NULL); -} - - static void -dochange_filespec (GtkWidget * widget, gftp_dialog_data * data) +dochange_filespec (gftp_window_data * wdata, gftp_dialog_data * ddata) { GList * templist, * filelist; gftp_file * tempfle; - gftp_window_data * wdata; const char *edttext; int num; - wdata = data->data; wdata->show_selected = 0; - edttext = gtk_entry_get_text (GTK_ENTRY (data->edit)); + edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); if (*edttext == '\0') { ftp_log (gftp_logging_misc, NULL, @@ -221,28 +190,17 @@ void -save_directory_listing (gpointer data) +change_filespec (gpointer data) { - gftp_save_dir_struct * str; - GtkWidget *filew; - - filew = gtk_file_selection_new (_("Save Directory Listing")); - - str = g_malloc (sizeof (*str)); - str->filew = filew; - str->wdata = data; + gftp_window_data * wdata; - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), - "clicked", GTK_SIGNAL_FUNC (dosave_directory_listing), - str); - gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), - "clicked", - GTK_SIGNAL_FUNC (destroy_save_directory_listing), - GTK_OBJECT (str)); - gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (destroy_save_directory_listing), GTK_OBJECT (str)); + wdata = data; + if (!check_status (_("Change Filespec"), wdata, 0, 0, 0, 1)) + return; - gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Directory Listing", "gFTP"); - gtk_widget_show (filew); + MakeEditDialog (_("Change Filespec"), _("Enter the new file specification"), + wdata->filespec, 1, NULL, gftp_dialog_button_change, + dochange_filespec, wdata, NULL, NULL); } @@ -314,6 +272,32 @@ } +void +save_directory_listing (gpointer data) +{ + gftp_save_dir_struct * str; + GtkWidget *filew; + + filew = gtk_file_selection_new (_("Save Directory Listing")); + + str = g_malloc (sizeof (*str)); + str->filew = filew; + str->wdata = data; + + gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), + "clicked", GTK_SIGNAL_FUNC (dosave_directory_listing), + str); + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), + "clicked", + GTK_SIGNAL_FUNC (destroy_save_directory_listing), + str); + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (destroy_save_directory_listing), str); + + gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Directory Listing", "gFTP"); + gtk_widget_show (filew); +} + + void show_selected (gpointer data) { @@ -401,28 +385,12 @@ } -void -site_dialog (gpointer data) +static void +dosite (gftp_window_data * wdata, gftp_dialog_data * ddata) { - gftp_window_data * wdata; - - wdata = data; - if (!check_status (_("Site"), wdata, 0, 0, 0, wdata->request->site != NULL)) - return; - - MakeEditDialog (_("Site"), _("Enter site-specific command"), NULL, 1, 1, - NULL, _("OK"), dosite, wdata, _(" Cancel "), NULL, NULL); -} - - -static void -dosite (GtkWidget * widget, gftp_dialog_data * data) -{ - gftp_window_data * wdata; const char *edttext; - wdata = data->data; - edttext = gtk_entry_get_text (GTK_ENTRY (data->edit)); + edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); if (*edttext == '\0') { ftp_log (gftp_logging_misc, NULL, @@ -439,6 +407,20 @@ } +void +site_dialog (gpointer data) +{ + gftp_window_data * wdata; + + wdata = data; + if (!check_status (_("Site"), wdata, 0, 0, 0, wdata->request->site != NULL)) + return; + + MakeEditDialog (_("Site"), _("Enter site-specific command"), NULL, 1, + NULL, gftp_dialog_button_ok, dosite, wdata, NULL, NULL); +} + + int chdir_edit (GtkWidget * widget, gpointer data) { @@ -688,26 +670,6 @@ } -void -savelog (gpointer data) -{ - GtkWidget *filew; - - filew = gtk_file_selection_new (_("Save Log")); - - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), - "clicked", GTK_SIGNAL_FUNC (dosavelog), filew); - gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), - "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (filew)); - gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (filew)); - - gtk_file_selection_set_filename (GTK_FILE_SELECTION (filew), "gftp.log"); - gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Log", "gFTP"); - gtk_widget_show (filew); -} - - static void dosavelog (GtkWidget * widget, GtkFileSelection * fs) { @@ -767,6 +729,26 @@ void +savelog (gpointer data) +{ + GtkWidget *filew; + + filew = gtk_file_selection_new (_("Save Log")); + + gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), + "clicked", GTK_SIGNAL_FUNC (dosavelog), filew); + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (filew)); + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (filew)); + + gtk_file_selection_set_filename (GTK_FILE_SELECTION (filew), "gftp.log"); + gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Log", "gFTP"); + gtk_widget_show (filew); +} + + +void clear_cache (gpointer data) { gftp_clear_cache_files (); @@ -789,20 +771,31 @@ no_license_agreement = g_strdup_printf (_("Cannot find the license agreement file COPYING. Please make sure it is in either %s or in %s"), BASE_CONF_DIR, SHARE_DIR); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP")); - gtk_window_set_wmclass (GTK_WINDOW(dialog), "about", "gFTP"); - gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); +#else + dialog = gtk_dialog_new_with_buttons (_("About gFTP"), NULL, 0, + GTK_STOCK_CLOSE, + GTK_RESPONSE_CLOSE, + NULL); +#endif + gtk_window_set_wmclass (GTK_WINDOW(dialog), "about", "gFTP"); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - gtk_signal_connect_object (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (dialog)); + gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); gtk_widget_realize (dialog); + if (gftp_icon != NULL) + { + gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, + gftp_icon->bitmap); + gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); + } + notebook = gtk_notebook_new (); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0); @@ -883,6 +876,7 @@ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 tempwid = gtk_button_new_with_label (_(" Close ")); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, @@ -892,6 +886,11 @@ GTK_OBJECT (dialog)); gtk_widget_grab_default (tempwid); gtk_widget_show (tempwid); +#else + g_signal_connect_swapped (GTK_OBJECT (dialog), "response", + G_CALLBACK (gtk_widget_destroy), + GTK_OBJECT (dialog)); +#endif tempstr = g_strconcat ("/usr/share/common-licenses/GPL", NULL); if (access (tempstr, F_OK) != 0)
--- a/src/gtk/misc-gtk.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/misc-gtk.c Mon Sep 16 12:27:50 2002 +0000 @@ -22,7 +22,6 @@ static void set_menu_sensitive ( gftp_window_data * wdata, char *path, int sensitive ); -static void destroy_dialog_data ( gftp_dialog_data * data ); static gint delete_event ( GtkWidget * widget, GdkEvent * event, gpointer data ); @@ -503,6 +502,7 @@ return (1); } + static gchar * gftp_item_factory_translate (const char *path, gpointer func_data) @@ -524,11 +524,10 @@ return (char *)result; } + GtkItemFactory * -item_factory_new (GtkType container_type, - const char *path, - GtkAccelGroup *accel_group, - const char *strip_prefix) +item_factory_new (GtkType container_type, const char *path, + GtkAccelGroup *accel_group, const char *strip_prefix) { GtkItemFactory *result = gtk_item_factory_new (container_type, path, accel_group); gchar *strip_prefix_dup = g_strdup (g_strdup (strip_prefix)); @@ -543,6 +542,7 @@ return result; } + void create_item_factory (GtkItemFactory * ifactory, guint n_entries, GtkItemFactoryEntry * entries, gpointer callback_data) @@ -776,185 +776,227 @@ } +#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) +static void +dialog_response (GtkWidget * widget, gint response, gftp_dialog_data * ddata) +{ + if (ddata->edit == NULL) + gtk_widget_destroy (widget); + + switch (response) + { + case GTK_RESPONSE_YES: + if (ddata->yesfunc != NULL) + ddata->yesfunc (ddata->yespointer, ddata); + break; + default: + if (ddata->nofunc != NULL) + ddata->nofunc (ddata->nopointer, ddata); + break; + } + + if (ddata->edit != NULL) + gtk_widget_destroy (widget); + + g_free (ddata); +} +#endif + + void -MakeEditDialog (char *diagtxt, char *infotxt, char *deftext, int edit_shown, - int erase, char *checktext, - char *oktxt, void (*okfunc) (), void *okptr, - char *canceltxt, void (*cancelfunc) (), void *cancelptr) +MakeEditDialog (char *diagtxt, char *infotxt, char *deftext, int passwd_item, + char *checktext, + gftp_dialog_button okbutton, void (*okfunc) (), void *okptr, + void (*cancelfunc) (), void *cancelptr) { - gftp_dialog_data * d, * cancel_d; - GtkWidget * tempwid; + GtkWidget * tempwid, * dialog; + gftp_dialog_data * ddata; + const gchar * yes_text; + + ddata = g_malloc (sizeof (*ddata)); + ddata->yesfunc = okfunc; + ddata->yespointer = okptr; + ddata->nofunc = cancelfunc; + ddata->nopointer = cancelptr; - d = g_malloc0 (sizeof (*d)); - cancel_d = g_malloc0 (sizeof (*cancel_d)); - cancel_d->data = cancelptr; - d->data = okptr; - cancel_d->all_buttons = d->all_buttons = NULL; - d->dialog = cancel_d->dialog = gtk_dialog_new (); - gtk_grab_add (d->dialog); - gtk_window_set_title (GTK_WINDOW (d->dialog), diagtxt); - gtk_window_set_wmclass (GTK_WINDOW(d->dialog), "edit", "gFTP"); - gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (d->dialog)->vbox), 10); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 + dialog = gtk_dialog_new (); + gtk_window_set_title (GTK_WINDOW (dialog), diagtxt); + gtk_grab_add (dialog); gtk_container_border_width (GTK_CONTAINER - (GTK_DIALOG (d->dialog)->action_area), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (d->dialog)->vbox), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (d->dialog)->action_area), 15); - gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (d->dialog)->action_area), TRUE); - gtk_window_set_position (GTK_WINDOW (d->dialog), GTK_WIN_POS_MOUSE); + (GTK_DIALOG (dialog)->action_area), 5); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); + gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); +#else + switch (okbutton) + { + case gftp_dialog_button_create: + yes_text = GTK_STOCK_ADD; + break; + case gftp_dialog_button_change: + yes_text = _("Change"); + break; + case gftp_dialog_button_connect: + yes_text = _("Connect"); + break; + case gftp_dialog_button_rename: + yes_text = _("Rename"); + break; + default: + yes_text = GTK_STOCK_MISSING_IMAGE; + break; + } - if (cancelfunc) - gtk_signal_connect (GTK_OBJECT (d->dialog), "delete_event", - GTK_SIGNAL_FUNC (cancelfunc), (gpointer) cancel_d); + dialog = gtk_dialog_new_with_buttons (_(diagtxt), NULL, 0, + yes_text, + GTK_RESPONSE_YES, + GTK_STOCK_CANCEL, + GTK_RESPONSE_NO, + NULL); +#endif + gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); + gtk_window_set_wmclass (GTK_WINDOW(dialog), "edit", "gFTP"); + gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + gtk_widget_realize (dialog); - gtk_signal_connect_object (GTK_OBJECT (d->dialog), "delete_event", - GTK_SIGNAL_FUNC (destroy_dialog_data), - (gpointer) cancel_d); + if (gftp_icon != NULL) + { + gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, + gftp_icon->bitmap); + gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); + } + + ddata->dialog = dialog; + tempwid = gtk_label_new (infotxt); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (d->dialog)->vbox), tempwid, TRUE, + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), tempwid, TRUE, TRUE, 0); gtk_widget_show (tempwid); - d->edit = cancel_d->edit = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (d->dialog)->vbox), d->edit, TRUE, + ddata->edit = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), ddata->edit, TRUE, TRUE, 0); - if (okfunc) - gtk_signal_connect (GTK_OBJECT (d->edit), "activate", - GTK_SIGNAL_FUNC (okfunc), (gpointer) d); - if (erase || !okfunc) - gtk_signal_connect_object (GTK_OBJECT (d->edit), "activate", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) d->dialog); + gtk_widget_grab_focus (ddata->edit); + gtk_entry_set_visibility (GTK_ENTRY (ddata->edit), passwd_item); - gtk_widget_grab_focus (d->edit); - gtk_entry_set_visibility (GTK_ENTRY (d->edit), edit_shown); if (deftext != NULL) { - gtk_entry_set_text (GTK_ENTRY (d->edit), deftext); - gtk_entry_select_region (GTK_ENTRY (d->edit), 0, strlen (deftext)); + gtk_entry_set_text (GTK_ENTRY (ddata->edit), deftext); + gtk_entry_select_region (GTK_ENTRY (ddata->edit), 0, strlen (deftext)); } - gtk_widget_show (d->edit); + gtk_widget_show (ddata->edit); - if (checktext) + if (checktext != NULL) { - d->checkbox = cancel_d->checkbox = - gtk_check_button_new_with_label (checktext); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (d->dialog)->vbox), d->checkbox, - TRUE, TRUE, 0); - gtk_widget_show (d->checkbox); + ddata->checkbox = gtk_check_button_new_with_label (checktext); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + ddata->checkbox, TRUE, TRUE, 0); + gtk_widget_show (ddata->checkbox); } +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 +/* FIXME - fix call backs */ tempwid = gtk_button_new_with_label (oktxt); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (d->dialog)->action_area), tempwid, + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, TRUE, TRUE, 0); - if (okfunc) - gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (okfunc), (gpointer) d); - if (erase || !okfunc) - gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) d->dialog); gtk_widget_grab_default (tempwid); gtk_widget_show (tempwid); tempwid = gtk_button_new_with_label (canceltxt); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (d->dialog)->action_area), tempwid, + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, TRUE, TRUE, 0); - if (cancelfunc) - gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (cancelfunc), (gpointer) cancel_d); - if (erase || !cancelfunc) - gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) d->dialog); gtk_widget_show (tempwid); +#else + g_signal_connect (GTK_OBJECT (dialog), "response", + G_CALLBACK (dialog_response), ddata); +#endif - d->all_buttons = g_list_append (d->all_buttons, d); - d->all_buttons = g_list_append (d->all_buttons, cancel_d); - cancel_d->all_buttons = d->all_buttons; - gtk_widget_show (d->dialog); + gtk_widget_show (dialog); } void -MakeYesNoDialog (char *diagtxt, char *infotxt, int erase, int num, ...) +MakeYesNoDialog (char *diagtxt, char *infotxt, + void (*yesfunc) (), gpointer yespointer, + void (*nofunc) (), gpointer nopointer) { - GtkWidget * text, * tempwid, * dialog; - typedef void (*func) (); - gftp_dialog_data * d; - char *tempstr; - va_list argp; - func myfunc; - GList * list; - void *ptr; - int i; + GtkWidget * text, * dialog; +#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) + gftp_dialog_data * ddata; +#endif +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 dialog = gtk_dialog_new (); gtk_grab_add (dialog); gtk_window_set_title (GTK_WINDOW (dialog), diagtxt); - gtk_window_set_wmclass (GTK_WINDOW(dialog), "yndiag", "gFTP"); - gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); +#else + dialog = gtk_dialog_new_with_buttons (_(diagtxt), NULL, 0, + GTK_STOCK_YES, + GTK_RESPONSE_YES, + GTK_STOCK_NO, + GTK_RESPONSE_NO, + NULL); +#endif + gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + gtk_window_set_wmclass (GTK_WINDOW(dialog), "yndiag", "gFTP"); + gtk_widget_realize (dialog); + + if (gftp_icon != NULL) + { + gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, + gftp_icon->bitmap); + gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); + } text = gtk_label_new (infotxt); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), text, TRUE, TRUE, 0); gtk_widget_show (text); - list = NULL; - ptr = g_malloc0 (sizeof (gftp_dialog_data)); - list = g_list_append (list, ptr); - va_start (argp, num); - for (i = 0; i < num; i++) - { - tempstr = va_arg (argp, char *); - myfunc = va_arg (argp, func); - ptr = va_arg (argp, void *); - d = g_malloc (sizeof (gftp_dialog_data)); - list = g_list_append (list, d); - d->dialog = dialog; - d->data = ptr; - d->all_buttons = list; +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 +/* FIXME - fix call backs */ + tempwid = gtk_button_new_with_label (_(" Yes ")); + GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, + FALSE, FALSE, 0); + gtk_signal_connect_object_before (GTK_OBJECT (tempwid), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (dialog)); + gtk_widget_grab_default (tempwid); + gtk_widget_show (tempwid); - tempwid = gtk_button_new_with_label (tempstr); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, - TRUE, TRUE, 0); - if (myfunc) - gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (myfunc), (gpointer) d); - if (erase || !myfunc) - gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) d->dialog); - gtk_widget_show (tempwid); - } + tempwid = gtk_button_new_with_label (_(" No ")); + GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, + FALSE, FALSE, 0); + gtk_signal_connect_object_before (GTK_OBJECT (tempwid), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (dialog)); + gtk_widget_show (tempwid); + +#else + ddata = g_malloc (sizeof (*ddata)); + ddata->yesfunc = yesfunc; + ddata->yespointer = yespointer; + ddata->nofunc = nofunc; + ddata->nopointer = nopointer; + + g_signal_connect (GTK_OBJECT (dialog), "response", + G_CALLBACK (dialog_response), ddata); +#endif gtk_widget_show (dialog); } -static void -destroy_dialog_data (gftp_dialog_data * data) -{ - GList * list; - - list = data->all_buttons; - while (list != NULL) - { - if (list->data != data && list->data) - g_free (list->data); - list = list->next; - } - g_list_free (data->all_buttons); - g_free (data); -} - - void update_directory_download_progress (gftp_transfer * transfer) {
--- a/src/gtk/mkdir_dialog.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/mkdir_dialog.c Mon Sep 16 12:27:50 2002 +0000 @@ -19,56 +19,18 @@ #include "gftp-gtk.h" -static void domkdir ( GtkWidget * widget, - gftp_dialog_data * data ); -static void *do_make_dir_thread ( void * data ); -static RETSIGTYPE sig_mkdirquit ( int signo ); - static const char *edttext; static sigjmp_buf mkdirenvir; -void -mkdir_dialog (gpointer data) -{ - gftp_window_data * wdata; - wdata = data; - if (!check_status (_("Mkdir"), wdata, wdata->request->use_threads, 0, 0, - wdata->request->mkdir != NULL)) - return; - - MakeEditDialog (_("Make Directory"), _("Enter name of directory to create"), - NULL, 1, 1, NULL, _("Create"), domkdir, wdata, - _(" Cancel "), NULL, NULL); -} - - -static void -domkdir (GtkWidget * widget, gftp_dialog_data * data) +static RETSIGTYPE +sig_mkdirquit (int signo) { - gftp_window_data * wdata; - - wdata = data->data; - edttext = gtk_entry_get_text (GTK_ENTRY (data->edit)); - if (*edttext == '\0') - { - ftp_log (gftp_logging_misc, NULL, - _("Mkdir: Operation canceled...you must enter a string\n")); - return; - } - - if (check_reconnect (wdata) < 0) - return; - - if ((int) generic_thread (do_make_dir_thread, wdata)) - { - gftp_delete_cache_entry (wdata->request); - refresh (wdata); - } + signal (signo, sig_mkdirquit); + siglongjmp (mkdirenvir, signo == SIGINT ? 1 : 2); } - static void * do_make_dir_thread (void * data) { @@ -115,10 +77,40 @@ } -static RETSIGTYPE -sig_mkdirquit (int signo) +static void +domkdir (gftp_window_data * wdata, gftp_dialog_data * ddata) { - signal (signo, sig_mkdirquit); - siglongjmp (mkdirenvir, signo == SIGINT ? 1 : 2); + edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); + if (*edttext == '\0') + { + ftp_log (gftp_logging_misc, NULL, + _("Mkdir: Operation canceled...you must enter a string\n")); + return; + } + + if (check_reconnect (wdata) < 0) + return; + + if ((int) generic_thread (do_make_dir_thread, wdata)) + { + gftp_delete_cache_entry (wdata->request); + refresh (wdata); + } } + +void +mkdir_dialog (gpointer data) +{ + gftp_window_data * wdata; + + wdata = data; + if (!check_status (_("Mkdir"), wdata, wdata->request->use_threads, 0, 0, + wdata->request->mkdir != NULL)) + return; + + MakeEditDialog (_("Make Directory"), _("Enter name of directory to create"), + NULL, 1, NULL, gftp_dialog_button_create, domkdir, wdata, + NULL, NULL); +} +
--- a/src/gtk/options_dialog.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/options_dialog.c Mon Sep 16 12:27:50 2002 +0000 @@ -45,6 +45,25 @@ static GList * new_proxy_hosts; static char *custom_proxy; +#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) +static void +options_action (GtkWidget * widget, gint response, gpointer user_data) +{ + switch (response) + { + case GTK_RESPONSE_APPLY: + apply_changes (widget, NULL); + break; + case GTK_RESPONSE_OK: + apply_changes (widget, NULL); + /* no break */ + default: + gtk_widget_destroy (widget); + } +} +#endif + + void options_dialog (gpointer data) { @@ -53,16 +72,35 @@ int i, tbl_col, tbl_num, combo_num; GList * combo_list; +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), _("Options")); - gtk_window_set_wmclass (GTK_WINDOW(dialog), "options", "gFTP"); - gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); +#else + dialog = gtk_dialog_new_with_buttons (_("Options"), NULL, 0, + GTK_STOCK_SAVE, + GTK_RESPONSE_OK, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_APPLY, + GTK_RESPONSE_APPLY, + NULL); +#endif + gtk_window_set_wmclass (GTK_WINDOW(dialog), "options", "gFTP"); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2); + gtk_widget_realize (dialog); + + if (gftp_icon != NULL) + { + gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, + gftp_icon->bitmap); + gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); + } notebook = gtk_notebook_new (); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, @@ -270,6 +308,7 @@ make_proxy_hosts_tab (notebook); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 tempwid = gtk_button_new_with_label (_("OK")); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, @@ -300,6 +339,10 @@ GTK_SIGNAL_FUNC (apply_changes), NULL); gtk_widget_grab_default (tempwid); gtk_widget_show (tempwid); +#else + g_signal_connect (GTK_OBJECT (dialog), "response", + G_CALLBACK (options_action), NULL); +#endif gtk_widget_show (dialog); } @@ -413,13 +456,29 @@ } +#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) +static void +proxyhosts_action (GtkWidget * widget, gint response, gpointer user_data) +{ + switch (response) + { + case GTK_RESPONSE_OK: + add_ok (widget, user_data); + /* no break */ + default: + gtk_widget_destroy (widget); + } +} +#endif + + static void add_proxy_host (GtkWidget * widget, gpointer data) { GtkWidget *tempwid, *dialog, *frame, *box, *table; gftp_proxy_hosts *hosts; + char *tempstr, *title; GList *templist; - char *tempstr; if (data) { @@ -435,21 +494,27 @@ templist = NULL; } + title = hosts ? _("Edit Host") : _("Add Host"); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (dialog), - hosts ? _("Edit Host") : _("Add Host")); - gtk_window_set_wmclass (GTK_WINDOW(dialog), "hostinfo", "Gftp"); - gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); + gtk_window_set_title (GTK_WINDOW (dialog), title); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); + gtk_grab_add (dialog); +#else + dialog = gtk_dialog_new_with_buttons (title, NULL, 0, + GTK_STOCK_SAVE, + GTK_RESPONSE_OK, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + NULL); +#endif + gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2); + gtk_window_set_wmclass (GTK_WINDOW(dialog), "hostinfo", "Gftp"); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - gtk_signal_connect_object (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (dialog)); - gtk_grab_add (dialog); frame = gtk_frame_new (NULL); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), frame, TRUE, TRUE, @@ -617,6 +682,7 @@ } } +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 tempwid = gtk_button_new_with_label (_("OK")); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, @@ -636,6 +702,10 @@ GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (dialog)); gtk_widget_show (tempwid); +#else + g_signal_connect (GTK_OBJECT (dialog), "response", + G_CALLBACK (proxyhosts_action), NULL); +#endif gtk_widget_show (dialog); }
--- a/src/gtk/rename_dialog.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/rename_dialog.c Mon Sep 16 12:27:50 2002 +0000 @@ -19,65 +19,19 @@ #include "gftp-gtk.h" -static void dorenCB ( GtkWidget * widget, - gftp_dialog_data * data ); -static void *do_rename_thread ( void * data ); -static RETSIGTYPE sig_renquit ( int signo ); - static sigjmp_buf renenvir; static const char *edttext; static gftp_file * curfle; -void -rename_dialog (gpointer data) + +static RETSIGTYPE +sig_renquit (int signo) { - GList *templist, *filelist; - gftp_window_data * wdata; - char *tempstr; - int num; - - wdata = data; - if (!check_status (_("Rename"), wdata, wdata->request->use_threads, 1, 1, - wdata->request->rename != NULL)) - return; - - templist = GTK_CLIST (wdata->listbox)->selection; - num = 0; - filelist = wdata->files; - templist = get_next_selection (templist, &filelist, &num); - curfle = filelist->data; - - tempstr = g_strdup_printf (_("What would you like to rename %s to?"), - curfle->file); - MakeEditDialog (_("Rename"), tempstr, curfle->file, 1, 1, NULL, - _("Rename"), dorenCB, wdata, _(" Cancel "), NULL, NULL); - g_free (tempstr); + signal (signo, sig_renquit); + siglongjmp (renenvir, signo == SIGINT ? 1 : 2); } -static void -dorenCB (GtkWidget * widget, gftp_dialog_data * data) -{ - gftp_window_data * wdata; - - wdata = data->data; - edttext = gtk_entry_get_text (GTK_ENTRY (data->edit)); - if (*edttext == '\0') - { - ftp_log (gftp_logging_misc, NULL, - _("Rename: Operation canceled...you must enter a string\n")); - return; - } - - if (check_reconnect (wdata) < 0) - return; - - if ((int) generic_thread (do_rename_thread, wdata)) - refresh ((gpointer) wdata); -} - - - static void * do_rename_thread (void * data) { @@ -124,10 +78,48 @@ } -static RETSIGTYPE -sig_renquit (int signo) +static void +dorenCB (gftp_window_data * wdata, gftp_dialog_data * ddata) { - signal (signo, sig_renquit); - siglongjmp (renenvir, signo == SIGINT ? 1 : 2); + edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); + if (*edttext == '\0') + { + ftp_log (gftp_logging_misc, NULL, + _("Rename: Operation canceled...you must enter a string\n")); + return; + } + + if (check_reconnect (wdata) < 0) + return; + + if ((int) generic_thread (do_rename_thread, wdata)) + refresh ((gpointer) wdata); } + +void +rename_dialog (gpointer data) +{ + GList *templist, *filelist; + gftp_window_data * wdata; + char *tempstr; + int num; + + wdata = data; + if (!check_status (_("Rename"), wdata, wdata->request->use_threads, 1, 1, + wdata->request->rename != NULL)) + return; + + templist = GTK_CLIST (wdata->listbox)->selection; + num = 0; + filelist = wdata->files; + templist = get_next_selection (templist, &filelist, &num); + curfle = filelist->data; + + tempstr = g_strdup_printf (_("What would you like to rename %s to?"), + curfle->file); + MakeEditDialog (_("Rename"), tempstr, curfle->file, 1, NULL, + gftp_dialog_button_rename, dorenCB, wdata, NULL, NULL); + g_free (tempstr); +} +
--- a/src/gtk/transfer.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/transfer.c Mon Sep 16 12:27:50 2002 +0000 @@ -20,20 +20,12 @@ #include <gftp-gtk.h> static void *getdir_thread ( void *data ); -static void try_connect_again ( GtkWidget * widget, - gftp_dialog_data * data ); -static void dont_connect_again ( GtkWidget * widget, - gftp_dialog_data * data ); static void *connect_thread ( void *data ); static void on_next_transfer ( gftp_transfer * tdata ); static void show_transfer ( gftp_transfer * tdata ); static void transfer_done ( GList * node ); static void create_transfer ( gftp_transfer * tdata ); static void update_file_status ( gftp_transfer * tdata ); -static void get_trans_password ( GtkWidget * widget, - gftp_dialog_data * data ); -static void cancel_get_trans_password ( GtkWidget * widget, - gftp_dialog_data * data ); static void trans_selectall ( GtkWidget * widget, gpointer data ); static void trans_unselectall ( GtkWidget * widget, @@ -51,11 +43,11 @@ static void gftp_gtk_calc_kbs ( gftp_transfer * tdata, ssize_t num_read ); static void check_done_process ( void ); -static void do_upload ( GtkWidget * widget, - gftp_dialog_data * data ); -static void free_edit_data ( GtkWidget * widget, - gftp_dialog_data * data ); -static void do_free_edit_data ( gftp_viewedit_data * ve_proc ); +static void do_upload ( gftp_viewedit_data * ve_proc, + gftp_dialog_data * ddata ); +static void dont_upload ( gftp_viewedit_data * ve_proc, + gftp_dialog_data * ddata ); +static void free_edit_data ( gftp_viewedit_data *ve_proc ); static int get_status ( gftp_transfer * tdata, ssize_t num_read ); static void wakeup_main_thread ( gpointer data, @@ -221,6 +213,21 @@ } +static void +try_connect_again (gftp_request * request, gftp_dialog_data * ddata) +{ + gftp_set_password (request, gtk_entry_get_text (GTK_ENTRY (ddata->edit))); + request->stopable = 0; +} + + +static void +dont_connect_again (gftp_request * request, gftp_dialog_data * ddata) +{ + request->stopable = 0; +} + + int ftp_connect (gftp_window_data * wdata, gftp_request * request, int getdir) { @@ -243,8 +250,9 @@ request->stopable = 1; MakeEditDialog (_("Enter Password"), _("Please enter your password for this site"), NULL, - 0, 1, NULL, _("Connect"), try_connect_again, request, - _(" Cancel "), dont_connect_again, request); + 0, NULL, gftp_dialog_button_connect, + try_connect_again, request, + dont_connect_again, request); while (request->stopable) g_main_iteration (TRUE); @@ -292,29 +300,6 @@ } -static void -try_connect_again (GtkWidget * widget, gftp_dialog_data * data) -{ - gftp_request * request; - - request = data->data; - gftp_set_password (request, gtk_entry_get_text (GTK_ENTRY (data->edit))); - data->data = NULL; - request->stopable = 0; -} - - -static void -dont_connect_again (GtkWidget * widget, gftp_dialog_data * data) -{ - gftp_request * request; - - request = data->data; - data->data = NULL; - request->stopable = 0; -} - - static void * connect_thread (void *data) { @@ -1044,6 +1029,34 @@ static void +get_trans_password (gftp_request * request, gftp_dialog_data * ddata) +{ + gftp_set_password (request, gtk_entry_get_text (GTK_ENTRY (ddata->edit))); + request->stopable = 0; +} + + +static void +cancel_get_trans_password (gftp_transfer * tdata, gftp_dialog_data * ddata) +{ + if (tdata->fromreq->stopable == 0) + return; + + pthread_mutex_lock (tdata->structmutex); + if (tdata->started) + tdata->cancel = 1; + else + tdata->done = 1; + + tdata->fromreq->stopable = 0; + tdata->toreq->stopable = 0; + ftp_log (gftp_logging_misc, NULL, _("Stopping the transfer of %s\n"), + ((gftp_file *) tdata->curfle->data)->file); + pthread_mutex_unlock (tdata->structmutex); +} + + +static void show_transfer (gftp_transfer * tdata) { GdkPixmap * closedir_pixmap, * opendir_pixmap; @@ -1102,8 +1115,9 @@ tdata->toreq->stopable = 1; MakeEditDialog (_("Enter Password"), _("Please enter your password for this site"), NULL, 0, - 1, NULL, _("Connect"), get_trans_password, tdata->toreq, - _(" Cancel "), cancel_get_trans_password, tdata); + NULL, gftp_dialog_button_connect, + get_trans_password, tdata->toreq, + cancel_get_trans_password, tdata); } if (!tdata->fromreq->stopable && tdata->fromreq->need_userpass && @@ -1112,8 +1126,9 @@ tdata->fromreq->stopable = 1; MakeEditDialog (_("Enter Password"), _("Please enter your password for this site"), NULL, 0, - 1, NULL, _("Connect"), get_trans_password, tdata->fromreq, - _(" Cancel "), cancel_get_trans_password, tdata); + NULL, gftp_dialog_button_connect, + get_trans_password, tdata->fromreq, + cancel_get_trans_password, tdata); } } @@ -1290,40 +1305,6 @@ } -static void -get_trans_password (GtkWidget * widget, gftp_dialog_data * data) -{ - gftp_request * request; - - request = data->data; - gftp_set_password (request, gtk_entry_get_text (GTK_ENTRY (data->edit))); - data->data = NULL; - request->stopable = 0; -} - - -static void -cancel_get_trans_password (GtkWidget * widget, gftp_dialog_data * data) -{ - gftp_transfer * tdata; - - tdata = data->data; - if (tdata->fromreq->stopable == 0) - return; - pthread_mutex_lock (tdata->structmutex); - if (tdata->started) - tdata->cancel = 1; - else - tdata->done = 1; - tdata->fromreq->stopable = 0; - tdata->toreq->stopable = 0; - data->data = NULL; - ftp_log (gftp_logging_misc, NULL, _("Stopping the transfer of %s\n"), - ((gftp_file *) tdata->curfle->data)->file); - pthread_mutex_unlock (tdata->structmutex); -} - - void start_transfer (gpointer data) { @@ -1597,7 +1578,7 @@ dltitles[1] = _("Local Size"); dltitles[2] = _("Remote Size"); dltitles[3] = _("Action"); - dialog = gtk_dialog_new (); + dialog = gtk_dialog_new (); /* FIXME - gtk+ 2.0 stock icons */ gtk_grab_add (dialog); gtk_window_set_title (GTK_WINDOW (dialog), tdata->transfer_direction == GFTP_DIRECTION_DOWNLOAD ? @@ -1910,7 +1891,7 @@ tdata->stalled = 0; difftime = (tv.tv_sec - tdata->starttime.tv_sec) + ((double) (tv.tv_usec - tdata->starttime.tv_usec) / 1000000.0); - if (difftime == 0) + if (difftime <= 0) tdata->kbs = (double) tdata->trans_bytes / 1024.0; else tdata->kbs = (double) tdata->trans_bytes / 1024.0 / difftime; @@ -1996,18 +1977,18 @@ { memcpy (&ve_proc->st, &st, sizeof (ve_proc->st)); str = g_strdup_printf ( - _("File %s has changed.\nWhat would you like to do?"), + _("File %s has changed.\nWould you like to upload it?"), ve_proc->remote_filename); - MakeYesNoDialog (_("Edit File"), str, 1, 2, - _("Upload"), do_upload, ve_proc, - _(" Cancel "), free_edit_data, ve_proc); + MakeYesNoDialog (_("Edit File"), str, + do_upload, ve_proc, + dont_upload, ve_proc); g_free (str); continue; } } - do_free_edit_data (ve_proc); + free_edit_data (ve_proc); continue; } } @@ -2016,13 +1997,11 @@ static void -do_upload (GtkWidget * widget, gftp_dialog_data * data) +do_upload (gftp_viewedit_data * ve_proc, gftp_dialog_data * ddata) { - gftp_viewedit_data * ve_proc; gftp_file * tempfle; GList * newfile; - ve_proc = data->data; tempfle = g_malloc0 (sizeof (*tempfle)); tempfle->destfile = ve_proc->remote_filename; ve_proc->remote_filename = NULL; @@ -2032,23 +2011,20 @@ newfile = g_list_append (NULL, tempfle); add_file_transfer (ve_proc->fromwdata->request, ve_proc->towdata->request, ve_proc->fromwdata, ve_proc->towdata, newfile, 1); - do_free_edit_data (ve_proc); + free_edit_data (ve_proc); } static void -free_edit_data (GtkWidget * widget, gftp_dialog_data * data) +dont_upload (gftp_viewedit_data * ve_proc, gftp_dialog_data * ddata) { - gftp_viewedit_data * ve_proc; - - ve_proc = data->data; remove_file (ve_proc->filename); - do_free_edit_data (data->data); + free_edit_data (ve_proc); } static void -do_free_edit_data (gftp_viewedit_data * ve_proc) +free_edit_data (gftp_viewedit_data * ve_proc) { int i;
--- a/src/gtk/view_dialog.c Wed Sep 11 10:26:13 2002 +0000 +++ b/src/gtk/view_dialog.c Mon Sep 16 12:27:50 2002 +0000 @@ -243,17 +243,29 @@ g_strerror (errno)); } +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), filename); - gtk_window_set_wmclass (GTK_WINDOW(dialog), "fileview", "gFTP"); - gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5); gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5); + gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); +#else + dialog = gtk_dialog_new_with_buttons (filename, NULL, 0, + GTK_STOCK_CLOSE, + GTK_RESPONSE_CLOSE, + NULL); +#endif + gtk_window_set_wmclass (GTK_WINDOW(dialog), "fileview", "gFTP"); + gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); - gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); - gtk_signal_connect_object (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (dialog)); + gtk_widget_realize (dialog); + + if (gftp_icon != NULL) + { + gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, + gftp_icon->bitmap); + gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); + } table = gtk_table_new (1, 2, FALSE); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0); @@ -298,6 +310,7 @@ gtk_widget_set_size_request (table, 500, 400); gtk_widget_show (table); +#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 tempwid = gtk_button_new_with_label (_(" Close ")); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, FALSE, FALSE, 0); @@ -305,6 +318,11 @@ GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (dialog)); gtk_widget_show (tempwid); +#else + g_signal_connect_swapped (GTK_OBJECT (dialog), "response", + G_CALLBACK (gtk_widget_destroy), + GTK_OBJECT (dialog)); +#endif buf[sizeof (buf) - 1] = '\0'; while ((n = read (fd, buf, sizeof (buf) - 1)))