xref: /haiku/src/tests/kits/interface/bshelf/ShelfInspector/InfoApplication.cpp (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 // InfoApplication.cpp
2 
3 
4 
5 #include "InfoApplication.h"
6 
7 const char *XCONTAINER_APP		= "application/x-vnd.reh-XContainer";
8 
9 
10 #define	CMD_UPDATE_CONTAINER_ITEM  'updC'
11 
12 
13 InfoApplication :: InfoApplication()
14 		  		  		 : IEApplication("application/x-vnd.reh-XShelfInspector")
15 {
16 	// instantiate a new window
17 	fLaunched = true;
18 	fInfoWindow = new InfoWindow();
19 }
20 
21 InfoApplication :: ~InfoApplication()
22 {
23 	be_roster -> StopWatching(fMsgnr);
24 }
25 
26 
27 void InfoApplication :: MessageReceived(BMessage *msg)
28 {
29 	switch (msg->what)
30 	{
31 		case B_SOME_APP_QUIT:
32 		case B_SOME_APP_ACTIVATED:
33 		case B_SOME_APP_LAUNCHED:
34 			{
35 				if (  (be_roster -> IsRunning(XCONTAINER_APP)) == false )
36 				{
37 					be_roster->Launch(XCONTAINER_APP);				// Launch the XContainer
38 
39 					if (fLaunched == true)
40 					{
41 					 	fInfoWindow -> GetPrefs();
42 						fInfoWindow -> Show();
43 				 		fLaunched = false;
44 					 	break;
45 					}
46 					BMessenger	messenger;
47 					BMessage	msg(CMD_UPDATE_CONTAINER_ITEM);	// Update XContainer
48 					messenger = BMessenger(fInfoWindow);
49 					messenger.SendMessage(&msg);
50 				}
51 			}
52 			break;
53 
54 	default:
55 		BApplication :: MessageReceived(msg);
56 	break;
57 	}
58 }
59 
60 void InfoApplication::ReadyToRun()
61 {
62 	fMsgnr = BMessenger(this);
63 	be_roster -> StartWatching(fMsgnr);
64 	PostMessage(B_SOME_APP_LAUNCHED);
65 }
66 
67 
68 int main()
69 {
70 	InfoApplication	infoApplication;
71 	infoApplication.Run();
72 	return(0);
73 }
74