[maemo-users] Text Editor with dead keys support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some time ago I made severe critics about the Maemo Development.
Well, I remain with the same opinion: it?s a crap.
Too much bla bla bla about "the next upcoming features" and no effective results, and of course, I was a moron, stupid, puny programmer and other nice adjectives.
I don?t care... It?s not my company or my job. 
But if some of you need a very crude Text Editor with dead keys support for Bluetooth keyboards, you may try my Python Editor. Obviously I made it for my portuguese needs, but the code is fairly simple and you can easily adapt for your needs. 
It can save text and open, work's in fullscreen too. And finish, no fancy fonts and colors.

There's no deb package, I don?t have time for that.

You can install as I say:
-Install Python
-Install Become Root
-Install xTerminal
Save the editor and editor.desktop file in your memory stick

Open the terminal

Do this as root:
Sudo su -

Chmod +x editor
Cp editor /usr/bin/

maemo-select-menu-location editor.desktop tana_fi_utilities

That's it... Finally I can use my Nokia for some word processing... Before that I enjoyed toillet internet (much better than newspaper) and as a big pendrive. Now my money worth something. 

Thanks for nothing to INDT and Nokia for no help at all. Ah, one last question... Where are the dozens of new software for nokia 770? I say: with the development architecture in use forget it... Indeed, with the arrogance of INDT and the Nokia fear to really release the Maemo for true Open Source Development, try a new cell fone...

With time I'll put this little Text Editor at www.ihatenokia770.com.
If you don?t have a Nokia 770 do yourself a favor and buy an UMPC with Windows Tablet.
And don?t mail me to blame about the editor, about the lack of a deb package and so on...
If you own a Nokia 770 you probably think yourself as a Linux hotshot, so expect to deal with hard code.

Here's the source code for the editor (beware with the TAB's, you can mail me for the file fonts) 
----------------------------------------
#!/usr/bin/python
import gtk
import hildon

