clutter-imcontext-0.1.4/000077500000000000000000000000001123615432200152055ustar00rootroot00000000000000clutter-imcontext-0.1.4/AUTHORS000066400000000000000000000000271123615432200162540ustar00rootroot00000000000000raymond.liu@intel.com clutter-imcontext-0.1.4/COPYING000066400000000000000000000635011123615432200162450ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! clutter-imcontext-0.1.4/ChangeLog000066400000000000000000000001411123615432200167530ustar00rootroot000000000000002009-03-23 raymond liu v0.1 Project created by Linux Project Generator clutter-imcontext-0.1.4/INSTALL000066400000000000000000000002161123615432200162350ustar00rootroot00000000000000 Building: $ ./autogen.sh [--enable-gtk-doc] [--prefix=/usr] $ make Installing: $ sudo make install Running: $ clutter-imcontext clutter-imcontext-0.1.4/Makefile.am000066400000000000000000000002031123615432200172340ustar00rootroot00000000000000EXTRA_DIST = autogen.sh SUBDIRS = clutter-imcontext tools tests doc DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc CLEANFILES = *~ clutter-imcontext-0.1.4/NEWS000066400000000000000000000000001123615432200156720ustar00rootroot00000000000000clutter-imcontext-0.1.4/README000066400000000000000000000000001123615432200160530ustar00rootroot00000000000000clutter-imcontext-0.1.4/autogen.sh000077500000000000000000000002561123615432200172110ustar00rootroot00000000000000#!/bin/sh [ -e config.cache ] && rm -f config.cache libtoolize --automake gtkdocize --flavour no-tmpl || exit 1 aclocal autoconf autoheader automake -a ./configure $@ exit clutter-imcontext-0.1.4/clutter-imcontext/000077500000000000000000000000001123615432200206775ustar00rootroot00000000000000clutter-imcontext-0.1.4/clutter-imcontext/Makefile.am000066400000000000000000000052221123615432200227340ustar00rootroot00000000000000pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = clutter-imcontext-$(CLUTTER_IMCONTEXT_API_VERSION).pc clutter-imcontext-$(CLUTTER_IMCONTEXT_API_VERSION).pc: clutter-imcontext.pc $(QUIET_GEN)cp $< $@ pcfiles = clutter-imcontext-$(CLUTTER_IMCONTEXT_API_VERSION).pc \ clutter-imcontext.pc #library_include_HEADERS = clutter-imcontext.h #Tell library where data directory is (/usr/share/clutter-imcontext) AM_CFLAGS = -DPKGDATADIR="\"$(pkgdatadir)\"" INCLUDES = \ -DCLUTTER_IMCONTEXT_SYSCONFDIR=\"$(sysconfdir)\" \ -DCLUTTER_IMCONTEXT_LIBDIR=\"$(libdir)\" \ $(CLUTTER_CFLAGS) MARSHALFILES = clutter-imcontext-marshal.c clutter-imcontext-marshal.h STAMP_FILES = stamp-clutter-imcontext-marshal.h BUILT_SOURCES = \ $(MARSHALFILES) clutter-imcontext-marshal.h: stamp-clutter-imcontext-marshal.h @true stamp-clutter-imcontext-marshal.h: Makefile clutter-imcontext-marshal.list $(GLIB_GENMARSHAL) \ --prefix=clutter_imcontext_marshal \ --header \ $(srcdir)/clutter-imcontext-marshal.list > xgen-tmh && \ (cmp -s xgen-tmh clutter-imcontext-marshal.h || cp -f xgen-tmh clutter-imcontext-marshal.h) && \ rm -f xgen-tmh && \ echo timestamp > $(@F) clutter-imcontext-marshal.c: Makefile clutter-imcontext-marshal.list (echo "#include \"clutter-imcontext-marshal.h\"" ; \ $(GLIB_GENMARSHAL) \ --prefix=clutter_imcontext_marshal \ --body \ $(srcdir)/clutter-imcontext-marshal.list ) > xgen-tmc && \ cp -f xgen-tmc clutter-imcontext-marshal.c && \ rm -f xgen-tmc lib_LTLIBRARIES = libclutter-imcontext-@CLUTTER_IMCONTEXT_API_VERSION@.la clutter_imcontext_source_c = \ clutter-imcontext.c \ clutter-imcontext-marshal.c \ clutter-imcontext-private.c \ clutter-imcontextsimple.c \ clutter-immodule.c \ clutter-immulticontext.c \ clutter-imtext.c clutter_imcontext_source_h = \ clutter-imcontext.h \ clutter-imcontext-marshal.h \ clutter-imcontextsimple.h \ clutter-immodule.h \ clutter-immulticontext.h \ clutter-imtext.h clutter_imcontext_source_h_priv = \ clutter-imcontext-private.h clutterimcontext_includedir=$(includedir)/clutter-imcontext-$(CLUTTER_IMCONTEXT_API_VERSION)/clutter-imcontext clutterimcontext_include_DATA=$(clutter_imcontext_source_h) libclutter_imcontext_@CLUTTER_IMCONTEXT_API_VERSION@_la_SOURCES = \ $(clutter_imcontext_source_c) \ $(clutter_imcontext_source_h) \ $(clutter_imcontext_source_h_priv) libclutter_imcontext_@CLUTTER_IMCONTEXT_API_VERSION@_la_LIBADD = $(CLUTTER_LIBS) libclutter_imcontext_@CLUTTER_IMCONTEXT_API_VERSION@_la_LDFLAGS= -no-undefined DISTCLEANFILES = \ $(MARSHALFILES) CLEANFILES = *~ $(pcfiles) $(STAMP_FILES) $(BUILT_SOURCES) EXTRA_DIST = \ clutter-imcontext-marshal.list clutter-imcontext-0.1.4/clutter-imcontext/clutter-imcontext-marshal.list000066400000000000000000000000631123615432200267120ustar00rootroot00000000000000BOOLEAN:INT,INT BOOLEAN:VOID VOID:STRING VOID:VOID clutter-imcontext-0.1.4/clutter-imcontext/clutter-imcontext-private.c000066400000000000000000000025571123615432200262160ustar00rootroot00000000000000/* * clutter-imcontext-private.c * * Author: raymond liu * * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #include "clutter-imcontext-private.h" gboolean _clutter_boolean_handled_accumulator (GSignalInvocationHint *ihint, GValue *return_accu, const GValue *handler_return, gpointer dummy) { gboolean continue_emission; gboolean signal_handled; signal_handled = g_value_get_boolean (handler_return); g_value_set_boolean (return_accu, signal_handled); continue_emission = !signal_handled; return continue_emission; } clutter-imcontext-0.1.4/clutter-imcontext/clutter-imcontext-private.h000066400000000000000000000030251123615432200262120ustar00rootroot00000000000000/* * clutter-imcontext-private.h * * Author: raymond liu * * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #ifndef __CLUTTER_IMCONTEXT_PRIVATE_H__ #define __CLUTTER_IMCONTEXT_PRIVATE_H__ #include #include G_BEGIN_DECLS #define I_(str) (g_intern_static_string ((str))) #if (ENABLE_DEBUG) #define DBG(x, a...) g_fprintf (stderr, __FILE__ ",%d,%s: " x "\n", __LINE__, __func__, ##a) #else #define DBG(x, a...) do {} while (0) #endif #define STEP() DBG("") gboolean _clutter_boolean_handled_accumulator (GSignalInvocationHint *ihint, GValue *return_accu, const GValue *handler_return, gpointer dummy); G_END_DECLS #endif /* __CLUTTER_IMCONTEXT_PRIVATE_H__ */ clutter-imcontext-0.1.4/clutter-imcontext/clutter-imcontext.c000066400000000000000000000422661123615432200245470ustar00rootroot00000000000000/* * clutter-imcontext * clutter-imcontext is an imcontext framework modified base on GTK's imcontext. * * Author: raymond liu * * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ /** * SECTION:clutter-imcontext * @short_description: Base class for input method contexts * @include: clutter-imcontext/clutter-imcontext.h * @stability: Unstable * * #ClutterIMContext is a base class for input method contexts. */ #include "config.h" #include #include #include "clutter-imcontext.h" #include "clutter-imcontext-marshal.h" #include "clutter-imcontext-private.h" enum { PREEDIT_START, PREEDIT_END, PREEDIT_CHANGED, COMMIT, RETRIEVE_SURROUNDING, DELETE_SURROUNDING, LAST_SIGNAL }; static guint im_context_signals[LAST_SIGNAL] = { 0 }; static void clutter_im_context_real_get_preedit_string (ClutterIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos); static gboolean clutter_im_context_real_filter_keypress (ClutterIMContext *context, ClutterKeyEvent *event); static gboolean clutter_im_context_real_get_surrounding (ClutterIMContext *context, gchar **text, gint *cursor_index); static void clutter_im_context_real_set_surrounding (ClutterIMContext *context, const char *text, gint len, gint cursor_index); G_DEFINE_ABSTRACT_TYPE (ClutterIMContext, clutter_im_context, G_TYPE_OBJECT) static void clutter_im_context_class_init (ClutterIMContextClass *klass) { klass->get_preedit_string = clutter_im_context_real_get_preedit_string; klass->filter_keypress = clutter_im_context_real_filter_keypress; klass->get_surrounding = clutter_im_context_real_get_surrounding; klass->set_surrounding = clutter_im_context_real_set_surrounding; /** * ClutterIMContext::preedit-start * @context: The context object that receive this signal */ im_context_signals[PREEDIT_START] = g_signal_new (I_("preedit-start"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterIMContextClass, preedit_start), NULL, NULL, clutter_imcontext_marshal_VOID__VOID, G_TYPE_NONE, 0); /** * ClutterIMContext::preedit-end * @context: The context object that receive this signal */ im_context_signals[PREEDIT_END] = g_signal_new (I_("preedit-end"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterIMContextClass, preedit_end), NULL, NULL, clutter_imcontext_marshal_VOID__VOID, G_TYPE_NONE, 0); /** * ClutterIMContext::preedit-changed * @context: The context object that receive this signal */ im_context_signals[PREEDIT_CHANGED] = g_signal_new (I_("preedit-changed"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterIMContextClass, preedit_changed), NULL, NULL, clutter_imcontext_marshal_VOID__VOID, G_TYPE_NONE, 0); /** * ClutterIMContext::commit * @context: The context object that receive this signal * @str: The UTF_8 string been committed * * The ::commit signal is emitted when input method have some data to commit */ im_context_signals[COMMIT] = g_signal_new (I_("commit"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterIMContextClass, commit), NULL, NULL, clutter_imcontext_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); /** * ClutterIMContext::retrieve-surrounding * @context: The context object that receive this signal */ im_context_signals[RETRIEVE_SURROUNDING] = g_signal_new (I_("retrieve-surrounding"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterIMContextClass, retrieve_surrounding), _clutter_boolean_handled_accumulator, NULL, clutter_imcontext_marshal_BOOLEAN__VOID, G_TYPE_BOOLEAN, 0); /** * ClutterIMContext::delete-surrounding * @context: The context object that receive this signal * @offset: offset from cursor position in chars; * a negative value means start before the cursor. * @n_chars: number of characters to delete. */ im_context_signals[DELETE_SURROUNDING] = g_signal_new (I_("delete-surrounding"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterIMContextClass, delete_surrounding), _clutter_boolean_handled_accumulator, NULL, clutter_imcontext_marshal_BOOLEAN__INT_INT, G_TYPE_BOOLEAN, 2, G_TYPE_INT, G_TYPE_INT); } static void clutter_im_context_init (ClutterIMContext *im_context) { } static void clutter_im_context_real_get_preedit_string (ClutterIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos) { if (str) *str = g_strdup (""); if (attrs) *attrs = pango_attr_list_new (); if (cursor_pos) *cursor_pos = 0; } static gboolean clutter_im_context_real_filter_keypress (ClutterIMContext *context, ClutterKeyEvent *event) { return FALSE; } typedef struct { gchar *text; gint cursor_index; } SurroundingInfo; static void clutter_im_context_real_set_surrounding (ClutterIMContext *context, const gchar *text, gint len, gint cursor_index) { SurroundingInfo *info = g_object_get_data (G_OBJECT (context), "clutter-im-surrounding-info"); if (info) { g_free (info->text); info->text = g_strndup (text, len); info->cursor_index = cursor_index; } } static gboolean clutter_im_context_real_get_surrounding (ClutterIMContext *context, gchar **text, gint *cursor_index) { gboolean result; gboolean info_is_local = FALSE; SurroundingInfo local_info = { NULL, 0 }; SurroundingInfo *info; info = g_object_get_data (G_OBJECT (context), "clutter-im-surrounding-info"); if (!info) { info = &local_info; g_object_set_data (G_OBJECT (context), I_("clutter-im-surrounding-info"), info); info_is_local = TRUE; } g_signal_emit (context, im_context_signals[RETRIEVE_SURROUNDING], 0, &result); if (result) { *text = g_strdup (info->text ? info->text : ""); *cursor_index = info->cursor_index; } else { *text = NULL; *cursor_index = 0; } if (info_is_local) { g_free (info->text); g_object_set_data (G_OBJECT (context), I_("clutter-im-surrounding-info"), NULL); } return result; } /** * clutter_im_context_get_preedit_string: * @context: a #ClutterIMContext * @str: location to store the retrieved string. The * string retrieved must be freed with g_free (). * @attrs: location to store the retrieved attribute list. * When you are done with this list, you must * unreference it with pango_attr_list_unref(). * @cursor_pos: location to store position of cursor (in characters) * within the preedit string. * * Retrieve the current preedit string for the input context, * and a list of attributes to apply to the string. * This string should be displayed inserted at the insertion * point. **/ void clutter_im_context_get_preedit_string (ClutterIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos) { ClutterIMContextClass *klass; g_return_if_fail (CLUTTER_IS_IM_CONTEXT (context)); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); klass->get_preedit_string (context, str, attrs, cursor_pos); g_return_if_fail (str == NULL || g_utf8_validate (*str, -1, NULL)); } /** * clutter_im_context_filter_keypress: * @context: a #ClutterIMContext * @event: the key event * * Allow an input method to internally handle key press and release * events. If this function returns %TRUE, then no further processing * should be done for this key event. * * Return value: %TRUE if the input method handled the key event. * **/ gboolean clutter_im_context_filter_keypress (ClutterIMContext *context, ClutterKeyEvent *key) { ClutterIMContextClass *klass; STEP(); g_return_val_if_fail (CLUTTER_IS_IM_CONTEXT (context), FALSE); g_return_val_if_fail (key != NULL, FALSE); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); return klass->filter_keypress (context, key); } /** * clutter_im_context_focus_in: * @context: a #ClutterIMContext * * Notify the input method that the widget to which this * input context corresponds has gained focus. The input method * may, for example, change the displayed feedback to reflect * this change. **/ void clutter_im_context_focus_in (ClutterIMContext *context) { ClutterIMContextClass *klass; STEP(); g_return_if_fail (CLUTTER_IS_IM_CONTEXT (context)); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); if (klass->focus_in) klass->focus_in (context); } /** * clutter_im_context_focus_out: * @context: a #ClutterIMContext * * Notify the input method that the widget to which this * input context corresponds has lost focus. The input method * may, for example, change the displayed feedback or reset the contexts * state to reflect this change. **/ void clutter_im_context_focus_out (ClutterIMContext *context) { ClutterIMContextClass *klass; STEP(); g_return_if_fail (CLUTTER_IS_IM_CONTEXT (context)); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); if (klass->focus_out) klass->focus_out (context); } /** * clutter_im_context_show: * @context: a #ClutterIMContext * * Notify the input method that the IM UI need to be shown * **/ void clutter_im_context_show (ClutterIMContext *context) { ClutterIMContextClass *klass; STEP(); g_return_if_fail (CLUTTER_IS_IM_CONTEXT (context)); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); if (klass->show) klass->show (context); } /** * clutter_im_context_hide: * @context: a #ClutterIMContext * * Notify the input method that the IM UI need to be hidden * **/ void clutter_im_context_hide (ClutterIMContext *context) { ClutterIMContextClass *klass; STEP(); g_return_if_fail (CLUTTER_IS_IM_CONTEXT (context)); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); if (klass->hide) klass->hide (context); } /** * clutter_im_context_reset: * @context: a #ClutterIMContext * * Notify the input method that a change such as a change in cursor * position has been made. This will typically cause the input * method to clear the preedit state. **/ void clutter_im_context_reset (ClutterIMContext *context) { ClutterIMContextClass *klass; STEP(); g_return_if_fail (CLUTTER_IS_IM_CONTEXT (context)); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); if (klass->reset) klass->reset (context); } /** * clutter_im_context_set_cursor_location: * @context: a #ClutterIMContext * @area: new location * * Notify the input method that a change in cursor * position has been made. The location is relative to the client * window. **/ void clutter_im_context_set_cursor_location (ClutterIMContext *context, const ClutterIMRectangle *area) { ClutterIMContextClass *klass; STEP(); g_return_if_fail (CLUTTER_IS_IM_CONTEXT (context)); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); if (klass->set_cursor_location) klass->set_cursor_location (context, (ClutterIMRectangle *) area); } /** * clutter_im_context_set_use_preedit: * @context: a #ClutterIMContext * @use_preedit: whether the IM context should use the preedit string. * * Sets whether the IM context should use the preedit string * to display feedback. If @use_preedit is FALSE (default * is TRUE), then the IM context may use some other method to display * feedback, such as displaying it in a child of the root window. **/ void clutter_im_context_set_use_preedit (ClutterIMContext *context, gboolean use_preedit) { ClutterIMContextClass *klass; STEP(); g_return_if_fail (CLUTTER_IS_IM_CONTEXT (context)); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); if (klass->set_use_preedit) klass->set_use_preedit (context, use_preedit); } /** * clutter_im_context_set_surrounding: * @context: a #ClutterIMContext * @text: text surrounding the insertion point, as UTF-8. * the preedit string should not be included within * @text. * @len: the length of @text, or -1 if @text is nul-terminated * @cursor_index: the byte index of the insertion cursor within @text. * * Sets surrounding context around the insertion point and preedit * string. This function is expected to be called in response to the * ClutterIMContext::retrieve_surrounding signal, and will likely have no * effect if called at other times. **/ void clutter_im_context_set_surrounding (ClutterIMContext *context, const gchar *text, gint len, gint cursor_index) { ClutterIMContextClass *klass; g_return_if_fail (CLUTTER_IS_IM_CONTEXT (context)); g_return_if_fail (text != NULL || len == 0); if (text == NULL && len == 0) text = ""; if (len < 0) len = strlen (text); g_return_if_fail (cursor_index >= 0 && cursor_index <= len); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); if (klass->set_surrounding) klass->set_surrounding (context, text, len, cursor_index); } /** * clutter_im_context_get_surrounding: * @context: a #ClutterIMContext * @text: location to store a UTF-8 encoded string of text * holding context around the insertion point. * If the function returns %TRUE, then you must free * the result stored in this location with g_free(). * @cursor_index: location to store byte index of the insertion cursor * within @text. * * Retrieves context around the insertion point. Input methods * typically want context in order to constrain input text based on * existing text; this is important for languages such as Thai where * only some sequences of characters are allowed. * * This function is implemented by emitting the * ClutterIMContext::retrieve_surrounding signal on the input method; in * response to this signal, a widget should provide as much context as * is available, up to an entire paragraph, by calling * clutter_im_context_set_surrounding(). Note that there is no obligation * for a widget to respond to the ::retrieve_surrounding signal, so input * methods must be prepared to function without context. * * Return value: %TRUE if surrounding text was provided; in this case * you must free the result stored in *text. **/ gboolean clutter_im_context_get_surrounding (ClutterIMContext *context, gchar **text, gint *cursor_index) { ClutterIMContextClass *klass; gchar *local_text = NULL; gint local_index; gboolean result = FALSE; g_return_val_if_fail (CLUTTER_IS_IM_CONTEXT (context), FALSE); klass = CLUTTER_IM_CONTEXT_GET_CLASS (context); if (klass->get_surrounding) result = klass->get_surrounding (context, text ? text : &local_text, cursor_index ? cursor_index : &local_index); if (result) g_free (local_text); return result; } /** * clutter_im_context_delete_surrounding: * @context: a #ClutterIMContext * @offset: offset from cursor position in chars; * a negative value means start before the cursor. * @n_chars: number of characters to delete. * * Asks the widget that the input context is attached to to delete * characters around the cursor position by emitting the * ClutterIMContext::delete_surrounding signal. Note that @offset and @n_chars * are in characters not in bytes which differs from the usage other * places in #ClutterIMContext. * * In order to use this function, you should first call * clutter_im_context_get_surrounding() to get the current context, and * call this function immediately afterwards to make sure that you * know what you are deleting. You should also account for the fact * that even if the signal was handled, the input context might not * have deleted all the characters that were requested to be deleted. * * This function is used by an input method that wants to make * subsitutions in the existing text in response to new input. It is * not useful for applications. * * Return value: %TRUE if the signal was handled. **/ gboolean clutter_im_context_delete_surrounding (ClutterIMContext *context, gint offset, gint n_chars) { gboolean result; g_return_val_if_fail (CLUTTER_IS_IM_CONTEXT (context), FALSE); g_signal_emit (context, im_context_signals[DELETE_SURROUNDING], 0, offset, n_chars, &result); return result; } clutter-imcontext-0.1.4/clutter-imcontext/clutter-imcontext.h000066400000000000000000000127501123615432200245470ustar00rootroot00000000000000/* * clutter-imcontext * clutter-imcontext is an imcontext framework modified base on GTK's imcontext. * * Author: raymond liu * * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #ifndef __CLUTTER_IM_CONTEXT_H__ #define __CLUTTER_IM_CONTEXT_H__ #include #include G_BEGIN_DECLS typedef struct _ClutterIMRectangle ClutterIMRectangle; struct _ClutterIMRectangle { gint x; gint y; gint width; gint height; }; #define CLUTTER_TYPE_IM_CONTEXT (clutter_im_context_get_type ()) #define CLUTTER_IM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_IM_CONTEXT, ClutterIMContext)) #define CLUTTER_IM_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_IM_CONTEXT, ClutterIMContextClass)) #define CLUTTER_IS_IM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_IM_CONTEXT)) #define CLUTTER_IS_IM_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_IM_CONTEXT)) #define CLUTTER_IM_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_IM_CONTEXT, ClutterIMContextClass)) typedef struct _ClutterIMContext ClutterIMContext; typedef struct _ClutterIMContextClass ClutterIMContextClass; struct _ClutterIMContext { GObject parent_instance; ClutterActor *actor; }; struct _ClutterIMContextClass { GObjectClass parent_class; /* Signals */ void (*preedit_start) (ClutterIMContext *context); void (*preedit_end) (ClutterIMContext *context); void (*preedit_changed) (ClutterIMContext *context); void (*commit) (ClutterIMContext *context, const gchar *str); gboolean (*retrieve_surrounding) (ClutterIMContext *context); gboolean (*delete_surrounding) (ClutterIMContext *context, gint offset, gint n_chars); /* Virtual functions */ void (*get_preedit_string) (ClutterIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos); gboolean (*filter_keypress) (ClutterIMContext *context, ClutterKeyEvent *event); void (*focus_in) (ClutterIMContext *context); void (*focus_out) (ClutterIMContext *context); void (*show) (ClutterIMContext *context); void (*hide) (ClutterIMContext *context); void (*reset) (ClutterIMContext *context); void (*set_cursor_location) (ClutterIMContext *context, ClutterIMRectangle *area); void (*set_use_preedit) (ClutterIMContext *context, gboolean use_preedit); void (*set_surrounding) (ClutterIMContext *context, const gchar *text, gint len, gint cursor_index); gboolean (*get_surrounding) (ClutterIMContext *context, gchar **text, gint *cursor_index); /* Padding for future expansion */ void (*_clutter_reserved1) (void); void (*_clutter_reserved2) (void); void (*_clutter_reserved3) (void); void (*_clutter_reserved4) (void); void (*_clutter_reserved5) (void); void (*_clutter_reserved6) (void); }; GType clutter_im_context_get_type (void) G_GNUC_CONST; void clutter_im_context_get_preedit_string (ClutterIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos); gboolean clutter_im_context_filter_keypress (ClutterIMContext *context, ClutterKeyEvent *event); void clutter_im_context_focus_in (ClutterIMContext *context); void clutter_im_context_focus_out (ClutterIMContext *context); void clutter_im_context_show (ClutterIMContext *context); void clutter_im_context_hide (ClutterIMContext *context); void clutter_im_context_reset (ClutterIMContext *context); void clutter_im_context_set_cursor_location (ClutterIMContext *context, const ClutterIMRectangle *area); void clutter_im_context_set_use_preedit (ClutterIMContext *context, gboolean use_preedit); void clutter_im_context_set_surrounding (ClutterIMContext *context, const gchar *text, gint len, gint cursor_index); gboolean clutter_im_context_get_surrounding (ClutterIMContext *context, gchar **text, gint *cursor_index); gboolean clutter_im_context_delete_surrounding (ClutterIMContext *context, gint offset, gint n_chars); G_END_DECLS #endif /* __CLUTTER_IM_CONTEXT_H__ */ clutter-imcontext-0.1.4/clutter-imcontext/clutter-imcontext.pc.in000066400000000000000000000006151123615432200253240ustar00rootroot00000000000000 prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ apiversion=@CLUTTER_IMCONTEXT_API_VERSION@ datarootdir=@datarootdir@ localedir=@localedir@ Name: Clutter Input Method Context Description: IMContext For Clutter Requires: clutter-1.0 Version: @VERSION@ Libs: -L${libdir} -lclutter-imcontext-${apiversion} Cflags: -I${includedir}/clutter-imcontext-${apiversion} clutter-imcontext-0.1.4/clutter-imcontext/clutter-imcontextsimple.c000066400000000000000000000070761123615432200257610ustar00rootroot00000000000000/* * clutter-imcontext * clutter-imcontext is an imcontext framework modified base on GTK's imcontext. * * Author: raymond liu * * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ /** * SECTION:clutter-imcontextsimple * @short_description: simple fallback imcontext * @stability: Unstable */ #include "config.h" #include #include #include "clutter-imcontextsimple.h" static void clutter_im_context_simple_finalize (GObject *obj); static gboolean clutter_im_context_simple_filter_keypress (ClutterIMContext *context, ClutterKeyEvent *key); static void clutter_im_context_simple_reset (ClutterIMContext *context); static void clutter_im_context_simple_get_preedit_string (ClutterIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos); G_DEFINE_TYPE (ClutterIMContextSimple, clutter_im_context_simple, CLUTTER_TYPE_IM_CONTEXT) static void clutter_im_context_simple_class_init (ClutterIMContextSimpleClass *class) { ClutterIMContextClass *im_context_class = CLUTTER_IM_CONTEXT_CLASS (class); GObjectClass *gobject_class = G_OBJECT_CLASS (class); im_context_class->filter_keypress = clutter_im_context_simple_filter_keypress; im_context_class->reset = clutter_im_context_simple_reset; im_context_class->get_preedit_string = clutter_im_context_simple_get_preedit_string; gobject_class->finalize = clutter_im_context_simple_finalize; } static void clutter_im_context_simple_init (ClutterIMContextSimple *im_context_simple) { } static void clutter_im_context_simple_finalize (GObject *obj) { G_OBJECT_CLASS (clutter_im_context_simple_parent_class)->finalize (obj); } /** * clutter_im_context_simple_new: * * Creates a new #ClutterIMContextSimple. * * Returns: a new #ClutterIMContextSimple. **/ ClutterIMContext * clutter_im_context_simple_new (void) { return g_object_new (CLUTTER_TYPE_IM_CONTEXT_SIMPLE, NULL); } static gboolean clutter_im_context_simple_filter_keypress (ClutterIMContext *context, ClutterKeyEvent *event) { return FALSE; } static void clutter_im_context_simple_reset (ClutterIMContext *context) { } static void clutter_im_context_simple_get_preedit_string (ClutterIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos) { char outbuf[37]; /* up to 6 hex digits */ int len = 0; outbuf[len] = '\0'; if (str) *str = g_strdup (outbuf); if (attrs) { *attrs = pango_attr_list_new (); if (len) { PangoAttribute *attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE); attr->start_index = 0; attr->end_index = len; pango_attr_list_insert (*attrs, attr); } } if (cursor_pos) *cursor_pos = len; } clutter-imcontext-0.1.4/clutter-imcontext/clutter-imcontextsimple.h000066400000000000000000000044061123615432200257600ustar00rootroot00000000000000/* * clutter-imcontext * clutter-imcontext is an imcontext framework modified base on GTK's imcontext. * * Author: raymond liu * * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #ifndef __CLUTTER_IM_CONTEXT_SIMPLE_H__ #define __CLUTTER_IM_CONTEXT_SIMPLE_H__ #include "clutter-imcontext.h" G_BEGIN_DECLS #define CLUTTER_TYPE_IM_CONTEXT_SIMPLE (clutter_im_context_simple_get_type ()) #define CLUTTER_IM_CONTEXT_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_IM_CONTEXT_SIMPLE, ClutterIMContextSimple)) #define CLUTTER_IM_CONTEXT_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_IM_CONTEXT_SIMPLE, ClutterIMContextSimpleClass)) #define CLUTTER_IS_IM_CONTEXT_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_IM_CONTEXT_SIMPLE)) #define CLUTTER_IS_IM_CONTEXT_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_IM_CONTEXT_SIMPLE)) #define CLUTTER_IM_CONTEXT_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_IM_CONTEXT_SIMPLE, ClutterIMContextSimpleClass)) typedef struct _ClutterIMContextSimple ClutterIMContextSimple; typedef struct _ClutterIMContextSimpleClass ClutterIMContextSimpleClass; struct _ClutterIMContextSimple { ClutterIMContext object; }; struct _ClutterIMContextSimpleClass { ClutterIMContextClass parent_class; }; GType clutter_im_context_simple_get_type (void) G_GNUC_CONST; ClutterIMContext *clutter_im_context_simple_new (void); G_END_DECLS #endif /* __CLUTTER_IM_CONTEXT_SIMPLE_H__ */ clutter-imcontext-0.1.4/clutter-imcontext/clutter-immodule.c000066400000000000000000000276021123615432200243450ustar00rootroot00000000000000/* * clutter-imcontext * clutter-imcontext is an imcontext framework modified base on GTK's imcontext. * * Author: raymond liu * * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #include "config.h" #include #include #include #include #include #include #include "clutter-immodule.h" #include "clutter-imcontextsimple.h" #define SIMPLE_ID "clutter-im-context-simple" typedef struct _ClutterIMModule ClutterIMModule; typedef struct _ClutterIMModuleClass ClutterIMModuleClass; #define CLUTTER_TYPE_IM_MODULE (clutter_im_module_get_type ()) #define CLUTTER_IM_MODULE(im_module) (G_TYPE_CHECK_INSTANCE_CAST ((im_module), CLUTTER_TYPE_IM_MODULE, ClutterIMModule)) #define CLUTTER_IS_IM_MODULE(im_module) (G_TYPE_CHECK_INSTANCE_TYPE ((im_module), CLUTTER_TYPE_IM_MODULE)) struct _ClutterIMModule { GTypeModule parent_instance; gboolean builtin; GModule *library; void (*list) (const ClutterIMContextInfo ***contexts, guint *n_contexts); void (*init) (GTypeModule *module); void (*exit) (void); ClutterIMContext *(*create) (const gchar *context_id); ClutterIMContextInfo **contexts; guint n_contexts; gchar *path; }; struct _ClutterIMModuleClass { GTypeModuleClass parent_class; }; static GType clutter_im_module_get_type (void); static gint n_loaded_contexts = 0; static GHashTable *contexts_hash = NULL; static GSList *modules_list = NULL; static GObjectClass *parent_class = NULL; static gchar *im_module_file = NULL; static gchar * clutter_get_im_module_file (void) { const gchar *var = g_getenv ("CLUTTER_IM_MODULE_FILE"); gchar *result = NULL; if (var) result = g_strdup (var); if (!result) { if (im_module_file) result = g_strdup (im_module_file); else result = g_build_filename (CLUTTER_IMCONTEXT_SYSCONFDIR, "clutter-imcontext", "clutter.immodules", NULL); } return result; } static gboolean clutter_im_module_load (GTypeModule *module) { ClutterIMModule *im_module = CLUTTER_IM_MODULE (module); if (!im_module->builtin) { im_module->library = g_module_open (im_module->path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); if (!im_module->library) { g_warning ("%s", g_module_error()); return FALSE; } /* extract symbols from the lib */ if (!g_module_symbol (im_module->library, "im_module_init", (gpointer *)&im_module->init) || !g_module_symbol (im_module->library, "im_module_exit", (gpointer *)&im_module->exit) || !g_module_symbol (im_module->library, "im_module_list", (gpointer *)&im_module->list) || !g_module_symbol (im_module->library, "im_module_create", (gpointer *)&im_module->create)) { g_warning ("%s", g_module_error()); g_module_close (im_module->library); return FALSE; } } /* call the module's init function to let it */ /* setup anything it needs to set up. */ im_module->init (module); return TRUE; } static void clutter_im_module_unload (GTypeModule *module) { ClutterIMModule *im_module = CLUTTER_IM_MODULE (module); im_module->exit(); if (!im_module->builtin) { g_module_close (im_module->library); im_module->library = NULL; im_module->init = NULL; im_module->exit = NULL; im_module->list = NULL; im_module->create = NULL; } } /* This only will ever be called if an error occurs during * initialization */ static void clutter_im_module_finalize (GObject *object) { ClutterIMModule *module = CLUTTER_IM_MODULE (object); g_free (module->path); parent_class->finalize (object); } G_DEFINE_TYPE (ClutterIMModule, clutter_im_module, G_TYPE_TYPE_MODULE) static void clutter_im_module_class_init (ClutterIMModuleClass *class) { GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class); GObjectClass *gobject_class = G_OBJECT_CLASS (class); parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (class)); module_class->load = clutter_im_module_load; module_class->unload = clutter_im_module_unload; gobject_class->finalize = clutter_im_module_finalize; } static void clutter_im_module_init (ClutterIMModule* object) { } static void free_info (ClutterIMContextInfo *info) { g_free ((char *)info->context_id); g_free ((char *)info->context_name); g_free ((char *)info->domain); g_free ((char *)info->domain_dirname); g_free ((char *)info->default_locales); g_free (info); } static void add_module (ClutterIMModule *module, GSList *infos) { GSList *tmp_list = infos; gint i = 0; gint n = g_slist_length (infos); module->contexts = g_new (ClutterIMContextInfo *, n); while (tmp_list) { ClutterIMContextInfo *info = tmp_list->data; if (g_hash_table_lookup (contexts_hash, info->context_id)) { free_info (info); /* Duplicate */ } else { g_hash_table_insert (contexts_hash, (char *)info->context_id, module); module->contexts[i++] = tmp_list->data; n_loaded_contexts++; } tmp_list = tmp_list->next; } g_slist_free (infos); module->n_contexts = i; modules_list = g_slist_prepend (modules_list, module); } static void clutter_im_module_initialize (void) { GString *line_buf = g_string_new (NULL); GString *tmp_buf = g_string_new (NULL); gchar *filename = clutter_get_im_module_file(); FILE *file; gboolean have_error = FALSE; ClutterIMModule *module = NULL; GSList *infos = NULL; contexts_hash = g_hash_table_new (g_str_hash, g_str_equal); file = g_fopen (filename, "r"); if (!file) { /* In case someone wants only the default input method, * we allow no file at all. */ g_string_free (line_buf, TRUE); g_string_free (tmp_buf, TRUE); g_free (filename); return; } while (!have_error && pango_read_line (file, line_buf)) { const char *p; p = line_buf->str; if (!pango_skip_space (&p)) { /* Blank line marking the end of a module */ if (module && *p != '#') { add_module (module, infos); module = NULL; infos = NULL; } continue; } if (!module) { /* Read a module location */ module = g_object_new (CLUTTER_TYPE_IM_MODULE, NULL); if (!pango_scan_string (&p, tmp_buf) || pango_skip_space (&p)) { g_warning ("Error parsing context info in '%s'\n %s", filename, line_buf->str); have_error = TRUE; } module->path = g_strdup (tmp_buf->str); g_type_module_set_name (G_TYPE_MODULE (module), module->path); } else { ClutterIMContextInfo *info = g_new0 (ClutterIMContextInfo, 1); /* Read information about a context type */ if (!pango_scan_string (&p, tmp_buf)) goto context_error; info->context_id = g_strdup (tmp_buf->str); if (!pango_scan_string (&p, tmp_buf)) goto context_error; info->context_name = g_strdup (tmp_buf->str); if (!pango_scan_string (&p, tmp_buf)) goto context_error; info->domain = g_strdup (tmp_buf->str); if (!pango_scan_string (&p, tmp_buf)) goto context_error; info->domain_dirname = g_strdup (tmp_buf->str); if (!pango_scan_string (&p, tmp_buf)) goto context_error; info->default_locales = g_strdup (tmp_buf->str); if (pango_skip_space (&p)) goto context_error; infos = g_slist_prepend (infos, info); continue; context_error: g_warning ("Error parsing context info in '%s'\n %s", filename, line_buf->str); have_error = TRUE; } } if (have_error) { GSList *tmp_list = infos; while (tmp_list) { free_info (tmp_list->data); tmp_list = tmp_list->next; } g_slist_free (infos); g_object_unref (module); } else if (module) add_module (module, infos); fclose (file); g_string_free (line_buf, TRUE); g_string_free (tmp_buf, TRUE); g_free (filename); } static gint compare_clutterimcontextinfo_name(const ClutterIMContextInfo **a, const ClutterIMContextInfo **b) { return g_utf8_collate ((*a)->context_name, (*b)->context_name); } /** * _clutter_im_module_list: * @contexts: location to store an array of pointers to #ClutterIMContextInfo * this array should be freed with g_free() when you are finished. * The structures it points are statically allocated and should * not be modified or freed. * @n_contexts: the length of the array stored in @contexts * * List all available types of input method context **/ void _clutter_im_module_list (const ClutterIMContextInfo ***contexts, guint *n_contexts) { int n = 0; static ClutterIMContextInfo simple_context_info = { SIMPLE_ID, "Simple", "", "", "" }; if (!contexts_hash) clutter_im_module_initialize (); if (n_contexts) *n_contexts = (n_loaded_contexts + 1); if (contexts) { GSList *tmp_list; int i; *contexts = g_new (const ClutterIMContextInfo *, n_loaded_contexts + 1); (*contexts)[n++] = &simple_context_info; tmp_list = modules_list; while (tmp_list) { ClutterIMModule *module = tmp_list->data; for (i=0; in_contexts; i++) (*contexts)[n++] = module->contexts[i]; tmp_list = tmp_list->next; } /* fisrt element (Default) should always be at top */ qsort ((*contexts)+1, n-1, sizeof (ClutterIMContextInfo *), (GCompareFunc)compare_clutterimcontextinfo_name); } } /** * _clutter_im_module_create: * @context_id: the context ID for the context type to create * * Create an IM context of a type specified by the string * ID @context_id. * * Return value: a newly created input context of or @context_id, or * if that could not be created, a newly created ClutterIMContextSimple. **/ ClutterIMContext * _clutter_im_module_create (const gchar *context_id) { ClutterIMModule *im_module; ClutterIMContext *context = NULL; if (!contexts_hash) clutter_im_module_initialize (); if (strcmp (context_id, SIMPLE_ID) != 0) { im_module = g_hash_table_lookup (contexts_hash, context_id); if (!im_module) { g_warning ("Attempt to load unknown IM context type '%s'", context_id); } else { if (g_type_module_use (G_TYPE_MODULE (im_module))) { context = im_module->create (context_id); g_type_module_unuse (G_TYPE_MODULE (im_module)); } if (!context) g_warning ("Loading IM context type '%s' failed", context_id); } } if (!context) return clutter_im_context_simple_new (); else return context; } /** * _clutter_im_module_get_default_context_id: * * Return value: the context ID (will never be %NULL) **/ const gchar * _clutter_im_module_get_default_context_id () { const gchar *context_id = NULL; const gchar *envvar; if (!contexts_hash) clutter_im_module_initialize (); envvar = g_getenv ("CLUTTER_IM_MODULE"); if (envvar && (strcmp (envvar, SIMPLE_ID) == 0 || g_hash_table_lookup (contexts_hash, envvar))) return envvar; return context_id ? context_id : SIMPLE_ID; } gchar * get_im_module_path (void) { gchar *module_path = NULL; module_path = g_build_filename (CLUTTER_IMCONTEXT_LIBDIR, "clutter-imcontext", "immodules", NULL); return module_path; } clutter-imcontext-0.1.4/clutter-imcontext/clutter-immodule.h000066400000000000000000000037741123615432200243560ustar00rootroot00000000000000/* * clutter-imcontext * clutter-imcontext is an imcontext framework modified base on GTK's imcontext. * * Author: raymond liu * * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #ifndef __CLUTTER_IM_MODULE_H__ #define __CLUTTER_IM_MODULE_H__ #include "clutter-imcontext.h" G_BEGIN_DECLS typedef struct _ClutterIMContextInfo ClutterIMContextInfo; struct _ClutterIMContextInfo { const gchar *context_id; const gchar *context_name; const gchar *domain; const gchar *domain_dirname; const gchar *default_locales; }; void _clutter_im_module_list (const ClutterIMContextInfo ***contexts, guint *n_contexts); ClutterIMContext * _clutter_im_module_create (const gchar *context_id); const gchar * _clutter_im_module_get_default_context_id (void); /* The following entry points are exported by each input method module */ /* void im_module_list (const ClutterIMContextInfo ***contexts, guint *n_contexts); void im_module_init (GTypeModule *module); void im_module_exit (void); ClutterIMContext *im_module_create (const gchar *context_id); */ gchar * get_im_module_path (void); G_END_DECLS #endif /* __CLUTTER_IM_MODULE_H__ */ clutter-imcontext-0.1.4/clutter-imcontext/clutter-immulticontext.c000066400000000000000000000374411123615432200256210ustar00rootroot00000000000000/* * clutter-imcontext * clutter-imcontext is an imcontext framework modified base on GTK's imcontext. * * Author: raymond liu * * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ /** * SECTION:clutter-immulticontext * @short_description: An input method context supporting multiple, loadable input methods * @stability: Unstable * * #ClutterIMMultiContext is an wrap input method context for supporting loadable input methods. */ #include "config.h" #include #include #include "clutter-immulticontext.h" #include "clutter-immodule.h" struct _ClutterIMMulticontextPrivate { ClutterIMRectangle cursor_location; guint use_preedit : 1; guint have_cursor_location : 1; guint focus_in : 1; }; static void clutter_im_multicontext_finalize (GObject *object); static void clutter_im_multicontext_set_slave (ClutterIMMulticontext *multicontext, ClutterIMContext *slave, gboolean finalizing); static void clutter_im_multicontext_get_preedit_string (ClutterIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos); static gboolean clutter_im_multicontext_filter_keypress (ClutterIMContext *context, ClutterKeyEvent *event); static void clutter_im_multicontext_focus_in (ClutterIMContext *context); static void clutter_im_multicontext_focus_out (ClutterIMContext *context); static void clutter_im_multicontext_show (ClutterIMContext *context); static void clutter_im_multicontext_hide (ClutterIMContext *context); static void clutter_im_multicontext_reset (ClutterIMContext *context); static void clutter_im_multicontext_set_cursor_location (ClutterIMContext *context, ClutterIMRectangle *area); static void clutter_im_multicontext_set_use_preedit (ClutterIMContext *context, gboolean use_preedit); static gboolean clutter_im_multicontext_get_surrounding (ClutterIMContext *context, gchar **text, gint *cursor_index); static void clutter_im_multicontext_set_surrounding (ClutterIMContext *context, const char *text, gint len, gint cursor_index); static void clutter_im_multicontext_preedit_start_cb (ClutterIMContext *slave, ClutterIMMulticontext *multicontext); static void clutter_im_multicontext_preedit_end_cb (ClutterIMContext *slave, ClutterIMMulticontext *multicontext); static void clutter_im_multicontext_preedit_changed_cb (ClutterIMContext *slave, ClutterIMMulticontext *multicontext); static void clutter_im_multicontext_commit_cb (ClutterIMContext *slave, const gchar *str, ClutterIMMulticontext *multicontext); static gboolean clutter_im_multicontext_retrieve_surrounding_cb (ClutterIMContext *slave, ClutterIMMulticontext *multicontext); static gboolean clutter_im_multicontext_delete_surrounding_cb (ClutterIMContext *slave, gint offset, gint n_chars, ClutterIMMulticontext *multicontext); static const gchar *user_context_id = NULL; static const gchar *global_context_id = NULL; G_DEFINE_TYPE (ClutterIMMulticontext, clutter_im_multicontext, CLUTTER_TYPE_IM_CONTEXT) static void clutter_im_multicontext_class_init (ClutterIMMulticontextClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); ClutterIMContextClass *im_context_class = CLUTTER_IM_CONTEXT_CLASS (class); im_context_class->get_preedit_string = clutter_im_multicontext_get_preedit_string; im_context_class->filter_keypress = clutter_im_multicontext_filter_keypress; im_context_class->focus_in = clutter_im_multicontext_focus_in; im_context_class->focus_out = clutter_im_multicontext_focus_out; im_context_class->show = clutter_im_multicontext_show; im_context_class->hide = clutter_im_multicontext_hide; im_context_class->reset = clutter_im_multicontext_reset; im_context_class->set_cursor_location = clutter_im_multicontext_set_cursor_location; im_context_class->set_use_preedit = clutter_im_multicontext_set_use_preedit; im_context_class->set_surrounding = clutter_im_multicontext_set_surrounding; im_context_class->get_surrounding = clutter_im_multicontext_get_surrounding; gobject_class->finalize = clutter_im_multicontext_finalize; g_type_class_add_private (gobject_class, sizeof (ClutterIMMulticontextPrivate)); } static void clutter_im_multicontext_init (ClutterIMMulticontext *multicontext) { multicontext->slave = NULL; multicontext->priv = G_TYPE_INSTANCE_GET_PRIVATE (multicontext, CLUTTER_TYPE_IM_MULTICONTEXT, ClutterIMMulticontextPrivate); multicontext->priv->use_preedit = FALSE; multicontext->priv->have_cursor_location = FALSE; multicontext->priv->focus_in = FALSE; } /** * clutter_im_multicontext_new: * * Creates a new #ClutterIMMulticontext. * * Returns: a new #ClutterIMMulticontext. **/ ClutterIMContext * clutter_im_multicontext_new (void) { return g_object_new (CLUTTER_TYPE_IM_MULTICONTEXT, NULL); } static void clutter_im_multicontext_finalize (GObject *object) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (object); clutter_im_multicontext_set_slave (multicontext, NULL, TRUE); g_free (multicontext->context_id); G_OBJECT_CLASS (clutter_im_multicontext_parent_class)->finalize (object); } static void clutter_im_multicontext_set_slave (ClutterIMMulticontext *multicontext, ClutterIMContext *slave, gboolean finalizing) { ClutterIMMulticontextPrivate *priv = multicontext->priv; gboolean need_preedit_changed = FALSE; if (multicontext->slave) { if (!finalizing) clutter_im_context_reset (multicontext->slave); g_signal_handlers_disconnect_by_func (multicontext->slave, clutter_im_multicontext_preedit_start_cb, multicontext); g_signal_handlers_disconnect_by_func (multicontext->slave, clutter_im_multicontext_preedit_end_cb, multicontext); g_signal_handlers_disconnect_by_func (multicontext->slave, clutter_im_multicontext_preedit_changed_cb, multicontext); g_signal_handlers_disconnect_by_func (multicontext->slave, clutter_im_multicontext_commit_cb, multicontext); multicontext->slave->actor = NULL; g_object_unref (multicontext->slave); multicontext->slave = NULL; if (!finalizing) need_preedit_changed = TRUE; } multicontext->slave = slave; if (multicontext->slave) { g_object_ref (multicontext->slave); g_signal_connect (multicontext->slave, "preedit-start", G_CALLBACK (clutter_im_multicontext_preedit_start_cb), multicontext); g_signal_connect (multicontext->slave, "preedit-end", G_CALLBACK (clutter_im_multicontext_preedit_end_cb), multicontext); g_signal_connect (multicontext->slave, "preedit-changed", G_CALLBACK (clutter_im_multicontext_preedit_changed_cb), multicontext); g_signal_connect (multicontext->slave, "commit", G_CALLBACK (clutter_im_multicontext_commit_cb), multicontext); g_signal_connect (multicontext->slave, "retrieve-surrounding", G_CALLBACK (clutter_im_multicontext_retrieve_surrounding_cb), multicontext); g_signal_connect (multicontext->slave, "delete-surrounding", G_CALLBACK (clutter_im_multicontext_delete_surrounding_cb), multicontext); multicontext->slave->actor = CLUTTER_IM_CONTEXT(multicontext)->actor; if (!priv->use_preedit) clutter_im_context_set_use_preedit (slave, FALSE); if (priv->have_cursor_location) clutter_im_context_set_cursor_location (slave, &priv->cursor_location); if (priv->focus_in) clutter_im_context_focus_in (slave); } if (need_preedit_changed) g_signal_emit_by_name (multicontext, "preedit-changed"); } static ClutterIMContext * clutter_im_multicontext_get_slave (ClutterIMMulticontext *multicontext) { if (!multicontext->slave) { ClutterIMContext *slave; if (!global_context_id) { if (user_context_id) global_context_id = user_context_id; else global_context_id = _clutter_im_module_get_default_context_id (); } slave = _clutter_im_module_create (global_context_id); clutter_im_multicontext_set_slave (multicontext, slave, FALSE); g_object_unref (slave); g_free (multicontext->context_id); multicontext->context_id = g_strdup (global_context_id); } return multicontext->slave; } static void clutter_im_multicontext_get_preedit_string (ClutterIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave = clutter_im_multicontext_get_slave (multicontext); if (slave) clutter_im_context_get_preedit_string (slave, str, attrs, cursor_pos); else { if (str) *str = g_strdup (""); if (attrs) *attrs = pango_attr_list_new (); } } static gboolean clutter_im_multicontext_filter_keypress (ClutterIMContext *context, ClutterKeyEvent *event) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave = clutter_im_multicontext_get_slave (multicontext); if (slave) return clutter_im_context_filter_keypress (slave, event); else return FALSE; } static void clutter_im_multicontext_focus_in (ClutterIMContext *context) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave; /* If the global context type is different from the context we were * using before, get rid of the old slave and create a new one * for the new global context type. */ if (multicontext->context_id == NULL || global_context_id == NULL || strcmp (global_context_id, multicontext->context_id) != 0) clutter_im_multicontext_set_slave (multicontext, NULL, FALSE); slave = clutter_im_multicontext_get_slave (multicontext); multicontext->priv->focus_in = TRUE; if (slave) clutter_im_context_focus_in (slave); } static void clutter_im_multicontext_focus_out (ClutterIMContext *context) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave = clutter_im_multicontext_get_slave (multicontext); multicontext->priv->focus_in = FALSE; if (slave) clutter_im_context_focus_out (slave); } static void clutter_im_multicontext_show (ClutterIMContext *context) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave; /* If the global context type is different from the context we were * using before, get rid of the old slave and create a new one * for the new global context type. */ if (multicontext->context_id == NULL || global_context_id == NULL || strcmp (global_context_id, multicontext->context_id) != 0) clutter_im_multicontext_set_slave (multicontext, NULL, FALSE); slave = clutter_im_multicontext_get_slave (multicontext); if (slave) clutter_im_context_show (slave); } static void clutter_im_multicontext_hide (ClutterIMContext *context) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave = clutter_im_multicontext_get_slave (multicontext); if (slave) clutter_im_context_hide (slave); } static void clutter_im_multicontext_reset (ClutterIMContext *context) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave = clutter_im_multicontext_get_slave (multicontext); if (slave) clutter_im_context_reset (slave); } static void clutter_im_multicontext_set_cursor_location (ClutterIMContext *context, ClutterIMRectangle *area) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave = clutter_im_multicontext_get_slave (multicontext); multicontext->priv->have_cursor_location = TRUE; multicontext->priv->cursor_location = *area; if (slave) clutter_im_context_set_cursor_location (slave, area); } static void clutter_im_multicontext_set_use_preedit (ClutterIMContext *context, gboolean use_preedit) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave = clutter_im_multicontext_get_slave (multicontext); use_preedit = use_preedit != FALSE; multicontext->priv->use_preedit = use_preedit; if (slave) clutter_im_context_set_use_preedit (slave, use_preedit); } static gboolean clutter_im_multicontext_get_surrounding (ClutterIMContext *context, gchar **text, gint *cursor_index) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave = clutter_im_multicontext_get_slave (multicontext); if (slave) return clutter_im_context_get_surrounding (slave, text, cursor_index); else { if (text) *text = NULL; if (cursor_index) *cursor_index = 0; return FALSE; } } static void clutter_im_multicontext_set_surrounding (ClutterIMContext *context, const char *text, gint len, gint cursor_index) { ClutterIMMulticontext *multicontext = CLUTTER_IM_MULTICONTEXT (context); ClutterIMContext *slave = clutter_im_multicontext_get_slave (multicontext); if (slave) clutter_im_context_set_surrounding (slave, text, len, cursor_index); } static void clutter_im_multicontext_preedit_start_cb (ClutterIMContext *slave, ClutterIMMulticontext *multicontext) { g_signal_emit_by_name (multicontext, "preedit-start"); } static void clutter_im_multicontext_preedit_end_cb (ClutterIMContext *slave, ClutterIMMulticontext *multicontext) { g_signal_emit_by_name (multicontext, "preedit-end"); } static void clutter_im_multicontext_preedit_changed_cb (ClutterIMContext *slave, ClutterIMMulticontext *multicontext) { g_signal_emit_by_name (multicontext, "preedit-changed"); } static void clutter_im_multicontext_commit_cb (ClutterIMContext *slave, const gchar *str, ClutterIMMulticontext *multicontext) { g_signal_emit_by_name (multicontext, "commit", str);; } static gboolean clutter_im_multicontext_retrieve_surrounding_cb (ClutterIMContext *slave, ClutterIMMulticontext *multicontext) { gboolean result; g_signal_emit_by_name (multicontext, "retrieve-surrounding", &result); return result; } static gboolean clutter_im_multicontext_delete_surrounding_cb (ClutterIMContext *slave, gint offset, gint n_chars, ClutterIMMulticontext *multicontext) { gboolean result; g_signal_emit_by_name (multicontext, "delete-surrounding", offset, n_chars, &result); return result; } clutter-imcontext-0.1.4/clutter-imcontext/clutter-immulticontext.h000066400000000000000000000050711123615432200256200ustar00rootroot00000000000000/* * clutter-imcontext * clutter-imcontext is an imcontext framework modified base on GTK's imcontext. * * Author: raymond liu * * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #ifndef __CLUTTER_IM_MULTICONTEXT_H__ #define __CLUTTER_IM_MULTICONTEXT_H__ #include "clutter-imcontext.h" G_BEGIN_DECLS #define CLUTTER_TYPE_IM_MULTICONTEXT (clutter_im_multicontext_get_type ()) #define CLUTTER_IM_MULTICONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_IM_MULTICONTEXT, ClutterIMMulticontext)) #define CLUTTER_IM_MULTICONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_IM_MULTICONTEXT, ClutterIMMulticontextClass)) #define CLUTTER_IS_IM_MULTICONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_IM_MULTICONTEXT)) #define CLUTTER_IS_IM_MULTICONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_IM_MULTICONTEXT)) #define CLUTTER_IM_MULTICONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_IM_MULTICONTEXT, ClutterIMMulticontextClass)) typedef struct _ClutterIMMulticontext ClutterIMMulticontext; typedef struct _ClutterIMMulticontextClass ClutterIMMulticontextClass; typedef struct _ClutterIMMulticontextPrivate ClutterIMMulticontextPrivate; struct _ClutterIMMulticontext { ClutterIMContext object; ClutterIMContext *slave; ClutterIMMulticontextPrivate *priv; gchar *context_id; }; struct _ClutterIMMulticontextClass { ClutterIMContextClass parent_class; /* Padding for future expansion */ void (*_clutter_reserved1) (void); void (*_clutter_reserved2) (void); void (*_clutter_reserved3) (void); void (*_clutter_reserved4) (void); }; GType clutter_im_multicontext_get_type (void) G_GNUC_CONST; ClutterIMContext *clutter_im_multicontext_new (void); G_END_DECLS #endif /* __CLUTTER_IM_MULTICONTEXT_H__ */ clutter-imcontext-0.1.4/clutter-imcontext/clutter-imtext.c000066400000000000000000000173661123615432200240520ustar00rootroot00000000000000/* * clutter-imtext * * Author: raymond liu * * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ /** * SECTION:clutter-imtext * @short_description: Text widget with Input Method Context embbed * @stability: Unstable * @see_also: #ClutterText * @include: clutter-imtext/clutter-imtext.h * * #ClutterIMText is a widget which can work with Different Input Method. It derives from * #ClutterText to add the capability to handle Input Method Related function and signals. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "clutter-immulticontext.h" #include "clutter-imtext.h" #define CLUTTER_IMTEXT_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_IMTEXT, ClutterIMTextPrivate)) struct _ClutterIMTextPrivate { ClutterIMContext *im_context; gboolean auto_show_im; }; G_DEFINE_TYPE (ClutterIMText, clutter_imtext, CLUTTER_TYPE_TEXT) static gboolean _get_env_enable_autoshow(void) { static gint env_enable_autoshow = -1; if (env_enable_autoshow == -1) { const gchar *envvar = NULL; envvar = g_getenv ("CLUTTER_IMCONTEXT_AUTOSHOW"); if (envvar && !g_ascii_strcasecmp (envvar, "TRUE")) env_enable_autoshow = 1; else env_enable_autoshow = 0; } return (env_enable_autoshow == 1); } /** * clutter_text_position_to_pixel: * @text: a #ClutterText * @position: position in characters * @x: return location for the X coordinate in pixel, or %NULL * @y: return location for the Y coordinate in pixel, or %NULL * @line_height: return location for the line height in pixel, or %NULL * * Retrieves the coordinates of the given @position in pixel. * * Return value: %TRUE if the conversion was successful */ static gboolean clutter_text_position_to_pixel (ClutterText *text, gint position, gint *x, gint *y, gint *line_height) { gfloat fx = 0, fy = 0, fheight = 0; clutter_text_position_to_coords(text, position, &fx, &fy, &fheight); if (x) *x = fx; if (y) *y = fy; if (line_height) *line_height = fheight; return TRUE; } static void update_im_cursor_location (ClutterIMText *self) { ClutterIMTextPrivate *priv = self->priv; ClutterText *clutter_text = CLUTTER_TEXT (self); gint position = clutter_text_get_cursor_position(clutter_text); ClutterIMRectangle area; clutter_text_position_to_pixel (clutter_text, position, &area.x, &area.y, &area.height); area.width = 0; clutter_im_context_set_cursor_location (priv->im_context, &area); } static void clutter_imtext_commit_cb (ClutterIMContext *context, const gchar *str, ClutterIMText *imtext) { ClutterIMTextPrivate *priv = imtext->priv; ClutterText *clutter_text = CLUTTER_TEXT (imtext); if (clutter_text_get_editable(clutter_text)) { clutter_text_delete_selection(clutter_text); clutter_text_insert_text (clutter_text, str, clutter_text_get_cursor_position (clutter_text)); } } static void clutter_imtext_focus_in_cb (ClutterIMText *imtext) { ClutterIMTextPrivate *priv = imtext->priv; ClutterText *clutter_text = CLUTTER_TEXT (imtext); if (!clutter_text_get_editable(clutter_text)) return; if (priv->auto_show_im) clutter_im_context_show (priv->im_context); else clutter_im_context_focus_in (priv->im_context); } static void clutter_imtext_focus_out_cb (ClutterIMText *imtext) { ClutterIMTextPrivate *priv = imtext->priv; ClutterText *clutter_text = CLUTTER_TEXT (imtext); if (!clutter_text_get_editable(clutter_text)) return; if (priv->auto_show_im) clutter_im_context_hide (priv->im_context); else clutter_im_context_focus_out (priv->im_context); } static void clutter_imtext_paint (ClutterActor *actor) { ClutterIMText *self = CLUTTER_IMTEXT (actor); ClutterText *clutter_text = CLUTTER_TEXT (actor); if (CLUTTER_ACTOR_CLASS (clutter_imtext_parent_class)->paint) CLUTTER_ACTOR_CLASS (clutter_imtext_parent_class)->paint (actor); if (clutter_text_get_editable(clutter_text)) update_im_cursor_location(self); } static gboolean clutter_imtext_key_press (ClutterActor *actor, ClutterKeyEvent *event) { ClutterIMText *self = CLUTTER_IMTEXT (actor); ClutterIMTextPrivate *priv = self->priv; ClutterText *clutter_text = CLUTTER_TEXT (actor); if (!clutter_text_get_editable(clutter_text)) return FALSE; if (clutter_im_context_filter_keypress (priv->im_context, event)) return TRUE; if (CLUTTER_ACTOR_CLASS (clutter_imtext_parent_class)->key_press_event) return CLUTTER_ACTOR_CLASS (clutter_imtext_parent_class)->key_press_event (actor, event); return FALSE; } static gboolean clutter_imtext_key_release (ClutterActor *actor, ClutterKeyEvent *event) { ClutterIMText *self = CLUTTER_IMTEXT (actor); ClutterIMTextPrivate *priv = self->priv; ClutterText *clutter_text = CLUTTER_TEXT (actor); if (!clutter_text_get_editable(clutter_text)) return FALSE; if (clutter_im_context_filter_keypress (priv->im_context, event)) return TRUE; if (CLUTTER_ACTOR_CLASS (clutter_imtext_parent_class)->key_release_event) return CLUTTER_ACTOR_CLASS (clutter_imtext_parent_class)->key_release_event (actor, event); return FALSE; } static void clutter_imtext_class_init (ClutterIMTextClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); g_type_class_add_private (klass, sizeof (ClutterIMTextPrivate)); actor_class->paint = clutter_imtext_paint; actor_class->key_press_event = clutter_imtext_key_press; actor_class->key_release_event = clutter_imtext_key_release; } static void clutter_imtext_init (ClutterIMText *self) { ClutterIMTextPrivate *priv; self->priv = priv = CLUTTER_IMTEXT_GET_PRIVATE (self); g_signal_connect (self, "key-focus-in", G_CALLBACK (clutter_imtext_focus_in_cb), self); g_signal_connect (self, "key-focus-out", G_CALLBACK (clutter_imtext_focus_out_cb), self); priv->im_context = clutter_im_multicontext_new (); priv->im_context->actor = CLUTTER_ACTOR(self); priv->auto_show_im = _get_env_enable_autoshow(); g_signal_connect (priv->im_context, "commit", G_CALLBACK (clutter_imtext_commit_cb), self); } /** * clutter_imtext_new: * @text: text to set to * * Create a new #ClutterIMText with the specified text * * Returns: a new #ClutterActor */ ClutterActor * clutter_imtext_new (const gchar *text) { return g_object_new (CLUTTER_TYPE_IMTEXT, "text", text, NULL); } /** * clutter_imtext_set_autoshow_im: * @self: a #ClutterIMText * @autoshow: TRUE to send show event to IM on focus * * Set to True if you want to ask IM to show it's UI when #ClutterIMText is on focus * */ void clutter_imtext_set_autoshow_im (ClutterIMText *self, gboolean autoshow) { ClutterIMTextPrivate *priv; g_return_if_fail (CLUTTER_IS_IMTEXT (self)); priv = CLUTTER_IMTEXT_GET_PRIVATE (self); priv->auto_show_im = autoshow; } clutter-imcontext-0.1.4/clutter-imcontext/clutter-imtext.h000066400000000000000000000041361123615432200240460ustar00rootroot00000000000000/* * clutter-imtext.h * * Author: raymond liu * * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef __CLUTTER_IMTEXT_H__ #define __CLUTTER_IMTEXT_H__ G_BEGIN_DECLS #include #include "clutter-imcontext.h" #define CLUTTER_TYPE_IMTEXT (clutter_imtext_get_type ()) #define CLUTTER_IMTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_IMTEXT, ClutterIMText)) #define CLUTTER_IS_IMTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_IMTEXT)) #define CLUTTER_IMTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_IMTEXT, ClutterIMTextClass)) #define CLUTTER_IS_IMTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_IMTEXT)) #define CLUTTER_IMTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_IMTEXT, ClutterIMTextClass)) typedef struct _ClutterIMText ClutterIMText; typedef struct _ClutterIMTextPrivate ClutterIMTextPrivate; typedef struct _ClutterIMTextClass ClutterIMTextClass; struct _ClutterIMText { ClutterText parent_instance; ClutterIMTextPrivate *priv; }; struct _ClutterIMTextClass { ClutterTextClass parent_class; }; GType clutter_imtext_get_type (void) G_GNUC_CONST; ClutterActor * clutter_imtext_new (const gchar *text); void clutter_imtext_set_autoshow_im (ClutterIMText *self, gboolean autoshow); G_END_DECLS #endif /* __CLUTTER_IMTEXT_H__ */ clutter-imcontext-0.1.4/configure.ac000066400000000000000000000034421123615432200174760ustar00rootroot00000000000000AC_PREREQ(2.61) # package version number (not shared library version) # odd micro numbers indicate in-progress development # even micro numbers indicate released versions m4_define([clutter_imcontext_version_major], [0]) m4_define([clutter_imcontext_version_minor], [1]) m4_define([clutter_imcontext_version_micro], [4]) m4_define([clutter_imcontext_version], [clutter_imcontext_version_major.clutter_imcontext_version_minor.clutter_imcontext_version_micro]) m4_define([clutter_imcontext_api_version], [clutter_imcontext_version_major.clutter_imcontext_version_minor]) AC_INIT(clutter_imcontext, clutter_imcontext_version) AM_INIT_AUTOMAKE(clutter_imcontext, clutter_imcontext_version) AC_CONFIG_HEADERS(config.h) CLUTTER_IMCONTEXT_API_VERSION=clutter_imcontext_api_version AC_SUBST(CLUTTER_IMCONTEXT_API_VERSION) # Check for programs AC_PROG_LIBTOOL AC_PROG_CC AC_PROG_INSTALL # enable pkg-config PKG_PROG_PKG_CONFIG # Check for function availability # AC_CHECK_FUNCS([memset]) AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal]) PKG_CHECK_MODULES(CLUTTER, glib-2.0 clutter-1.0 >= 1.0.0) AC_SUBST(CLUTTER_CFLAGS) AC_SUBST(CLUTTER_LIBS) GTK_DOC_CHECK([1.9]) # Add --enable-debug arg AC_ARG_ENABLE(debug, [ --enable-debug Turn on debugging], , enable_debug=no) if test "$enable_debug" = "yes"; then AC_DEFINE(ENABLE_DEBUG,1,[Define this to enable the debug facility]) fi # Output files AC_OUTPUT([Makefile clutter-imcontext/Makefile clutter-imcontext/clutter-imcontext.pc tools/Makefile tests/Makefile doc/Makefile doc/reference/Makefile doc/reference/version.xml ]) echo "" echo " clutter-imcontext $VERSION" echo " =====================" echo " Documentation: ${enable_gtk_doc}" echo "" echo " To build the project, run \"make\"" echo "" clutter-imcontext-0.1.4/doc/000077500000000000000000000000001123615432200157525ustar00rootroot00000000000000clutter-imcontext-0.1.4/doc/Makefile.am000066400000000000000000000000721123615432200200050ustar00rootroot00000000000000SUBDIRS = reference # EXTRA_DIST = clutter-imcontext-0.1.4/doc/reference/000077500000000000000000000000001123615432200177105ustar00rootroot00000000000000clutter-imcontext-0.1.4/doc/reference/Makefile.am000066400000000000000000000047131123615432200217510ustar00rootroot00000000000000AUTOMAKE_OPTIONS = 1.6 # The name of the module, e.g. 'glib'. DOC_MODULE=clutter-imcontext # The top-level SGML file. You can change this if you want to. DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml # The directory containing the source code. Relative to this file's loc # gtk-doc will search all .c & .h files beneath here for inline comments # documenting the functions and macros. # e.g. DOC_SOURCE_DIR=../../../gtk DOC_SOURCE_DIR=../../clutter-imcontext # Extra options to supply to gtkdoc-mkdb. # e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml MKDB_OPTIONS=--sgml-mode --output-format=xml SCAN_OPTIONS= # Used for dependencies. The docs will be rebuilt if any of these change. # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c HFILE_GLOB=../../clutter-imcontext/*.h CFILE_GLOB=../../clutter-imcontext/*.c # Header files to ignore when scanning. # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h IGNORE_HFILES=\ clutter-imcontext-marshal.h \ clutter-imcontext-private.h \ clutter-immodule.h \ stamp-clutter-imcontext-marshal.h # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png HTML_IMAGES= # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). # e.g. content_files=running.sgml building.sgml changes-2.0.sgml content_files=version.xml # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded # These files must be listed here *and* in content_files # e.g. expand_content_files=running.sgml expand_content_files= # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. # Only needed if you are using gtkdoc-scangobj to dynamically query widget # signals and properties. # e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) INCLUDES=-I$(top_srcdir) -I$(top_srcdir)/clutter-imcontext $(CLUTTER_CFLAGS) GTKDOC_LIBS=$(top_builddir)/clutter-imcontext/libclutter-imcontext-@CLUTTER_IMCONTEXT_API_VERSION@.la $(CLUTTER_LIBS) # This includes the standard gtk-doc make rules, copied by gtkdocize. include $(top_srcdir)/gtk-doc.make # Other files to distribute # e.g. EXTRA_DIST += version.xml.in EXTRA_DIST += version.xml.in # Files not to distribute # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types # for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt #DISTCLEANFILES += # Comment this out if you want your docs-status tested during 'make check' #TESTS = $(GTKDOC_CHECK) clutter-imcontext-0.1.4/doc/reference/clutter-imcontext-docs.sgml000066400000000000000000000024241123615432200252160ustar00rootroot00000000000000 ]> clutter-imcontext Reference Manual For clutter-imcontext &version; 2009 Intel Corporation IMContext Widget Object Hierarchy API Index clutter-imcontext-0.1.4/doc/reference/clutter-imcontext-overview.xml000066400000000000000000000004051123615432200257670ustar00rootroot00000000000000 Overview ClutterIMContext is an Input Method Context framework for Clutter. It's port from GTK's IMContext framework with only necessary modification to work with Clutter. clutter-imcontext-0.1.4/doc/reference/version.xml.in000066400000000000000000000000401123615432200225160ustar00rootroot00000000000000@CLUTTER_IMCONTEXT_API_VERSION@ clutter-imcontext-0.1.4/tests/000077500000000000000000000000001123615432200163475ustar00rootroot00000000000000clutter-imcontext-0.1.4/tests/Makefile.am000066400000000000000000000004071123615432200204040ustar00rootroot00000000000000noinst_PROGRAMS = \ test-imtext INCLUDES = -I$(top_srcdir) LDADD = $(top_builddir)/clutter-imcontext/libclutter-imcontext-@CLUTTER_IMCONTEXT_API_VERSION@.la AM_CFLAGS = $(CLUTTER_CFLAGS) AM_LDFLAGS = $(CLUTTER_LIBS) test_imtext_SOURCES = test-imtext.c clutter-imcontext-0.1.4/tests/test-imtext.c000066400000000000000000000113371123615432200210070ustar00rootroot00000000000000/* * test-imtext.c * * Author: raymond liu * * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #include #include #include #include #include #define FONT "Mono Bold 22px" #define STEP g_message("%s,%d\n", __func__, __LINE__) ClutterActor *the_stage = NULL; static gchar *testtext = "Hello\n" "测试\n"; static void stage_focus_in(ClutterActor *actor) { STEP; } static void on_key_focus_in(ClutterActor *actor) { STEP; } static void on_show(ClutterActor *actor) { STEP; } static void on_key_focus_out(ClutterActor *actor) { STEP; } static gboolean on_key_press(ClutterActor *actor, ClutterKeyEvent *event, gpointer *data) { //STEP; return FALSE; } static void on_text_paint (ClutterActor *actor, gpointer data) { ClutterActorBox allocation = { 0, }; float width, height; clutter_actor_get_allocation_box (actor, &allocation); width = allocation.x2 - allocation.x1; height = allocation.y2 - allocation.y1; cogl_set_source_color4ub (255, 255, 255, 255); cogl_path_round_rectangle (0, 0, width, height, (float)(4), COGL_ANGLE_FROM_DEG (1.0)); cogl_path_stroke (); } int main (int argc, char **argv) { ClutterActor *stage; ClutterActor *text, *text2; ClutterActor *group; ClutterColor text_color = { 0x33, 0xff, 0x33, 0xff }; ClutterColor cursor_color = { 0xff, 0x33, 0x33, 0xff }; ClutterColor background_color = { 0x00, 0x00, 0x30, 0xff }; clutter_init (&argc, &argv); the_stage = stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &background_color); text = clutter_imtext_new ("Auto Show IM"); clutter_container_add_actor (CLUTTER_CONTAINER (stage), text); clutter_actor_set_size (text, 380, 90); clutter_actor_set_position (text, 10, 10); clutter_text_set_line_wrap (CLUTTER_TEXT (text), TRUE); clutter_actor_set_reactive (text, TRUE); clutter_text_set_editable (CLUTTER_TEXT (text), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (text), TRUE); clutter_text_set_cursor_color (CLUTTER_TEXT (text), &cursor_color); clutter_text_set_color (CLUTTER_TEXT (text), &text_color); clutter_text_set_font_name (CLUTTER_TEXT (text), FONT); clutter_imtext_set_autoshow_im (CLUTTER_IMTEXT (text), TRUE); g_signal_connect (text, "key-focus-in", G_CALLBACK (on_key_focus_in), NULL); g_signal_connect (text, "key-focus-out", G_CALLBACK (on_key_focus_out), NULL); g_signal_connect (text, "show", G_CALLBACK (on_show), NULL); g_signal_connect (text, "key-press-event", G_CALLBACK (on_key_press), NULL); g_signal_connect (text, "paint", G_CALLBACK (on_text_paint), NULL); // text2 text2 = clutter_imtext_new ("Show IM According to env: CLUTTER_IMCONTEXT_AUTOSHOW"); clutter_container_add_actor (CLUTTER_CONTAINER (stage), text2); clutter_actor_set_position (text2, 10, 120); clutter_actor_set_size (text2, 380, 90); clutter_text_set_line_wrap (CLUTTER_TEXT (text2), TRUE); clutter_actor_set_reactive (text2, TRUE); clutter_text_set_editable (CLUTTER_TEXT (text2), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (text2), TRUE); clutter_text_set_cursor_color (CLUTTER_TEXT (text2), &cursor_color); clutter_text_set_color (CLUTTER_TEXT (text2), &text_color); clutter_text_set_font_name (CLUTTER_TEXT (text2), FONT); g_signal_connect (text2, "key-focus-in", G_CALLBACK (on_key_focus_in), NULL); g_signal_connect (text2, "key-focus-out", G_CALLBACK (on_key_focus_out), NULL); g_signal_connect (text2, "show", G_CALLBACK (on_show), NULL); g_signal_connect (text2, "key-press-event", G_CALLBACK (on_key_press), NULL); g_signal_connect (text2, "paint", G_CALLBACK (on_text_paint), NULL); g_signal_connect (stage, "key-focus-in", G_CALLBACK (stage_focus_in), NULL); clutter_actor_set_size (stage, 420, 220); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; } clutter-imcontext-0.1.4/tools/000077500000000000000000000000001123615432200163455ustar00rootroot00000000000000clutter-imcontext-0.1.4/tools/Makefile.am000066400000000000000000000004521123615432200204020ustar00rootroot00000000000000AM_CFLAGS = @CLUTTER_CFLAGS@ AM_LDFLAGS = @CLUTTER_LIBS@ INCLUDES = -I$(top_srcdir) bin_PROGRAMS = \ clutter-scan-immodules clutter_scan_immodules_SOURCES = scan-immodules.c clutter_scan_immodules_LDADD = $(top_builddir)/clutter-imcontext/libclutter-imcontext-@CLUTTER_IMCONTEXT_API_VERSION@.la clutter-imcontext-0.1.4/tools/scan-immodules.c000066400000000000000000000102141123615432200214270ustar00rootroot00000000000000/* * scan-immodules.c * scan-immodules.c is copied and modified from GTK's queryimmodules.c. * * Author: raymond liu * * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2009, Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #include "config.h" #include #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif #ifdef USE_LA_MODULES #define SOEXT ".la" #else #define SOEXT ".so" #endif #include "clutter-imcontext/clutter-immodule.h" static char * escape_string (const char *str) { GString *result = g_string_new (NULL); while (TRUE) { char c = *str++; switch (c) { case '\0': goto done; case '\n': g_string_append (result, "\\n"); break; case '\"': g_string_append (result, "\\\""); break; default: g_string_append_c (result, c); } } done: return g_string_free (result, FALSE); } static void print_escaped (const char *str) { char *tmp = escape_string (str); g_printf ("\"%s\" ", tmp); g_free (tmp); } static gboolean query_module (const char *dir, const char *name) { void (*list) (const ClutterIMContextInfo ***contexts, guint *n_contexts); gpointer list_ptr; gpointer init_ptr; gpointer exit_ptr; gpointer create_ptr; GModule *module; gchar *path; gboolean error = FALSE; if (g_path_is_absolute (name)) path = g_strdup (name); else path = g_build_filename (dir, name, NULL); module = g_module_open (path, 0); if (!module) { g_fprintf (stderr, "Cannot load module %s: %s\n", path, g_module_error()); error = TRUE; } if (module && g_module_symbol (module, "im_module_list", &list_ptr) && g_module_symbol (module, "im_module_init", &init_ptr) && g_module_symbol (module, "im_module_exit", &exit_ptr) && g_module_symbol (module, "im_module_create", &create_ptr)) { const ClutterIMContextInfo **contexts; guint n_contexts; int i; list = list_ptr; print_escaped (path); fputs ("\n", stdout); (*list) (&contexts, &n_contexts); for (i=0; icontext_id); print_escaped (contexts[i]->context_name); print_escaped (contexts[i]->domain); print_escaped (contexts[i]->domain_dirname); print_escaped (contexts[i]->default_locales); fputs ("\n", stdout); } fputs ("\n", stdout); } else { g_fprintf (stderr, "%s does not export Clutter IM module API: %s\n", path, g_module_error ()); error = TRUE; } g_free (path); if (module) g_module_close (module); return error; } int main (int argc, char **argv) { int i; char *cwd; char *path; gboolean error = FALSE; g_printf ("# Clutter Input Method Modules file\n" "# Automatically generated by %s, do not edit\n", argv[0]); if (argc == 1) { path = get_im_module_path (); g_printf ("# ModulesPath = %s\n#\n", path); GDir *dir = g_dir_open (path, 0, NULL); if (dir) { const char *dent; while ((dent = g_dir_read_name (dir))) { if (g_str_has_suffix (dent, SOEXT)) error |= query_module (path, dent); } g_dir_close (dir); } g_free(path); } else { cwd = g_get_current_dir (); for (i=1; i