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