# HG changeset patch # User masneyb # Date 1170813380 0 # Node ID 19dacfb6943324bc15dca29902ff3c436c793bc9 # Parent a15adc70e3277fd670842befd975a804d07daf7a 2007-2-6 Brian Masney * src/gtk/menu-items.c - removed duplicated code that was found by PMD diff -r a15adc70e327 -r 19dacfb69433 ChangeLog --- a/ChangeLog Mon Feb 05 23:24:04 2007 +0000 +++ b/ChangeLog Wed Feb 07 01:56:20 2007 +0000 @@ -1,3 +1,6 @@ +2007-2-6 Brian Masney + * src/gtk/menu-items.c - removed duplicated code that was found by PMD + 2007-2-5 Brian Masney * src/gtk/gftp-gtk.c (CreateMenus) - fixes for creating the transfers menu. This was only broken in CVS. diff -r a15adc70e327 -r 19dacfb69433 src/gtk/menu-items.c --- a/src/gtk/menu-items.c Mon Feb 05 23:24:04 2007 +0000 +++ b/src/gtk/menu-items.c Wed Feb 07 01:56:20 2007 +0000 @@ -21,26 +21,12 @@ static const char cvsid[] = "$Id$"; static void -dochange_filespec (gftp_window_data * wdata, gftp_dialog_data * ddata) +update_window_listbox (gftp_window_data * wdata) { GList * templist, * filelist; gftp_file * tempfle; - const char *edttext; int num; - wdata->show_selected = 0; - - edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); - if (*edttext == '\0') - { - ftp_log (gftp_logging_error, NULL, - _("Change Filespec: Operation canceled...you must enter a string\n")); - return; - } - if (wdata->filespec) - g_free (wdata->filespec); - wdata->filespec = g_strdup (edttext); - filelist = wdata->files; templist = gftp_gtk_get_list_selection (wdata); num = 0; @@ -65,6 +51,29 @@ } +static void +dochange_filespec (gftp_window_data * wdata, gftp_dialog_data * ddata) +{ + const char *edttext; + + wdata->show_selected = 0; + + edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); + if (*edttext == '\0') + { + ftp_log (gftp_logging_error, NULL, + _("Change Filespec: Operation canceled...you must enter a string\n")); + return; + } + + if (wdata->filespec) + g_free (wdata->filespec); + + wdata->filespec = g_strdup (edttext); + update_window_listbox (wdata); +} + + void change_filespec (gpointer data) { @@ -155,35 +164,11 @@ void show_selected (gpointer data) { - GList * templist, * filelist; gftp_window_data * wdata; - gftp_file * tempfle; - int num; wdata = data; wdata->show_selected = 1; - - filelist = wdata->files; - templist = gftp_gtk_get_list_selection (wdata); - num = 0; - while (templist != NULL) - { - templist = get_next_selection (templist, &filelist, &num); - tempfle = filelist->data; - tempfle->was_sel = 1; - } - - gtk_clist_freeze (GTK_CLIST (wdata->listbox)); - gtk_clist_clear (GTK_CLIST (wdata->listbox)); - templist = wdata->files; - while (templist != NULL) - { - tempfle = templist->data; - add_file_listbox (wdata, tempfle); - templist = templist->next; - } - gtk_clist_thaw (GTK_CLIST (wdata->listbox)); - update_window (wdata); + update_window_listbox (wdata); } @@ -647,21 +632,15 @@ } -void -compare_windows (gpointer data) +static void +_do_compare_windows (gftp_window_data * win1, gftp_window_data * win2) { gftp_file * curfle, * otherfle; GList * curlist, * otherlist; int row, curdir, othdir; - if (!check_status (_("Compare Windows"), &window2, 1, 0, 0, 1)) - return; - - deselectall (&window1); - deselectall (&window2); - row = 0; - curlist = window1.files; + curlist = win1->files; while (curlist != NULL) { curfle = curlist->data; @@ -671,7 +650,7 @@ continue; } - otherlist = window2.files; + otherlist = win2->files; while (otherlist != NULL) { otherfle = otherlist->data; @@ -693,46 +672,22 @@ } if (otherlist == NULL) - gtk_clist_select_row (GTK_CLIST (window1.listbox), row, 0); - row++; - curlist = curlist->next; - } - - row = 0; - curlist = window2.files; - while (curlist != NULL) - { - curfle = curlist->data; - if (!curfle->shown) - { - curlist = curlist->next; - continue; - } - - otherlist = window1.files; - while (otherlist != NULL) - { - otherfle = otherlist->data; - if (!otherfle->shown) - { - otherlist = otherlist->next; - continue; - } - - curdir = S_ISDIR (curfle->st_mode); - othdir = S_ISDIR (otherfle->st_mode); - - if (strcmp (otherfle->file, curfle->file) == 0 && - curdir == othdir && - (curdir || otherfle->size == curfle->size)) - break; - - otherlist = otherlist->next; - } - - if (otherlist == NULL) - gtk_clist_select_row (GTK_CLIST (window2.listbox), row, 0); + gtk_clist_select_row (GTK_CLIST (win1->listbox), row, 0); row++; curlist = curlist->next; } } + + +void +compare_windows (gpointer data) +{ + if (!check_status (_("Compare Windows"), &window2, 1, 0, 0, 1)) + return; + + deselectall (&window1); + deselectall (&window2); + + _do_compare_windows (&window1, &window2); + _do_compare_windows (&window2, &window1); +}