Fix directory for setup tool

It is in /usr/libexec/ibus-setup-table on Fedora.
Use @PYTHON@ instead of just 'python' in ibus-setup-table.in

To get it replaced by the correct python interpreter when
doing something like:

PYTHON=python3 ./configure
Add profiling support

Write profiling information into the debug log when started with
“--profile”.

The profiling information appears automatically in the debug log after
“ibus restart” when profiling is enabled.
Port ibus-table from Python2 to Python3

I kept it working with Python2 for the moment, but in the long run
it is probably not worth the maintenance effort to keep it working
with Python2.

- I added stuff like

     if type(s) != type(u''):
         s = s.decode('UTF-8')

  for compatibility with Python2.

  http://docs.python.org/3/whatsnew/3.3.html says:

  > • The u'unicode' syntax is accepted again for str objects.

  So the above compatibility hack does not work for Python3 < 3.3.

- define our own compatibility function

    def ascii_ispunct(character):
        if character in '''!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~''':
            return True
        else:
            return False
  instead of using ascii.ispunct() from “from curses import ascii”
  to get the intended behaviour both in Python2 and Python3:

    $ python3
    Python 3.3.2 (default, Feb 19 2014, 14:35:19)
    [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from curses import ascii
    >>> ascii.ispunct('.')
    True
    >>> ascii.ispunct('a')
    False
    >>> ascii.ispunct('☺')
    True
    >>> ascii.ispunct(u'a')
    False
    >>> ascii.ispunct(u'☺')
    True
    >>> ascii.ispunct(u'あ')
    True
    >>>

    $ python2
    Python 2.7.5 (default, Feb 19 2014, 13:47:28)
    [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from curses import ascii
    >>> ascii.ispunct('.')
    True
    >>> ascii.ispunct('a')
    False
    >>> ascii.ispunct('☺')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib64/python2.7/curses/ascii.py", line 63, in ispunct
        def ispunct(c): return _ctoi(c) != 32 and not isalnum(c)
      File "/usr/lib64/python2.7/curses/ascii.py", line 50, in _ctoi
        return ord(c)
    TypeError: ord() expected a character, but string of length 3 found
    >>> ascii.ispunct(u'a')
    True
    >>> ascii.ispunct(u'☺')
    True
    >>> ascii.ispunct(u'あ')
    True
    >>> ascii.ispunct(u'a'.encode('ascii'))
    False
    >>>

Python3
use editor.commit_to_preedit() instead of deleted editor.l_shift ()

Resolves: rhbz#1072940 - Left Shift stopped work for ibus-table-1.5.0.20140218-1.fc20.noarch
See also: https://bugzilla.redhat.com/show_bug.cgi?id=1072940

Was broken by:

https://github.com/kaio/ibus-table/commit/fb11d92439fe4bd55fcad480d3998a17434f6870

commit fb11d92439fe4bd55fcad480d3998a17434f6870
Author: Caius "kaio" CHANCE <me@kaio.net>
Date:   Mon May 6 21:05:35 2013 +1000

    Issue #17:
    Removed excessive instance creation of IBusLookupTable in editor class.
    Removed
Don’t try to set _prev_char in commit_string() when an empty string is committed

Without this fix one can produce a backtrace by using “wubi-haifeng86”
and typing “dkl” followed by “Shift” and “Space”.

After “Shift” the preëdit is empty and “Space” commits and empty string
then. This leads to the following backtrace:

Traceback (most recent call last):
  File "/local/mfabian/src/ibus-table/engine/table.py", line 1589, in do_process_key_event
    result = self._process_key_event (key)
  File "/local/mfabian/src/ibus-table/engine/table.py", line 1611, in _process_key_event
    return self._table_mode_process_key_event (key)
  File "/local/mfabian/src/ibus-table/engine/table.py", line 1824, in _table_mode_process_key_event
    self.commit_string (sp_res[1])
  File "/local/mfabian/src/ibus-table/engine/table.py", line 1516, in commit_string
    self._prev_char = string[-1]
IndexError: string index out of range
Remove unused speedmeter code which has already been commented  out
Fix spelling mistake in variable name
Correct description of toggle_tab_py_mode() and cycle_next_cand()
Remove trailing whitespace and fix some spelling mistakes in comments
add autogenerated files version.py ibus-setup-table to setup/.gitignore
add autogenerated files table.xml and ibus-table-createdb.1 to .gitignore
Make it possible to interrupt the setup tool with Control-C from the command line
Add a .desktop file and make the setup tool work with Gnome

Previously, the setup tool could be called from the command
line, for example:

    /usr/libexec/ibus-setup-table cangjie3
    /usr/libexec/ibus-setup-table wubi-jidian86
    ...

But it could not be called from “gnome-control-center region”,
not setup icon did appear for the ibus-table engines.

To make this work, a desktop files

    /usr/share/applications/ibus-setup-{...}.desktop

need to be added where {...} is the engine name up to the first “:”
character. When the engine names are just the table names
(“cangjie3”, “wubi-jidian86”, ...), each table would need to
supply its own .desktop file

    /usr/share/applications/ibus-setup-cangjie3.desktop
    /usr/share/applications/ibus-setup-wubi-jidian86.desktop
    ...

That is not nice, especially as many tables are in different rpm packages.
It is better to have just a single .desktop file

    /usr/share/applications/ibus-setup-table.desktop

This can be used for all engines if the ibus engine names are changed like:

    cangjie3 → table:cangjie3
    wubi-jidian86 → table:wubi-jidian86
    ...

because only the part before the first “:” in the ibus engine name
is used by gnome to decide which desktop file to use.

The desktop file contains a line like:

    Exec=/usr/libexec/ibus-setup-table

and the setup tool is is called by Gnome without any command line
arguments. But Gnome sets the enviromnent variable IBUS_ENGINE_NAME
to the engine name when calling the setup tool.

So I changed the setup tool to work like this:

    IBUS_ENGINE_NAME=table:cangjie3 /usr/libexec/ibus-setup-table

or

    /usr/libexec/ibus-setup-table --engine-name table:cangjie

(The command line option is preferred over the environment variable
when both are given).
Fix regression introduced by the Python3 port

ascii.ispunct() from “from curses import ascii” can take
both characters  or integers as the argument.

My replacement ascii_ispunct() takes only a character.
Fix a spelling error in a variable name, a regression introduced by the Python3 port
Add generated .tar.gz to .gitignore
Merge pull request #29 from mike-fabian/fix-setup-tool-for-use-with-gnome

Fix setup tool for use with gnome