From a2618d1f2218bf54e257ec947440a81a8b0bc113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 23 Aug 2005 11:28:52 +0000 Subject: [PATCH] clean up git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14052 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/keymap/KeymapApplication.cpp | 122 +------------------ src/preferences/keymap/KeymapApplication.h | 6 +- src/preferences/keymap/KeymapWindow.cpp | 4 +- src/preferences/keymap/KeymapWindow.h | 7 +- 4 files changed, 7 insertions(+), 132 deletions(-) diff --git a/src/preferences/keymap/KeymapApplication.cpp b/src/preferences/keymap/KeymapApplication.cpp index 582854d1ba..282b63e230 100644 --- a/src/preferences/keymap/KeymapApplication.cpp +++ b/src/preferences/keymap/KeymapApplication.cpp @@ -13,28 +13,13 @@ // // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -#include -#include -#include -#include -#include -#include -#if DEBUG - #include - #include -#endif //DEBUG -#include "KeymapWindow.h" #include "KeymapApplication.h" -#include - KeymapApplication::KeymapApplication() : BApplication( APP_SIGNATURE ) { // create the window - BRect frame = WINDOW_DIMENSIONS; - frame.OffsetTo( WINDOW_LEFT_TOP_POSITION ); - fWindow = new KeymapWindow( frame ); + fWindow = new KeymapWindow(); fWindow->Show(); } @@ -44,111 +29,6 @@ void KeymapApplication::MessageReceived( BMessage * message ) } - - - -/*bool -KeymapApplication::UseKeymap( BEntry *keymap ) -{ // Copies keymap to ~/config/settings/key_map - BFile *inFile; - BFile *outFile; - - // Open input file - if( !keymap->Exists() ) - return false; - inFile = new BFile( keymap, B_READ_ONLY ); - if( !inFile->IsReadable() ) { - delete inFile; - return false; - } - - // Is keymap a valid keymap file? - if( !IsValidKeymap( inFile ) ) { - delete inFile; - return false; - } - - // Open output file - // TODO: find a nice constant for the path and use that instead - outFile = new BFile( "/boot/home/config/settings/Key_map", B_WRITE_ONLY|B_ERASE_FILE|B_CREATE_FILE ); - if( !outFile->IsWritable() ) { - delete inFile; - delete outFile; - return false; - } - - // Copy file - if( Copy( inFile, outFile ) != B_OK ) { - delete inFile; - delete outFile; - return false; - } - delete inFile; - delete outFile; - - // Tell Input Server there is a new keymap - if( NotifyInputServer() != B_OK ) - return false; - - return true; -} - - -bool -KeymapApplication::IsValidKeymap( BFile *inFile ) -{ - // TODO: implement this thing - - return true; -} - - -int -KeymapApplication::Copy( BFile *original, BFile *copy ) -{ - char *buffer[ COPY_BUFFER_SIZE ]; - int offset = 0; - int errorCode = B_NO_ERROR; - ssize_t nrBytesRead; - ssize_t nrBytesWritten; - - while( true ) { - nrBytesRead = original->ReadAt( offset, buffer, COPY_BUFFER_SIZE ); - if( nrBytesRead == 0 ) - { - errorCode = B_OK; - break; - } - nrBytesWritten = copy->WriteAt( offset, buffer, nrBytesRead ); - if( nrBytesWritten != nrBytesRead ) - { - errorCode = B_ERROR; - break; - } - if( nrBytesRead < COPY_BUFFER_SIZE ) - { - errorCode = B_OK; - break; - } - offset += nrBytesRead; - } - - return errorCode; -}*/ - - -int -KeymapApplication::NotifyInputServer() -{ - // This took me days to find out. Go figure. - // Be didn't need to restart the thing - they prolly used - // a proprietary interface to notify it. Coordinate with - // the input_server guys. - system("kill -KILL input_server"); - return B_NO_ERROR; -} - - int main () { diff --git a/src/preferences/keymap/KeymapApplication.h b/src/preferences/keymap/KeymapApplication.h index 966ad4696f..6b11dfd511 100644 --- a/src/preferences/keymap/KeymapApplication.h +++ b/src/preferences/keymap/KeymapApplication.h @@ -16,12 +16,12 @@ #ifndef KEYMAP_APPLICATION_H #define KEYMAP_APPLICATION_H -#include +#include +#include +#include "KeymapWindow.h" #define APP_SIGNATURE "application/x-vnd.haiku.Keymap" -class KeymapWindow; - class KeymapApplication : public BApplication { public: KeymapApplication(); diff --git a/src/preferences/keymap/KeymapWindow.cpp b/src/preferences/keymap/KeymapWindow.cpp index dfc09c08ec..17c2627134 100644 --- a/src/preferences/keymap/KeymapWindow.cpp +++ b/src/preferences/keymap/KeymapWindow.cpp @@ -49,8 +49,8 @@ #define USE_KEYMAP 'UkyM' #define REVERT 'Rvrt' -KeymapWindow::KeymapWindow( BRect frame ) - : BWindow( frame, WINDOW_TITLE, B_TITLED_WINDOW, +KeymapWindow::KeymapWindow() + : BWindow(BRect(80,25,692,281), "Keymap", B_TITLED_WINDOW, B_NOT_ZOOMABLE|B_NOT_RESIZABLE|B_ASYNCHRONOUS_CONTROLS ) { // Add the menu bar diff --git a/src/preferences/keymap/KeymapWindow.h b/src/preferences/keymap/KeymapWindow.h index 8096052413..21a79ba928 100644 --- a/src/preferences/keymap/KeymapWindow.h +++ b/src/preferences/keymap/KeymapWindow.h @@ -23,12 +23,7 @@ #include "KeymapTextView.h" #include "Keymap.h" -#define WINDOW_TITLE "Keymap" -#define WINDOW_LEFT_TOP_POSITION BPoint( 80, 25 ) -#define WINDOW_DIMENSIONS BRect( 0,0, 612,256 ) - class KeymapListItem; -class KeymapApplication; class MapView : public BControl { @@ -64,7 +59,7 @@ private: class KeymapWindow : public BWindow { public: - KeymapWindow( BRect frame ); + KeymapWindow(); ~KeymapWindow(); bool QuitRequested(); void MessageReceived( BMessage* message );