summaryrefslogtreecommitdiff
path: root/src/pkg_node.h
blob: aedf422c2aac61fdfbf913d7ad1b08b3a365a223 (plain)
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
// pkg_node.h	-*-c++-*-
//
//  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.
//
//  In the fine tradition of breaking header files up into their smallest
// usable components..

#ifndef PKG_NODE_H
#define PKG_NODE_H

#include "menu_redirect.h"

#include <cwidget/widgets/treeitem.h>

class undo_group;
class keybindings;

class pkg_tree_node:virtual public cwidget::widgets::treeitem, public menu_redirect
// Provides some extra package-related interfaces.
{
  /** Used to convert calls via the menu interface to wrapped
   *  invocations of the low-level action methods.
   */
  bool package_action(void (pkg_tree_node::* action)(undo_group *));
public:
  virtual void select(undo_group *undo)=0;
  virtual void hold(undo_group *undo)=0;
  virtual void keep(undo_group *undo)=0;
  virtual void remove(undo_group *undo)=0;
  virtual void purge(undo_group *undo)=0;
  virtual void reinstall(undo_group *undo)=0;
  // set_auto is idempotent!  No stupid toggling stuff.
  virtual void set_auto(bool isauto, undo_group *undo)=0;

  void mark_auto(undo_group *undo) {set_auto(true, undo);}
  void unmark_auto(undo_group *undo) {set_auto(false, undo);}

  bool dispatch_key(const cwidget::config::key &k, cwidget::widgets::tree *owner);
  // IMPORTANT NOTE: pkg_tree_node::dispatch_char() does NOT call
  // cwidget::widgets::treeitem::dispatch_char!

  static keybindings *bindings;
  static void init_bindings();

  // Menu redirections:
  bool package_enabled();
  bool package_install();
  bool package_remove();
  bool package_purge();
  bool package_hold();
  bool package_keep();
  bool package_mark_auto();
  bool package_unmark_auto();
};

#endif