Table des Matières Tracker | Index Tracker |
Le Tracker offre un système de raccourcis pratique via l'utilisation d'add-ons. L'utilisateur peut accéder au menu des add-ons par un clic-droit dans le Tracker. Le Tracker interragit avec un add-on au moyen de la fonction process_refs() décrite plus loin.
Les add-ons du Tracker doivent être placés dans /boot/home/config/add-ons/Tracker. Un raccourci clavier peut être associé à un add-on en ajoutant au nom de l'add-on un tiret suivi du raccourci associé.
Declaré dans : <be/add-ons/tracker/TrackerAddOn.h>
|
Le Tracker appelle cette fonction lorsque l'utilisateur lance l'add-on. Le répertoire courant se trouve dans dir_ref. msg est un BMessage B_REFS_RECEIVED standard, et le tableau "refs" contient les entry_refs des fichiers sélectionnés par l'utilisateur. Le troisième argument n'est pas utilisé pour le moment.
process_refs() tourne dans un thread à part au sein de la Tracker team, donc si votre add-on plante, le Tracker plante également.
Voici un Add-On simple pour le Tracker. Il récupère le contenu des arguments de process_refs() et les affiche dans une fenêtre.
#include <Application.h> #include <InterfaceKit.h> #include <StorageKit.h> #include <stdio.h> #include <string.h> #include <be/add-ons/tracker/TrackerAddon.h> void process_refs(entry_ref dir_ref, BMessage *msg, void *) { BWindow *window = new BWindow(BRect(100,100,300,300), "Sample Tracker Add-on", B_TITLED_WINDOW, 0); BTextView *view = new BTextView(BRect(0,0,200,200), "view", BRect(0,0,200,200), B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); BPath path; BEntry entry(&dir_ref); entry.GetPath(&path); view->Insert("Current Directory: "); view->Insert(path.Path()); view->Insert("n"); int refs; entry_ref file_ref; for (refs=0;msg->FindRef("refs", refs, &file_ref) == B_NO_ERROR;refs++) { if (refs == 0) view->Insert("Selected files:n"); entry.SetTo(&file_ref); entry.GetPath(&path); view->Insert(path.Path()); view->Insert("n"); } if (refs == 0) view->Insert("No files selected.n"); view->MakeEditable(false); window->AddChild(view); window->Show(); } main() { new BApplication("application/x-sample-tracker-add-on"); (new BAlert("", "Sample Tracker Add-on", "swell"))->Go(); delete be_app; }
Table des Matières Tracker | Index Tracker |
Copyright © 2000 Be, Inc. All rights reserved..