From 4a90063981c143badfc318f0bb479d67871ee072 Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Fri, 6 Mar 2009 02:07:54 +0000 Subject: [PATCH] - make pkgconfig noarch with ibus-table-pkgconfig-noarch.patch - fix license field: actually LGPL - drop gettext-devel BR - require ibus > 1.1.0 --- ibus-table-0.1.1.20081014-4a.rhbz466430.patch | 164 ------------------ ibus-table-0.1.1.20081014-4b.rhbz466844.patch | 20 --- ibus-table-pkgconfig-noarch.patch | 13 ++ ibus-table.spec | 28 +-- sources | 1 - 5 files changed, 28 insertions(+), 198 deletions(-) delete mode 100644 ibus-table-0.1.1.20081014-4a.rhbz466430.patch delete mode 100644 ibus-table-0.1.1.20081014-4b.rhbz466844.patch create mode 100644 ibus-table-pkgconfig-noarch.patch diff --git a/ibus-table-0.1.1.20081014-4a.rhbz466430.patch b/ibus-table-0.1.1.20081014-4a.rhbz466430.patch deleted file mode 100644 index 02dd8df..0000000 --- a/ibus-table-0.1.1.20081014-4a.rhbz466430.patch +++ /dev/null @@ -1,164 +0,0 @@ -diff -up ibus-table-0.1.1.20081014/engine/table.py.4a-bz466430 ibus-table-0.1.1.20081014/engine/table.py ---- ibus-table-0.1.1.20081014/engine/table.py.4a-bz466430 2008-10-16 10:59:17.000000000 +1000 -+++ ibus-table-0.1.1.20081014/engine/table.py 2009-02-04 09:15:13.000000000 +1000 -@@ -148,6 +148,9 @@ class editor: - self._chars[0].append (c) - except: - self._chars[1].append (c) -+ elif (not self._py_mode and ( c in u'*')): -+ self._tabkey_list += self._parser (c) -+ self._chars[0].append (c) - else: - self._chars[1].append (c) - self._t_chars.append(c) -@@ -432,7 +435,17 @@ class editor: - # here we need to consider two parts, table and pinyin - # first table - if not self._py_mode: -- self._candidates[0] = self.db.select_words( self._tabkey_list, self._onechar ) -+ if not u'*' in self._chars[0]: -+ self._candidates[0] = self.db.select_words(\ -+ self._tabkey_list, self._onechar) -+ else: -+ if not u'*' in self._chars[0][ len(self._chars[0]) - 1 ]: -+ self._candidates[0] = self.db.select_words_wildcard_closed(\ -+ self._tabkey_list, self._onechar) -+ else: -+ # for inputs of '*' as last key inputted, -+ # but this is not implemented -+ pass - else: - self._candidates[0] = self.db.select_zi( self._tabkey_list ) - self._chars[2] = self._chars[0][:] -@@ -1193,6 +1206,7 @@ class tabengine (ibus.EngineBase): - return False - - elif unichr(key.code) in self._valid_input_chars or \ -+ unichr(key.code) in u'*' or \ - ( self._editor._py_mode and \ - unichr(key.code) in u'abcdefghijklmnopqrstuvwxyz' ): - if self._direct_commit and len(self._editor._chars[0]) == self._ml: -@@ -1270,12 +1284,15 @@ class tabengine (ibus.EngineBase): - - # below for initial test - def focus_in (self): -+ self.reset () - self.register_properties (self.properties) - self._refresh_properties () - self._update_ui () - - def focus_out (self): -- pass -+ self._lookup_table.clean () -+ self._strings = [] -+ self._update_ui () - - def lookup_table_page_up (self): - if self._editor.page_up (): -diff -up ibus-table-0.1.1.20081014/engine/tabsqlitedb.py.4a-bz466430 ibus-table-0.1.1.20081014/engine/tabsqlitedb.py ---- ibus-table-0.1.1.20081014/engine/tabsqlitedb.py.4a-bz466430 2008-10-16 10:59:17.000000000 +1000 -+++ ibus-table-0.1.1.20081014/engine/tabsqlitedb.py 2009-02-04 09:16:46.000000000 +1000 -@@ -595,6 +595,103 @@ class tabsqlitedb: - _cand.sort(cmp=self.compare) - return _cand[:] - -+ def select_words_wildcard_closed( self, tabkeys, onechar=False, bitmask=0 ): -+ ''' -+ Get phrases from database by tab_key objects -+ ( which should be equal or less than the max key length) -+ This method is called in table.py by passing UserInput held data -+ Return result[:] -+ ''' -+ result = [] -+ selectlen = 2 -+ while selectlen <= 5: -+ # firstly, we make sure the len we used is equal or less than the max key length -+ _len = min( selectlen - 1,self._mlen ) -+ _condition = '' -+ _condition += ''.join ( 'AND mlen = ? ' ) -+ _condition += ''.join ( 'AND m0 = ? ' ) -+ _condition += ''.join ( 'AND m%d = ? ' % _len ) -+ if onechar: -+ # for some users really like to select only single characters -+ _condition += 'AND clen=1 ' -+ if bitmask: -+ # now just the bits for chinese -+ all_ints = xrange(1,5) -+ need_ints = filter (lambda x: x & bitmask, all_ints) -+ bit_condition = 'OR'.join( map(lambda x: ' category = %d ' %x,\ -+ need_ints) ) -+ _condition += 'AND (%s) ' % bit_condition -+ -+ # you can increase the x in _len + x to include more result, but in the most case, we only need one more key result, so we don't need the extra overhead :) -+ # we start search for 1 key more, if nothing, then 2 key more and so on -+ # this is the max len we need to add into the select cause. -+ w_len = self._mlen - _len +1 -+ # we start from 2, because it is < in the sqlite select, which need 1 more. -+ x_len = 2 -+ while x_len <= w_len + 1: -+ sqlstr = '''SELECT * FROM (SELECT * FROM main.phrases WHERE mlen < %(mk)d %(condition)s -+ UNION ALL -+ SELECT * FROM user_db.phrases WHERE mlen < %(mk)d %(condition)s -+ UNION ALL -+ SELECT * FROM mudb.phrases WHERE mlen < %(mk)d %(condition)s ) -+ ORDER BY mlen ASC, user_freq DESC, freq DESC;''' % { 'mk':_len+x_len, 'condition':_condition} -+ # we have redefine the __int__(self) in class tabdict.tab_key to return the key id, so we can use map to got key id :) -+ _tabkeys = [selectlen, int(tabkeys[0]), int(tabkeys[len(tabkeys) - 1])] -+ _tabkeys += _tabkeys + _tabkeys -+ result_tmp = self.db.execute(sqlstr, _tabkeys).fetchall() -+ #self.db.commit() -+ # if we find word, we stop this while, -+ if len(result) >0: -+ break -+ x_len += 1 -+ result += result_tmp -+ selectlen += 1 -+ # here in order to get high speed, I use complicated map -+ # to subtitute for -+ sysdb={} -+ usrdb={} -+ mudb={} -+ _cand = [] -+ #searchres = map ( lambda res: res[-2] and [ True, [(res[:-2],[res[:-1],res[-1:]])] ]\ -+ # or [ False, [(res[:-2] , [res[:-1],res[-1:]])] ] \ -+ # , result ) -+ searchres = map ( lambda res: [ int(res[-2]), int(res[-1]), [(res[:-2],[res[:-1],res[-1:]])] ], result) -+ # for sysdb -+ reslist=filter( lambda x: not x[1], searchres ) -+ map (lambda x: sysdb.update(x[2]), reslist) -+ # for usrdb -+ reslist=filter( lambda x: ( x[0] in [0,-1] ) and x[1], searchres ) -+ map (lambda x: usrdb.update(x[2]), reslist) -+ # for mudb -+ reslist=filter( lambda x: ( x[0] not in [0,-1] ) and x[1], searchres ) -+ map (lambda x: mudb.update(x[2]), reslist) -+ -+ # first process mudb -+ searchres = map ( lambda key: mudb[key][0] + mudb[key][1], mudb ) -+ #print searchres -+ map (_cand.append, searchres) -+ -+ # now process usrdb and sysdb -+ searchres = map ( lambda key: (not mudb.has_key(key)) and usrdb[key][0] + usrdb[key][1]\ -+ or None , usrdb ) -+ searchres = filter(lambda x: bool(x), searchres ) -+ #print searchres -+ map (_cand.append, searchres) -+ searchres = map ( lambda key: ((not mudb.has_key(key)) and (not usrdb.has_key(key)) )and sysdb[key][0] + sysdb[key][1]\ -+ or None, sysdb ) -+ searchres = filter (lambda x: bool(x), searchres) -+ map (_cand.append, searchres) -+ #for key in usrdb: -+ # if not sysdb.has_key (key): -+ # _cand.append( usrdb[key][0] + usrdb[key][1] ) -+ # else: -+ # _cand.append( sysdb[key][0] + usrdb[key][1] ) -+ #for key in sysdb: -+ # if not usrdb.has_key (key): -+ # _cand.append( sysdb[key][0] + sysdb[key][1] ) -+ _cand.sort(cmp=self.compare) -+ return _cand[:] -+ - def select_zi( self, tabkeys ): - ''' - Get zi from database by tab_key objects diff --git a/ibus-table-0.1.1.20081014-4b.rhbz466844.patch b/ibus-table-0.1.1.20081014-4b.rhbz466844.patch deleted file mode 100644 index 4902f5f..0000000 --- a/ibus-table-0.1.1.20081014-4b.rhbz466844.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff -up ibus-table-0.1.1.20081014/engine/table.py.1-rhbz466844 ibus-table-0.1.1.20081014/engine/table.py ---- ibus-table-0.1.1.20081014/engine/table.py.1-rhbz466844 2008-10-16 10:59:17.000000000 +1000 -+++ ibus-table-0.1.1.20081014/engine/table.py 2008-10-28 14:42:16.000000000 +1000 -@@ -1270,12 +1270,15 @@ class tabengine (ibus.EngineBase): - - # below for initial test - def focus_in (self): -+ self.reset () - self.register_properties (self.properties) - self._refresh_properties () - self._update_ui () - - def focus_out (self): -- pass -+ self._lookup_table.clean () -+ self._strings = [] -+ self._update_ui () - - def lookup_table_page_up (self): - if self._editor.page_up (): diff --git a/ibus-table-pkgconfig-noarch.patch b/ibus-table-pkgconfig-noarch.patch new file mode 100644 index 0000000..3893064 --- /dev/null +++ b/ibus-table-pkgconfig-noarch.patch @@ -0,0 +1,13 @@ +diff -u ibus-table-1.1.0.20090220/ibus-table.pc.in\~ ibus-table-1.1.0.20090220/ibus-table.pc.in +--- ibus-table-1.1.0.20090220/ibus-table.pc.in~ 2009-02-20 11:42:40.000000000 +1000 ++++ ibus-table-1.1.0.20090220/ibus-table.pc.in 2009-03-06 11:45:18.001898774 +1000 +@@ -1,6 +1,6 @@ + prefix=@prefix@ + exec_prefix=@exec_prefix@ +-libdir=@libdir@ ++libdir=@datadir@ + datarootdir=@datarootdir@ + datadir=@datadir@ + + +Diff finished. Fri Mar 6 11:46:24 2009 diff --git a/ibus-table.spec b/ibus-table.spec index 2d452ea..393f60e 100644 --- a/ibus-table.spec +++ b/ibus-table.spec @@ -1,19 +1,16 @@ Name: ibus-table Version: 1.1.0.20090220 -Release: 4%{?dist} +Release: 5%{?dist} Summary: The Table engine for IBus platform -License: GPLv2+ +License: LGPLv2+ Group: System Environment/Libraries URL: http://code.google.com/p/ibus/ Source0: http://ibus.googlecode.com/files/%{name}-%{version}.tar.gz - BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch - -BuildRequires: gettext-devel -BuildRequires: ibus-devel - -Requires: ibus +BuildRequires: ibus-devel > 1.1.0 +Requires: ibus > 1.1.0 +Patch1: ibus-table-pkgconfig-noarch.patch %description The package contains general Table engine for IBus platform. @@ -27,17 +24,16 @@ Requires: %{name} = %{version}-%{release} This package contains additional tables. %prep -%setup -b0 -q +%setup -q +%patch1 -p1 -b .orig %build -cd ../%{name}-%{version} %configure --disable-static --enable-additional - make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT -make DESTDIR=${RPM_BUILD_ROOT} NO_INDEX=true install +make DESTDIR=${RPM_BUILD_ROOT} NO_INDEX=true install pkgconfigdir=%{_datadir}/pkgconfig %find_lang %{name} @@ -57,7 +53,7 @@ ibus-table-createdb -i -n %{_datadir}/ibus-table/tables/latex.db %dir %{_datadir}/%{name}/icons %dir %{_datadir}/%{name}/data %{_datadir}/ibus/component/table.xml -%{_libdir}/pkgconfig/%{name}.pc +%{_datadir}/pkgconfig/%{name}.pc %{_libexecdir}/ibus-engine-table %{_bindir}/%{name}-createdb %{_datadir}/%{name}/tables/template.txt @@ -110,6 +106,12 @@ ibus-table-createdb -i -n %{_datadir}/ibus-table/tables/latex.db %{_datadir}/%{name}/icons/latex.svg %changelog +* Fri Mar 6 2009 Jens Petersen - 1.1.0.20090220-5 +- make pkgconfig noarch with ibus-table-pkgconfig-noarch.patch +- fix license field: actually LGPL +- drop gettext-devel BR +- require ibus > 1.1.0 + * Mon Mar 02 2009 Caius Chance - 1.1.0.20090220-4.fc11 - Rebuilt. diff --git a/sources b/sources index bb3a739..afe2036 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ -8c72c6ec97a0dcc822784e42ed6625c8 ibus-table-0.1.1.20081014.tar.gz 8949db247404207879183915e04cf602 ibus-table-1.1.0.20090220.tar.gz