Mercurial > gftp.yaz
comparison src/gtk/menu-items.c @ 875:19dacfb69433
2007-2-6 Brian Masney <masneyb@gftp.org>
* src/gtk/menu-items.c - removed duplicated code that was found by PMD
author | masneyb |
---|---|
date | Wed, 07 Feb 2007 01:56:20 +0000 |
parents | afbe37351940 |
children | 1808cebed602 |
comparison
equal
deleted
inserted
replaced
874:a15adc70e327 | 875:19dacfb69433 |
---|---|
19 | 19 |
20 #include "gftp-gtk.h" | 20 #include "gftp-gtk.h" |
21 static const char cvsid[] = "$Id$"; | 21 static const char cvsid[] = "$Id$"; |
22 | 22 |
23 static void | 23 static void |
24 dochange_filespec (gftp_window_data * wdata, gftp_dialog_data * ddata) | 24 update_window_listbox (gftp_window_data * wdata) |
25 { | 25 { |
26 GList * templist, * filelist; | 26 GList * templist, * filelist; |
27 gftp_file * tempfle; | 27 gftp_file * tempfle; |
28 const char *edttext; | |
29 int num; | 28 int num; |
30 | |
31 wdata->show_selected = 0; | |
32 | |
33 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); | |
34 if (*edttext == '\0') | |
35 { | |
36 ftp_log (gftp_logging_error, NULL, | |
37 _("Change Filespec: Operation canceled...you must enter a string\n")); | |
38 return; | |
39 } | |
40 if (wdata->filespec) | |
41 g_free (wdata->filespec); | |
42 wdata->filespec = g_strdup (edttext); | |
43 | 29 |
44 filelist = wdata->files; | 30 filelist = wdata->files; |
45 templist = gftp_gtk_get_list_selection (wdata); | 31 templist = gftp_gtk_get_list_selection (wdata); |
46 num = 0; | 32 num = 0; |
47 while (templist != NULL) | 33 while (templist != NULL) |
60 add_file_listbox (wdata, tempfle); | 46 add_file_listbox (wdata, tempfle); |
61 templist = templist->next; | 47 templist = templist->next; |
62 } | 48 } |
63 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | 49 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); |
64 update_window (wdata); | 50 update_window (wdata); |
51 } | |
52 | |
53 | |
54 static void | |
55 dochange_filespec (gftp_window_data * wdata, gftp_dialog_data * ddata) | |
56 { | |
57 const char *edttext; | |
58 | |
59 wdata->show_selected = 0; | |
60 | |
61 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); | |
62 if (*edttext == '\0') | |
63 { | |
64 ftp_log (gftp_logging_error, NULL, | |
65 _("Change Filespec: Operation canceled...you must enter a string\n")); | |
66 return; | |
67 } | |
68 | |
69 if (wdata->filespec) | |
70 g_free (wdata->filespec); | |
71 | |
72 wdata->filespec = g_strdup (edttext); | |
73 update_window_listbox (wdata); | |
65 } | 74 } |
66 | 75 |
67 | 76 |
68 void | 77 void |
69 change_filespec (gpointer data) | 78 change_filespec (gpointer data) |
153 | 162 |
154 | 163 |
155 void | 164 void |
156 show_selected (gpointer data) | 165 show_selected (gpointer data) |
157 { | 166 { |
158 GList * templist, * filelist; | |
159 gftp_window_data * wdata; | 167 gftp_window_data * wdata; |
160 gftp_file * tempfle; | |
161 int num; | |
162 | 168 |
163 wdata = data; | 169 wdata = data; |
164 wdata->show_selected = 1; | 170 wdata->show_selected = 1; |
165 | 171 update_window_listbox (wdata); |
166 filelist = wdata->files; | |
167 templist = gftp_gtk_get_list_selection (wdata); | |
168 num = 0; | |
169 while (templist != NULL) | |
170 { | |
171 templist = get_next_selection (templist, &filelist, &num); | |
172 tempfle = filelist->data; | |
173 tempfle->was_sel = 1; | |
174 } | |
175 | |
176 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
177 gtk_clist_clear (GTK_CLIST (wdata->listbox)); | |
178 templist = wdata->files; | |
179 while (templist != NULL) | |
180 { | |
181 tempfle = templist->data; | |
182 add_file_listbox (wdata, tempfle); | |
183 templist = templist->next; | |
184 } | |
185 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
186 update_window (wdata); | |
187 } | 172 } |
188 | 173 |
189 | 174 |
190 void | 175 void |
191 selectall (gpointer data) | 176 selectall (gpointer data) |
645 g_free (no_license_agreement); | 630 g_free (no_license_agreement); |
646 gftp_free_pixmap ("gftp-logo.xpm"); | 631 gftp_free_pixmap ("gftp-logo.xpm"); |
647 } | 632 } |
648 | 633 |
649 | 634 |
650 void | 635 static void |
651 compare_windows (gpointer data) | 636 _do_compare_windows (gftp_window_data * win1, gftp_window_data * win2) |
652 { | 637 { |
653 gftp_file * curfle, * otherfle; | 638 gftp_file * curfle, * otherfle; |
654 GList * curlist, * otherlist; | 639 GList * curlist, * otherlist; |
655 int row, curdir, othdir; | 640 int row, curdir, othdir; |
656 | 641 |
657 if (!check_status (_("Compare Windows"), &window2, 1, 0, 0, 1)) | |
658 return; | |
659 | |
660 deselectall (&window1); | |
661 deselectall (&window2); | |
662 | |
663 row = 0; | 642 row = 0; |
664 curlist = window1.files; | 643 curlist = win1->files; |
665 while (curlist != NULL) | 644 while (curlist != NULL) |
666 { | 645 { |
667 curfle = curlist->data; | 646 curfle = curlist->data; |
668 if (!curfle->shown) | 647 if (!curfle->shown) |
669 { | 648 { |
670 curlist = curlist->next; | 649 curlist = curlist->next; |
671 continue; | 650 continue; |
672 } | 651 } |
673 | 652 |
674 otherlist = window2.files; | 653 otherlist = win2->files; |
675 while (otherlist != NULL) | 654 while (otherlist != NULL) |
676 { | 655 { |
677 otherfle = otherlist->data; | 656 otherfle = otherlist->data; |
678 if (!otherfle->shown) | 657 if (!otherfle->shown) |
679 { | 658 { |
691 | 670 |
692 otherlist = otherlist->next; | 671 otherlist = otherlist->next; |
693 } | 672 } |
694 | 673 |
695 if (otherlist == NULL) | 674 if (otherlist == NULL) |
696 gtk_clist_select_row (GTK_CLIST (window1.listbox), row, 0); | 675 gtk_clist_select_row (GTK_CLIST (win1->listbox), row, 0); |
697 row++; | 676 row++; |
698 curlist = curlist->next; | 677 curlist = curlist->next; |
699 } | 678 } |
700 | 679 } |
701 row = 0; | 680 |
702 curlist = window2.files; | 681 |
703 while (curlist != NULL) | 682 void |
704 { | 683 compare_windows (gpointer data) |
705 curfle = curlist->data; | 684 { |
706 if (!curfle->shown) | 685 if (!check_status (_("Compare Windows"), &window2, 1, 0, 0, 1)) |
707 { | 686 return; |
708 curlist = curlist->next; | 687 |
709 continue; | 688 deselectall (&window1); |
710 } | 689 deselectall (&window2); |
711 | 690 |
712 otherlist = window1.files; | 691 _do_compare_windows (&window1, &window2); |
713 while (otherlist != NULL) | 692 _do_compare_windows (&window2, &window1); |
714 { | 693 } |
715 otherfle = otherlist->data; | |
716 if (!otherfle->shown) | |
717 { | |
718 otherlist = otherlist->next; | |
719 continue; | |
720 } | |
721 | |
722 curdir = S_ISDIR (curfle->st_mode); | |
723 othdir = S_ISDIR (otherfle->st_mode); | |
724 | |
725 if (strcmp (otherfle->file, curfle->file) == 0 && | |
726 curdir == othdir && | |
727 (curdir || otherfle->size == curfle->size)) | |
728 break; | |
729 | |
730 otherlist = otherlist->next; | |
731 } | |
732 | |
733 if (otherlist == NULL) | |
734 gtk_clist_select_row (GTK_CLIST (window2.listbox), row, 0); | |
735 row++; | |
736 curlist = curlist->next; | |
737 } | |
738 } |