2
* $Id: downloads_common.c,v 1.5 2005/07/01 09:35:51 daichik Exp $
4
* Copyright (c) 2001-2003, Raphael Manfredi, Richard Eckart
6
*----------------------------------------------------------------------
7
* This file is part of gtk-gnutella.
9
* gtk-gnutella is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* gtk-gnutella is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with gtk-gnutella; if not, write to the Free Software
22
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
*----------------------------------------------------------------------
28
RCSID("$Id: downloads_common.c,v 1.5 2005/07/01 09:35:51 daichik Exp $");
29
#include "downloads_common.h"
30
#include "downloads.h"
31
#include "statusbar.h"
34
#include "gtk2/downloads_cb.h"
37
#include "gtk1/downloads_cb.h"
40
#include "if/bridge/ui2c.h"
41
#include "if/gui_property_priv.h"
43
#include "lib/override.h" /* Must be the last header included */
45
#define IO_STALLED 60 /**< If nothing exchanged after that many secs */
46
#define IO_AVG_RATE 5 /**< Compute global recv rate every 5 secs */
48
static gboolean update_download_clear_needed = FALSE;
51
* Remember that we need to check for cleared downloads at the next
52
* invocation of gui_update_download_clear_now(), which happens once
53
* every second only to avoid too frequent costly list traversals.
56
gui_update_download_clear(void)
58
update_download_clear_needed = TRUE;
62
* Checks if there are any active downloads that are clearable
63
* If so, this activates the "Clear Stopped" button
66
gui_update_download_clear_now(void)
68
if (!update_download_clear_needed)
71
gtk_widget_set_sensitive(
72
lookup_widget(main_window, "button_downloads_clear_stopped"),
73
guc_download_something_to_clear());
77
* Checks if the download queue is frozen, if so update the freeze queue
78
* widgets and display a message on the statusbar
81
gui_update_queue_frozen(void)
83
static gboolean msg_displayed = FALSE;
84
static statusbar_msgid_t id = {0, 0};
86
GtkWidget *togglebutton_queue_freeze;
88
togglebutton_queue_freeze =
89
lookup_widget(main_window, "togglebutton_queue_freeze");
92
g_message("frozen %i, msg %i\n",
93
guc_download_queue_is_frozen(),
94
(gint) msg_displayed);
96
if (guc_download_queue_is_frozen() > 0) {
98
gtk_widget_hide(lookup_widget(main_window, "vbox_queue_freeze"));
99
gtk_widget_show(lookup_widget(main_window, "vbox_queue_thaw"));
103
GTK_LABEL(GTK_BIN(togglebutton_queue_freeze)->child),
106
if (!msg_displayed) {
107
msg_displayed = TRUE;
108
id = statusbar_gui_message(0, "QUEUE FROZEN");
112
gtk_widget_show(lookup_widget(main_window, "vbox_queue_freeze"));
113
gtk_widget_hide(lookup_widget(main_window, "vbox_queue_thaw"));
117
GTK_LABEL(GTK_BIN(togglebutton_queue_freeze)->child),
121
msg_displayed = FALSE;
122
statusbar_gui_remove(id);
126
gtk_signal_handler_block_by_func(
127
GTK_OBJECT(togglebutton_queue_freeze),
128
GTK_SIGNAL_FUNC(on_togglebutton_queue_freeze_toggled),
131
gtk_toggle_button_set_active(
132
GTK_TOGGLE_BUTTON(togglebutton_queue_freeze),
133
guc_download_queue_is_frozen() > 0);
135
gtk_signal_handler_unblock_by_func(
136
GTK_OBJECT(togglebutton_queue_freeze),
137
GTK_SIGNAL_FUNC(on_togglebutton_queue_freeze_toggled),
142
* Enable the "start now" menu entry for queued items.
145
gui_download_enable_start_now(guint32 running_downloads, guint32 max_downloads)
147
GtkWidget *w = lookup_widget(popup_queue, "popup_queue_start_now");
148
gboolean selected = TRUE;
151
selected = GTK_CLIST(
152
lookup_widget(main_window, "ctree_downloads_queue"))->selection != NULL;
154
gtk_widget_set_sensitive(w, selected && running_downloads < max_downloads);
159
* Clear all stopped, complete, and unavailable downloads.
162
on_button_downloads_clear_stopped_clicked(GtkButton *unused_button,
163
gpointer unused_udata)
165
(void) unused_button;
167
guc_download_clear_stopped(TRUE, TRUE, TRUE, TRUE);
172
* Freeze the downloads queue.
174
void on_togglebutton_queue_freeze_toggled(GtkToggleButton *togglebutton,
175
gpointer unused_udata)
179
if (gtk_toggle_button_get_active(togglebutton)) {
180
guc_download_freeze_queue();
182
guc_download_thaw_queue();
186
/* vi: set ts=4 sw=4 cindent: */