Commit afd042a6 authored by twanvl's avatar twanvl

Some changes to the package manager:

 - use a single button for install/upgrade
 - show versions of installed package and installer
Named actions in enum PACKAGE_ACT_* to avoid confusion with the status enum.
parent 06d588f1
......@@ -520,8 +520,15 @@ label:
package installed: installed
package installable: not installed
install package: install
upgrade package: upgrade
reinstall package: reinstall
upgrade package: update
remove package: remove
installed version: Installed version:
installable version: Latest version:
installer size: Size:
installer status: Status:
no version: -
############################################################## Buttons/checkboxes/choices in the GUI
button:
......@@ -594,7 +601,8 @@ button:
keep package: &Don't change
don't install package: &Don't install
install package: &Install
upgrade package: &Upgrade
upgrade package: &Update
reinstall package: Re&install
remove package: &Remove
install group: &Install All
upgrade group: &Upgrade All
......
......@@ -286,51 +286,54 @@ InstallablePackage::InstallablePackage(const PackageDescriptionP& description, c
: description(description)
, installed(installed)
, status(PACKAGE_INSTALLED)
, action(PACKAGE_NOTHING)
, action(PACKAGE_ACT_NOTHING)
{}
InstallablePackage::InstallablePackage(const PackageDescriptionP& description , const DownloadableInstallerP& installer)
: description(description)
, installer(installer)
, status(PACKAGE_INSTALLABLE)
, action(PACKAGE_NOTHING)
, action(PACKAGE_ACT_NOTHING)
{}
void InstallablePackage::determineStatus() {
status = PACKAGE_NOT_INSTALLED;
if (installer) {
status = (PackageStatus)(status | PACKAGE_INSTALLER);
if (!installed || installed->version < description->version) {
if (!installed || installed->version <= description->version) {
status = (PackageStatus)(status | PACKAGE_INSTALLABLE);
}
if (!installed || installed->version < description->version) {
status = (PackageStatus)(status | PACKAGE_NOT_UP_TO_DATE);
}
}
if (installed) {
status = (PackageStatus)(status | PACKAGE_INSTALLED);
if (!(installed->status & PackageVersion::STATUS_FIXED)) {
status = (PackageStatus)(status | PACKAGE_REMOVABLE);
}
#if USE_MODIFIED_CHECK
if (installed->status & PackageVersion::STATUS_MODIFIED) {
status = (PackageStatus)(status | PACKAGE_MODIFIED);
}
#endif
}
#if USE_MODIFIED_CHECK
if (installed && (installed->status & PackageVersion::STATUS_MODIFIED)) {
status = (PackageStatus)(status | PACKAGE_MODIFIED);
}
#endif
}
bool InstallablePackage::willBeInstalled() const {
return (action & PACKAGE_INSTALL) ||
((status & PACKAGE_INSTALLED) && !(action & PACKAGE_REMOVE));
return has(PACKAGE_ACT_INSTALL) ||
(has(PACKAGE_INSTALLED) && !has(PACKAGE_ACT_REMOVE));
}
bool InstallablePackage::can(PackageAction act) const {
if (act & PACKAGE_INSTALL) return flag(status, PACKAGE_INSTALLABLE);
if (act & PACKAGE_REMOVE) {
if (act & PACKAGE_ACT_INSTALL) return flag(status, PACKAGE_INSTALLABLE);
if (act & PACKAGE_ACT_REMOVE) {
bool ok = flag(status, PACKAGE_REMOVABLE);
if (!(act & PACKAGE_GLOBAL) && installed && PackageVersion::STATUS_GLOBAL) {
if (!(act & PACKAGE_ACT_GLOBAL) && installed && PackageVersion::STATUS_GLOBAL) {
// package installed globally can't be removed locally
return false;
}
return ok;
}
if (act & PACKAGE_NOTHING) {
if (act & PACKAGE_ACT_NOTHING) {
return true;
}
else return false;
......@@ -338,6 +341,9 @@ bool InstallablePackage::can(PackageAction act) const {
bool InstallablePackage::has(PackageAction act) const {
return (action & act) == act;
}
bool InstallablePackage::has(PackageStatus stat) const {
return (status & stat) == stat;
}
void InstallablePackage::merge(const InstallablePackage& p) {
if (!installed) installed = p.installed;
......@@ -456,11 +462,11 @@ void add_package_dependency(InstallablePackages& packages, Dep dep, PackageActio
if (!dep.package) return;
bool change = false;
if (dep.new_version) {
change = !(dep.package->action & PACKAGE_INSTALL);
dep.package->action = where | PACKAGE_INSTALL;
change = !(dep.package->action & PACKAGE_ACT_INSTALL);
dep.package->action = where | PACKAGE_ACT_INSTALL;
inc_if_nonzero(dep.package->automatic);
} else if (dep.package->action & PACKAGE_REMOVE) {
dep.package->action = where | PACKAGE_NOTHING;
} else if (dep.package->action & PACKAGE_ACT_REMOVE) {
dep.package->action = where | PACKAGE_ACT_NOTHING;
dep.package->automatic = 0;
}
if (change) {
......@@ -469,10 +475,10 @@ void add_package_dependency(InstallablePackages& packages, Dep dep, PackageActio
}
void remove_package_dependency_need_not_install(InstallablePackages& packages, Dep dep, PackageAction where) {
if (!dep.package) return;
if (dep.new_version && (dep.package->action & PACKAGE_INSTALL) && dep.package->automatic) {
if (dep.new_version && (dep.package->action & PACKAGE_ACT_INSTALL) && dep.package->automatic) {
// we no longer need to install this package
if (--dep.package->automatic == 0) {
dep.package->action = where | PACKAGE_NOTHING;
dep.package->action = where | PACKAGE_ACT_NOTHING;
for_each_dependency(remove_package_dependency_need_not_install, packages, dep, where);
}
}
......@@ -482,12 +488,12 @@ void remove_package_dependency(InstallablePackages& packages, Dep dep, PackageAc
if (!dep.package) return;
bool change = false;
if (dep.new_version) {
change = !(dep.package->action & PACKAGE_NOTHING);
dep.package->action = where | PACKAGE_NOTHING;
change = !dep.package->has(PACKAGE_ACT_NOTHING);
dep.package->action = where | PACKAGE_ACT_NOTHING;
dep.package->automatic = 0;
} else if (dep.package->status & PACKAGE_REMOVABLE) {
change = !(dep.package->action & PACKAGE_REMOVE);
dep.package->action = where | PACKAGE_REMOVE;
} else if (dep.package->has(PACKAGE_REMOVABLE)) {
change = !dep.package->has(PACKAGE_ACT_REMOVE);
dep.package->action = where | PACKAGE_ACT_REMOVE;
inc_if_nonzero(dep.package->automatic);
}
if (change) {
......@@ -508,19 +514,19 @@ bool add_package_dependency(InstallablePackages& packages, const PackageDependen
// if !set then instead the dependency is no longer needed because we are not installing the package
if (!p->installed || p->installed->version < dep.version) {
bool change = false;
if (p->action & PACKAGE_INSTALL) {
if (p->action & PACKAGE_ACT_INSTALL) {
// this package is already scheduled for installation
if (p->automatic) {
// we are already automatically depending on this package
p->automatic += set ? +1 : -1;
if (p->automatic == 0) {
// no one needs this package anymore
p->action = PACKAGE_NOTHING;
p->action = PACKAGE_ACT_NOTHING;
change = true;
}
}
} else if (set) {
p->action = where | PACKAGE_INSTALL;
p->action = where | PACKAGE_ACT_INSTALL;
p->automatic = 1;
change = true;
}
......@@ -542,17 +548,17 @@ void remove_package_dependency(InstallablePackages& packages, const PackageDescr
FOR_EACH(dep, p->description->dependencies) {
if (dep->package == ver.name) {
// we can no longer use package p
if (p->action & PACKAGE_REMOVE) {
if (p->action & PACKAGE_ACT_REMOVE) {
if (p->automatic) {
p->automatic += set ? +1 : -1;
if (p->automatic == 0) {
// no one needs this package anymore
p->action = PACKAGE_NOTHING;
p->action = PACKAGE_ACT_NOTHING;
remove_package_dependency(packages, *p->description, where, set);
}
}
} else if (set) {
p->action = where | PACKAGE_REMOVE;
p->action = where | PACKAGE_ACT_REMOVE;
p->automatic = 1;
remove_package_dependency(packages, *p->description, where, set);
}
......@@ -563,21 +569,21 @@ void remove_package_dependency(InstallablePackages& packages, const PackageDescr
}
bool set_package_action_unsafe(InstallablePackages& packages, const InstallablePackageP& package, PackageAction action) {
PackageAction where = (PackageAction)(action & PACKAGE_WHERE);
if ((action & PACKAGE_INSTALL) || ((action & PACKAGE_NOTHING) && (package->status & PACKAGE_INSTALLED))) {
PackageAction where = (PackageAction)(action & PACKAGE_ACT_WHERE);
if ((action & PACKAGE_ACT_INSTALL) || ((action & PACKAGE_ACT_NOTHING) && package->has(PACKAGE_INSTALLED))) {
// need the package
package->automatic = 0;
package->action = action;
// check dependencies
FOR_EACH(dep, package->description->dependencies) {
if (!add_package_dependency(packages, *dep, where, !(action & PACKAGE_NOTHING))) return false;
if (!add_package_dependency(packages, *dep, where, !(action & PACKAGE_ACT_NOTHING))) return false;
}
return true;
} else if ((action & PACKAGE_REMOVE) || ((action & PACKAGE_NOTHING) && !(package->status & PACKAGE_INSTALLED))) {
} else if ((action & PACKAGE_ACT_REMOVE) || ((action & PACKAGE_ACT_NOTHING) && !package->has(PACKAGE_INSTALLED))) {
package->automatic = 0;
package->action = action;
// check dependencies
remove_package_dependency(packages, *package->description, where, !(action & PACKAGE_NOTHING));
remove_package_dependency(packages, *package->description, where, !(action & PACKAGE_ACT_NOTHING));
return true;
}
return false;
......
......@@ -111,21 +111,22 @@ enum PackageStatus
, PACKAGE_INSTALLED = 0x0001
, PACKAGE_REMOVABLE = 0x0002
, PACKAGE_INSTALLER = 0x0010 ///< Package can be installed (there is an installer)
, PACKAGE_INSTALLABLE = 0x0110 ///< Package can be installed (it makes sense to do so)
, PACKAGE_UPDATES = 0x0111 ///< Remote updates available
, PACKAGE_INSTALLABLE = 0x0110 ///< Package can be installed (and it makes sense to do so)
, PACKAGE_NOT_UP_TO_DATE= 0x0200 ///< The local installed version (if any) is not up to date
, PACKAGE_UPDATES = 0x0311 ///< Remote updates available
, PACKAGE_MODIFIED = 0x1001 ///< Local changes made
, PACKAGE_MISSING_DEP = 0x0200 ///< Missing a dependency for installation
, PACKAGE_MISSING_DEP = 0x2000 ///< Missing a dependency for installation
, PACKAGE_CONFLICTS = PACKAGE_UPDATES | PACKAGE_MODIFIED
};
/// (un)install a package?
enum PackageAction
{ PACKAGE_NOTHING = 0x001 ///< Don't change anything
, PACKAGE_INSTALL = 0x002 ///< Install or upgrade the package
, PACKAGE_REMOVE = 0x004 ///< Remove the package (if it was installed)
, PACKAGE_LOCAL = 0x010 ///< In the local package directory
, PACKAGE_GLOBAL = 0x020 ///< In the global package directory
, PACKAGE_WHERE = PACKAGE_LOCAL | PACKAGE_GLOBAL
{ PACKAGE_ACT_NOTHING = 0x001 ///< Don't change anything
, PACKAGE_ACT_INSTALL = 0x002 ///< Install or upgrade the package
, PACKAGE_ACT_REMOVE = 0x004 ///< Remove the package (if it was installed)
, PACKAGE_ACT_LOCAL = 0x010 ///< In the local package directory
, PACKAGE_ACT_GLOBAL = 0x020 ///< In the global package directory
, PACKAGE_ACT_WHERE = PACKAGE_ACT_LOCAL | PACKAGE_ACT_GLOBAL
};
// bit twidling
inline PackageAction operator | (PackageAction a, PackageAction b) { return (PackageAction)((int)a | (int) b); }
......@@ -159,6 +160,8 @@ class InstallablePackage : public IntrusivePtrVirtualBase {
bool can(PackageAction act) const;
/// Is the action currently selected?
bool has(PackageAction act) const;
/// Does the package have the given status bits all set?
bool has(PackageStatus stat) const;
/// Merge two descriptions of installable packages
void merge(const InstallablePackage& p2);
......
......@@ -195,7 +195,7 @@ PackageUpdateList::PackageUpdateList(Window* parent, const InstallablePackages&
, show_only_installable(show_only_installable)
, packages(packages)
{
item_height = max(item_height,17);
item_height = max(item_height,19);
rebuild();
}
PackageUpdateList::~PackageUpdateList() {
......@@ -238,48 +238,54 @@ void PackageUpdateList::initItems() {
}
void PackageUpdateList::drawItem(DC& dc, size_t index, size_t column, int x, int y, bool selected) const {
// offset for drawing
x += 1; y += 3;
// the item
const TreeItem& ti = static_cast<const TreeItem&>(*items[index]);
Color color = wxSystemSettings::GetColour(selected ? wxSYS_COLOUR_HIGHLIGHTTEXT : wxSYS_COLOUR_WINDOWTEXT);
if (column == 0) {
// Name
const Bitmap& bmp = ti.highlight() ? ti.icon : ti.icon_grey;
if (bmp.Ok()) dc.DrawBitmap(bmp,x,y);
if (bmp.Ok()) dc.DrawBitmap(bmp, x-1,y-2);
dc.SetTextForeground(color);
dc.DrawText(capitalize_sentence(ti.label), x+18, y+2);
dc.DrawText(capitalize_sentence(ti.label), x+17, y);
} else if (column == 1 && ti.package) {
// Status
int stat = ti.package->status;
if ((stat & PACKAGE_CONFLICTS) == PACKAGE_CONFLICTS) {
InstallablePackage& package = *ti.package;
if (package.has(PACKAGE_CONFLICTS)) {
dc.SetTextForeground(lerp(color,Color(255,0,0),0.8));
dc.DrawText(_LABEL_("package conflicts"), x+1,y+2);
} else if ((stat & PACKAGE_MODIFIED) == PACKAGE_MODIFIED) {
dc.DrawText(_LABEL_("package conflicts"), x,y);
} else if (package.has(PACKAGE_MODIFIED)) {
dc.SetTextForeground(lerp(color,Color(255,255,0),0.5));
dc.DrawText(_LABEL_("package modified"), x+1,y+2);
} else if ((stat & PACKAGE_UPDATES) == PACKAGE_UPDATES) {
dc.DrawText(_LABEL_("package modified"), x,y);
} else if (package.has(PACKAGE_UPDATES)) {
dc.SetTextForeground(lerp(color,Color(0,0,255),0.5));
dc.DrawText(_LABEL_("package updates"), x+1,y+2);
} else if ((stat & PACKAGE_INSTALLED) == PACKAGE_INSTALLED) {
dc.DrawText(_LABEL_("package updates"), x,y);
} else if (package.has(PACKAGE_INSTALLED)) {
dc.SetTextForeground(color);
dc.DrawText(_LABEL_("package installed"), x+1,y+2);
} else if ((stat & PACKAGE_INSTALLABLE) == PACKAGE_INSTALLABLE) {
dc.DrawText(_LABEL_("package installed"), x,y);
} else if (package.has(PACKAGE_INSTALLABLE)) {
dc.SetTextForeground(lerp(color,Color(128,128,128),0.6));
dc.SetTextForeground(color);
dc.DrawText(_LABEL_("package installable"), x+1,y+2);
dc.DrawText(_LABEL_("package installable"), x,y);
}
} else if (column == 2 && ti.package) {
// Action
int act = ti.package->action;
if (act & PACKAGE_INSTALL) {
if (ti.package->status & PACKAGE_INSTALLED) {
dc.SetTextForeground(lerp(color,Color(0,0,255),0.5));
dc.DrawText(_LABEL_("upgrade package"), x+1,y+2);
InstallablePackage& package = *ti.package;
if (package.has(PACKAGE_ACT_INSTALL)) {
if (package.has(PACKAGE_UPDATES)) {
dc.SetTextForeground(lerp(color,Color(0,0,255),0.6));
dc.DrawText(_LABEL_("upgrade package"), x,y);
} else if (package.has(PACKAGE_INSTALLED)) {
dc.SetTextForeground(lerp(color,Color(0,0,255),0.2));
dc.DrawText(_LABEL_("reinstall package"), x,y);
} else {
dc.SetTextForeground(lerp(color,Color(0,255,0),0.5));
dc.DrawText(_LABEL_("install package"), x+1,y+2);
dc.SetTextForeground(lerp(color,Color(0,255,0),0.6));
dc.DrawText(_LABEL_("install package"), x,y);
}
} else if (act & PACKAGE_REMOVE) {
dc.SetTextForeground(lerp(color,Color(255,0,0),0.5));
dc.DrawText(_LABEL_("remove package"), x+1,y+2);
} else if (package.has(PACKAGE_ACT_REMOVE)) {
dc.SetTextForeground(lerp(color,Color(255,0,0),0.7));
dc.DrawText(_LABEL_("remove package"), x,y);
}
}
}
......@@ -294,9 +300,9 @@ String PackageUpdateList::columnText(size_t column) const {
int PackageUpdateList::columnWidth(size_t column) const {
if (column == 0) {
wxSize cs = GetClientSize();
return cs.x - 300;
return cs.x - 240;
} else {
return 150;
return 120;
}
}
......@@ -14,6 +14,7 @@
#include <util/window_id.hpp>
#include <data/installer.hpp>
#include <data/settings.hpp>
#include <gfx/gfx.hpp>
#include <wx/wfstream.h>
#include <wx/html/htmlwin.h>
#include <wx/dialup.h>
......@@ -142,15 +143,48 @@ void PackageInfoPanel::draw(DC& dc) {
// draw package info
if (!package) return;
PackageDescription& d = *package->description;
int x = 5;
// some borders
//%int width = cs.x - 10, height = cs.y - 10;
int x = 5, y = 5;
// draw icon
if (d.icon.Ok()) {
int h = d.icon.GetHeight();
int y = max(0,20-h)/2 + 5;
dc.DrawBitmap(d.icon, x,y);
x += d.icon.GetWidth();
int max_size = 105;
Image icon = d.icon;
int icon_w = icon.GetWidth();
int icon_h = icon.GetHeight();
if (icon_w <= 20 && icon_h <= 20) {
// upsample
icon = resample_preserve_aspect(icon, 96, 96);
icon_w = icon.GetWidth();
icon_h = icon.GetHeight();
}
dc.DrawBitmap(icon, x+(max_size-icon_w)/2, y+(max_size-icon_h)/2);
x += max_size;
}
// package name
x += 7;
dc.SetFont(wxFont(16, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, _("Arial")));
dc.DrawText(d.full_name, x + 5, 3);
dc.DrawText(d.full_name, x, y);
y += dc.GetCharHeight() + 7;
// version
dc.SetFont(*wxNORMAL_FONT);
int dy = dc.GetCharHeight() + 3;
dc.DrawText(_LABEL_("installed version"), x, y);
dc.DrawText(_LABEL_("installable version"), x, y + 1*dy);
//dc.DrawText(_LABEL_("installer size"), x, y + 2*dy);
//dc.DrawText(_LABEL_("installer status"), x, y + 3*dy);
// text size?
int dx = 0, max_dx = 0;
dc.GetTextExtent(_LABEL_("installed version"), &dx, nullptr); max_dx = max(max_dx, dx);
dc.GetTextExtent(_LABEL_("installable version"), &dx, nullptr); max_dx = max(max_dx, dx);
//dc.GetTextExtent(_LABEL_("installer size"), &dx, nullptr); max_dx = max(max_dx, dx);
//dc.GetTextExtent(_LABEL_("installer status"), &dx, nullptr); max_dx = max(max_dx, dx);
x += max_dx + 5;
dc.DrawText(package->installed ? package->installed->version.toString() : _LABEL_("no version"), x, y);
dc.DrawText(package->installer ? package->description->version.toString() : _LABEL_("no version"), x, y + 1*dy);
//dc.DrawText(_("?"), x, y + 2*dy);
//dc.DrawText(_("?"), x, y + 3*dy);
}
wxSize PackageInfoPanel::DoGetBestSize() const {
......@@ -184,8 +218,8 @@ PackagesWindow::PackagesWindow(Window* parent, const InstallerP& installer)
FOR_EACH(p, installable_packages) p->determineStatus();
// mark all packages in the installer for installation
FOR_EACH(ip, installable_packages) {
if (ip->can(PACKAGE_INSTALL)) {
set_package_action(installable_packages, ip, PACKAGE_INSTALL | where);
if (ip->can(PACKAGE_ACT_INSTALL)) {
set_package_action(installable_packages, ip, PACKAGE_ACT_INSTALL | where);
}
}
// update window
......@@ -195,8 +229,8 @@ PackagesWindow::PackagesWindow(Window* parent, const InstallerP& installer)
}
void PackagesWindow::init(Window* parent, bool show_only_installable) {
where = is_install_local(settings.install_type) ? PACKAGE_LOCAL : PACKAGE_GLOBAL;
Create(parent, wxID_ANY, _TITLE_("packages window"), wxDefaultPosition, wxSize(640,480), wxDEFAULT_DIALOG_STYLE | wxCLIP_CHILDREN | wxRESIZE_BORDER);
where = is_install_local(settings.install_type) ? PACKAGE_ACT_LOCAL : PACKAGE_ACT_GLOBAL;
Create(parent, wxID_ANY, _TITLE_("packages window"), wxDefaultPosition, wxSize(640,580), wxDEFAULT_DIALOG_STYLE | wxCLIP_CHILDREN | wxRESIZE_BORDER);
// get packages
wxBusyCursor busy;
......@@ -211,7 +245,6 @@ void PackagesWindow::init(Window* parent, bool show_only_installable) {
wxToggleButton* keep_button = new wxToggleButton(this, ID_KEEP, _BUTTON_("keep package"));
wxToggleButton* install_button = new wxToggleButton(this, ID_INSTALL, _BUTTON_("install package"));
wxToggleButton* upgrade_button = new wxToggleButton(this, ID_UPGRADE, _BUTTON_("upgrade package"));
wxToggleButton* remove_button = new wxToggleButton(this, ID_REMOVE, _BUTTON_("remove package"));
/*
wxRadioButton* keep_button = new wxRadioButton(this, ID_KEEP, _BUTTON_("keep package"));
......@@ -227,11 +260,9 @@ void PackagesWindow::init(Window* parent, bool show_only_installable) {
wxBoxSizer* h = new wxBoxSizer(wxHORIZONTAL);
h->Add(package_info, 1, wxRIGHT, 4);
wxBoxSizer* v2 = new wxBoxSizer(wxVERTICAL);
v2->Add(keep_button, 0, wxEXPAND | wxBOTTOM, 4);
v2->AddStretchSpacer();
v2->Add(install_button, 0, wxEXPAND | wxBOTTOM, 4);
v2->AddStretchSpacer();
v2->Add(upgrade_button, 0, wxEXPAND | wxBOTTOM, 4);
v2->Add(keep_button, 0, wxEXPAND | wxBOTTOM, 4);
v2->AddStretchSpacer();
v2->Add(remove_button, 0, wxEXPAND | wxBOTTOM, 0);
h->Add(v2);
......@@ -254,10 +285,10 @@ void PackagesWindow::onPackageSelect(wxCommandEvent& ev) {
void PackagesWindow::onActionChange(wxCommandEvent& ev) {
if (package) {
PackageAction act = ev.GetId() == ID_INSTALL ? PACKAGE_INSTALL
: ev.GetId() == ID_UPGRADE ? PACKAGE_INSTALL
: ev.GetId() == ID_REMOVE ? PACKAGE_REMOVE
: PACKAGE_NOTHING;
PackageAction act = ev.GetId() == ID_INSTALL ? PACKAGE_ACT_INSTALL
: ev.GetId() == ID_UPGRADE ? PACKAGE_ACT_INSTALL
: ev.GetId() == ID_REMOVE ? PACKAGE_ACT_REMOVE
: PACKAGE_ACT_NOTHING;
act = act | where;
// set action
set_package_action(installable_packages, package, act);
......@@ -274,11 +305,11 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
int to_remove = 0;
int with_modifications = 0;
FOR_EACH(ip, installable_packages) {
if (!ip->has(PACKAGE_NOTHING)) ++to_change;
if ((ip->action & PACKAGE_INSTALL) && ip->installer && !ip->installer->installer) ++to_download;
if (ip->action & PACKAGE_REMOVE) {
if (!ip->has(PACKAGE_ACT_NOTHING)) ++to_change;
if (ip->has(PACKAGE_ACT_INSTALL) && ip->installer && !ip->installer->installer) ++to_download;
if (ip->has(PACKAGE_ACT_REMOVE)) {
to_remove++;
if ((ip->status & PACKAGE_MODIFIED) == PACKAGE_MODIFIED) with_modifications++;
if (ip->has(PACKAGE_MODIFIED)) with_modifications++;
}
}
// anything to do?
......@@ -307,7 +338,7 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
// Download installers
int package_pos = 0, step = 0;
FOR_EACH(ip, installable_packages) {
if ((ip->action & PACKAGE_INSTALL) && ip->installer && !ip->installer->installer) {
if (ip->has(PACKAGE_ACT_INSTALL) && ip->installer && !ip->installer->installer) {
if (!progress.Update(step++, String::Format(_ERROR_("downloading updates"), ++package_pos, to_download))) {
return; // aborted
}
......@@ -330,14 +361,14 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
package_pos = 0;
int success = 0, install = 0, remove = 0;
FOR_EACH(ip, installable_packages) {
if (ip->has(PACKAGE_NOTHING)) continue; // package unchanged
if (ip->has(PACKAGE_ACT_NOTHING)) continue; // package unchanged
if (!progress.Update(step++, String::Format(_ERROR_("installing updates"), ++package_pos, to_change))) {
// don't allow abort.
}
bool ok = package_manager.install(*ip);
if (ok) {
install += ip->has(PACKAGE_INSTALL) && !ip->installed;
remove += ip->has(PACKAGE_REMOVE);
install += ip->has(PACKAGE_ACT_INSTALL) && !ip->installed;
remove += ip->has(PACKAGE_ACT_REMOVE);
success += 1;
}
}
......@@ -360,21 +391,20 @@ void PackagesWindow::onUpdateUI(wxUpdateUIEvent& ev) {
wxToggleButton* w = (wxToggleButton*)ev.GetEventObject();
switch (ev.GetId()) {
case ID_KEEP:
w->SetValue(package && package->has(PACKAGE_NOTHING));
w->Enable (package && package->can(PACKAGE_NOTHING | where));
w->SetValue(package && package->has(PACKAGE_ACT_NOTHING));
w->Enable (package && package->can(PACKAGE_ACT_NOTHING | where));
w->SetLabel(package && package->installed ? _BUTTON_("keep package") : _BUTTON_("don't install package"));
break;
case ID_INSTALL:
w->SetValue(package && package->has(PACKAGE_INSTALL | where) && !package->installed);
w->Enable (package && package->can(PACKAGE_INSTALL | where) && !package->installed);
break;
case ID_UPGRADE:
w->SetValue(package && package->has(PACKAGE_INSTALL | where) && package->installed);
w->Enable (package && package->can(PACKAGE_INSTALL | where) && package->installed);
w->SetValue(package && package->has(PACKAGE_ACT_INSTALL | where));
w->Enable (package && package->can(PACKAGE_ACT_INSTALL | where));
w->SetLabel( !package || !package->installed ? _BUTTON_("install package")
: package->has(PACKAGE_UPDATES) ? _BUTTON_("upgrade package")
: _BUTTON_("reinstall package"));
break;
case ID_REMOVE:
w->SetValue(package && package->has(PACKAGE_REMOVE | where));
w->Enable (package && package->can(PACKAGE_REMOVE | where));
w->SetValue(package && package->has(PACKAGE_ACT_REMOVE | where));
w->Enable (package && package->can(PACKAGE_ACT_REMOVE | where));
//w->SetLabel(package && package->... ? _BUTTON_("remove group") : _BUTTON_("remove package"));
break;
}
......
# This file contains the keys expected to be in MSE locales
# It was automatically generated by tools/locale/locale.pl
# Generated on Wed Aug 27 13:54:25 2008
# Generated on Sun Aug 31 20:53:39 2008
action:
add control point: 0
......@@ -74,6 +74,7 @@ button:
overwrite: 0
random seed: 0
refer parameter: 0
reinstall package: 0
remove group: optional, 0
remove item: 0
remove package: 0
......@@ -290,11 +291,16 @@ label:
html export options: 0
html template: 0
install package: 0
installable version: 0
installed version: 0
installer size: optional, 0
installer status: optional, 0
keyword: 0
language: 0
magic set editor package: optional, 0
match: 0
mode: 0
no version: 0
original: 0
original size: 0
pack selection: 0
......@@ -308,6 +314,7 @@ label:
package status: 0
package updates: 0
percent of normal: 0
reinstall package: 0
reminder: 0
remove package: 0
result: 0
......
......@@ -162,7 +162,7 @@ void PackageManager::findAllInstalledPackages(vector<InstallablePackageP>& packa
}
bool PackageManager::install(const InstallablePackage& package) {
bool install_local = package.action & PACKAGE_LOCAL;
bool install_local = package.has(PACKAGE_ACT_LOCAL);
return (install_local ? local : global).install(package);
}
......@@ -321,10 +321,10 @@ String PackageDirectory::databaseFile() {
bool PackageDirectory::install(const InstallablePackage& package) {
String n = name(package.description->name);
if (package.action & PACKAGE_REMOVE) {
if (package.action & PACKAGE_ACT_REMOVE) {
if (!remove_file_or_dir(n)) return false;
removeFromDatabase(package.description->name);
} else if (package.action & PACKAGE_INSTALL) {
} else if (package.action & PACKAGE_ACT_INSTALL) {
if (!remove_file_or_dir(n + _(".new"))) return false;
bool ok = actual_install(package, n + _(".new"));
if (!ok) return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment