comparison src/gtkft.c @ 5826:bd0d0e89cac3

[gaim-migrate @ 6256] You can once again set your buddy icon. Of course, you* haven't been using CVS, so you've always been able to set your buddy icon. * Gaim developers not applicable committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 10 Jun 2003 01:09:26 +0000
parents bb8f0a149831
children 059d95c67cda
comparison
equal deleted inserted replaced
5825:729e688fd2e7 5826:bd0d0e89cac3
93 }; 93 };
94 94
95 /************************************************************************** 95 /**************************************************************************
96 * Utility Functions 96 * Utility Functions
97 **************************************************************************/ 97 **************************************************************************/
98 static char *
99 get_size_string(size_t size)
100 {
101 static const char *size_str[4] = { "bytes", "KB", "MB", "GB" };
102 float size_mag;
103 int size_index = 0;
104
105 if (size == -1) {
106 return g_strdup(_("Calculating..."));
107 }
108 else if (size == 0) {
109 return g_strdup(_("Unknown."));
110 }
111 else {
112 size_mag = (float)size;
113
114 while ((size_index < 4) && (size_mag > 1024)) {
115 size_mag /= 1024;
116 size_index++;
117 }
118
119 return g_strdup_printf("%.2f %s", size_mag, size_str[size_index]);
120 }
121 }
122
123 static void 98 static void
124 get_xfer_info_strings(struct gaim_xfer *xfer, 99 get_xfer_info_strings(struct gaim_xfer *xfer,
125 char **kbsec, char **time_elapsed, 100 char **kbsec, char **time_elapsed,
126 char **time_remaining) 101 char **time_remaining)
127 { 102 {
776 751
777 data->start_time = time(NULL); 752 data->start_time = time(NULL);
778 753
779 type = gaim_xfer_get_type(xfer); 754 type = gaim_xfer_get_type(xfer);
780 755
781 size_str = get_size_string(gaim_xfer_get_size(xfer)); 756 size_str = gaim_get_size_string(gaim_xfer_get_size(xfer));
782 remaining_str = get_size_string(gaim_xfer_get_bytes_remaining(xfer)); 757 remaining_str = gaim_get_size_string(gaim_xfer_get_bytes_remaining(xfer));
783 758
784 pixbuf = gtk_widget_render_icon(dialog->window, 759 pixbuf = gtk_widget_render_icon(dialog->window,
785 (type == GAIM_XFER_RECEIVE 760 (type == GAIM_XFER_RECEIVE
786 ? GAIM_STOCK_DOWNLOAD 761 ? GAIM_STOCK_DOWNLOAD
787 : GAIM_STOCK_UPLOAD), 762 : GAIM_STOCK_UPLOAD),
894 return; 869 return;
895 870
896 if (!(data = GAIM_GTKXFER(xfer))) 871 if (!(data = GAIM_GTKXFER(xfer)))
897 return; 872 return;
898 873
899 size_str = get_size_string(gaim_xfer_get_size(xfer)); 874 size_str = gaim_get_size_string(gaim_xfer_get_size(xfer));
900 remaining_str = get_size_string(gaim_xfer_get_bytes_remaining(xfer)); 875 remaining_str = gaim_get_size_string(gaim_xfer_get_bytes_remaining(xfer));
901 876
902 gtk_list_store_set(xfer_dialog->model, &data->iter, 877 gtk_list_store_set(xfer_dialog->model, &data->iter,
903 COLUMN_PROGRESS, gaim_xfer_get_progress(xfer), 878 COLUMN_PROGRESS, gaim_xfer_get_progress(xfer),
904 COLUMN_SIZE, size_str, 879 COLUMN_SIZE, size_str,
905 COLUMN_REMAINING, remaining_str, 880 COLUMN_REMAINING, remaining_str,
1115 char *buf, *size_buf; 1090 char *buf, *size_buf;
1116 size_t size; 1091 size_t size;
1117 1092
1118 size = gaim_xfer_get_size(xfer); 1093 size = gaim_xfer_get_size(xfer);
1119 1094
1120 size_buf = get_size_string(size); 1095 size_buf = gaim_get_size_string(size);
1121 1096
1122 buf = g_strdup_printf(_("%s wants to send you %s (%s)"), 1097 buf = g_strdup_printf(_("%s wants to send you %s (%s)"),
1123 xfer->who, gaim_xfer_get_filename(xfer), size_buf); 1098 xfer->who, gaim_xfer_get_filename(xfer), size_buf);
1124 1099
1125 g_free(size_buf); 1100 g_free(size_buf);