2
* $Id: monitor.c,v 1.6 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
*----------------------------------------------------------------------
30
* GUI stuff used by 'share.c'.
32
* @author Raphael Manfredi
33
* @author Richard Eckart
39
RCSID("$Id: monitor.c,v 1.6 2005/07/01 09:35:51 daichik Exp $");
41
#include "gtk/monitor.h"
43
#include "if/core/share.h"
44
#include "if/gui_property_priv.h"
45
#include "if/bridge/ui2c.h"
48
#include "lib/glib-missing.h"
49
#include "lib/override.h" /* Must be the last header included */
55
static guint32 monitor_items = 0;
62
monitor_gui_append_to_monitor(query_type_t type, const gchar *item,
63
guint32 unused_ip, guint16 unused_port)
65
static GtkWidget *clist_monitor = NULL;
70
if (clist_monitor == NULL) {
71
clist_monitor = lookup_widget(main_window, "clist_monitor");
72
g_assert(clist_monitor != NULL);
75
gtk_clist_freeze(GTK_CLIST(clist_monitor));
77
for (/* empty */; monitor_items >= monitor_max_items; monitor_items--) {
78
gint row = GTK_CLIST(clist_monitor)->rows - 1;
83
gtk_clist_remove(GTK_CLIST(clist_monitor), row);
86
if (monitor_max_items > 0) {
90
if (type == QUERY_SHA1) {
91
/* If the query is empty and we have a SHA1 extension,
92
* we print a urn:sha1-query instead. */
93
gm_snprintf(tmpstr, sizeof(tmpstr), "urn:sha1:%s", item);
95
g_strlcpy(tmpstr, item, sizeof(tmpstr));
99
gtk_clist_prepend(GTK_CLIST(clist_monitor), titles);
103
gtk_clist_thaw(GTK_CLIST(clist_monitor));
114
monitor_gui_init(void)
116
gtk_clist_column_titles_passive
117
(GTK_CLIST(lookup_widget(main_window, "clist_monitor")));
121
monitor_gui_shutdown(void)
123
monitor_gui_enable_monitor(FALSE);
127
* Remove all but the first n items from the monitor.
130
monitor_gui_clear_monitor(void)
132
GtkWidget *clist_monitor;
134
clist_monitor = lookup_widget(main_window, "clist_monitor");
136
gtk_clist_clear(GTK_CLIST(clist_monitor));
141
* Enable/disable monitor.
144
monitor_gui_enable_monitor(const gboolean val)
146
static gboolean registered = FALSE;
147
gtk_widget_set_sensitive
148
(lookup_widget(main_window, "clist_monitor"), !val);
150
if (val != registered) {
152
guc_share_add_search_request_listener
153
(monitor_gui_append_to_monitor);
155
guc_share_remove_search_request_listener
156
(monitor_gui_append_to_monitor);
162
/* vi: set ts=4 sw=4 cindent: */