clean up
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14052 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
19dfa58852
commit
a2618d1f22
@ -13,28 +13,13 @@
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
|
||||
#include <InputServerDevice.h>
|
||||
#include <File.h>
|
||||
#include <Application.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <Path.h>
|
||||
#if DEBUG
|
||||
#include <interface/Input.h>
|
||||
#include <stdio.h>
|
||||
#endif //DEBUG
|
||||
#include "KeymapWindow.h"
|
||||
#include "KeymapApplication.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
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 ()
|
||||
{
|
||||
|
@ -16,12 +16,12 @@
|
||||
#ifndef KEYMAP_APPLICATION_H
|
||||
#define KEYMAP_APPLICATION_H
|
||||
|
||||
#include <storage/Entry.h>
|
||||
#include <Application.h>
|
||||
#include <Entry.h>
|
||||
#include "KeymapWindow.h"
|
||||
|
||||
#define APP_SIGNATURE "application/x-vnd.haiku.Keymap"
|
||||
|
||||
class KeymapWindow;
|
||||
|
||||
class KeymapApplication : public BApplication {
|
||||
public:
|
||||
KeymapApplication();
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user