2
* $Id: upload_stats_cb.c,v 1.5 2005/06/25 01:37:44 daichik Exp $
4
* Copyright (c) 2003, Raphael Manfredi
5
* Copyright (c) 2001-2003, Richard Eckart
7
*----------------------------------------------------------------------
8
* This file is part of gtk-gnutella.
10
* gtk-gnutella is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* gtk-gnutella is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with gtk-gnutella; if not, write to the Free Software
23
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
*----------------------------------------------------------------------
31
* Handles common GUI operations for upload stats.
33
* @author Raphael Manfredi
35
* @author Richard Eckart
41
RCSID("$Id: upload_stats_cb.c,v 1.5 2005/06/25 01:37:44 daichik Exp $");
43
#include "upload_stats_cb.h"
44
#include "upload_stats.h"
45
#include "gtkcolumnchooser.h"
48
#include "if/bridge/ui2c.h"
49
#include "if/gui_property_priv.h"
51
#include "lib/override.h" /* Must be the last header included */
59
on_button_ul_stats_clear_all_clicked(GtkButton *unused_button,
64
guc_upload_stats_clear_all();
68
on_button_ul_stats_clear_deleted_clicked(GtkButton *unused_button,
73
guc_upload_stats_prune_nonexistent();
79
compare_ul_size(GtkCList *unused_clist, gconstpointer ptr1, gconstpointer ptr2)
85
s1 = ((const struct ul_stats *) ((const GtkCListRow *) ptr1)->data)->size;
86
s2 = ((const struct ul_stats *) ((const GtkCListRow *) ptr2)->data)->size;
88
return (s1 == s2) ? 0 : (s1 > s2) ? 1 : -1;
92
* first by complete, then by attempts
95
compare_ul_complete(GtkCList *unused_clist,
96
gconstpointer ptr1, gconstpointer ptr2)
98
guint32 a1 = ((const struct ul_stats *)
99
((const GtkCListRow *) ptr1)->data)->attempts;
100
guint32 a2 = ((const struct ul_stats *)
101
((const GtkCListRow *) ptr2)->data)->attempts;
102
guint32 c1 = ((const struct ul_stats *)
103
((const GtkCListRow *) ptr1)->data)->complete;
104
guint32 c2 = ((const struct ul_stats *)
105
((const GtkCListRow *) ptr2)->data)->complete;
108
return (c1 != c2) ? ((c1 > c2) ? 1 : -1) :
109
(a1 == a2) ? 0 : (a1 > a2) ? 1 : -1;
113
* first by normalized, then by complete
116
compare_ul_norm(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
121
n1 = ((const struct ul_stats *) ((const GtkCListRow *) ptr1)->data)->norm;
122
n2 = ((const struct ul_stats *) ((const GtkCListRow *) ptr2)->data)->norm;
124
return (n1 != n2) ? ((n1 > n2) ? 1 : -1) :
125
compare_ul_complete(clist, ptr1, ptr2);
129
* first by attempts, then by complete
132
compare_ul_attempts(GtkCList *unused_clist,
133
gconstpointer ptr1, gconstpointer ptr2)
135
guint32 a1 = ((const struct ul_stats *)
136
((const GtkCListRow *) ptr1)->data)->attempts;
137
guint32 a2 = ((const struct ul_stats *)
138
((const GtkCListRow *) ptr2)->data)->attempts;
139
guint32 c1 = ((const struct ul_stats *)
140
((const GtkCListRow *) ptr1)->data)->complete;
141
guint32 c2 = ((const struct ul_stats *)
142
((const GtkCListRow *) ptr2)->data)->complete;
145
return (a1 != a2) ? ((a1 > a2) ? 1 : -1) :
146
(c1 == c2) ? 0 : (c1 > c2) ? 1 : -1;
150
on_clist_ul_stats_click_column(GtkCList *clist, gint column,
151
gpointer unused_udata)
153
static gint ul_sort_column = 2;
154
static gint ul_sort_order = GTK_SORT_DESCENDING;
159
gtk_clist_set_compare_func(clist, NULL);
162
gtk_clist_set_compare_func(clist, compare_ul_size);
165
gtk_clist_set_compare_func(clist, compare_ul_attempts);
168
gtk_clist_set_compare_func(clist, compare_ul_complete);
171
gtk_clist_set_compare_func(clist, compare_ul_norm);
174
g_assert_not_reached();
177
if (column == ul_sort_column) {
178
ul_sort_order = (ul_sort_order == GTK_SORT_DESCENDING) ?
179
GTK_SORT_ASCENDING : GTK_SORT_DESCENDING;
181
ul_sort_column = column;
183
gtk_clist_set_sort_type(clist, ul_sort_order);
184
gtk_clist_set_sort_column(clist, column);
185
gtk_clist_sort(clist);
189
on_clist_ul_stats_resize_column(GtkCList *unused_clist,
190
gint column, gint width, gpointer unused_udata)
194
/* FIXME: use properties */
195
*(gint *) &ul_stats_col_widths[column] = width;
202
on_popup_upload_stats_config_cols_activate(GtkMenuItem *unused_menuitem,
203
gpointer unused_udata)
207
(void) unused_menuitem;
209
cc = gtk_column_chooser_new(
210
lookup_widget(main_window, "treeview_ul_stats"));
211
gtk_menu_popup(GTK_MENU(cc), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
213
#endif /* USE_GTK2 */
215
/* vi: set ts=4 sw=4: */