Network: let add-ons replace themselves by name.
* Ie. an add-on "Super duper service" in ~/config will override one with the same name in /system (and non-packaged in packaged, etc.). * Fixed size of the scroller to ignore the content size vertically.
This commit is contained in:
@@ -126,6 +126,7 @@ NetworkWindow::NetworkWindow()
|
|||||||
|
|
||||||
BScrollView* scrollView = new BScrollView("ScrollView", fListView,
|
BScrollView* scrollView = new BScrollView("ScrollView", fListView,
|
||||||
0, false, true);
|
0, false, true);
|
||||||
|
scrollView->SetExplicitMinSize(BSize(B_SIZE_UNSET, 42));
|
||||||
|
|
||||||
fAddOnShellView = new BView("add-on shell", 0,
|
fAddOnShellView = new BView("add-on shell", 0,
|
||||||
new BGroupLayout(B_VERTICAL));
|
new BGroupLayout(B_VERTICAL));
|
||||||
@@ -349,6 +350,11 @@ NetworkWindow::_ScanAddOns()
|
|||||||
BPathFinder::FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY, "Network Settings",
|
BPathFinder::FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY, "Network Settings",
|
||||||
paths);
|
paths);
|
||||||
|
|
||||||
|
// Collect add-on paths by name, so that each name will only be
|
||||||
|
// loaded once.
|
||||||
|
typedef std::map<BString, BPath> PathMap;
|
||||||
|
PathMap addOnMap;
|
||||||
|
|
||||||
for (int32 i = 0; i < paths.CountStrings(); i++) {
|
for (int32 i = 0; i < paths.CountStrings(); i++) {
|
||||||
BDirectory directory(paths.StringAt(i));
|
BDirectory directory(paths.StringAt(i));
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
@@ -357,6 +363,15 @@ NetworkWindow::_ScanAddOns()
|
|||||||
if (entry.GetPath(&path) != B_OK)
|
if (entry.GetPath(&path) != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (addOnMap.find(path.Leaf()) == addOnMap.end())
|
||||||
|
addOnMap.insert(std::pair<BString, BPath>(path.Leaf(), path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PathMap::const_iterator iterator = addOnMap.begin();
|
||||||
|
iterator != addOnMap.end(); iterator++) {
|
||||||
|
const BPath& path = iterator->second;
|
||||||
|
|
||||||
image_id image = load_add_on(path.Path());
|
image_id image = load_add_on(path.Path());
|
||||||
if (image < 0) {
|
if (image < 0) {
|
||||||
printf("Failed to load %s addon: %s.\n", path.Path(),
|
printf("Failed to load %s addon: %s.\n", path.Path(),
|
||||||
@@ -372,9 +387,8 @@ NetworkWindow::_ScanAddOns()
|
|||||||
B_SYMBOL_TYPE_TEXT, (void**)&instantiateAddOn);
|
B_SYMBOL_TYPE_TEXT, (void**)&instantiateAddOn);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
// No "addon instantiate function" symbol found in this addon
|
// No "addon instantiate function" symbol found in this addon
|
||||||
printf("No symbol \"instantiate_network_settings_add_on\" "
|
printf("No symbol \"instantiate_network_settings_add_on\" found "
|
||||||
"found in %s addon: not a network setup addon!\n",
|
"in %s addon: not a network setup addon!\n", path.Path());
|
||||||
path.Path());
|
|
||||||
unload_add_on(image);
|
unload_add_on(image);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -423,7 +437,6 @@ NetworkWindow::_ScanAddOns()
|
|||||||
_SortItemsUnder(fDialUpItem);
|
_SortItemsUnder(fDialUpItem);
|
||||||
_SortItemsUnder(fOtherItem);
|
_SortItemsUnder(fOtherItem);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fListView->SortItemsUnder(NULL, true,
|
fListView->SortItemsUnder(NULL, true,
|
||||||
NetworkWindow::_CompareTopLevelListItems);
|
NetworkWindow::_CompareTopLevelListItems);
|
||||||
|
|||||||
Reference in New Issue
Block a user