Example #1
0
void
ModulesView::PopulateScreenSaverList()
{
	// Blackness is a built-in screen saver
	ScreenSaverItem* defaultItem
		= new ScreenSaverItem(B_TRANSLATE("Blackness"), "");
	fScreenSaversListView->AddItem(defaultItem);

	// Iterate over add-on directories, and add their files to the list view

	directory_which which[] = {
		B_USER_NONPACKAGED_ADDONS_DIRECTORY,
		B_USER_ADDONS_DIRECTORY,
		B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
		B_SYSTEM_ADDONS_DIRECTORY,
	};
	ScreenSaverItem* selectedItem = NULL;

	for (uint32 i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
		BPath basePath;
		if (find_directory(which[i], &basePath) != B_OK)
			continue;
		else if (basePath.Append("Screen Savers", true) != B_OK)
			continue;

		BDirectory dir(basePath.Path());
		BEntry entry;
		while (dir.GetNextEntry(&entry, true) == B_OK) {
			char name[B_FILE_NAME_LENGTH];
			if (entry.GetName(name) != B_OK)
				continue;

			BPath path(basePath);
			if (path.Append(name) != B_OK)
				continue;

			ScreenSaverItem* item = new ScreenSaverItem(name, path.Path());
			fScreenSaversListView->AddItem(item);

			if (selectedItem != NULL)
				continue;

			if (strcmp(fSettings.ModuleName(), item->Text()) == 0)
				selectedItem = item;
		}
	}

	fScreenSaversListView->SortItems(_CompareScreenSaverItems);
	if (selectedItem == NULL)
		selectedItem = defaultItem;

	fScreenSaversListView->Select(fScreenSaversListView->IndexOf(selectedItem));
	fScreenSaversListView->ScrollToSelection();
}
Example #2
0
void
ModulesView::PopulateScreenSaverList()
{
 	fScreenSaversListView->DeselectAll();
	while (ScreenSaverItem* item
			= (ScreenSaverItem*)fScreenSaversListView->RemoveItem((int32)0)) {
		delete item;
	}

	// Blackness is a built-in screen saver
	fScreenSaversListView->AddItem(
		new ScreenSaverItem(B_TRANSLATE("Blackness"), ""));

	// Iterate over add-on directories, and add their files to the list view

	directory_which which[] = {
		B_USER_ADDONS_DIRECTORY,
		B_COMMON_ADDONS_DIRECTORY,
		B_SYSTEM_ADDONS_DIRECTORY,
	};
	ScreenSaverItem* selectItem = NULL;

	for (uint32 i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
		BPath basePath;
		find_directory(which[i], &basePath);
		basePath.Append("Screen Savers", true);

		BDirectory dir(basePath.Path());
		BEntry entry;
		while (dir.GetNextEntry(&entry, true) == B_OK) {
			char name[B_FILE_NAME_LENGTH];
			if (entry.GetName(name) != B_OK)
				continue;

			BPath path = basePath;
			path.Append(name);

			ScreenSaverItem* item = new ScreenSaverItem(name, path.Path());
			fScreenSaversListView->AddItem(item);

			if (strcmp(fSettings.ModuleName(), item->Text()) != 0
				|| (strcmp(fSettings.ModuleName(), "") != 0
					&& strcmp(item->Text(), B_TRANSLATE("Blackness")) != 0)) {
				selectItem = item;
			}
		}
	}

	fScreenSaversListView->SortItems(_CompareScreenSaverItems);

	fScreenSaversListView->Select(fScreenSaversListView->IndexOf(selectItem));
	fScreenSaversListView->ScrollToSelection();
}
Example #3
0
// ResourceUsageWindow::InitWindow -- Initialization Commands here
void ResourceUsageWindow::InitWindow(BList &list)
{
	BRect rtab = Bounds();
	BRect rlist = Bounds();
	rtab.top += 10;
	rlist.top += 10;
	rlist.left += 12;
	rlist.right -= 15 + B_V_SCROLL_BAR_WIDTH;
	rlist.bottom -= 47;

	// Create the TabView and Tabs
	BTabView *tabView = new BTabView(rtab,"resource_usage_tabview");
	tabView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	
	rtab = tabView->Bounds();
	rtab.InsetBy(5,5);
	
	// Create the ListViews
	BListView *IRQListView = new BListView(rlist, "IRQListView",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		B_WILL_DRAW | B_NAVIGABLE);
	BListView *DMAListView = new BListView(rlist, "DMAListView",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		B_WILL_DRAW | B_NAVIGABLE);
	BListView *IORangeListView = new BListView(rlist, "IORangeListView",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		B_WILL_DRAW | B_NAVIGABLE);
	BListView *memoryListView = new BListView(rlist, "memoryListView",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		B_WILL_DRAW | B_NAVIGABLE);
	
	BScrollView *IRQScrollView = new BScrollView("scroll_list1", IRQListView,
		B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true, B_FANCY_BORDER);
	BScrollView *DMAScrollView = new BScrollView("scroll_list2", DMAListView,
		B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true, B_FANCY_BORDER);
	BScrollView *IORangeScrollView = new BScrollView("scroll_list3",
		IORangeListView, B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true,
		B_FANCY_BORDER);
	BScrollView *memoryScrollView = new BScrollView("scroll_list4",
		memoryListView, B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true,
		B_FANCY_BORDER);
	
	BTab *tab = new BTab();
	tabView->AddTab(IRQScrollView, tab);
	tab->SetLabel(B_TRANSLATE("IRQ"));
	tab = new BTab();
	tabView->AddTab(DMAScrollView, tab);
	tab->SetLabel(B_TRANSLATE("DMA"));
	tab = new BTab();
	tabView->AddTab(IORangeScrollView, tab);
	tab->SetLabel(B_TRANSLATE("IO Range"));
	tab = new BTab();
	tabView->AddTab(memoryScrollView, tab);
	tab->SetLabel(B_TRANSLATE("Memory Range"));
	
	{
		uint32 mask = 1;
		
		for (int i=0;i<16;mask<<=1,i++) {
			bool first = true;
			
			for (int32 j=0; j<list.CountItems(); j++) {
				DevicesInfo *deviceInfo = (DevicesInfo *)list.ItemAt(j);
				struct device_configuration *current = deviceInfo->GetCurrent();
				resource_descriptor r;
				
				int32 num = count_resource_descriptors_of_type(current,
					B_IRQ_RESOURCE);
				
				for (int32 k=0;k<num;k++) {
					get_nth_resource_descriptor_of_type(current, k, B_IRQ_RESOURCE,
							&r, sizeof(resource_descriptor));
					
					if (mask & r.d.m.mask) {
						IRQListView->AddItem(new IRQDMAItem(first ? i : -1,
							deviceInfo->GetCardName()));
						first = false;
					}
				}
			}
			
			if (first) {
				IRQListView->AddItem(new IRQDMAItem(i, ""));
			}
		}
	}
	
	{
		uint32 mask = 1;
		
		for (int i=0;i<8;mask<<=1,i++) {
			bool first = true;
			
			for (int32 j=0; j<list.CountItems(); j++) {
				DevicesInfo *deviceInfo = (DevicesInfo *)list.ItemAt(j);
				struct device_configuration *current = deviceInfo->GetCurrent();
				resource_descriptor r;
				
				int32 num = count_resource_descriptors_of_type(current,
					B_DMA_RESOURCE);
				
				for (int32 k=0;k<num;k++) {
					get_nth_resource_descriptor_of_type(current, k,
						B_DMA_RESOURCE,	&r, sizeof(resource_descriptor));
					
					if (mask & r.d.m.mask) {
						DMAListView->AddItem(new IRQDMAItem(first ? i : -1,
							deviceInfo->GetCardName()));
						first = false;
					}
				}
			}
			
			if (first) {
				DMAListView->AddItem(new IRQDMAItem(i, ""));
			}
		}
	}

	{
		for (int32 j=0; j<list.CountItems(); j++) {
			DevicesInfo *deviceInfo = (DevicesInfo *)list.ItemAt(j);
			struct device_configuration *current = deviceInfo->GetCurrent();
			resource_descriptor r;
			
			int32 num = count_resource_descriptors_of_type(current,
				B_IO_PORT_RESOURCE);
			
			for (int32 k=0;k<num;k++) {
				get_nth_resource_descriptor_of_type(current, k,
					B_IO_PORT_RESOURCE,	&r, sizeof(resource_descriptor));
				
				IORangeListView->AddItem(new RangeItem(r.d.r.minbase, 
					r.d.r.minbase + r.d.r.len - 1, deviceInfo->GetCardName()));
			}
		}
	
		IORangeListView->SortItems(&RangeItem::Compare);
	}
	
	{
		for (int32 j=0; j<list.CountItems(); j++) {
			DevicesInfo *deviceInfo = (DevicesInfo *)list.ItemAt(j);
			struct device_configuration *current = deviceInfo->GetCurrent();
			resource_descriptor r;
			
			int32 num = count_resource_descriptors_of_type(current,
				B_MEMORY_RESOURCE);
			
			for (int32 k=0;k<num;k++) {
				get_nth_resource_descriptor_of_type(current, k, B_MEMORY_RESOURCE,
						&r, sizeof(resource_descriptor));
				
				memoryListView->AddItem(new RangeItem(r.d.r.minbase, 
					r.d.r.minbase + r.d.r.len - 1, deviceInfo->GetCardName()));
			}
		}
	
		memoryListView->SortItems(&RangeItem::Compare);
	}
	
	
	BBox *background = new BBox(Bounds(), "background");
	background->SetBorder(B_NO_BORDER);
	AddChild(background);
	background->AddChild(tabView);
}