File: pkgwindow.cc

package info (click to toggle)
paco 2.0.9-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,136 kB
  • sloc: sh: 10,464; cpp: 6,463; ansic: 338; makefile: 277; perl: 260
file content (110 lines) | stat: -rw-r--r-- 2,407 bytes parent folder | download | duplicates (3)
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
//=======================================================================
// pkgwindow.cc
//-----------------------------------------------------------------------
// This file is part of the package paco
// Copyright (C) 2004-2009 David Rosal
// For more information visit http://paco.sourceforge.net
//=======================================================================

#include "config.h"
#include "pkgwindow.h"
#include "filestab.h"
#include "infotab.h"
#include "removetab.h"
#include "packagetab.h"
#include "pkg.h"
#include <gtkmm/stock.h>
#include <gtkmm/notebook.h>

using Glib::ustring;
using namespace Gpaco;


PkgWindow::PkgWindow(Pkg& pkg)
:
	Gtk::Window(),
	mPkg(pkg),
	mpFilesTab(new FilesTab(pkg)),
	mpInfoTab(new InfoTab(pkg)),
	mpRemoveTab(new RemoveTab(pkg)),
	mpPackageTab(new PackageTab(pkg)),
	mNotebook()
{
	set_title(pkg.name());
	set_default_size(1, 400);
	try { set_icon_from_file(DATADIR "/pixmaps/gpaco.png"); }
	catch (...) { }

	add(mNotebook);

	mNotebook.append_page(*mpFilesTab, 
		*(Gtk::manage(new TabLabel("Files", Gtk::Stock::DIRECTORY))));
	mNotebook.append_page(*mpInfoTab, 
		*(Gtk::manage(new TabLabel("Properties", Gtk::Stock::PROPERTIES))));
	mNotebook.append_page(*mpRemoveTab, 
		*(Gtk::manage(new TabLabel("Remove", Gtk::Stock::DELETE))));
	mNotebook.append_page(*mpPackageTab, *(Gtk::manage
		(new TabLabel("Package", DATADIR "/pixmaps/gpaco-package.png"))));
	
	mNotebook.show();
	show();
}


PkgWindow::~PkgWindow()
{
	mPkg.changed(true);
	delete mpFilesTab;
	delete mpInfoTab;
	delete mpRemoveTab;
	delete mpPackageTab;
}


void PkgWindow::presentTab(int const& tab)
{
	mNotebook.set_current_page(tab);
	present();
}


// [virtual]
bool PkgWindow::on_delete_event(GdkEventAny*)
{
	g_usleep(1000);
	mPkg.deleteWindow();
	return true;
}


//---------------------//
// PkgWindow::TabLabel //
//---------------------//


PkgWindow::TabLabel::TabLabel(ustring const& title, ustring const& file)
:
	Gtk::HBox(false, 5)
{
	try {
		pack_start(*(Gtk::manage(new Gtk::Image(file))));
	}
	catch (...) { }
	pack_start(*(Gtk::manage(new Gtk::Label(title))));
	show_all_children();
}


PkgWindow::TabLabel::TabLabel(ustring const& title, Gtk::StockID id)
:
	Gtk::HBox(false, 5)
{
	pack_start(*(Gtk::manage(new Gtk::Image(id, Gtk::ICON_SIZE_MENU))));
	pack_start(*(Gtk::manage(new Gtk::Label(title))));
	show_all_children();
}


PkgWindow::TabLabel::~TabLabel()
{ }