* Applied patch by Jorma Karvonen which localizes the app. Thanks!
* Fixed issues in the patch, global initializers are executed before the application constructor, and thus before loading the fAppCatalog! Please always at least test-run the application which you patch! * Removed BeOS support, as it no longer builds for BeOS anyway. (Even before this patch) * Fixed broken layout code (setting layout on BScrollView). * Simplyfied view hierarchy. * Coding style cleanups. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36661 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
SubDir HAIKU_TOP src apps installedpackages ;
|
SubDir HAIKU_TOP src apps installedpackages ;
|
||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
|
||||||
|
|
||||||
UsePrivateHeaders shared interface ;
|
UsePrivateHeaders shared interface ;
|
||||||
SubDirHdrs $(HAIKU_TOP) src apps packageinstaller ;
|
SubDirHdrs $(HAIKU_TOP) src apps packageinstaller ;
|
||||||
|
|
||||||
@@ -13,5 +11,14 @@ Application InstalledPackages :
|
|||||||
main.cpp
|
main.cpp
|
||||||
UninstallWindow.cpp
|
UninstallWindow.cpp
|
||||||
UninstallView.cpp
|
UninstallView.cpp
|
||||||
: be tracker $(TARGET_LIBSUPC++)
|
: be locale tracker translation z $(TARGET_LIBSUPC++)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
DoCatalogs InstalledPackages :
|
||||||
|
x-vnd.Haiku-InstalledPackages
|
||||||
|
:
|
||||||
|
main.cpp
|
||||||
|
UninstallView.cpp
|
||||||
|
UninstallWindow.cpp
|
||||||
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, Haiku, Inc.
|
* Copyright (c) 2007-2010, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
* Łukasz 'Sil2100' Zemczak <[email protected]>
|
* Łukasz 'Sil2100' Zemczak <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "UninstallView.h"
|
#include "UninstallView.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -13,19 +15,27 @@
|
|||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
|
#include <GroupLayout.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <ListView.h>
|
||||||
|
#include <Locale.h>
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
|
#include <ScrollView.h>
|
||||||
|
#include <SeparatorView.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
#include <SpaceLayoutItem.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
|
||||||
# include <GroupLayout.h>
|
#undef TR_CONTEXT
|
||||||
# include <GroupLayoutBuilder.h>
|
#define TR_CONTEXT "UninstallView"
|
||||||
# include <SpaceLayoutItem.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -34,10 +44,6 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Reserved
|
|
||||||
#define T(x) x
|
|
||||||
|
|
||||||
|
|
||||||
// TODO list:
|
// TODO list:
|
||||||
// - B_ENTRY_MOVED
|
// - B_ENTRY_MOVED
|
||||||
// - Right now the installed package info naming convention is the same
|
// - Right now the installed package info naming convention is the same
|
||||||
@@ -45,37 +51,38 @@ enum {
|
|||||||
// - Add a status window (reuse the one from PackageInstall)
|
// - Add a status window (reuse the one from PackageInstall)
|
||||||
|
|
||||||
|
|
||||||
static const char* kNoPackageSelected = "No package selected.";
|
|
||||||
|
|
||||||
class UninstallView::InfoItem : public BStringItem {
|
class UninstallView::InfoItem : public BStringItem {
|
||||||
public:
|
public:
|
||||||
InfoItem(const BString& name, const BString& version,
|
InfoItem(const BString& name, const BString& version,
|
||||||
const char* filename, const node_ref& ref)
|
const char* filename, const node_ref& ref)
|
||||||
: BStringItem(name.String()),
|
:
|
||||||
fName(name),
|
BStringItem(name.String()),
|
||||||
fVersion(version),
|
fName(name),
|
||||||
fNodeRef(ref)
|
fVersion(version),
|
||||||
{
|
fNodeRef(ref)
|
||||||
if (fName.Length() == 0)
|
{
|
||||||
SetText(filename);
|
if (fName.Length() == 0)
|
||||||
}
|
SetText(filename);
|
||||||
|
}
|
||||||
|
|
||||||
const char* GetName() { return fName.String(); }
|
const char* GetName() { return fName.String(); }
|
||||||
const char* GetVersion() { return fVersion.String(); };
|
const char* GetVersion() { return fVersion.String(); };
|
||||||
node_ref GetNodeRef() { return fNodeRef; };
|
node_ref GetNodeRef() { return fNodeRef; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fName;
|
BString fName;
|
||||||
BString fVersion;
|
BString fVersion;
|
||||||
node_ref fNodeRef;
|
node_ref fNodeRef;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UninstallView::UninstallView(BRect frame)
|
UninstallView::UninstallView()
|
||||||
: BView(frame, "uninstall_view", B_FOLLOW_NONE, 0)
|
:
|
||||||
|
BGroupView(B_VERTICAL)
|
||||||
{
|
{
|
||||||
|
fNoPackageSelectedString = TR("No package selected.");
|
||||||
_InitView();
|
_InitView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,23 +144,23 @@ UninstallView::MessageReceived(BMessage* msg)
|
|||||||
fprintf(stderr, "Created?...\n");
|
fprintf(stderr, "Created?...\n");
|
||||||
BString filename, name, version;
|
BString filename, name, version;
|
||||||
node_ref ref;
|
node_ref ref;
|
||||||
if (msg->FindString("name", &filename) != B_OK ||
|
if (msg->FindString("name", &filename) != B_OK
|
||||||
msg->FindInt32("device", &ref.device) != B_OK ||
|
|| msg->FindInt32("device", &ref.device) != B_OK
|
||||||
msg->FindInt64("node", &ref.node) != B_OK)
|
|| msg->FindInt64("node", &ref.node) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO: This obviously is a hack
|
// TODO: This obviously is a hack
|
||||||
// The node watcher informs the view a bit to early, and because
|
// The node watcher informs the view a bit to early, and
|
||||||
// of this the data of the node is not ready at this moment.
|
// because of this the data of the node is not ready at this
|
||||||
// For this reason, we must give the filesystem some time before
|
// moment. For this reason, we must give the filesystem some
|
||||||
// continuing.
|
// time before continuing.
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
|
|
||||||
if (fWatcherRunning) {
|
if (fWatcherRunning) {
|
||||||
_AddFile(filename.String(), ref);
|
_AddFile(filename.String(), ref);
|
||||||
} else {
|
} else {
|
||||||
// This most likely means we were waiting for the packages/ dir
|
// This most likely means we were waiting for
|
||||||
// to appear
|
// the packages/ dir to appear
|
||||||
if (filename == "packages") {
|
if (filename == "packages") {
|
||||||
if (watch_node(&ref, B_WATCH_DIRECTORY, this) == B_OK)
|
if (watch_node(&ref, B_WATCH_DIRECTORY, this) == B_OK)
|
||||||
fWatcherRunning = true;
|
fWatcherRunning = true;
|
||||||
@@ -161,25 +168,25 @@ UninstallView::MessageReceived(BMessage* msg)
|
|||||||
}
|
}
|
||||||
} else if (opcode == B_ENTRY_REMOVED) {
|
} else if (opcode == B_ENTRY_REMOVED) {
|
||||||
node_ref ref;
|
node_ref ref;
|
||||||
if (msg->FindInt32("device", &ref.device) != B_OK ||
|
if (msg->FindInt32("device", &ref.device) != B_OK
|
||||||
msg->FindInt64("node", &ref.node) != B_OK)
|
|| msg->FindInt64("node", &ref.node) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int32 i, count = fAppList->CountItems();
|
int32 i, count = fAppList->CountItems();
|
||||||
InfoItem *iter;
|
InfoItem* iter;
|
||||||
for (i = 0;i < count;i++) {
|
for (i = 0; i < count; i++) {
|
||||||
iter = static_cast<InfoItem *>(fAppList->ItemAt(i));
|
iter = static_cast<InfoItem *>(fAppList->ItemAt(i));
|
||||||
if (iter->GetNodeRef() == ref) {
|
if (iter->GetNodeRef() == ref) {
|
||||||
if (i == fAppList->CurrentSelection())
|
if (i == fAppList->CurrentSelection())
|
||||||
fDescription->SetText(T(kNoPackageSelected));
|
fDescription->SetText(fNoPackageSelectedString);
|
||||||
fAppList->RemoveItem(i);
|
fAppList->RemoveItem(i);
|
||||||
delete iter;
|
delete iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (opcode == B_ENTRY_MOVED) {
|
} else if (opcode == B_ENTRY_MOVED) {
|
||||||
ino_t from, to;
|
ino_t from, to;
|
||||||
if (msg->FindInt64("from directory", &from) != B_OK ||
|
if (msg->FindInt64("from directory", &from) != B_OK
|
||||||
msg->FindInt64("to directory", &to) != B_OK)
|
|| msg->FindInt64("to directory", &to) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BDirectory packagesDir(fToPackages.Path());
|
BDirectory packagesDir(fToPackages.Path());
|
||||||
@@ -199,7 +206,7 @@ UninstallView::MessageReceived(BMessage* msg)
|
|||||||
case P_MSG_SELECT:
|
case P_MSG_SELECT:
|
||||||
{
|
{
|
||||||
fButton->SetEnabled(false);
|
fButton->SetEnabled(false);
|
||||||
fDescription->SetText(T(kNoPackageSelected));
|
fDescription->SetText(fNoPackageSelectedString);
|
||||||
|
|
||||||
int32 index = fAppList->CurrentSelection();
|
int32 index = fAppList->CurrentSelection();
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
@@ -236,16 +243,16 @@ UninstallView::MessageReceived(BMessage* msg)
|
|||||||
BListItem* item = fAppList->RemoveItem(index);
|
BListItem* item = fAppList->RemoveItem(index);
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
fDescription->SetText(T(kNoPackageSelected));
|
fDescription->SetText(fNoPackageSelectedString);
|
||||||
|
|
||||||
notify = new BAlert("removal_success",
|
notify = new BAlert("removal_success",
|
||||||
T("The package you selected has been successfully removed "
|
TR("The package you selected has been successfully removed "
|
||||||
"from your system."), T("OK"));
|
"from your system."), TR("OK"));
|
||||||
} else {
|
} else {
|
||||||
notify = new BAlert("removal_failed",
|
notify = new BAlert("removal_failed",
|
||||||
T("The selected package was not removed from your system. "
|
TR("The selected package was not removed from your system. "
|
||||||
"The given installed package information file might have "
|
"The given installed package information file might have "
|
||||||
"been corrupted."), T("OK"), NULL,
|
"been corrupted."), TR("OK"), NULL,
|
||||||
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,40 +270,30 @@ UninstallView::_InitView()
|
|||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
|
||||||
BBox* descriptionBox = new BBox(B_PLAIN_BORDER, NULL);
|
|
||||||
BGroupLayout* descriptionLayout = new BGroupLayout(B_VERTICAL, 5);
|
|
||||||
descriptionBox->SetLayout(descriptionLayout);
|
|
||||||
|
|
||||||
BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL);
|
|
||||||
BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, 5);
|
|
||||||
buttonBox->SetLayout(buttonLayout);
|
|
||||||
|
|
||||||
fAppList = new BListView("pkg_list", B_SINGLE_SELECTION_LIST);
|
fAppList = new BListView("pkg_list", B_SINGLE_SELECTION_LIST);
|
||||||
fAppList->SetSelectionMessage(new BMessage(P_MSG_SELECT));
|
fAppList->SetSelectionMessage(new BMessage(P_MSG_SELECT));
|
||||||
BScrollView* scrollView = new BScrollView("list_scroll", fAppList,
|
BScrollView* scrollView = new BScrollView("list_scroll", fAppList,
|
||||||
B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
|
0, false, true, B_NO_BORDER);
|
||||||
BGroupLayout* scrollLayout = new BGroupLayout(B_HORIZONTAL);
|
|
||||||
scrollView->SetLayout(scrollLayout);
|
|
||||||
|
|
||||||
BStringView* descriptionLabel = new BStringView("desc_label",
|
BStringView* descriptionLabel = new BStringView("desc_label",
|
||||||
T("Package description"));
|
TR("Package description"));
|
||||||
descriptionLabel->SetFont(be_bold_font);
|
descriptionLabel->SetFont(be_bold_font);
|
||||||
|
|
||||||
fDescription = new BTextView("description", B_WILL_DRAW);
|
fDescription = new BTextView("description", B_WILL_DRAW);
|
||||||
fDescription->MakeSelectable(false);
|
fDescription->MakeSelectable(false);
|
||||||
fDescription->MakeEditable(false);
|
fDescription->MakeEditable(false);
|
||||||
fDescription->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fDescription->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
fDescription->SetText(T(kNoPackageSelected));
|
fDescription->SetText(fNoPackageSelectedString);
|
||||||
|
|
||||||
fButton = new BButton("removal", T("Remove"), new BMessage(P_MSG_REMOVE));
|
fButton = new BButton("removal", TR("Remove"), new BMessage(P_MSG_REMOVE));
|
||||||
fButton->SetEnabled(false);
|
fButton->SetEnabled(false);
|
||||||
|
|
||||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
BGroupLayoutBuilder(GroupLayout())
|
||||||
.Add(scrollView)
|
.Add(scrollView)
|
||||||
.Add(BGroupLayoutBuilder(descriptionLayout)
|
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||||
|
.Add(BGroupLayoutBuilder(B_VERTICAL)
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
|
||||||
.Add(descriptionLabel)
|
.Add(descriptionLabel)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
@@ -305,69 +302,15 @@ UninstallView::_InitView()
|
|||||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10))
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10))
|
||||||
.Add(fDescription)
|
.Add(fDescription)
|
||||||
)
|
)
|
||||||
.SetInsets(5, 5, 5, 5)
|
.SetInsets(spacing, spacing, spacing, spacing)
|
||||||
)
|
)
|
||||||
.Add(BGroupLayoutBuilder(buttonLayout)
|
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||||
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(fButton)
|
.Add(fButton)
|
||||||
.SetInsets(5, 5, 5, 5)
|
.SetInsets(spacing, spacing, spacing, spacing)
|
||||||
)
|
)
|
||||||
);
|
;
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
BRect rect = Bounds().InsetBySelf(10.0f, 10.0f);
|
|
||||||
rect.bottom = 125.0f;
|
|
||||||
rect.right -= B_V_SCROLL_BAR_WIDTH;
|
|
||||||
fAppList = new BListView(rect, "pkg_list", B_SINGLE_SELECTION_LIST,
|
|
||||||
B_FOLLOW_NONE);
|
|
||||||
fAppList->SetSelectionMessage(new BMessage(P_MSG_SELECT));
|
|
||||||
|
|
||||||
BScrollView *scroll = new BScrollView("list_scroll", fAppList,
|
|
||||||
B_FOLLOW_NONE, 0, false, true);
|
|
||||||
AddChild(scroll);
|
|
||||||
|
|
||||||
rect.top = rect.bottom + 8.0f;
|
|
||||||
rect.bottom += 120.0f;
|
|
||||||
rect.right += B_V_SCROLL_BAR_WIDTH;
|
|
||||||
BBox* box = new BBox(rect, "desc_box");
|
|
||||||
|
|
||||||
BStringView *descLabel = new BStringView(BRect(3, 3, 10, 10), "desc_label",
|
|
||||||
T("Package description:"));
|
|
||||||
descLabel->ResizeToPreferred();
|
|
||||||
box->AddChild(descLabel);
|
|
||||||
|
|
||||||
BRect inside = box->Bounds().InsetBySelf(3.0f, 3.0f);
|
|
||||||
inside.top = descLabel->Frame().bottom + 10.0f;
|
|
||||||
inside.right -= B_V_SCROLL_BAR_WIDTH;
|
|
||||||
fDescription = new BTextView(inside, "description",
|
|
||||||
BRect(0, 0, inside.Width(), inside.Height()), B_FOLLOW_NONE,
|
|
||||||
B_WILL_DRAW);
|
|
||||||
fDescription->MakeSelectable(true);
|
|
||||||
fDescription->MakeEditable(false);
|
|
||||||
fDescription->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
fDescription->SetText(T(kNoPackageSelected));
|
|
||||||
|
|
||||||
fDescScroll = new BScrollView("desc_scroll", fDescription, B_FOLLOW_NONE,
|
|
||||||
0, false, true, B_NO_BORDER);
|
|
||||||
box->AddChild(fDescScroll);
|
|
||||||
|
|
||||||
AddChild(box);
|
|
||||||
|
|
||||||
fButton = new BButton(BRect(0, 0, 1, 1), "removal", T("Remove"),
|
|
||||||
new BMessage(P_MSG_REMOVE));
|
|
||||||
fButton->ResizeToPreferred();
|
|
||||||
fButton->SetEnabled(false);
|
|
||||||
|
|
||||||
rect.top = rect.bottom + 5.0f;
|
|
||||||
rect.left = Bounds().Width() - 5.0f - fButton->Bounds().Width();
|
|
||||||
|
|
||||||
fButton->MoveTo(rect.LeftTop());
|
|
||||||
AddChild(fButton);
|
|
||||||
|
|
||||||
ResizeTo(Bounds().Width(), fButton->Frame().bottom + 10.0f);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -420,10 +363,8 @@ UninstallView::_AddFile(const char* filename, const node_ref& ref)
|
|||||||
{
|
{
|
||||||
BString name;
|
BString name;
|
||||||
status_t ret = info_get_package_name(filename, name);
|
status_t ret = info_get_package_name(filename, name);
|
||||||
if (ret != B_OK || name.Length() == 0) {
|
if (ret != B_OK || name.Length() == 0)
|
||||||
fprintf(stderr, "Error extracting package name: %s\n",
|
fprintf(stderr, "Error extracting package name: %s\n", strerror(ret));
|
||||||
strerror(ret));
|
|
||||||
}
|
|
||||||
BString version;
|
BString version;
|
||||||
ret = info_get_package_version(filename, version);
|
ret = info_get_package_version(filename, version);
|
||||||
if (ret != B_OK || version.Length() == 0) {
|
if (ret != B_OK || version.Length() == 0) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, Haiku, Inc.
|
* Copyright (c) 2007-2010, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
@@ -8,41 +8,47 @@
|
|||||||
#ifndef UNINSTALLVIEW_H
|
#ifndef UNINSTALLVIEW_H
|
||||||
#define UNINSTALLVIEW_H
|
#define UNINSTALLVIEW_H
|
||||||
|
|
||||||
#include <View.h>
|
#include <GroupView.h>
|
||||||
#include <Layout.h>
|
|
||||||
#include <ListView.h>
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <TextView.h>
|
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
#include "InstalledPackageInfo.h"
|
#include "InstalledPackageInfo.h"
|
||||||
|
|
||||||
|
|
||||||
class UninstallView : public BView {
|
class BButton;
|
||||||
public:
|
class BListView;
|
||||||
UninstallView(BRect frame);
|
class BTextView;
|
||||||
virtual ~UninstallView();
|
class BScrollView;
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
class UninstallView : public BGroupView {
|
||||||
|
public:
|
||||||
|
UninstallView();
|
||||||
|
virtual ~UninstallView();
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class InfoItem;
|
void _InitView();
|
||||||
|
status_t _ReloadAppList();
|
||||||
|
void _AddFile(const char* filename,
|
||||||
|
const node_ref& ref);
|
||||||
|
void _ClearAppList();
|
||||||
|
void _CachePathToPackages();
|
||||||
|
|
||||||
void _InitView();
|
private:
|
||||||
status_t _ReloadAppList();
|
class InfoItem;
|
||||||
void _AddFile(const char* filename, const node_ref& ref);
|
|
||||||
void _ClearAppList();
|
|
||||||
void _CachePathToPackages();
|
|
||||||
|
|
||||||
BPath fToPackages;
|
BPath fToPackages;
|
||||||
BListView* fAppList;
|
BListView* fAppList;
|
||||||
BTextView* fDescription;
|
BTextView* fDescription;
|
||||||
BButton* fButton;
|
BButton* fButton;
|
||||||
BScrollView* fDescScroll;
|
BScrollView* fDescScroll;
|
||||||
InstalledPackageInfo fCurrentSelection;
|
InstalledPackageInfo fCurrentSelection;
|
||||||
bool fWatcherRunning;
|
bool fWatcherRunning;
|
||||||
|
|
||||||
|
const char* fNoPackageSelectedString;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // UNINSTALLVIEW_H
|
#endif // UNINSTALLVIEW_H
|
||||||
|
|||||||
@@ -1,29 +1,30 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, Haiku, Inc.
|
* Copyright (c) 2007-2010, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
* Łukasz 'Sil2100' Zemczak <[email protected]>
|
* Łukasz 'Sil2100' Zemczak <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "UninstallWindow.h"
|
#include "UninstallWindow.h"
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
|
#include <Locale.h>
|
||||||
|
|
||||||
|
|
||||||
// Macro reserved for later localization
|
#undef TR_CONTEXT
|
||||||
#define T(x) x
|
#define TR_CONTEXT "UninstallWindow"
|
||||||
|
|
||||||
|
|
||||||
UninstallWindow::UninstallWindow()
|
UninstallWindow::UninstallWindow()
|
||||||
: BWindow(BRect(100, 100, 600, 300), T("Installed packages"),
|
:
|
||||||
B_TITLED_WINDOW, B_NOT_ZOOMABLE
|
BWindow(BRect(100, 100, 600, 300), TR("Installed packages"),
|
||||||
| B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS)
|
B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_QUIT_ON_WINDOW_CLOSE
|
||||||
|
| B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
{
|
{
|
||||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
|
AddChild(new UninstallView());
|
||||||
BView* view = new UninstallView(Bounds());
|
|
||||||
AddChild(view);
|
|
||||||
|
|
||||||
ResizeTo(Bounds().Width(), view->Bounds().Height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,50 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, Haiku, Inc.
|
* Copyright (c) 2007-2010, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
* Łukasz 'Sil2100' Zemczak <[email protected]>
|
* Łukasz 'Sil2100' Zemczak <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "UninstallWindow.h"
|
#include "UninstallWindow.h"
|
||||||
#include <Application.h>
|
|
||||||
#include <List.h>
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <TextView.h>
|
#include <Application.h>
|
||||||
#include <Entry.h>
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
#include <Locale.h>
|
||||||
|
#include <List.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "UninstallApplication"
|
||||||
|
|
||||||
|
|
||||||
class UninstallApplication : public BApplication {
|
class UninstallApplication : public BApplication {
|
||||||
public:
|
public:
|
||||||
UninstallApplication();
|
UninstallApplication();
|
||||||
~UninstallApplication();
|
~UninstallApplication();
|
||||||
|
|
||||||
void MessageReceived(BMessage *msg);
|
void AboutRequested();
|
||||||
|
|
||||||
void AboutRequested();
|
private:
|
||||||
|
UninstallWindow* fWindow;
|
||||||
private:
|
BCatalog fAppCatalog;
|
||||||
UninstallWindow *fWindow;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
UninstallApplication::UninstallApplication()
|
UninstallApplication::UninstallApplication()
|
||||||
: BApplication("application/x-vnd.Haiku-InstalledPackages")
|
:
|
||||||
|
BApplication("application/x-vnd.Haiku-InstalledPackages"),
|
||||||
|
fWindow(NULL),
|
||||||
|
fAppCatalog(NULL)
|
||||||
{
|
{
|
||||||
|
be_locale->GetAppCatalog(&fAppCatalog);
|
||||||
fWindow = new UninstallWindow();
|
fWindow = new UninstallWindow();
|
||||||
fWindow->Show();
|
fWindow->Show();
|
||||||
}
|
}
|
||||||
@@ -42,44 +55,35 @@ UninstallApplication::~UninstallApplication()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
UninstallApplication::MessageReceived(BMessage *msg)
|
|
||||||
{
|
|
||||||
switch (msg->what) {
|
|
||||||
default:
|
|
||||||
BApplication::MessageReceived(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
UninstallApplication::AboutRequested()
|
UninstallApplication::AboutRequested()
|
||||||
{
|
{
|
||||||
BAlert *about = new BAlert("about",
|
BString aboutString = TR("InstalledPackages");
|
||||||
"InstalledPackages\n"
|
int appNameLength = aboutString.Length();
|
||||||
"BeOS legacy .pkg package removing application for Haiku.\n\n"
|
aboutString << "\n";
|
||||||
"Copyright 2007,\nŁukasz 'Sil2100' Zemczak\n\n"
|
aboutString << TR("BeOS legacy .pkg package removing application "
|
||||||
"Copyright (c) 2007 Haiku, Inc. \n",
|
"for Haiku.\n\n"
|
||||||
"Close");
|
"Copyright 2007,\nŁukasz 'Sil2100' Zemczak\n\n"
|
||||||
|
"Copyright (c) 2007 Haiku, Inc.\n");
|
||||||
|
BAlert* about = new BAlert("about", aboutString.String(), TR("Close"));
|
||||||
|
|
||||||
BTextView *view = about->TextView();
|
BTextView* view = about->TextView();
|
||||||
BFont font;
|
BFont font;
|
||||||
view->SetStylable(true);
|
view->SetStylable(true);
|
||||||
view->GetFont(&font);
|
view->GetFont(&font);
|
||||||
font.SetFace(B_BOLD_FACE);
|
font.SetFace(B_BOLD_FACE);
|
||||||
font.SetSize(font.Size() * 1.5);
|
font.SetSize(font.Size() * 1.5);
|
||||||
view->SetFontAndColor(0, 15, &font);
|
view->SetFontAndColor(0, appNameLength, &font);
|
||||||
|
|
||||||
about->Go();
|
about->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(void)
|
main()
|
||||||
{
|
{
|
||||||
UninstallApplication app;
|
UninstallApplication app;
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user