~ubuntu-branches/ubuntu/karmic/gtk-gnutella/karmic

« back to all changes in this revision

Viewing changes to src/ui/gtk/gtk2/nodes_cb.c

  • Committer: Bazaar Package Importer
  • Author(s): Anand Kumria
  • Date: 2005-08-04 11:32:05 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050804113205-q746i4lgo3rtlegn
Tags: 0.95.4-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: nodes_cb.c,v 1.8 2005/06/25 01:37:45 daichik Exp $
 
3
 *
 
4
 * Copyright (c) 2001-2003, Raphael Manfredi, Richard Eckart
 
5
 *
 
6
 *----------------------------------------------------------------------
 
7
 * This file is part of gtk-gnutella.
 
8
 *
 
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.
 
13
 *
 
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.
 
18
 *
 
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
 
21
 *  Foundation, Inc.:
 
22
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 *----------------------------------------------------------------------
 
24
 */
 
25
 
 
26
/**
 
27
 * @ingroup gtk
 
28
 * @file
 
29
 *
 
30
 * GUI filtering functions.
 
31
 *
 
32
 * @author Raphael Manfredi
 
33
 * @author Richard Eckart
 
34
 * @date 2001-2003
 
35
 */
 
36
 
 
37
#include "gtk/gui.h"
 
38
 
 
39
RCSID("$Id: nodes_cb.c,v 1.8 2005/06/25 01:37:45 daichik Exp $");
 
40
 
 
41
#include "nodes_cb.h"
 
42
#include "gtk/gtkcolumnchooser.h"
 
43
#include "gtk/nodes_common.h"
 
44
 
 
45
#include "if/bridge/ui2c.h"
 
46
 
 
47
#include "lib/iso3166.h"
 
48
#include "lib/override.h"               /* Must be the last header included */
 
49
 
 
50
static void
 
51
add_node(void)
 
52
{
 
53
    gchar *addr;
 
54
    GtkEditable *editable = GTK_EDITABLE
 
55
        (lookup_widget(main_window, "entry_host"));
 
56
 
 
57
    addr = gtk_editable_get_chars(editable, 0, -1);
 
58
    nodes_gui_common_connect_by_name(addr);
 
59
    G_FREE_NULL(addr);
 
60
    gtk_entry_set_text(GTK_ENTRY(editable), "");
 
61
}
 
62
 
 
63
void
 
64
on_button_nodes_remove_clicked(GtkButton *unused_button, gpointer unused_udata)
 
65
{
 
66
        (void) unused_button;
 
67
        (void) unused_udata;
 
68
        nodes_gui_remove_selected();
 
69
}
 
70
 
 
71
gboolean
 
72
on_popup_nodes_disconnect_activate(GtkItem *unused_item, gpointer unused_udata)
 
73
{
 
74
        (void) unused_item;
 
75
        (void) unused_udata;
 
76
        nodes_gui_remove_selected();
 
77
        return TRUE;
 
78
}
 
79
 
 
80
gboolean
 
81
on_popup_nodes_reverse_lookup_activate(GtkItem *unused_item,
 
82
                gpointer unused_udata)
 
83
{
 
84
        (void) unused_item;
 
85
        (void) unused_udata;
 
86
        nodes_gui_reverse_lookup_selected();
 
87
        return TRUE;
 
88
}
 
89
 
 
90
void
 
91
on_button_nodes_add_clicked(GtkButton *unused_button, gpointer unused_udata)
 
92
{
 
93
        (void) unused_button;
 
94
        (void) unused_udata;
 
95
    add_node();
 
96
}
 
97
 
 
98
void
 
99
on_entry_host_activate(GtkEditable *unused_editable, gpointer unused_udata)
 
100
{
 
101
        (void) unused_editable;
 
102
        (void) unused_udata;
 
103
    add_node();
 
104
}
 
105
 
 
106
void
 
107
on_entry_host_changed(GtkEditable *editable, gpointer unused_udata)
 
108
{
 
109
        gchar *e;
 
110
 
 
111
        (void) unused_udata;
 
112
        e = gtk_editable_get_chars(editable, 0, -1);
 
113
        g_strstrip(e);
 
114
        gtk_widget_set_sensitive(lookup_widget(main_window, "button_nodes_add"),
 
115
        e[0] != '\0');
 
116
        G_FREE_NULL(e);
 
117
}
 
118
 
 
119
gboolean
 
120
on_treeview_nodes_button_press_event(GtkWidget *unused_widget,
 
121
                GdkEventButton *event, gpointer unused_udata)
 
122
{
 
123
        (void) unused_widget;
 
124
        (void) unused_udata;
 
125
 
 
126
    if (3 == event->button) {
 
127
        /* right click section (popup menu) */
 
128
 
 
129
        gtk_menu_popup(GTK_MENU(popup_nodes), NULL, NULL, NULL, NULL, 1, 0);
 
130
        return TRUE;
 
131
        }
 
132
        return FALSE;
 
133
}
 
134
 
 
135
/**
 
136
 * Creates and pops up the column chooser for ``treeview_nodes''
 
137
 */
 
138
gboolean
 
139
on_popup_nodes_config_cols_activate(GtkItem *unused_menuitem,
 
140
        gpointer unused_udata)
 
141
{
 
142
    GtkWidget *cc;
 
143
 
 
144
        (void) unused_menuitem;
 
145
        (void) unused_udata;
 
146
    cc = gtk_column_chooser_new(lookup_widget(main_window, "treeview_nodes"));
 
147
    gtk_menu_popup(GTK_MENU(cc), NULL, NULL, NULL, NULL, 1, 0);
 
148
 
 
149
    /* GtkColumnChooser takes care of cleaning up itself */
 
150
        return TRUE;
 
151
}
 
152
 
 
153
/* vi: set ts=4 sw=4 cindent: */