comparison src/gtk/menu-items.c @ 45:311e29c40ed6

2002-10-31 Brian Masney <masneyb@gftp.org> * src/gtk/*.[ch] - don't check for gtk+ version based on the minor version. May cause problems later on. * lib/protocols.c src/gtk/bookmarks.c src/gtk/misc-gtk.c - use UTF8 functions for user data when using glib 2.0
author masneyb
date Thu, 31 Oct 2002 23:55:17 +0000
parents cd169e4789df
children eec25f215772
comparison
equal deleted inserted replaced
44:9c0825c047e7 45:311e29c40ed6
585 585
586 void 586 void
587 clearlog (gpointer data) 587 clearlog (gpointer data)
588 { 588 {
589 guint len; 589 guint len;
590 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 590 #if GTK_MAJOR_VERSION == 1
591 len = gtk_text_get_length (GTK_TEXT (logwdw)); 591 len = gtk_text_get_length (GTK_TEXT (logwdw));
592 gtk_text_set_point (GTK_TEXT (logwdw), len); 592 gtk_text_set_point (GTK_TEXT (logwdw), len);
593 gtk_text_backward_delete (GTK_TEXT (logwdw), len); 593 gtk_text_backward_delete (GTK_TEXT (logwdw), len);
594 #else 594 #else
595 GtkTextBuffer * textbuf; 595 GtkTextBuffer * textbuf;
609 { 609 {
610 char *tempstr, *txt, *pos; 610 char *tempstr, *txt, *pos;
611 guint textlen; 611 guint textlen;
612 ssize_t len; 612 ssize_t len;
613 int fd; 613 int fd;
614 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) 614 #if GTK_MAJOR_VERSION > 1
615 GtkTextBuffer * textbuf; 615 GtkTextBuffer * textbuf;
616 GtkTextIter iter, iter2; 616 GtkTextIter iter, iter2;
617 #endif 617 #endif
618 618
619 tempstr = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXXXXXX", NULL); 619 tempstr = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXXXXXX", NULL);
626 return; 626 return;
627 } 627 }
628 chmod (tempstr, S_IRUSR | S_IWUSR); 628 chmod (tempstr, S_IRUSR | S_IWUSR);
629 unlink (tempstr); 629 unlink (tempstr);
630 630
631 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 631 #if GTK_MAJOR_VERSION == 1
632 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); 632 textlen = gtk_text_get_length (GTK_TEXT (logwdw));
633 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); 633 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1);
634 #else 634 #else
635 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); 635 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw));
636 textlen = gtk_text_buffer_get_char_count (textbuf); 636 textlen = gtk_text_buffer_get_char_count (textbuf);
665 char *txt, *pos; 665 char *txt, *pos;
666 guint textlen; 666 guint textlen;
667 ssize_t len; 667 ssize_t len;
668 FILE *fd; 668 FILE *fd;
669 int ok; 669 int ok;
670 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) 670 #if GTK_MAJOR_VERSION > 1
671 GtkTextBuffer * textbuf; 671 GtkTextBuffer * textbuf;
672 GtkTextIter iter, iter2; 672 GtkTextIter iter, iter2;
673 #endif 673 #endif
674 674
675 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); 675 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
679 _("Error: Cannot open %s for writing: %s\n"), filename, 679 _("Error: Cannot open %s for writing: %s\n"), filename,
680 g_strerror (errno)); 680 g_strerror (errno));
681 return; 681 return;
682 } 682 }
683 683
684 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 684 #if GTK_MAJOR_VERSION == 1
685 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); 685 textlen = gtk_text_get_length (GTK_TEXT (logwdw));
686 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); 686 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1);
687 #else 687 #else
688 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); 688 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw));
689 textlen = gtk_text_buffer_get_char_count (textbuf); 689 textlen = gtk_text_buffer_get_char_count (textbuf);
749 GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll, 749 GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll,
750 * dialog; 750 * dialog;
751 char *tempstr, *no_license_agreement, *str, buf[255]; 751 char *tempstr, *no_license_agreement, *str, buf[255];
752 size_t len; 752 size_t len;
753 FILE * fd; 753 FILE * fd;
754 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) 754 #if GTK_MAJOR_VERSION > 1
755 GtkTextBuffer * textbuf; 755 GtkTextBuffer * textbuf;
756 GtkTextIter iter; 756 GtkTextIter iter;
757 guint textlen; 757 guint textlen;
758 #endif 758 #endif
759 759
760 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); 760 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);
761 761
762 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 762 #if GTK_MAJOR_VERSION == 1
763 dialog = gtk_dialog_new (); 763 dialog = gtk_dialog_new ();
764 gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP")); 764 gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP"));
765 gtk_container_border_width (GTK_CONTAINER 765 gtk_container_border_width (GTK_CONTAINER
766 (GTK_DIALOG (dialog)->action_area), 5); 766 (GTK_DIALOG (dialog)->action_area), 5);
767 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); 767 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE);
821 821
822 tempwid = gtk_table_new (1, 2, FALSE); 822 tempwid = gtk_table_new (1, 2, FALSE);
823 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0); 823 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0);
824 gtk_widget_show (tempwid); 824 gtk_widget_show (tempwid);
825 825
826 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 826 #if GTK_MAJOR_VERSION == 1
827 view = gtk_text_new (NULL, NULL); 827 view = gtk_text_new (NULL, NULL);
828 gtk_text_set_editable (GTK_TEXT (view), FALSE); 828 gtk_text_set_editable (GTK_TEXT (view), FALSE);
829 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE); 829 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE);
830 830
831 gtk_table_attach (GTK_TABLE (tempwid), view, 0, 1, 0, 1, 831 gtk_table_attach (GTK_TABLE (tempwid), view, 0, 1, 0, 1,
862 label = gtk_label_new (_("License Agreement")); 862 label = gtk_label_new (_("License Agreement"));
863 gtk_widget_show (label); 863 gtk_widget_show (label);
864 864
865 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); 865 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label);
866 866
867 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 867 #if GTK_MAJOR_VERSION == 1
868 tempwid = gtk_button_new_with_label (_(" Close ")); 868 tempwid = gtk_button_new_with_label (_(" Close "));
869 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); 869 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
870 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, 870 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
871 FALSE, FALSE, 0); 871 FALSE, FALSE, 0);
872 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", 872 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
889 { 889 {
890 g_free (tempstr); 890 g_free (tempstr);
891 tempstr = expand_path (BASE_CONF_DIR "/COPYING"); 891 tempstr = expand_path (BASE_CONF_DIR "/COPYING");
892 if (access (tempstr, F_OK) != 0) 892 if (access (tempstr, F_OK) != 0)
893 { 893 {
894 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 894 #if GTK_MAJOR_VERSION == 1
895 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, 895 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL,
896 no_license_agreement, -1); 896 no_license_agreement, -1);
897 #else 897 #else
898 textlen = gtk_text_buffer_get_char_count (textbuf); 898 textlen = gtk_text_buffer_get_char_count (textbuf);
899 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); 899 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1);
905 } 905 }
906 } 906 }
907 907
908 if ((fd = fopen (tempstr, "r")) == NULL) 908 if ((fd = fopen (tempstr, "r")) == NULL)
909 { 909 {
910 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 910 #if GTK_MAJOR_VERSION == 1
911 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, 911 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL,
912 no_license_agreement, -1); 912 no_license_agreement, -1);
913 #else 913 #else
914 textlen = gtk_text_buffer_get_char_count (textbuf); 914 textlen = gtk_text_buffer_get_char_count (textbuf);
915 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); 915 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1);
923 923
924 memset (buf, 0, sizeof (buf)); 924 memset (buf, 0, sizeof (buf));
925 while ((len = fread (buf, 1, sizeof (buf) - 1, fd))) 925 while ((len = fread (buf, 1, sizeof (buf) - 1, fd)))
926 { 926 {
927 buf[len] = '\0'; 927 buf[len] = '\0';
928 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 928 #if GTK_MAJOR_VERSION == 1
929 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1); 929 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1);
930 #else 930 #else
931 textlen = gtk_text_buffer_get_char_count (textbuf); 931 textlen = gtk_text_buffer_get_char_count (textbuf);
932 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); 932 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1);
933 gtk_text_buffer_insert (textbuf, &iter, buf, -1); 933 gtk_text_buffer_insert (textbuf, &iter, buf, -1);