Beispiel #1
0
void
KeymapWindow::_AddKeyboardLayouts(BMenu* menu)
{
	directory_which dataDirectories[] = {
		B_USER_DATA_DIRECTORY,
		B_COMMON_DATA_DIRECTORY,
		B_BEOS_DATA_DIRECTORY
	};

	for (uint32 i = 0;
			i < sizeof(dataDirectories) / sizeof(dataDirectories[0]); i++) {
		BPath path;
		if (find_directory(dataDirectories[i], &path) != B_OK)
			continue;

		path.Append("KeyboardLayouts");

		BDirectory directory;
		if (directory.SetTo(path.Path()) == B_OK) {
			entry_ref ref;
			while (directory.GetNextRef(&ref) == B_OK) {
				if (menu->FindItem(ref.name) != NULL)
					continue;

				BMessage* message = new BMessage(kChangeKeyboardLayout);
				message->AddRef("ref", &ref);

				menu->AddItem(new BMenuItem(ref.name, message));
			}
		}
	}
}
Beispiel #2
0
void
OpenWindow::CollectDevices(BMenu *menu, BEntry *startEntry)
{
    BDirectory directory;
    if (startEntry != NULL)
        directory.SetTo(startEntry);
    else
        directory.SetTo("/dev/disk");

    BEntry entry;
    while (directory.GetNextEntry(&entry) == B_OK) {
        if (entry.IsDirectory()) {
            CollectDevices(menu, &entry);
            continue;
        }

        entry_ref ref;
        if (entry.GetRef(&ref) != B_OK)
            continue;

        BPath path;
        if (entry.GetPath(&path) != B_OK)
            continue;

        BMessage *message = new BMessage(B_REFS_RECEIVED);
        message->AddRef("refs", &ref);

        menu->AddItem(new BMenuItem(path.Path(), message));
    }
}
Beispiel #3
0
/*!	Adds a menu populated with the keyboard layouts found in the passed
	in directory to the passed in menu. Each subdirectory in the passed
	in directory is added as a submenu recursively.
*/
void
KeymapWindow::_AddKeyboardLayoutMenu(BMenu* menu, BDirectory directory)
{
	entry_ref ref;

	while (directory.GetNextRef(&ref) == B_OK) {
		if (menu->FindItem(ref.name) != NULL)
			continue;

		BDirectory subdirectory;
		subdirectory.SetTo(&ref);
		if (subdirectory.InitCheck() == B_OK) {
			BMenu* submenu = new BMenu(B_TRANSLATE_NOCOLLECT(ref.name));

			_AddKeyboardLayoutMenu(submenu, subdirectory);
			menu->AddItem(submenu);
		} else {
			BMessage* message = new BMessage(kChangeKeyboardLayout);

			message->AddRef("ref", &ref);
			menu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(ref.name),
				message));
		}
	}
}
Beispiel #4
0
void
FileTypes::ArgvReceived(int32 argc, char **argv)
{
	BMessage *message = CurrentMessage();

	BDirectory currentDirectory;
	if (message)
		currentDirectory.SetTo(message->FindString("cwd"));

	BMessage refs;

	for (int i = 1 ; i < argc ; i++) {
		BPath path;
		if (argv[i][0] == '/')
			path.SetTo(argv[i]);
		else
			path.SetTo(&currentDirectory, argv[i]);

		status_t status;
		entry_ref ref;
		BEntry entry;

		if ((status = entry.SetTo(path.Path(), false)) != B_OK
			|| (status = entry.GetRef(&ref)) != B_OK) {
			fprintf(stderr, "Could not open file \"%s\": %s\n",
				path.Path(), strerror(status));
			continue;
		}

		refs.AddRef("refs", &ref);
	}

	RefsReceived(&refs);
}
Beispiel #5
0
bool SeqNavMenu::AddEntry(BEntry& entry, bool useLeafForLabel)
{
	BPath			path;
	if( entry.GetPath( &path ) != B_OK ) {
		printf("\tquery returned an entry but couldn't get the path\n");
		return false;
	}
	const char*		label = (useLeafForLabel) ? path.Leaf(): path.Path();
	if( !label ) return false;
	_AmIconMenuItem* item = 0;
	uint32			tmpEntry;
	if( entry.IsDirectory() ) {
		tmpEntry = DIR_ENTRY;
		SeqNavMenu*	nm = new SeqNavMenu( label, mTarget );
		if( nm && (item = new _AmIconMenuItem( nm )) ) {
			nm->SetPath( path.Path() );
		}
	} else {
		tmpEntry = OTHER_ENTRY;
		BMessage*		msg = new BMessage( B_REFS_RECEIVED );
		entry_ref		ref;
		if( msg && (entry.GetRef( &ref ) == B_OK) ) {
			msg->AddRef( "refs", &ref );
			item = new _AmIconMenuItem( label, msg );
		}
	}

	if( item ) {
		mItems.push_back( item );
		item->SetIcon( GetIcon( entry ) );
		if( mFirstEntry == NO_ENTRY ) mFirstEntry = tmpEntry;
	}
	return true;
}
Beispiel #6
0
status_t
OpenAction(const BMessage &action, entry_ref &ref)
{
	entry_ref app;
	BString appName("");
	if (be_roster->FindApp(&ref,&app) == B_OK)
		appName = app.name;
	
	status_t status = be_roster->Launch(&ref);
	
	if (status == B_OK)
		printf("\tOpened %s in program %s\n",ref.name,appName.String());
	else
	{
		// R5 (and probably others) don't seem to want to open folders in Tracker --
		// FindApp() returns B_OK, but sets the entry_ref of the app to open it to
		// the folder's ref, which is dumb. This works around this apparent stupidity.
		BString typestr;
		if (BNode(&ref).ReadAttrString("BEOS:TYPE",&typestr) == B_OK &&
			typestr.Compare("application/x-vnd.Be-directory") == 0)
		{
			BMessage *msg = new BMessage(B_REFS_RECEIVED);
			msg->AddRef("refs",&ref);
			be_roster->Launch("application/x-vnd.Be-TRAK",msg);
			printf("\tOpened %s in program Tracker\n",ref.name);
			return B_OK;
		}
		if (appName.CountChars() > 0)
			printf("\tCouldn't open %s in program %s\n",ref.name,appName.String());
		else
			printf("\tCouldn't open %s -- the system couldn't find a program to do it.\n",ref.name);
	}
	
	return status;
}
Beispiel #7
0
bool ViewFileList::InitiateDrag(BPoint a, int32 index, bool selected) {
  if (selected == false) return false;

   PListItem *sam = ((PListItem*) ItemAt(index));
   if (sam == NULL) return false;
   BEntry *tempOne = new BEntry();
   if (sam->GetEntry(tempOne) == B_OK ) {
     entry_ref tmp;
     tempOne->GetRef(&tmp);   

     // get picture here
     BNode noddy(tempOne);
     BNodeInfo noddi(&noddy);
     
     BBitmap *snoopy = new BBitmap( BRect(0,0,31,31), B_CMAP8);
     noddi.GetTrackerIcon(snoopy,B_LARGE_ICON);
     
     BMessage *dragee = new BMessage(B_SIMPLE_DATA);
     dragee->AddRef("refs",&tmp);
     dragee->AddString("source","Peek");
      
     DragMessage(dragee, snoopy, B_OP_ALPHA, BPoint(15,15), NULL);
     
     delete dragee;
   } 
   delete tempOne;  

  return true;
}
Beispiel #8
0
BRect
LibraryWindow::ScanFolder(BPoint location, const char *path, float *maxwidth)
{
	BDirectory dir(path);
	if (dir.InitCheck() != B_OK)
		return BRect(0,0,-1,-1);
	
	float width = 0.0;
	dir.Rewind();
	entry_ref ref;
	BRect r(location.x,location.y,location.x + 1,location.y + 1);
	
	while (dir.GetNextRef(&ref) == B_OK)
	{
		BString str(ref.name);
		
		int32 soPos = str.FindLast(".so");
		int32 aPos = str.FindLast(".a");
		
		if (soPos < 0 && aPos < 0)
			continue;
		
		if (soPos >= 0 && soPos < str.CountChars() - 3)
			continue;
		
		if (aPos >= 0 && aPos < str.CountChars() - 2)
			continue;
		
		Lock();	
		BMessage *msg = new BMessage(M_TOGGLE_LIB);
		msg->AddRef("ref",&ref);
		msg->AddString("path",path);
		BCheckBox *box = new BCheckBox(r,ref.name,ref.name,msg);
		box->ResizeToPreferred();
		r = box->Frame();
		fCheckList->AddChild(box);
		fSystemLibs.AddItem(box);
		
		// Make sure that there isn't any shortcut normalization
		BPath dirpath(path);
		dirpath.Append(ref.name);
		
		if (fProject && fProject->HasLibrary(dirpath.Path()))
			box->SetValue(B_CONTROL_ON);
		else
			box->SetValue(B_CONTROL_OFF);
		Unlock();
		
		
		width = MAX(r.right,width);
		r.OffsetBy(0,r.Height());
	}
	
	if (r.Height() == 1)
		r.Set(0, 0, -1, -1);
	
	*maxwidth = width;
	return r;
}
void					
BF_GUI_FilesPanel::Action_Tracker_Addons_Run(const char *pc_AddOn)
{
	ASSERT(pc_AddOn);
		
	image_id 	uImage;	
	uImage = load_add_on(pc_AddOn);
	if(0==uImage) return;
	
	BEntry 		oEntry(oPath.Path());
	entry_ref	uEntryRef;
	
	if(B_OK!=oEntry.GetRef(&uEntryRef)) return;
	
	void (*Func_AddOn)(entry_ref dir_ref, BMessage *msg, void *);
	if(B_OK!=get_image_symbol(uImage, "process_refs", B_SYMBOL_TYPE_TEXT, (void**)&Func_AddOn)) return;
	
	BMessage 			*poMessage = new BMessage();	
	BF_NodeCollection	loSelNode;
	loNode.GetSelecting(loSelNode);
	if(loSelNode.CountItems()==0) loSelNode.AddItem(Nodes_Focus());
	if(loSelNode.CountItems()==0) return;
	ASSERT(poMessage);
	
	BF_Node 	*poNode=NULL;
	entry_ref	uNodeRef;	
	BL_String	s;
	for(int iNode=0;iNode<loSelNode.CountItems();iNode++){
		poNode = loSelNode.NodeAt(iNode);
		s=oPath.Path();
		s<<"/";
		s<<poNode->sName;
		if(B_OK!=oEntry.SetTo(s.String()) || B_OK!=oEntry.GetRef(&uNodeRef)) continue;
		poMessage->AddRef("refs",&uNodeRef);
	}
	
	
	poMessage->AddRef("folder_ref",&uEntryRef);
	poMessage->AddPointer("func",(void*)Func_AddOn);
	
	// run thread //
	thread_id idThread = spawn_thread(BF_GUI_FilesPanel_Action_Tracker_Addons_Run_Thread,"tracker_addon_thread",B_THREAD_SUSPENDED,(void*)poMessage);	
	ASSERT(idThread>0,"can`t start thread\n");	
	ASSERT(B_OK==resume_thread(idThread));		
	set_thread_priority(idThread,1);				
}
void
ExpanderWindow::StartExpanding()
{
	ExpanderRule* rule = fRules.MatchingRule(&fSourceRef);
	if (!rule)
		return;

	BEntry destEntry(fDestText->Text(), true);
	if (!destEntry.Exists()) {
		BAlert* alert = new BAlert("destAlert",
		B_TRANSLATE("The folder was either moved, renamed or not\nsupported."),
		B_TRANSLATE("Cancel"), NULL, NULL,
			B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
		alert->Go();
		return;
	}

	BMessage message;
	message.AddString("cmd", rule->ExpandCmd());
	message.AddRef("srcRef", &fSourceRef);
	message.AddRef("destRef", &fDestRef);

	fExpandButton->SetLabel(B_TRANSLATE("Stop"));
	fSourceButton->SetEnabled(false);
	fDestButton->SetEnabled(false);
	fShowContents->SetEnabled(false);
	fSourceItem->SetEnabled(false);
	fDestItem->SetEnabled(false);
	fExpandItem->SetEnabled(false);
	fShowItem->SetEnabled(false);
	fStopItem->SetEnabled(true);
	fPreferencesItem->SetEnabled(false);

	BEntry entry(&fSourceRef);
	BPath path(&entry);
	BString text(B_TRANSLATE("Expanding '%s'"));
	text.ReplaceFirst("%s", path.Leaf());
	fStatusView->SetText(text.String());

	fExpandingThread = new ExpanderThread(&message, new BMessenger(this));
	fExpandingThread->Start();

	fExpandingStarted = true;
}
	virtual void ArgvReceived(int32 argc,char **argv)
	{
	
		if (argc < 2) return;
		
		while (--argc) {
			if (get_ref_for_path(argv[argc],&ref)==B_OK)
				refs.AddRef("refs",&ref);
		}
	}
Beispiel #12
0
void
BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow,
	bool atEnd, bool addShortcuts, bool navMenuEntries)
{
	Model model(entry);
	if (model.InitCheck() != B_OK)
		return;

	BMessage* message = new BMessage(fCommand);
	message->AddRef(fEntryName.String(), model.EntryRef());

	// add reference to the container windows model so that we can
	// close the window if
	BContainerWindow* window = originatingWindow ?
		dynamic_cast<BContainerWindow*>(originatingWindow) : 0;
	if (window)
		message->AddData("nodeRefsToClose", B_RAW_TYPE,
			window->TargetModel()->NodeRef(), sizeof (node_ref));
	ModelMenuItem* item;
	if (navMenuEntries) {
		BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED,
			fTarget, window);
		entry_ref ref;
		entry->GetRef(&ref);
		subMenu->SetNavDir(&ref);
		item = new ModelMenuItem(&model, subMenu);
		item->SetLabel(model.Name());
		item->SetMessage(message);
	} else {
		item = new ModelMenuItem(&model, model.Name(), message);
	}

	if (addShortcuts) {
		if (model.IsDesktop())
			item->SetShortcut('D', B_COMMAND_KEY);
		else if (FSIsHomeDir(entry))
			item->SetShortcut('H', B_COMMAND_KEY);
	}

	if (atEnd)
		AddItem(item);
	else
		AddItem(item, 0);

	item->SetTarget(fTarget);

	if (fMenuBar) {
		ModelMenuItem* menu
			= dynamic_cast<ModelMenuItem*>(fMenuBar->ItemAt(0));
		if (menu) {
			ThrowOnError(menu->SetEntry(entry));
			item->SetMarked(true);
		}
	}
}
Beispiel #13
0
void
GrepWindow::_OnNewWindow()
{
	BMessage cloneRefs;
		// we don't want GrepWindow::InitRefsReceived()
		// to mess with the refs of the current window

	cloneRefs = fModel->fSelectedFiles;
	cloneRefs.AddRef("dir_ref", &(fModel->fDirectory));

	new GrepWindow(&cloneRefs);
}
Beispiel #14
0
status_t Enclosure::Flatten(void *buffer, ssize_t numBytes) const {
	BMessage flat;
	flat.AddString("url", fURL);
	flat.AddString("mime", fMIME);
	flat.AddString("description", fDescription);
	flat.AddInt32("size", fSize);
	flat.AddInt32("state", fState);
	if (fProgress) flat.AddFlat("progress", fProgress);
	flat.AddRef("localRef", &fLocalRef);
	
	return flat.Flatten((char *)buffer, numBytes);
};
Beispiel #15
0
ssize_t Enclosure::FlattenedSize(void) const {
	BMessage flat;
	flat.AddString("url", fURL);
	flat.AddString("mime", fMIME);
	flat.AddString("description", fDescription);
	flat.AddInt32("size", fSize);
	flat.AddInt32("state", fState);
	if (fProgress) flat.AddFlat("progress", fProgress);
	flat.AddRef("localRef", &fLocalRef);

	return flat.FlattenedSize();
};
BetterListItem *
each_adder( BetterListItem * _item, void * data)
{
	BMessage * msg = (BMessage*)data;
	TrackItem * item = dynamic_cast<TrackItem*>(_item);
	
	if ( item )
	{
		msg->AddRef("refs",item->GetTrack()->GetEntry() );
	}
	
	return NULL;
}
Beispiel #17
0
void QueryMenu::EntryCreated( const entry_ref &ref, ino_t node )
{
	BMessage 		*msg;
	BMenuItem 		*item;
	
	msg = new BMessage( B_REFS_RECEIVED );
	msg->AddRef( "refs", &ref );
	msg->AddInt64( "node", node );
	item = new BMenuItem( ref.name, msg );
	if( fTargetHandler )
		item->SetTarget( fTargetHandler );
	AddItem( item );
}
	virtual void RefsReceived(BMessage *message) 
	{ 
		uint32 type; 
		int32 count; 
		
		message->GetInfo("refs", &type, &count); 
		if ( type != B_REF_TYPE ) 
			return; 
		
		for ( long i = --count; i >= 0; --i )
			if ( message->FindRef("refs", i, &ref) == B_OK )
				refs.AddRef("refs",&ref);
	}
