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);
|
list->FillRect(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: only update periodically
|
|
||||||
_UpdateState();
|
|
||||||
|
|
||||||
BBitmap* stateIcon = _StateIcon();
|
BBitmap* stateIcon = _StateIcon();
|
||||||
const char* stateText = _StateText();
|
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
|
// #pragma mark - InterfaceListItem private methods
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public:
|
|||||||
|
|
||||||
inline const char* Name() { return fInterface.Name(); }
|
inline const char* Name() { return fInterface.Name(); }
|
||||||
|
|
||||||
|
void ConfigurationUpdated(const BMessage& message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _Init();
|
void _Init();
|
||||||
void _PopulateBitmaps(const char* mediaType);
|
void _PopulateBitmaps(const char* mediaType);
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ NetworkWindow::_ScanInterfaces()
|
|||||||
InterfaceListItem* item = new InterfaceListItem(interface.Name());
|
InterfaceListItem* item = new InterfaceListItem(interface.Name());
|
||||||
item->SetExpanded(true);
|
item->SetExpanded(true);
|
||||||
|
|
||||||
fInterfaceItemMap.insert(std::pair<BString, BListItem*>(
|
fInterfaceItemMap.insert(std::pair<BString, InterfaceListItem*>(
|
||||||
BString(interface.Name()), item));
|
BString(interface.Name()), item));
|
||||||
fListView->AddItem(item);
|
fListView->AddItem(item);
|
||||||
}
|
}
|
||||||
@@ -349,10 +349,11 @@ NetworkWindow::_ScanAddOns()
|
|||||||
fAddOns.AddItem(addOn);
|
fAddOns.AddItem(addOn);
|
||||||
|
|
||||||
// Per interface items
|
// Per interface items
|
||||||
ItemMap::const_iterator iterator = fInterfaceItemMap.begin();
|
InterfaceItemMap::const_iterator iterator
|
||||||
|
= fInterfaceItemMap.begin();
|
||||||
for (; iterator != fInterfaceItemMap.end(); iterator++) {
|
for (; iterator != fInterfaceItemMap.end(); iterator++) {
|
||||||
const BString& interface = iterator->first;
|
const BString& interface = iterator->first;
|
||||||
BListItem* interfaceItem = iterator->second;
|
InterfaceListItem* interfaceItem = iterator->second;
|
||||||
|
|
||||||
uint32 cookie = 0;
|
uint32 cookie = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -462,9 +463,16 @@ NetworkWindow::_BroadcastSettingsUpdate(uint32 type)
|
|||||||
void
|
void
|
||||||
NetworkWindow::_BroadcastConfigurationUpdate(const BMessage& message)
|
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();
|
SettingsMap::const_iterator iterator = fSettingsMap.begin();
|
||||||
for (; iterator != fSettingsMap.end(); iterator++)
|
for (; iterator != fSettingsMap.end(); iterator++)
|
||||||
iterator->second->ConfigurationUpdated(message);
|
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 BButton;
|
||||||
class BMenu;
|
class BMenu;
|
||||||
|
class InterfaceListItem;
|
||||||
class InterfaceView;
|
class InterfaceView;
|
||||||
|
|
||||||
|
|
||||||
@@ -54,14 +55,14 @@ private:
|
|||||||
private:
|
private:
|
||||||
typedef BObjectList<BNetworkSettingsAddOn> AddOnList;
|
typedef BObjectList<BNetworkSettingsAddOn> AddOnList;
|
||||||
typedef BObjectList<BNetworkSettingsItem> ItemList;
|
typedef BObjectList<BNetworkSettingsItem> ItemList;
|
||||||
typedef std::map<BString, BListItem*> ItemMap;
|
typedef std::map<BString, InterfaceListItem*> InterfaceItemMap;
|
||||||
typedef std::map<BListItem*, BNetworkSettingsItem*> SettingsMap;
|
typedef std::map<BListItem*, BNetworkSettingsItem*> SettingsMap;
|
||||||
|
|
||||||
BNetworkSettings fSettings;
|
BNetworkSettings fSettings;
|
||||||
AddOnList fAddOns;
|
AddOnList fAddOns;
|
||||||
|
|
||||||
BOutlineListView* fListView;
|
BOutlineListView* fListView;
|
||||||
ItemMap fInterfaceItemMap;
|
InterfaceItemMap fInterfaceItemMap;
|
||||||
BListItem* fServicesItem;
|
BListItem* fServicesItem;
|
||||||
BListItem* fDialUpItem;
|
BListItem* fDialUpItem;
|
||||||
BListItem* fOtherItem;
|
BListItem* fOtherItem;
|
||||||
|
|||||||
Reference in New Issue
Block a user