class MyEditor(hildon.Program):
	def __init__(self):
		hildon.Program.__init__(self)
		self.window = hildon.Window()
		self.window.connect("destroy", gtk.main_quit)
		self.window.connect("key-press-event", self.on_key_press)
		self.window.connect("window-state-event", self.on_window_state_change)
		self.add_window(self.window)
		
            file_menu = gtk.Menu()
            open_item = gtk.MenuItem("Open")
            save_item = gtk.MenuItem("Save")
            quit_item = gtk.MenuItem("Quit")
                
            file_menu.append(open_item)
            file_menu.append(save_item)
            file_menu.append(quit_item)

            open_item.connect_object("activate", self.menuitem_response, "file.open")
            save_item.connect_object("activate", self.menuitem_response, "file.save")
            quit_item.connect_object ("activate", self.menuitem_response, "file.quit")

            open_item.show()
            save_item.show()
            quit_item.show()

            self.window.set_menu(file_menu)
		self.Tbuffer= gtk.TextBuffer(table=None)	
		self.texto = gtk.TextView(buffer=self.Tbuffer)
		self.texto.set_wrap_mode(gtk.WRAP_WORD)
		self.AccentBuffer = ""
		self.window.set_title("Editor!")
		self.window.add(self.texto)
		self.window.show_all()
		self.window_on_fullscreen = False
		self.file_name = False
	def on_key_press(self, widget, event, *args):
             	self.texto.set_editable(True)
             	#whether or not accent
                if self.AccentBuffer == "":
                    if event.keyval == gtk.keysyms.asciitilde:
                        self.AccentBuffer = "~"
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.apostrophe:
                        self.AccentBuffer = "'"
                        self.texto.set_editable(False)
                    elif event.keyval == gtk.keysyms.asciicircum:
                        self.AccentBuffer = "^"
                        self.texto.set_editable(False)
                    elif event.keyval == gtk.keysyms.grave:
                        self.AccentBuffer = "`"
                        self.texto.set_editable(False)
                    elif event.keyval == gtk.keysyms.quotedbl:
                        self.AccentBuffer = '"'
                        self.texto.set_editable(False)
                #events for tilde
                elif self.AccentBuffer == "~":
                    self.AccentBuffer = ""
                    if event.keyval == gtk.keysyms.a:
                        self.Tbuffer.insert_at_cursor(u'\xe3')
				self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.A:
                        self.Tbuffer.insert_at_cursor(u'\xc3')
				self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.o:
                        self.Tbuffer.insert_at_cursor(u'\xf5')
				self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.O:
                        self.Tbuffer.insert_at_cursor(u'\xd5')
				self.texto.set_editable(False)
		    else:
                        if event.keyval == gtk.keysyms.Shift_L or event.keyval == gtk.keysyms.Shift_R:
                            self.texto.set_editable(False)
                            self.AccentBuffer = "~"
                        else:
                            self.Tbuffer.insert_at_cursor('~')
                            self.texto.set_editable(False)
		#events for apostrophe
		elif self.AccentBuffer == "'":
                  self.AccentBuffer = ""
                  if event.keyval == gtk.keysyms.c:
                        self.Tbuffer.insert_at_cursor(u'\xe7')
				self.texto.set_editable(False)
		    	elif event.keyval == gtk.keysyms.C:
                        self.Tbuffer.insert_at_cursor(u'\xc7')
				self.texto.set_editable(False)
		    	elif event.keyval == gtk.keysyms.a:
                        self.Tbuffer.insert_at_cursor(u'\xe1')
				self.texto.set_editable(False)
		    	elif event.keyval == gtk.keysyms.A:
                        self.Tbuffer.insert_at_cursor(u'\xc1')
				self.texto.set_editable(False)
		    	elif event.keyval == gtk.keysyms.e:
                        self.Tbuffer.insert_at_cursor(u'\xe9')
				self.texto.set_editable(False)
		    	elif event.keyval == gtk.keysyms.E:
                        self.Tbuffer.insert_at_cursor(u'\xc9')
				self.texto.set_editable(False)
		   	elif event.keyval == gtk.keysyms.i:
                        self.Tbuffer.insert_at_cursor(u'\xed')
				self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.I:
                        self.Tbuffer.insert_at_cursor(u'\xcd')
				self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.o:
                        self.Tbuffer.insert_at_cursor(u'\xf3')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.O:
                        self.Tbuffer.insert_at_cursor(u'\xd3')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.u:
                        self.Tbuffer.insert_at_cursor(u'\xfa')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.U:
                        self.Tbuffer.insert_at_cursor(u'\xda')
			self.texto.set_editable(False)
		    else:
                        if event.keyval == gtk.keysyms.Shift_L or event.keyval == gtk.keysyms.Shift_R:
                            self.texto.set_editable(False)
                            self.AccentBuffer = "'"
                        else:
                            self.Tbuffer.insert_at_cursor("'")
                            self.texto.set_editable(False)
                #events for circum
                elif self.AccentBuffer == "^":
                    self.AccentBuffer = ""
                    if event.keyval == gtk.keysyms.a:
                        self.Tbuffer.insert_at_cursor(u'\xe2')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.A:
                        self.Tbuffer.insert_at_cursor(u'\xc2')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.e:
                        self.Tbuffer.insert_at_cursor(u'\xea')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.E:
                        self.Tbuffer.insert_at_cursor(u'\xca')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.o:
                        self.Tbuffer.insert_at_cursor(u'\xf4')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.O:
                        self.Tbuffer.insert_at_cursor(u'\xd4')
			self.texto.set_editable(False)
		    else:
                        if event.keyval == gtk.keysyms.Shift_L or event.keyval == gtk.keysyms.Shift_R:
                            self.texto.set_editable(False)
                            self.AccentBuffer = "^"
                        else:
                            self.Tbuffer.insert_at_cursor("^")
                            self.texto.set_editable(False)
                #events for grave
                elif self.AccentBuffer == "`":
                    self.AccentBuffer = ""
                    if event.keyval == gtk.keysyms.a:
                        self.Tbuffer.insert_at_cursor(u'\xe0')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.A:
                        self.Tbuffer.insert_at_cursor(u'\xc0')
			self.texto.set_editable(False)
		    else:
                        if event.keyval == gtk.keysyms.Shift_L or event.keyval == gtk.keysyms.Shift_R:
                            self.texto.set_editable(False)
                            self.AccentBuffer = "`"
                        else:
                            self.Tbuffer.insert_at_cursor("`")
                            self.texto.set_editable(False)
                #events for diaeresis
                elif self.AccentBuffer == '"':
                    self.AccentBuffer = ""
                    if event.keyval == gtk.keysyms.u:
                        self.Tbuffer.insert_at_cursor(u'\xfc')
			self.texto.set_editable(False)
		    elif event.keyval == gtk.keysyms.U:
                        self.Tbuffer.insert_at_cursor(u'\xdc')
			self.texto.set_editable(False)
		    else:
                        if event.keyval == gtk.keysyms.Shift_L or event.keyval == gtk.keysyms.Shift_R:
                            self.texto.set_editable(False)
                            self.AccentBuffer = '"'
                        else:
                            self.Tbuffer.insert_at_cursor('"')
                            self.texto.set_editable(False)
		#maximize key
		if event.keyval == gtk.keysyms.F6:
			if self.window_in_fullscreen:
				self.window.unfullscreen()
			else:
				self.window.fullscreen()
        def on_window_state_change(self, widget, event, *args):
            if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN:
                self.window_in_fullscreen = True
            else:
                self.window_in_fullscreen = False
        def menuitem_response(self, string):
                if string == "file.open":
                    self.filedialog = gtk.FileSelection("File selection")
                    self.filedialog.ok_button.connect("clicked", self.file_ok_sel)
                    self.filedialog.cancel_button.connect("clicked",lambda w: self.filedialog.destroy())
                    self.filedialog.show()
                elif string == "file.quit":
                    gtk.main_quit()
                elif string == "file.save":
                    if not self.file_name:
                        self.filedialog = gtk.FileSelection("Save as")
                        self.filedialog.ok_button.connect("clicked", self.file_ok_save)
                        self.filedialog.cancel_button.connect("clicked",lambda w: self.filedialog.destroy())
                        self.filedialog.set_filename("*.*")
                        self.filedialog.show()
                    else:
                        stream = file(self.file_name, 'a')
                        first = self.Tbuffer.get_start_iter()
                        last = self.Tbuffer.get_end_iter()
                        texto = self.Tbuffer.get_text(first, last, True)
                        stream.writelines(texto)
                        stream.close()
        def file_ok_sel(self, widget):
            stream = file(self.filedialog.get_filename(), 'rw')
            self.file_name = self.filedialog.get_filename()
            texto = stream.readlines()
            self.Tbuffer.set_text("")
            for x in texto:
                self.Tbuffer.insert_at_cursor(x)
            self.filedialog.destroy()
            stream.close()
        def file_ok_save(self, widget):
            stream = file(self.filedialog.get_filename(), 'a')
            self.file_name = self.filedialog.get_filename()
            first = self.Tbuffer.get_start_iter()
            last = self.Tbuffer.get_end_iter()
            texto = self.Tbuffer.get_text(first, last, True)
            stream.writelines(texto)
            self.filedialog.destroy()
            stream.close()
	def run(self):
		self.window.show_all()
		gtk.main()
if __name__=="__main__":
	app = MyEditor()
	app.run()

--------------------------------------------
Desktop

[Desktop Entry]
Version=1.0.0
Encoding=UTF-8
Name=Editor
Exec=/usr/bin/editor
Type=Application
X-Osso-Type=application/x-executable


Essa mensagem ? destinada exclusivamente ao seu destinat?rio e pode conter informa??es confidenciais, protegidas por sigilo profissional ou cuja divulga??o seja proibida por lei. O uso n?o autorizado de tais informa??es ? proibido e est? sujeito ?s penalidades cab?veis.

This message is intended exclusively for its addressee and may contain information that is confidential and protected by a professional privilege or whose disclosure is prohibited by law. Unauthorized use of such information is prohibited and subject to applicable penalties.



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Big List of Linux Books]    

  Powered by Linux