1 /* 2 * Copyright 1999-2009 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Jeremy Friesner 7 */ 8 9 10 #ifndef ShortcutsWindow_h 11 #define ShortcutsWindow_h 12 13 #include <Message.h> 14 #include <Window.h> 15 #include <Point.h> 16 #include <Entry.h> 17 #include <FilePanel.h> 18 19 20 #include "ColumnListView.h" 21 #include "ResizableButton.h" 22 23 // This class defines our preferences/configuration window. 24 class ShortcutsWindow : public BWindow { 25 public: 26 // If (optSaveTo) is non-NULL, settings will be loaded from the file it 27 // represents. 28 ShortcutsWindow(); 29 ~ShortcutsWindow(); 30 31 virtual void DispatchMessage(BMessage* msg, BHandler* handler); 32 virtual void Quit(); 33 virtual void FrameResized(float w, float h); 34 virtual void MessageReceived(BMessage * msg); 35 virtual bool QuitRequested(); 36 37 // BMessage 'what' codes, representing commands understood by this Window. 38 enum { 39 ADD_HOTKEY_ITEM = 'SpKy', // Add a new hotkey entry to the GUI list. 40 REMOVE_HOTKEY_ITEM, // Remove a hotkey entry from the GUI list. 41 HOTKEY_ITEM_SELECTED, // Give the "focus bar" to the specified 42 // entry. 43 HOTKEY_ITEM_MODIFIED, // Update the state of an entry to reflect 44 // user's changes. 45 OPEN_KEYSET, // Bring up a File requester to load new 46 // settings. 47 APPEND_KEYSET, // Bring up a File requester to append 48 // settings. 49 REVERT_KEYSET, // Dump the current state and re-read 50 // settings from disk. 51 SAVE_KEYSET, // Save the current settings to disk 52 SAVE_KEYSET_AS, // Bring up a File requester to save 53 // current settings. 54 SELECT_APPLICATION, // Set the current entry to point to the 55 // given file. 56 }; 57 private: 58 BMenuItem* _CreateActuatorPresetMenuItem(const char* label) 59 const; 60 void _AddNewSpec(const char* defaultCommand); 61 void _MarkKeySetModified(); 62 bool _LoadKeySet(const BMessage& loadMsg); 63 bool _SaveKeySet(BEntry & saveEntry); 64 bool _GetSettingsFile(entry_ref* ref); 65 66 ResizableButton* fAddButton; 67 ResizableButton* fRemoveButton; 68 ResizableButton* fSaveButton; 69 ColumnListView* fColumnListView; 70 BFilePanel* fSavePanel; // for saving settings 71 BFilePanel* fOpenPanel; // for loading settings 72 BFilePanel* fSelectPanel; // for selecting apps to launch 73 74 // Points to the settings file to save to 75 BEntry fLastSaved; 76 77 // true iff changes were made since last load or save 78 bool fKeySetModified; 79 80 // true iff the file-requester's ref should be appended to current 81 bool fLastOpenWasAppend; 82 }; 83 84 #endif 85