1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
// pkg_node.cc
//
// Copyright 1999, 2000, 2002, 2005 Daniel Burrows
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// Implementations of stuff in pkg_node.h
#include <cwidget/config/keybindings.h>
#include "pkg_node.h"
#include "ui.h"
#include <generic/apt/apt.h>
#include <generic/apt/apt_undo_group.h>
#include <generic/apt/config_signal.h>
#include <generic/util/undo.h>
#include <cwidget/widgets/tree.h>
namespace cw = cwidget;
namespace cwidget
{
using namespace widgets;
}
cw::config::keybindings *pkg_tree_node::bindings=NULL;
void pkg_tree_node::init_bindings()
{
bindings = new cw::config::keybindings(&cw::config::global_bindings);
}
// FIXME: add a do_action() command that takes a function pointer and does all
// the extra junk below.
bool pkg_tree_node::dispatch_key(const cw::config::key &k, cw::tree *owner)
{
undo_group *grp=new apt_undo_group;
if(bindings->key_matches(k, "Install"))
select(grp);
else if(bindings->key_matches(k, "Remove"))
remove(grp);
else if(bindings->key_matches(k, "Hold"))
hold(grp);
else if(bindings->key_matches(k, "Keep"))
keep(grp);
else if(bindings->key_matches(k, "Purge"))
purge(grp);
else if(bindings->key_matches(k, "Reinstall"))
reinstall(grp);
else if(bindings->key_matches(k, "SetAuto"))
set_auto(true, grp);
else if(bindings->key_matches(k, "ClearAuto"))
set_auto(false, grp);
else
{
delete grp;
return false;
}
if(!grp->empty())
apt_undos->add_item(grp);
else
delete grp;
if(aptcfg->FindB(PACKAGE "::UI::Advance-On-Action", false))
owner->level_line_down();
package_states_changed();
return true;
}
//////////////////////////// Menu Redirections //////////////////////////
bool pkg_tree_node::package_action(void (pkg_tree_node::* action)(undo_group *))
{
undo_group *grp = new apt_undo_group;
(this->*action)(grp);
if(!grp->empty())
apt_undos->add_item(grp);
else
delete grp;
package_states_changed();
return true;
}
bool pkg_tree_node::package_enabled()
{
return true;
}
bool pkg_tree_node::package_install()
{
return package_action(&pkg_tree_node::select);
}
bool pkg_tree_node::package_remove()
{
return package_action(&pkg_tree_node::remove);
}
bool pkg_tree_node::package_purge()
{
return package_action(&pkg_tree_node::purge);
}
bool pkg_tree_node::package_keep()
{
return package_action(&pkg_tree_node::keep);
}
bool pkg_tree_node::package_hold()
{
return package_action(&pkg_tree_node::hold);
}
bool pkg_tree_node::package_mark_auto()
{
return package_action(&pkg_tree_node::mark_auto);
}
bool pkg_tree_node::package_unmark_auto()
{
return package_action(&pkg_tree_node::unmark_auto);
}
|