diff --git a/src/tests/kits/net/preflet/NetworkSetupProfile.cpp b/src/tests/kits/net/preflet/NetworkSetupProfile.cpp index 5ab787aeac..05b0008c83 100644 --- a/src/tests/kits/net/preflet/NetworkSetupProfile.cpp +++ b/src/tests/kits/net/preflet/NetworkSetupProfile.cpp @@ -73,23 +73,12 @@ status_t NetworkSetupProfile::SetName(const char *name) } -void NetworkSetupProfile::Unset() -{ -} - - bool NetworkSetupProfile::Exists() { return root->Exists(); } -status_t NetworkSetupProfile::Create() -{ - return B_ERROR; -} - - status_t NetworkSetupProfile::Delete() { return B_ERROR; @@ -102,13 +91,28 @@ bool NetworkSetupProfile::IsDefault() } -bool NetworkSetupProfile::IsActive() +bool NetworkSetupProfile::IsCurrent() { - return is_active; + return is_current; } -status_t NetworkSetupProfile::MakeActive() +status_t NetworkSetupProfile::MakeCurrent() { return B_ERROR; } + +// #pragma mark - + + +NetworkSetupProfile * NetworkSetupProfile::Default() +{ + return NULL; +} + + +NetworkSetupProfile * NetworkSetupProfile::Current() +{ + return NULL; +} + diff --git a/src/tests/kits/net/preflet/NetworkSetupProfile.h b/src/tests/kits/net/preflet/NetworkSetupProfile.h index 2587ded2ed..58d94adbf2 100644 --- a/src/tests/kits/net/preflet/NetworkSetupProfile.h +++ b/src/tests/kits/net/preflet/NetworkSetupProfile.h @@ -4,37 +4,41 @@ #include class NetworkSetupProfile { - public: - NetworkSetupProfile(); - NetworkSetupProfile(const char *path); - NetworkSetupProfile(const entry_ref *ref); - NetworkSetupProfile(BEntry *entry); - virtual ~NetworkSetupProfile(); +public: + NetworkSetupProfile(); + NetworkSetupProfile(const char *path); + NetworkSetupProfile(const entry_ref *ref); + NetworkSetupProfile(BEntry *entry); + +virtual ~NetworkSetupProfile(); - status_t SetTo(const char *path); - status_t SetTo(const entry_ref *ref); - status_t SetTo(BEntry *entry); + status_t SetTo(const char *path); + status_t SetTo(const entry_ref *ref); + status_t SetTo(BEntry *entry); - void Unset(); - - bool Exists(); + bool Exists(); const char * Name(); status_t SetName(const char *name); - - status_t Create(); - status_t Delete(); - virtual bool IsDefault(); - virtual bool IsActive(); - virtual status_t MakeActive(); + + bool IsDefault(); + bool IsCurrent(); - private: + status_t MakeCurrent(); + status_t Delete(); + +static NetworkSetupProfile * Default(); +static NetworkSetupProfile * Current(); + +private: BEntry * root; BPath * path; bool is_default; - bool is_active; + bool is_current; const char * name; + +static BDirectory * profiles_root; }; diff --git a/src/tests/kits/net/preflet/NetworkSetupWindow.cpp b/src/tests/kits/net/preflet/NetworkSetupWindow.cpp index 3e5566b6ee..7c0bdd544d 100644 --- a/src/tests/kits/net/preflet/NetworkSetupWindow.cpp +++ b/src/tests/kits/net/preflet/NetworkSetupWindow.cpp @@ -19,7 +19,7 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title) B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) { BMenu *menu; - BBox *box, *group, *line; + BBox *box, *line; // *group BButton *button; BCheckBox *check; BRect r; @@ -61,41 +61,6 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title) box->AddChild(button); fManageProfilesButton = button; - -/* - r.left += w/2 + H_MARGIN; - - button = new BButton(r, "new_profile", NEW_PROFILE_LABEL, - new BMessage(NEW_PROFILE_MSG), - B_FOLLOW_TOP | B_FOLLOW_RIGHT); - button->GetPreferredSize(&w, &h); - button->ResizeToPreferred(); - box->AddChild(button); - - fNewProfileButton = button; - - r.left += w + SMALL_MARGIN; - button = new BButton(r, "copy_profile", COPY_PROFILE_LABEL, - new BMessage(COPY_PROFILE_MSG), - B_FOLLOW_TOP | B_FOLLOW_RIGHT); - button->GetPreferredSize(&w, &h); - button->ResizeToPreferred(); - box->AddChild(button); - - fCopyProfileButton = button; - - r.left += w + SMALL_MARGIN; - button = new BButton(r, "delete_profile", DELETE_PROFILE_LABEL, - new BMessage(DELETE_PROFILE_MSG), - B_FOLLOW_TOP | B_FOLLOW_RIGHT); - button->GetPreferredSize(&w, &h); - button->ResizeToPreferred(); - box->AddChild(button); - - fDeleteProfileButton = button; - - r.left = H_MARGIN; -*/ r.top += h + V_MARGIN; // ---- Separator line between Profiles section and Settings section @@ -186,8 +151,10 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title) B_PLAIN_BORDER); box->AddChild(fPanel); - fShowRect = fPanel->Bounds(); - fShowView = NULL; + fAddonView = NULL; + + ResizeTo(fMinAddonViewRect.Width() + 2 * H_MARGIN, fMinAddonViewRect.Height()); + SetSizeLimits(Bounds().Width(), 20000, Bounds().Height(), 20000); } @@ -252,32 +219,16 @@ void NetworkSetupWindow::MessageReceived } case SHOW_MSG: { - BYAddon *by; - NetworkSetupAddOn *addon; - - if (fShowView) - fShowView->RemoveSelf(); + if (fAddonView) + fAddonView->RemoveSelf(); - fShowView = NULL; - - by = NULL; - addon = NULL; - if (msg->FindPointer("addon", (void **) &addon) != B_OK) { - if (msg->FindPointer("byaddon", (void **) &by) != B_OK) + fAddonView = NULL; + if (msg->FindPointer("addon_view", (void **) &fAddonView) != B_OK) break; - }; - - fShowRect = fPanel->Bounds(); - if (addon) - fShowView = addon->CreateView(&fShowRect); - else - fShowView = by->CreateView(&fShowRect); - if (fShowView) { - fPanel->AddChild(fShowView); - // fShowView->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256)); - fShowView->ResizeTo(fPanel->Bounds().Width(), fPanel->Bounds().Height()); - }; - + + fPanel->AddChild(fAddonView); + fAddonView->ResizeTo(fPanel->Bounds().Width(), fPanel->Bounds().Height()); + fAddonView->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256)); break; } @@ -343,7 +294,7 @@ void NetworkSetupWindow::BuildProfilesMenu item = menu->FindItem(current_profile); if (item) { BString label; - bool is_default = (strcmp(current_profile, "default") == 0); + // bool is_default = (strcmp(current_profile, "default") == 0); label << item->Label(); label << " (current)"; @@ -383,12 +334,14 @@ void NetworkSetupWindow::BuildShowMenu BEntry entry; char * search_paths; char * search_path; - char * next_path_token; + char * next_path_token; search_paths = getenv("ADDON_PATH"); if (!search_paths) // Nowhere to search addons!!! return; + + fMinAddonViewRect.Set(0, 0, 200, 200); search_paths = strdup(search_paths); search_path = strtok_r(search_paths, ":", &next_path_token); @@ -443,9 +396,14 @@ void NetworkSetupWindow::BuildShowMenu while ((addon = get_nth_addon(addon_id, n)) != NULL) { BMessage *msg = new BMessage(msg_what); + BRect r(0, 0, 0, 0); + BView * addon_view = addon->CreateView(&r); + fMinAddonViewRect = fMinAddonViewRect | r; + msg->AddInt32("image_id", addon_id); msg->AddString("addon_path", addon_path.Path()); msg->AddPointer("addon", addon); + msg->AddPointer("addon_view", addon_view); menu->AddItem(new BMenuItem(addon->Name(), msg)); n++; } @@ -458,10 +416,16 @@ void NetworkSetupWindow::BuildShowMenu BYAddon *addon; addon = by_instantiate(); + + BRect r(0, 0, 0, 0); + BView * addon_view = addon->CreateView(&r); + fMinAddonViewRect = fMinAddonViewRect | r; + BMessage *msg = new BMessage(msg_what); msg->AddInt32("image_id", addon_id); msg->AddString("addon_path", addon_path.Path()); msg->AddPointer("byaddon", addon); + msg->AddPointer("addon_view", addon_view); menu->AddItem(new BMenuItem(addon->Name(), msg)); continue; }; diff --git a/src/tests/kits/net/preflet/NetworkSetupWindow.h b/src/tests/kits/net/preflet/NetworkSetupWindow.h index 8f4ffb39b4..1803f0bb68 100644 --- a/src/tests/kits/net/preflet/NetworkSetupWindow.h +++ b/src/tests/kits/net/preflet/NetworkSetupWindow.h @@ -64,8 +64,8 @@ class NetworkSetupWindow : public BWindow BButton *fApplyNowButton; BBox *fPanel; - BView *fShowView; - BRect fShowRect; + BView *fAddonView; + BRect fMinAddonViewRect; }; #endif // ifdef NETWORKSETUPWINDOW_H