Beispiel #19
0
void
MainApp::_HandleFilePanelResult(BFilePanel* panel, const BMessage* message)
{
//	printf("_HandleFilePanelResult()\n");
//	message->PrintToStream();

	panel->GetPanelDirectory(&fLastFilePanelFolder);

	BMessage targetMessage;
	if (message->FindMessage("message", &targetMessage) != B_OK)
		targetMessage.what = message->what;

	BMessenger target;
	if (message->FindMessenger("target", &target) != B_OK) {
		if (targetMessage.what == M_OPEN_PANEL_RESULT
			|| targetMessage.what == M_SAVE_PANEL_RESULT) {
			// prevent endless message cycle
			return;
		}
		// send result message to ourselves
		target = BMessenger(this);
	}

	// copy the important contents of the message
	// save panel
	entry_ref directory;
	if (message->FindRef("directory", &directory) == B_OK)
		targetMessage.AddRef("directory", &directory);
	const char* name;
	if (message->FindString("name", &name) == B_OK)
		targetMessage.AddString("name", name);
	// open panel
	entry_ref ref;
	for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++)
		targetMessage.AddRef("refs", &ref);

	target.SendMessage(&targetMessage);
}
void
ExpanderWindow::OpenDestFolder()
{
	bool openFolder = true;
	fSettings.FindBool("open_destination_folder", &openFolder);

	if (!openFolder)
		return;

	BMessage* message = new BMessage(B_REFS_RECEIVED);
	message->AddRef("refs", &fDestRef);
	BPath path(&fDestRef);
	BMessenger tracker("application/x-vnd.Be-TRAK");
	tracker.SendMessage(message);
}
Beispiel #21
0
/*!	\brief Adds application monitoring related fields to a message.
	\param message The message.
	\param info The app_info of the concerned application.
	\return \c B_OK if everything went fine, an error code otherwise.
*/
status_t
TRoster::_AddMessageWatchingInfo(BMessage* message, const app_info* info)
{
	status_t error = B_OK;
	if (error == B_OK)
		error = message->AddString("be:signature", info->signature);
	if (error == B_OK)
		error = message->AddInt32("be:team", info->team);
	if (error == B_OK)
		error = message->AddInt32("be:thread", info->thread);
	if (error == B_OK)
		error = message->AddInt32("be:flags", (int32)info->flags);
	if (error == B_OK)
		error = message->AddRef("be:ref", &info->ref);
	return error;
}
Beispiel #22
0
void
GrepWindow::_OnTrimSelection()
{
	if (fSearchResults->CurrentSelection() < 0) {
		BString text;
		text << B_TRANSLATE("Please select the files you wish to keep searching.");
		text << "\n";
		text << B_TRANSLATE("The unselected files will be removed from the list.");
		text << "\n";
		BAlert* alert = new BAlert(NULL, text.String(), B_TRANSLATE("OK"), NULL, NULL,
			B_WIDTH_AS_USUAL, B_WARNING_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go(NULL);
		return;
	}

	BMessage message;
	BString path;

	for (int32 index = 0; ; index++) {
		BStringItem* item = dynamic_cast<BStringItem*>(
			fSearchResults->ItemAt(index));
		if (item == NULL)
			break;

		if (!item->IsSelected() || item->OutlineLevel() != 0)
			continue;

		if (path == item->Text())
			continue;

		path = item->Text();
		entry_ref ref;
		if (get_ref_for_path(path.String(), &ref) == B_OK)
			message.AddRef("refs", &ref);
	}

	fModel->fDirectory = entry_ref();
		// invalidated on purpose

	fModel->fSelectedFiles.MakeEmpty();
	fModel->fSelectedFiles = message;

	PostMessage(MSG_START_CANCEL);

	_SetWindowTitle();
}
Beispiel #23
0
int32
add_query_menu_items(BMenu* menu, const char* attribute, uint32 what,
	const char* format, bool popup)
{
	BVolume	volume;
	BVolumeRoster().GetBootVolume(&volume);

	BQuery query;
	query.SetVolume(&volume);
	query.PushAttr(attribute);
	query.PushString("*");
	query.PushOp(B_EQ);
	query.Fetch();

	int32 index = 0;
	BEntry entry;
	while (query.GetNextEntry(&entry) == B_OK) {
		BFile file(&entry, B_READ_ONLY);
		if (file.InitCheck() == B_OK) {
			BMessage* message = new BMessage(what);

			entry_ref ref;
			entry.GetRef(&ref);
			message->AddRef("ref", &ref);

			BString value;
			if (file.ReadAttrString(attribute, &value) < B_OK)
				continue;

			message->AddString("attribute", value.String());

			BString name;
			if (format != NULL)
				name.SetToFormat(format, value.String());
			else
				name = value;

			if (index < 9 && !popup)
				menu->AddItem(new BMenuItem(name, message, '1' + index));
			else
				menu->AddItem(new BMenuItem(name, message));
			index++;
		}
	}

	return index;
}
Beispiel #24
0
void InfoStrView::OpenFolder (const char *path) const
{
	/* This function opens a folder entry_ref through Tracker */
	BEntry entry (path, true);
	entry_ref refToDir;
	entry.GetRef (&refToDir);
	
	if (entry.Exists() == true)
	{
		BMessage trakMsg (B_REFS_RECEIVED);
		trakMsg.AddRef ("refs", &refToDir);

		/* Just check if tracker is running */
		if (be_roster->IsRunning (trackerSignature) == true)
			BMessenger(trackerSignature).SendMessage (&trakMsg);
	}
}
Beispiel #25
0
void
BDirMenu::AddDisksIconToMenu(bool atEnd)
{
	BEntry entry("/");
	Model model(&entry);
	if (model.InitCheck() != B_OK) 
		return;

	BMessage *message = new BMessage(fCommand);
	message->AddRef(fEntryName.String(), model.EntryRef());

	ModelMenuItem *item = new ModelMenuItem(&model, "Disks", message);
	if (atEnd)
		AddItem(item);
	else
		AddItem(item, 0);
}
Beispiel #26
0
void
BNavMenu::AddNavParentDir(const char *name,const Model *model,uint32 what,BHandler *target)
{
	BNavMenu *menu = new BNavMenu(name,what,target);
	menu->SetNavDir(model->EntryRef());
	menu->SetShowParent(true);
	menu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
			fTrackingHook.fDragMessage);

	BMenuItem *item = new SpecialModelMenuItem(model,menu);

	BMessage *message = new BMessage(what);
	message->AddRef("refs",model->EntryRef());
	item->SetMessage(message);

	AddItem(item);
}
Beispiel #27
0
filter_result
DCCFileFilter::HandleAlert (BMessage *msg)
{
	BTextControl *text (dynamic_cast<BTextControl *>(
		panel->Window()->FindView ("text view")));
	int32 which;

	msg->FindInt32 ("which", &which);

	if (which == 0 || text == 0)
	{
		return B_SKIP_MESSAGE;
	}

	entry_ref ref;
	panel->GetPanelDirectory (&ref);

	if (which == 2)
	{
		BDirectory dir (&ref);
		BFile file (&dir, text->Text(), B_READ_ONLY);
		BEntry entry (&dir, text->Text());
		BPath path;
		off_t position;

		file.GetSize (&position);
		entry.GetPath (&path);
		send_msg.AddString ("path", path.Path());
		send_msg.AddInt64  ("pos", position);

		send_msg.what = M_ADD_RESUME_DATA;
	}
	else
	{
		send_msg.AddRef ("directory", &ref);
		send_msg.AddString ("name", text->Text());
	}

	panel->Messenger().SendMessage (&send_msg);

	BMessage cmsg (B_CANCEL);
	cmsg.AddPointer ("source", panel);
	panel->Messenger().SendMessage (&cmsg);

	return B_SKIP_MESSAGE;
}
Beispiel #28
0
void IconBar::AttachedToWindow(void) {
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 	SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 	SetHighColor(0, 0, 0, 255);

	BDirectory dir(fAppPath.String());
 	entry_ref ref;
 	BRect iconRect = Bounds();

	fIconSize = (int16)(iconRect.Height() - (fPadding * 2));
 	
	iconRect.bottom -= fPadding;
	iconRect.top += fPadding;
 	iconRect.right = fIconSize;
 	iconRect.left += fPadding;
 	
 	fIconSize -= fPadding * 4;
	
 	while (dir.GetNextRef(&ref) == B_OK) {
 		BPath path(&ref);
 		BNode node(&ref);
 		BBitmap *icon = ReadNodeIcon(path.Path(), fIconSize, true);

		int32 length = -1;
		char *desc = ReadAttribute(node, "im_client:description", &length);
		if ((length < 1) || (desc == NULL)) desc = strdup(ref.name);
		
		BMessage *msg = new BMessage(kClickMsg);
		msg->AddRef("app_ref", &ref);
				
 		ImageButton *button = new ImageButton(iconRect, ref.name, msg,
 			B_FOLLOW_NONE, B_WILL_DRAW, icon, NULL);
 		fBubbles->SetHelp(button, desc);
 		AddChild(button);
 		
 		button->SetTarget(this);
 		
 		fButtons.push_back(button);
 		
 		free(desc);

 		
 		iconRect.OffsetBy(iconRect.Width() + fPadding, 0);
 	};
};
void
ExpanderWindow::StartListing()
{
	_UpdateWindowSize(true);

	if (!fSourceChanged)
		return;

	fPreviousHeight = -1.0;

	fLongestLine = 0.0f;

	ExpanderRule* rule = fRules.MatchingRule(&fSourceRef);
	if (!rule)
		return;

	BMessage message;
	message.AddString("cmd", rule->ListingCmd());
	message.AddRef("srcRef", &fSourceRef);

	fShowContents->SetEnabled(true);
	fSourceItem->SetEnabled(false);
	fDestItem->SetEnabled(false);
	fExpandItem->SetEnabled(false);
	fShowItem->SetEnabled(true);
	fShowItem->SetLabel(B_TRANSLATE("Hide contents"));
	fStopItem->SetEnabled(false);
	fPreferencesItem->SetEnabled(false);

	fSourceButton->SetEnabled(false);
	fDestButton->SetEnabled(false);
	fExpandButton->SetEnabled(false);

	BEntry entry(&fSourceRef);
	BPath path(&entry);
	BString text(B_TRANSLATE("Creating listing for '%s'"));
	text.ReplaceFirst("%s", path.Leaf());
	fStatusView->SetText(text.String());
	fListingText->SetText("");

	fListingThread = new ExpanderThread(&message, new BMessenger(this));
	fListingThread->Start();

	fListingStarted = true;
}
Beispiel #30
0
void
ExpanderApp::ArgvReceived(int32 argc, char **argv)
{
	BMessage* msg = NULL;
	for (int32 i = 1; i < argc; i++) {
		entry_ref ref;
		status_t err = get_ref_for_path(argv[i], &ref);
		if (err == B_OK) {
			if (!msg) {
				msg = new BMessage;
				msg->what = B_REFS_RECEIVED;
			}
			msg->AddRef("refs", &ref);
		}
	}
	if (msg)
		RefsReceived(msg);
}