Network: also notify interface list items
* When the network configuration changes.
This commit is contained in:
@@ -71,9 +71,6 @@ InterfaceListItem::DrawItem(BView* owner, BRect bounds, bool complete)
|
||||
list->FillRect(bounds);
|
||||
}
|
||||
|
||||
// TODO: only update periodically
|
||||
_UpdateState();
|
||||
|
||||
BBitmap* stateIcon = _StateIcon();
|
||||
const char* stateText = _StateText();
|
||||
|
||||
@@ -154,6 +151,13 @@ InterfaceListItem::Update(BView* owner, const BFont* font)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InterfaceListItem::ConfigurationUpdated(const BMessage& message)
|
||||
{
|
||||
_UpdateState();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - InterfaceListItem private methods
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ public:
|
||||
|
||||
inline const char* Name() { return fInterface.Name(); }
|
||||
|
||||
void ConfigurationUpdated(const BMessage& message);
|
||||
|
||||
private:
|
||||
void _Init();
|
||||
void _PopulateBitmaps(const char* mediaType);
|
||||
|
||||
@@ -294,7 +294,7 @@ NetworkWindow::_ScanInterfaces()
|
||||
InterfaceListItem* item = new InterfaceListItem(interface.Name());
|
||||
item->SetExpanded(true);
|
||||
|
||||
fInterfaceItemMap.insert(std::pair<BString, BListItem*>(
|
||||
fInterfaceItemMap.insert(std::pair<BString, InterfaceListItem*>(
|
||||
BString(interface.Name()), item));
|
||||
fListView->AddItem(item);
|
||||
}
|
||||
@@ -349,10 +349,11 @@ NetworkWindow::_ScanAddOns()
|
||||
fAddOns.AddItem(addOn);
|
||||
|
||||
// Per interface items
|
||||
ItemMap::const_iterator iterator = fInterfaceItemMap.begin();
|
||||
InterfaceItemMap::const_iterator iterator
|
||||
= fInterfaceItemMap.begin();
|
||||
for (; iterator != fInterfaceItemMap.end(); iterator++) {
|
||||
const BString& interface = iterator->first;
|
||||
BListItem* interfaceItem = iterator->second;
|
||||
InterfaceListItem* interfaceItem = iterator->second;
|
||||
|
||||
uint32 cookie = 0;
|
||||
while (true) {
|
||||
@@ -462,9 +463,16 @@ NetworkWindow::_BroadcastSettingsUpdate(uint32 type)
|
||||
void
|
||||
NetworkWindow::_BroadcastConfigurationUpdate(const BMessage& message)
|
||||
{
|
||||
InterfaceItemMap::const_iterator itemIterator = fInterfaceItemMap.begin();
|
||||
for (; itemIterator != fInterfaceItemMap.end(); itemIterator++)
|
||||
itemIterator->second->ConfigurationUpdated(message);
|
||||
|
||||
SettingsMap::const_iterator iterator = fSettingsMap.begin();
|
||||
for (; iterator != fSettingsMap.end(); iterator++)
|
||||
iterator->second->ConfigurationUpdated(message);
|
||||
|
||||
// TODO: improve invalidated region to the one that matters
|
||||
fListView->Invalidate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ using namespace BNetworkKit;
|
||||
|
||||
class BButton;
|
||||
class BMenu;
|
||||
class InterfaceListItem;
|
||||
class InterfaceView;
|
||||
|
||||
|
||||
@@ -54,14 +55,14 @@ private:
|
||||
private:
|
||||
typedef BObjectList<BNetworkSettingsAddOn> AddOnList;
|
||||
typedef BObjectList<BNetworkSettingsItem> ItemList;
|
||||
typedef std::map<BString, BListItem*> ItemMap;
|
||||
typedef std::map<BString, InterfaceListItem*> InterfaceItemMap;
|
||||
typedef std::map<BListItem*, BNetworkSettingsItem*> SettingsMap;
|
||||
|
||||
BNetworkSettings fSettings;
|
||||
AddOnList fAddOns;
|
||||
|
||||
BOutlineListView* fListView;
|
||||
ItemMap fInterfaceItemMap;
|
||||
InterfaceItemMap fInterfaceItemMap;
|
||||
BListItem* fServicesItem;
|
||||
BListItem* fDialUpItem;
|
||||
BListItem* fOtherItem;
|
||||
|
||||
Reference in New Issue
Block a user