summaryrefslogtreecommitdiff
path: root/src/edit_pkg_hier.h
blob: 5e628d9302d5a5872e073c9b87224bd0aa08dcd1 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// edit_pkg_hier.h           -*-c++-*-
//
//  Copyright 2001, 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.
//

#ifndef EDIT_PKG_HIER
#define EDIT_PKG_HIER

#include <generic/apt/pkg_hier.h>

#include <apt-pkg/pkgcache.h>

#include <cwidget/widgets/tree.h>

/** \brief Provides a convenient way to tweak the package hierarchy
 *
 * 
 *  This provides a convenient way to tweak the package hierarchy.  It lets
 *  the user select which 'groups' a package appears in, then allows them to
 *  save the changes to a file.
 *  
 *  Changes to the hierarchy are stored in GLOBAL VARIABLES.  Specifically,
 *  the user_pkg_hier global variable.
 * 
 *  \file edit_pkg_hier.h
 */

class hier_editor : public cwidget::widgets::tree
{
  class hier_item;

  // Ugh..track all the children we created..
  std::vector<hier_item *> items;

  pkg_hier::item *item;

  // Used for the "lazily load package hierarchies" behavior -- if we
  // get a "set package" command and this widget is invisible, it gets
  // deferred until the widget is shown.  This connection is used to
  // avoid connecting this command more than once.
  sigc::connection shown_conn;

  void save_hier(std::string file);

  void handle_reload();
protected:
  virtual bool handle_key(const cwidget::config::key &k);

  void paint(const cwidget::style &st);

  hier_editor();
public:
  static cwidget::util::ref_ptr<hier_editor> create()
  {
    cwidget::util::ref_ptr<hier_editor> rval(new hier_editor);
    rval->decref();
    return rval;
  }

  bool get_cursorvisible();

  void set_package(const pkgCache::PkgIterator &pkg);

  void set_package(const pkgCache::PkgIterator &pkg,
		   const pkgCache::VerIterator &ver);

  void set_package(std::string name);

  sigc::signal0<void> commit_changes;
};

typedef cwidget::util::ref_ptr<hier_editor> hier_editor_ref;

#endif