]> saetta.ns0.it Git - libgdaexgrid/commitdiff
Initial import (from libgdaex).
authorAndrea Zagli <andrea.zagli@email.it>
Mon, 17 Aug 2015 14:18:40 +0000 (16:18 +0200)
committerAndrea Zagli <andrea.zagli@email.it>
Mon, 17 Aug 2015 14:18:40 +0000 (16:18 +0200)
18 files changed:
.gitignore [new file with mode: 0644]
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
libgdaexgrid.pc.in [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/grid.c [new file with mode: 0644]
src/grid.h [new file with mode: 0644]
src/gridcolumn.c [new file with mode: 0644]
src/gridcolumn.h [new file with mode: 0644]
src/libgdaexgrid.h [new file with mode: 0644]
tests/Makefile.am [new file with mode: 0644]
tests/grid.c [new file with mode: 0644]
tests/grid.db [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..7bac8e9
--- /dev/null
@@ -0,0 +1,53 @@
+compile
+*~
+*.rpath
+*.pot
+*.mo
+*.gmo
+*.o
+*.lo
+*.la
+*.bak
+*.stamp
+*.tar.gz
+*.pc
+*.sed
+*.sin
+*.header
+.libs
+.deps
+ABOUT-NLS
+INSTALL
+Makefile
+Makefile.in
+Makefile.in.in
+Makevars
+aclocal.m4
+autom4te.cache/
+config.guess
+config.log
+config.sub
+config.h.in
+configure
+depcomp
+gtk-doc.make
+install-sh
+ltmain.sh
+m4/
+missing
+config.h
+config.status
+docs/reference/version.xml
+docs/reference/html/
+docs/reference/xml/
+libtool
+stamp-h1
+tests/test
+POTFILES
+mkinstalldirs
+stamp-it
+intltool-*
+Rules-quot
+*.exe
+*.csv
+tests/grid
diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..ad1de0f
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Andrea Zagli <azagli@libero.it>
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, 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
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU 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
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program 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 General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..c90089c
--- /dev/null
@@ -0,0 +1,29 @@
+SUBDIRS = src tests
+
+ACLOCAL_AMFLAGS = -I m4
+
+EXTRA_DIST = libgdaexgrid.pc.in
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libgdaexgrid.pc
+
+distclean-local:
+       if test "$(srcdir)" = "."; then :; else \
+               rm -f ChangeLog; \
+       fi
+
+ChangeLog:
+       @echo Creating $@
+       @if test -d "$(srcdir)/.git"; then \
+         (GIT_DIR=$(top_srcdir)/.git ./missing --run git log --stat -M -C --name-status --date=short --no-color) | fmt --split-only > $@.tmp \
+         && mv -f $@.tmp $@ \
+         || ($(RM) $@.tmp; \
+             echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \
+             (test -f $@ || echo git-log is required to generate this file >> $@)); \
+       else \
+         test -f $@ || \
+         (echo A git checkout and git-log is required to generate ChangeLog >&2 && \
+         echo A git checkout and git-log is required to generate this file >> $@); \
+       fi
+
+.PHONY: ChangeLog
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..2bfbe7f
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+test -n "$srcdir" || srcdir=`dirname "$0"`
+test -n "$srcdir" || srcdir=.
+
+olddir=`pwd`
+
+cd $srcdir
+
+(test -f configure.ac) || {
+        echo "*** ERROR: Directory "\`$srcdir\'" does not look like the top-level project directory ***"
+        exit 1
+}
+
+PKG_NAME=`autoconf --trace 'AC_INIT:$1' configure.ac`
+
+if [ "$#" = 0 -a "x$NOCONFIGURE" = "x" ]; then
+        echo "*** WARNING: I am going to run \`configure' with no arguments." >&2
+        echo "*** If you wish to pass any to it, please specify them on the" >&2
+        echo "*** \`$0\' command line." >&2
+        echo "" >&2
+fi
+
+set -x
+aclocal --install || exit 1
+glib-gettextize --force --copy || exit 1
+#gtkdocize --copy || exit 1
+intltoolize --force --copy --automake || exit 1
+autoreconf --verbose --force --install -Wno-portability || exit 1
+
+cd $olddir
+if [ "$NOCONFIGURE" = "" ]; then
+        $srcdir/configure "$@" || exit 1
+
+        if [ "$1" = "--help" ]; then exit 0 else
+                echo "Now type \`make\' to compile $PKG_NAME" || exit 1
+        fi
+else
+        echo "Skipping configure process."
+fi
+
+{ set +x; } 2>/dev/null
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..04b7133
--- /dev/null
@@ -0,0 +1,100 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.65)
+AC_INIT([libgdaexgrid], [0.0.1], [azagli@libero.it])
+AC_CONFIG_SRCDIR([src/grid.c])
+AC_CONFIG_HEADER([config.h])
+
+AM_INIT_AUTOMAKE(-Wall)
+
+m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+
+AM_MAINTAINER_MODE
+
+AC_CONFIG_MACRO_DIR([m4])
+
+AC_CANONICAL_SYSTEM
+
+LT_INIT
+
+AC_LIBTOOL_WIN32_DLL
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_PROG_LIBTOOL
+AC_PROG_RANLIB
+
+dnl ******************************
+dnl Translations
+dnl ******************************
+GETTEXT_PACKAGE=libgdaexgrid
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
+                   [The prefix for our gettext translation domains.])
+AM_GLIB_GNU_GETTEXT
+
+# Checks for libraries.
+PKG_CHECK_MODULES(GDAEXGRID, [libgdaex >= 0.5.0])
+
+AC_SUBST(GDAEXGRID_CFLAGS)
+AC_SUBST(GDAEXGRID_LIBS)
+
+PKG_CHECK_EXISTS(libreptool >= 0.2.2, [LIBREPTOOL_FOUND=yes], [LIBREPTOOL_FOUND=no])
+
+AM_CONDITIONAL(LIBREPTOOL_FOUND, test $LIBREPTOOL_FOUND = yes)
+
+if test $LIBREPTOOL_FOUND = yes; then
+PKG_CHECK_MODULES(REPTOOL, libreptool >= 0.2.2)
+
+AC_SUBST(REPTOOL_CFLAGS)
+AC_SUBST(REPTOOL_LIBS)
+fi
+
+PKG_CHECK_EXISTS(libsolipa >= 0.4.0, [LIBSOLIPA_FOUND=yes], [LIBSOLIPA_FOUND=no])
+
+AM_CONDITIONAL(LIBSOLIPA_FOUND, test $LIBSOLIPA_FOUND = yes)
+
+if test $LIBSOLIPA_FOUND = yes; then
+PKG_CHECK_MODULES(SOLIPA, libsolipa >= 0.4.0)
+
+AC_SUBST(SOLIPA_CFLAGS)
+AC_SUBST(SOLIPA_LIBS)
+fi
+
+# Checks for header files.
+AC_HEADER_STDC
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+
+# Checks for library functions.
+
+# Checks for library functions.
+
+dnl ******************************
+dnl Check for Operating System
+dnl ******************************
+
+platform_win32=no
+
+case "$host" in
+*-mingw*)
+    platform_win32=yes
+    ;;
+esac
+
+AM_CONDITIONAL(PLATFORM_WIN32, [test $platform_win32 = yes])
+
+# Output files
+AC_CONFIG_FILES([
+       libgdaexgrid.pc
+       Makefile
+       src/Makefile
+       tests/Makefile
+])
+AC_OUTPUT
diff --git a/libgdaexgrid.pc.in b/libgdaexgrid.pc.in
new file mode 100644 (file)
index 0000000..03562dd
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: @PACKAGE_NAME@
+Description: A grid (Gtk)widget based on libgda.
+Version: @PACKAGE_VERSION@
+Requires: libgdaex >= 0.5.0
+Libs: -L${libdir} -lgdaexgrid
+Cflags: -I${includedir}
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..c75ab33
--- /dev/null
@@ -0,0 +1,36 @@
+LIBS = $(GDAEXGRID_LIBS)
+
+AM_CPPFLAGS = $(GDAEXGRID_CFLAGS) \
+              -DLOCALEDIR=\"$(localedir)\" \
+              -DG_LOG_DOMAIN=\"GdaExGrid\"
+
+if LIBREPTOOL_FOUND
+AM_CPPFLAGS += \
+               $(REPTOOL_CFLAGS) \
+               -DREPTOOL_FOUND=1
+
+LIBS += \
+        $(REPTOOL_LIBS)
+endif
+
+if LIBSOLIPA_FOUND
+AM_CPPFLAGS += \
+               $(SOLIPA_CFLAGS) \
+               -DSOLIPA_FOUND=1
+
+LIBS += \
+        $(SOLIPA_LIBS)
+endif
+
+lib_LTLIBRARIES = libgdaexgrid.la
+
+libgdaexgrid_la_SOURCES = grid.c \
+                          gridcolumn.c
+
+libgdaexgrid_la_LDFLAGS = -no-undefined
+
+libgdaexgrid_include_HEADERS = libgdaexgrid.h \
+                               grid.h \
+                               gridcolumn.h
+
+libgdaexgrid_includedir = $(includedir)/libgdaexgrid
diff --git a/src/grid.c b/src/grid.c
new file mode 100644 (file)
index 0000000..1b6e91b
--- /dev/null
@@ -0,0 +1,958 @@
+/*
+ *  grid.c
+ *
+ *  Copyright (C) 2010-2015 Andrea Zagli <azagli@libero.it>
+ *
+ *  This file is part of libgdaexgrid.
+ *
+ *  libgdaex_grid is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  libgdaex_grid 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with libgdaex; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include <gtk/gtk.h>
+
+#if defined (REPTOOL_FOUND) || defined (SOLIPA_FOUND)
+       #include <gdk/gdk.h>
+#endif
+
+#ifdef REPTOOL_FOUND
+       #include <libreptool/libreptool.h>
+#endif
+
+#include "grid.h"
+
+static void gdaex_grid_class_init (GdaExGridClass *klass);
+static void gdaex_grid_init (GdaExGrid *gdaex_grid);
+
+static void gdaex_grid_set_property (GObject *object,
+                               guint property_id,
+                               const GValue *value,
+                               GParamSpec *pspec);
+static void gdaex_grid_get_property (GObject *object,
+                               guint property_id,
+                               GValue *value,
+                               GParamSpec *pspec);
+
+#if defined (REPTOOL_FOUND) || defined (SOLIPA_FOUND)
+static gboolean gdaex_grid_on_key_release_event (GtkWidget *widget,
+                            GdkEventKey *event,
+                            gpointer user_data);
+#endif
+
+#ifdef REPTOOL_FOUND
+static void gdaex_grid_on_print_menu_activate (GtkMenuItem *menuitem,
+                                   gpointer user_data);
+#endif
+
+#ifdef SOLIPA_FOUND
+static void gdaex_grid_on_export_menu_activate (GtkMenuItem *menuitem,
+                                   gpointer user_data);
+#endif
+
+static gboolean gdaex_grid_on_button_press_event (GtkWidget *widget,
+                                                  GdkEventButton *event,
+                                                  gpointer user_data);
+static gboolean gdaex_grid_on_popup_menu (GtkWidget *widget,
+                                          gpointer user_data);
+static void gdaex_grid_on_menu_item_toggled (GtkCheckMenuItem *checkmenuitem,
+                                             gpointer user_data);
+
+static GtkTreeModel *gdaex_grid_get_model (GdaExGrid *grid);
+static GtkTreeView *gdaex_grid_get_view (GdaExGrid *grid);
+
+#define GDAEX_GRID_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDAEX_TYPE_GRID, GdaExGridPrivate))
+
+typedef struct _GdaExGridPrivate GdaExGridPrivate;
+struct _GdaExGridPrivate
+       {
+               GPtrArray *columns; /* GdaExGridColumn */
+
+               gchar *title;
+
+               GtkTreeModel *model;
+               GtkWidget *view;
+               GtkWidget *menu;
+
+#ifdef SOLIPA_FOUND
+               Solipa *solipa;
+#endif
+       };
+
+G_DEFINE_TYPE (GdaExGrid, gdaex_grid, G_TYPE_OBJECT)
+
+#ifdef G_OS_WIN32
+static HMODULE hmodule;
+
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+         DWORD     fdwReason,
+         LPVOID    lpvReserved)
+{
+       switch (fdwReason)
+               {
+                       case DLL_PROCESS_ATTACH:
+                               hmodule = hinstDLL;
+                               break;
+               }
+
+       return TRUE;
+}
+#endif
+
+static void
+gdaex_grid_class_init (GdaExGridClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (object_class, sizeof (GdaExGridPrivate));
+
+       object_class->set_property = gdaex_grid_set_property;
+       object_class->get_property = gdaex_grid_get_property;
+}
+
+static void
+gdaex_grid_init (GdaExGrid *gdaex_grid)
+{
+       GdaExGridPrivate *priv = GDAEX_GRID_GET_PRIVATE (gdaex_grid);
+
+       priv->columns = g_ptr_array_new ();
+       priv->title = NULL;
+       priv->view = NULL;
+       priv->menu = NULL;
+}
+
+GdaExGrid
+*gdaex_grid_new ()
+{
+       gchar *localedir;
+
+       GdaExGrid *gdaex_grid = GDAEX_GRID (g_object_new (gdaex_grid_get_type (), NULL));
+
+       GdaExGridPrivate *priv = GDAEX_GRID_GET_PRIVATE (gdaex_grid);
+
+#ifdef G_OS_WIN32
+
+       gchar *moddir;
+       gchar *p;
+
+       moddir = g_win32_get_package_installation_directory_of_module (hmodule);
+
+       p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR));
+       if (p != NULL
+           && (g_ascii_strcasecmp (p + 1, "src") == 0
+               || g_ascii_strcasecmp (p + 1, ".libs") == 0))
+               {
+                       localedir = g_strdup (LOCALEDIR);
+               }
+       else
+               {
+                       localedir = g_build_filename (moddir, "share", "locale", NULL);
+               }
+
+       g_free (moddir);
+
+#else
+
+       localedir = g_strdup (LOCALEDIR);
+
+#endif
+
+       bindtextdomain (GETTEXT_PACKAGE, localedir);
+       textdomain (GETTEXT_PACKAGE);
+       bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+       g_free (localedir);
+
+       return gdaex_grid;
+}
+
+void
+gdaex_grid_set_title (GdaExGrid *grid, const gchar *title)
+{
+       GdaExGridPrivate *priv;
+
+       g_return_if_fail (GDAEX_IS_GRID (grid));
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       if (priv->title != NULL)
+               {
+                       g_free (priv->title);
+               }
+
+       if (title != NULL)
+               {
+                       priv->title = g_strdup (title);
+               }
+       else
+               {
+                       priv->title = NULL;
+               }
+}
+
+const gchar
+*gdaex_grid_get_title (GdaExGrid *grid)
+{
+       GdaExGridPrivate *priv;
+
+       g_return_val_if_fail (GDAEX_IS_GRID (grid), NULL);
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       if (priv->title != NULL)
+               {
+                       return g_strdup (priv->title);
+               }
+       else
+               {
+                       return NULL;
+               }
+}
+
+void
+gdaex_grid_add_column (GdaExGrid *grid, GdaExGridColumn *column)
+{
+       GdaExGridPrivate *priv;
+
+       g_return_if_fail (GDAEX_IS_GRID (grid));
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       g_ptr_array_add (priv->columns, g_object_ref (column));
+}
+
+void
+gdaex_grid_add_columns (GdaExGrid *grid, GSList *columns)
+{
+       GSList *first;
+
+       g_return_if_fail (GDAEX_IS_GRID (grid));
+
+       first = columns;
+       while (first != NULL)
+               {
+                       gdaex_grid_add_column (grid, (GdaExGridColumn *)first->data);
+                       first = g_slist_next (first);
+               }
+}
+
+void
+gdaex_grid_clear (GdaExGrid *grid)
+{
+       GdaExGridPrivate *priv;
+
+       guint col;
+
+       g_return_if_fail (GDAEX_IS_GRID (grid));
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       for (col = 0; priv->columns->len; col++)
+               {
+                       g_object_unref (g_ptr_array_index (priv->columns, col));
+               }
+
+       g_ptr_array_remove_range (priv->columns, 0, priv->columns->len);
+       g_ptr_array_unref (priv->columns);
+
+       priv->columns = g_ptr_array_new ();
+}
+
+GtkWidget
+*gdaex_grid_get_widget (GdaExGrid *grid)
+{
+       g_return_val_if_fail (GDAEX_IS_GRID (grid), NULL);
+
+       return GTK_WIDGET (gdaex_grid_get_view (grid));
+}
+
+gboolean
+gdaex_grid_fill_from_sql_with_missing_func (GdaExGrid *grid,
+                                            GdaEx *gdaex,
+                                            const gchar *sql,
+                                            GdaExGridFillListStoreMissingFunc missing_func, gpointer user_data,
+                                            GError **error)
+{
+       GdaDataModel *dm;
+
+       gchar *_sql;
+
+       gboolean ret;
+
+       g_return_val_if_fail (GDAEX_IS_GRID (grid), FALSE);
+       g_return_val_if_fail (IS_GDAEX (gdaex), FALSE);
+       g_return_val_if_fail (sql != NULL, FALSE);
+
+       _sql = g_strstrip (g_strdup (sql));
+
+       g_return_val_if_fail (g_strcmp0 (_sql, "") != 0, FALSE);
+
+       dm = gdaex_query (gdaex, _sql);
+       g_free (_sql);
+       ret = gdaex_grid_fill_from_datamodel_with_missing_func (grid, dm, missing_func, user_data, error);
+       g_object_unref (dm);
+
+       return ret;
+}
+
+gboolean
+gdaex_grid_fill_from_datamodel_with_missing_func (GdaExGrid *grid,
+                                                  GdaDataModel *dm,
+                                                  GdaExGridFillListStoreMissingFunc missing_func, gpointer user_data,
+                                                  GError **error)
+{
+       GdaExGridPrivate *priv;
+
+       GdaDataModelIter *dm_iter;
+       GtkTreeIter iter;
+
+       const gchar *field_name;
+
+       guint cols;
+       guint cols_sorted;
+       guint col;
+
+       GType col_gtype;
+
+       GdaExGridColumn *gdaex_col;
+       GType gdaex_col_gtype;
+
+       GdaColumn *gda_col;
+       GType gda_col_gtype;
+
+       gint *columns;
+       GValue *values;
+
+       GDateTime *gdatetime;
+       gdouble dval;
+
+       gboolean call_missing_func;
+
+       g_return_val_if_fail (GDAEX_IS_GRID (grid), FALSE);
+       g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       if (priv->model == NULL)
+               {
+                       gdaex_grid_get_model (grid);
+               }
+       g_return_val_if_fail (GTK_IS_TREE_MODEL (priv->model), FALSE);
+
+       dm_iter = gda_data_model_create_iter (dm);
+       g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (dm_iter), FALSE);
+
+       gtk_list_store_clear (GTK_LIST_STORE (priv->model));
+
+       cols = gtk_tree_model_get_n_columns (priv->model);
+       columns = g_new0 (gint, cols);
+       values = g_new0 (GValue, cols);
+
+       call_missing_func = FALSE;
+
+       while (gda_data_model_iter_move_next (dm_iter))
+               {
+                       gtk_list_store_append (GTK_LIST_STORE (priv->model), &iter);
+
+                       cols_sorted = priv->columns->len;
+                       for (col = 0; col < priv->columns->len; col++)
+                               {
+                                       GValue gval = {0};
+
+                                       columns[col] = col;
+
+                                       col_gtype = gtk_tree_model_get_column_type (priv->model, col);
+
+                                       gdaex_col = (GdaExGridColumn *)g_ptr_array_index (priv->columns, col);
+                                       field_name = gdaex_grid_column_get_field_name (gdaex_col);
+
+                                       g_value_init (&gval, col_gtype);
+
+                                       /* checking if field exists */
+                                       if (gda_data_model_get_column_index (dm, field_name) == -1)
+                                               {
+                                                       call_missing_func = TRUE;
+                                               }
+                                       else
+                                               {
+                                                       switch (col_gtype)
+                                                               {
+                                                                       case G_TYPE_STRING:
+                                                                               gda_col = gda_data_model_describe_column (dm, col);
+                                                                               gda_col_gtype = gda_column_get_g_type (gda_col);
+
+                                                                               switch (gda_col_gtype)
+                                                                                       {
+                                                                                               case G_TYPE_STRING:
+                                                                                                       g_value_set_string (&gval, gdaex_data_model_iter_get_field_value_stringify_at (dm_iter, field_name));
+                                                                                                       break;
+
+                                                                                               case G_TYPE_BOOLEAN:
+                                                                                                       g_value_set_string (&gval, gdaex_data_model_iter_get_field_value_boolean_at (dm_iter, field_name) ? "X" : "");
+                                                                                                       break;
+
+                                                                                               case G_TYPE_INT:
+                                                                                               case G_TYPE_FLOAT:
+                                                                                               case G_TYPE_DOUBLE:
+                                                                                                       dval = gdaex_data_model_iter_get_field_value_double_at (dm_iter, field_name);
+                                                                                                       g_value_set_string (&gval, gdaex_format_money (dval, gdaex_grid_column_get_decimals ((GdaExGridColumn *)g_ptr_array_index (priv->columns, col)), FALSE));
+                                                                                                       break;
+
+                                                                                               default:
+                                                                                                       if (gda_col_gtype == G_TYPE_DATE
+                                                                                                               || gda_col_gtype == G_TYPE_DATE_TIME
+                                                                                                               || gda_col_gtype == GDA_TYPE_TIMESTAMP)
+                                                                                                               {
+                                                                                                                       gdatetime = gdaex_data_model_iter_get_field_value_gdatetime_at (dm_iter, field_name);
+                                                                                                                       /* TODO find default format from locale */
+                                                                                                                       g_value_set_string (&gval, g_date_time_format (gdatetime, gda_col_gtype == G_TYPE_DATE ? "%d/%m/%Y" : "%d/%m/%Y %H.%M.%S"));
+                                                                                                                       g_date_time_unref (gdatetime);
+                                                                                                               }
+                                                                                                       else
+                                                                                                               {
+                                                                                                                       g_value_set_string (&gval, gdaex_data_model_iter_get_field_value_stringify_at (dm_iter, field_name));
+                                                                                                               }
+                                                                                                       break;
+                                                                                       }
+
+                                                                               break;
+
+                                                                       case G_TYPE_INT:
+                                                                               g_value_set_int (&gval, gdaex_data_model_iter_get_field_value_integer_at (dm_iter, field_name));
+                                                                               break;
+
+                                                                       case G_TYPE_FLOAT:
+                                                                               g_value_set_float (&gval, gdaex_data_model_iter_get_field_value_float_at (dm_iter, field_name));
+                                                                               break;
+
+                                                                       case G_TYPE_DOUBLE:
+                                                                               g_value_set_double (&gval, gdaex_data_model_iter_get_field_value_double_at (dm_iter, field_name));
+                                                                               break;
+
+                                                                       case G_TYPE_BOOLEAN:
+                                                                               g_value_set_boolean (&gval, gdaex_data_model_iter_get_field_value_boolean_at (dm_iter, field_name));
+                                                                               break;
+
+                                                                       default:
+                                                                               gval = *gda_value_new_from_string (gdaex_data_model_iter_get_field_value_stringify_at (dm_iter, field_name), col_gtype);
+                                                                               break;
+                                                               }
+                                               }
+                                       values[col] = gval;
+
+                                       gdaex_col_gtype = gdaex_grid_column_get_gtype (gdaex_col);
+
+                                       if ((gdaex_col_gtype == G_TYPE_DATE
+                                            || gdaex_col_gtype == G_TYPE_DATE_TIME
+                                            || gdaex_col_gtype == GDA_TYPE_TIMESTAMP
+                                            || ((gdaex_col_gtype == G_TYPE_INT
+                                                 || gdaex_col_gtype == G_TYPE_FLOAT
+                                                 || gdaex_col_gtype == G_TYPE_DOUBLE)
+                                                && gdaex_grid_column_get_decimals (gdaex_col) > -1))
+                                           && gdaex_grid_column_get_sortable (gdaex_col))
+                                               {
+                                                       columns[cols_sorted] = cols_sorted;
+
+                                                       GValue gval = {0};
+                                                       if (gdaex_col_gtype == G_TYPE_DATE
+                                                           || gdaex_col_gtype == G_TYPE_DATE_TIME
+                                                           || gdaex_col_gtype == GDA_TYPE_TIMESTAMP)
+                                                               {
+                                                                       g_value_init (&gval, G_TYPE_STRING);
+                                                                       gdatetime = gdaex_data_model_iter_get_field_value_gdatetime_at (dm_iter, field_name);
+                                                                       g_value_set_string (&gval, gdatetime != NULL ? g_date_time_format (gdatetime, gdaex_col_gtype == G_TYPE_DATE ? "%Y%m%d" : "%Y%m%d%H%M%S") : "");
+                                                                       g_date_time_unref (gdatetime);
+                                                               }
+                                                       else if (gdaex_col_gtype == G_TYPE_INT)
+                                                               {
+                                                                       g_value_init (&gval, G_TYPE_INT);
+                                                                       g_value_set_int (&gval, gdaex_data_model_iter_get_field_value_integer_at (dm_iter, field_name));
+                                                               }
+                                                       else if (gdaex_col_gtype == G_TYPE_FLOAT)
+                                                               {
+                                                                       g_value_init (&gval, G_TYPE_FLOAT);
+                                                                       g_value_set_float (&gval, gdaex_data_model_iter_get_field_value_float_at (dm_iter, field_name));
+                                                               }
+                                                       else if (gdaex_col_gtype == G_TYPE_DOUBLE)
+                                                               {
+                                                                       g_value_init (&gval, G_TYPE_DOUBLE);
+                                                                       g_value_set_double (&gval, gdaex_data_model_iter_get_field_value_double_at (dm_iter, field_name));
+                                                               }
+                                                       values[cols_sorted] = gval;
+                                                       cols_sorted++;
+                                               }
+                               }
+
+                       gtk_list_store_set_valuesv (GTK_LIST_STORE (priv->model), &iter, columns, values, cols);
+                       if (call_missing_func
+                           && missing_func != NULL)
+                               {
+                                       missing_func (GTK_LIST_STORE (priv->model), &iter, user_data);
+                               }
+               }
+
+       return TRUE;
+}
+
+gboolean
+gdaex_grid_fill_from_sql (GdaExGrid *grid, GdaEx *gdaex, const gchar *sql, GError **error)
+{
+       return gdaex_grid_fill_from_sql_with_missing_func (grid, gdaex, sql, NULL, NULL, error);
+}
+
+gboolean
+gdaex_grid_fill_from_datamodel (GdaExGrid *grid, GdaDataModel *dm, GError **error)
+{
+       return gdaex_grid_fill_from_datamodel_with_missing_func (grid, dm, NULL, NULL, error);
+}
+
+#ifdef SOLIPA_FOUND
+void
+gdaex_grid_set_solipa (GdaExGrid *grid, Solipa *solipa)
+{
+       GdaExGridPrivate *priv;
+
+       g_return_if_fail (GDAEX_IS_GRID (grid));
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       priv->solipa = solipa;
+}
+#endif
+
+/* PRIVATE */
+static void
+gdaex_grid_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+       GdaExGrid *gdaex_grid = GDAEX_GRID (object);
+       GdaExGridPrivate *priv = GDAEX_GRID_GET_PRIVATE (gdaex_grid);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+gdaex_grid_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+       GdaExGrid *gdaex_grid = GDAEX_GRID (object);
+       GdaExGridPrivate *priv = GDAEX_GRID_GET_PRIVATE (gdaex_grid);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static GtkTreeModel
+*gdaex_grid_get_model (GdaExGrid *grid)
+{
+       /* TODO for now it returns always a GtkListStore */
+       GdaExGridPrivate *priv;
+
+       guint cols;
+       guint col;
+
+       GdaExGridColumn *gcolumn;
+
+       GType *gtype;
+       GType col_gtype;
+
+       g_return_val_if_fail (GDAEX_IS_GRID (grid), NULL);
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       cols = priv->columns->len;
+       gtype = g_new0 (GType, cols);
+
+       for (col = 0; col < priv->columns->len; col++)
+               {
+                       gcolumn = (GdaExGridColumn *)g_ptr_array_index (priv->columns, col);
+
+                       col_gtype = gdaex_grid_column_get_gtype (gcolumn);
+                       if (col_gtype == G_TYPE_DATE
+                           || col_gtype == G_TYPE_DATE_TIME
+                           || col_gtype == GDA_TYPE_TIMESTAMP
+                           || ((col_gtype == G_TYPE_INT
+                                || col_gtype == G_TYPE_FLOAT
+                                || col_gtype == G_TYPE_DOUBLE)
+                               && gdaex_grid_column_get_decimals (gcolumn) > -1))
+                               {
+                                       gtype[col] = G_TYPE_STRING;
+
+                                       if (gdaex_grid_column_get_sortable (gcolumn))
+                                               {
+                                                       /* add one column for sorting */
+                                                       gtype = g_renew (GType, gtype, ++cols);
+                                                       if (col_gtype == G_TYPE_DATE
+                                                           || col_gtype == G_TYPE_DATE_TIME
+                                                           || col_gtype == GDA_TYPE_TIMESTAMP)
+                                                               {
+                                                                       gtype[cols - 1] = G_TYPE_STRING;
+                                                               }
+                                                       else
+                                                               {
+                                                                       gtype[cols - 1] = col_gtype;
+                                                               }
+                                               }
+                               }
+                       else
+                               {
+                                       gtype[col] = col_gtype;
+                               }
+               }
+
+       if (priv->model != NULL)
+               {
+                       g_object_unref (priv->model);
+               }
+       priv->model = GTK_TREE_MODEL (gtk_list_store_newv (cols, gtype));
+
+       return priv->model;
+}
+
+static GtkTreeView
+*gdaex_grid_get_view (GdaExGrid *grid)
+{
+       GtkWidget *view;
+
+       GdaExGridPrivate *priv;
+
+       GtkTreeModel *model;
+       GdaExGridColumn *gcolumn;
+       GtkTreeViewColumn *vcolumn;
+
+       GList *cells;
+
+       GType col_gtype;
+
+       guint col;
+       guint cols_sorted;
+
+       GtkWidget *mitem;
+       GtkWidget *submitem;
+
+       g_return_val_if_fail (GDAEX_IS_GRID (grid), NULL);
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       model = gdaex_grid_get_model (grid);
+       view = gtk_tree_view_new_with_model (model);
+
+       gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE);
+
+       if (priv->menu != NULL)
+               {
+                       g_free (priv->menu);
+               }
+       if (priv->columns->len > 0)
+               {
+                       priv->menu = gtk_menu_new ();
+               }
+       else
+               {
+                       priv->menu = NULL;
+               }
+
+       mitem = gtk_menu_item_new_with_mnemonic (_("_Columns"));
+       gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), mitem);
+       gtk_widget_show (mitem);
+
+       submitem = gtk_menu_new ();
+       gtk_menu_item_set_submenu (GTK_MENU_ITEM (mitem), submitem);
+       gtk_widget_show (submitem);
+
+       cols_sorted = 0;
+       for (col = 0; col < priv->columns->len; col++)
+               {
+                       gcolumn = (GdaExGridColumn *)g_ptr_array_index (priv->columns, col);
+                       vcolumn = gdaex_grid_column_get_column (gcolumn);
+                       if (vcolumn)
+                               {
+                                       cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (vcolumn));
+                                       cells = g_list_first (cells);
+
+                                       col_gtype = gdaex_grid_column_get_gtype (gcolumn);
+                                       if (col_gtype == G_TYPE_BOOLEAN)
+                                               {
+                                                       gtk_tree_view_column_add_attribute (vcolumn, (GtkCellRenderer *)cells->data, "active", col);
+                                               }
+                                       else
+                                               {
+                                                       gtk_tree_view_column_add_attribute (vcolumn, (GtkCellRenderer *)cells->data, "text", col);
+                                               }
+                                       g_object_set_data (G_OBJECT (vcolumn), "rpt_text_col_idx", g_strdup_printf ("%d", col));
+
+                                       if (gdaex_grid_column_get_sortable (gcolumn))
+                                               {
+                                                       if (col_gtype == G_TYPE_DATE
+                                                           || col_gtype == G_TYPE_DATE_TIME
+                                                           || col_gtype == GDA_TYPE_TIMESTAMP
+                                                           || ((col_gtype == G_TYPE_INT
+                                                                || col_gtype == G_TYPE_FLOAT
+                                                                || col_gtype == G_TYPE_DOUBLE)
+                                                                && gdaex_grid_column_get_decimals ((GdaExGridColumn *)g_ptr_array_index (priv->columns, col)) > -1))
+                                                               {
+                                                                       gtk_tree_view_column_set_sort_column_id (vcolumn, priv->columns->len + cols_sorted++);
+                                                               }
+                                                       else
+                                                               {
+                                                                       gtk_tree_view_column_set_sort_column_id (vcolumn, col);
+                                                               }
+                                               }
+
+                                       gtk_tree_view_append_column (GTK_TREE_VIEW (view), vcolumn);
+
+                                       /* popup menu */
+                                       mitem = gtk_check_menu_item_new_with_label (gdaex_grid_column_get_title (gcolumn));
+                                       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mitem), gdaex_grid_column_get_visible (gcolumn));
+
+                                       g_object_set_data (G_OBJECT (mitem), "GdaExGridColumn", gcolumn);
+
+                                       g_signal_connect (G_OBJECT (mitem), "toggled",
+                                                         G_CALLBACK (gdaex_grid_on_menu_item_toggled), (gpointer)grid);
+
+                                       gtk_menu_shell_append (GTK_MENU_SHELL (submitem), mitem);
+                                       gtk_widget_show (mitem);
+                               }
+               }
+
+       priv->view = view;
+       if (priv->menu != NULL)
+               {
+                       gtk_menu_attach_to_widget (GTK_MENU (priv->menu), priv->view, NULL);
+
+                       g_signal_connect (G_OBJECT (priv->view), "button-press-event",
+                                         G_CALLBACK (gdaex_grid_on_button_press_event), (gpointer)grid);
+                       g_signal_connect (G_OBJECT (priv->view), "popup-menu",
+                                         G_CALLBACK (gdaex_grid_on_popup_menu), (gpointer)grid);
+
+#ifdef REPTOOL_FOUND
+                       mitem = gtk_menu_item_new_with_mnemonic (_("_Print..."));
+                       gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), mitem);
+                       gtk_widget_show (mitem);
+
+                       g_signal_connect (mitem,
+                                         "activate", G_CALLBACK (gdaex_grid_on_print_menu_activate), (gpointer)grid);
+#endif
+
+#ifdef SOLIPA_FOUND
+                       mitem = gtk_menu_item_new_with_mnemonic (_("_Export..."));
+                       gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), mitem);
+                       gtk_widget_show (mitem);
+
+                       g_signal_connect (mitem,
+                                         "activate", G_CALLBACK (gdaex_grid_on_export_menu_activate), (gpointer)grid);
+#endif
+       }
+
+#ifdef REPTOOL_FOUND
+       g_signal_connect (view,
+                         "key-release-event", G_CALLBACK (gdaex_grid_on_key_release_event), (gpointer)grid);
+#endif
+
+       return GTK_TREE_VIEW (priv->view);
+}
+
+#if defined (REPTOOL_FOUND) || defined (SOLIPA_FOUND)
+static gboolean
+gdaex_grid_on_key_release_event (GtkWidget *widget,
+                            GdkEventKey *event,
+                            gpointer user_data)
+{
+       switch (event->keyval)
+               {
+#ifdef REPTOOL_FOUND
+                       case GDK_KEY_F12:
+                               {
+                                       if (event->state & GDK_CONTROL_MASK)
+                                               {
+                                                       gdaex_grid_on_print_menu_activate (NULL, user_data);
+                                                       return TRUE;
+                                               }
+                                       break;
+                               }
+#endif
+
+#ifdef SOLIPA_FOUND
+                       case GDK_KEY_F11:
+                               {
+                                       if (event->state & GDK_CONTROL_MASK)
+                                               {
+                                                       gdaex_grid_on_export_menu_activate (NULL, user_data);
+                                                       return TRUE;
+                                               }
+                                       break;
+                               }
+#endif
+
+                       default:
+                               break;
+               }
+
+       return FALSE;
+}
+#endif
+
+#ifdef REPTOOL_FOUND
+static void
+gdaex_grid_on_print_menu_activate (GtkMenuItem *menuitem,
+                                   gpointer user_data)
+{
+       GdaExGridPrivate *priv;
+
+       RptReport *rptr;
+       RptPrint *rptp;
+
+       gchar *_title;
+
+       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+
+       if (priv->title != NULL)
+               {
+                       _title = g_strdup_printf ("\"%s\"", priv->title);
+               }
+       else
+               {
+                       _title = NULL;
+               }
+       rptr = rpt_report_new_from_gtktreeview (GTK_TREE_VIEW (priv->view), _title);
+
+       if (rptr != NULL)
+               {
+                       xmlDoc *report = rpt_report_get_xml (rptr);
+                       rpt_report_set_output_type (rptr, RPT_OUTPUT_GTK);
+
+                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
+
+                       rptp = rpt_print_new_from_xml (rptprint);
+                       if (rptp != NULL)
+                               {
+                                       rpt_print_set_output_type (rptp, RPT_OUTPUT_GTK);
+                                       rpt_print_print (rptp, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (priv->view))));
+                               }
+               }
+
+       if (_title != NULL)
+               {
+                       g_free (_title);
+               }
+}
+#endif
+
+#ifdef SOLIPA_FOUND
+static void
+gdaex_grid_on_export_menu_activate (GtkMenuItem *menuitem,
+                                    gpointer user_data)
+{
+       GdaExGridPrivate *priv;
+
+       gint col;
+       GdaExGridColumn *gcolumn;
+       GString *gstr;
+
+       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+
+       if (!IS_SOLIPA (priv->solipa))
+               {
+                       g_warning ("No Solipa object found");
+                       return;
+               }
+
+       if (priv->columns->len)
+               {
+                       gstr = g_string_new ("");
+                       for (col = 0; col < priv->columns->len; col++)
+                               {
+                                       gcolumn = (GdaExGridColumn *)g_ptr_array_index (priv->columns, col);
+                                       if (gdaex_grid_column_get_visible (gcolumn))
+                                               {
+                                                       g_string_append_printf (gstr, "|%s", gdaex_grid_column_get_title (gcolumn));
+                                               }
+                                       else
+                                               {
+                                                       g_string_append (gstr, "|{SKIP}");
+                                               }
+                               }
+
+                       gchar **columns_title = g_strsplit (gstr->str + 1, "|", -1);
+
+                       solipa_gtktreemodel_to_csv_gui (priv->solipa, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (priv->view))), priv->model,
+                                                       columns_title, g_strv_length (columns_title));
+
+                       g_strfreev (columns_title);
+
+                       return;
+               }
+}
+#endif
+
+static gboolean
+gdaex_grid_on_button_press_event (GtkWidget *widget,
+                                  GdkEventButton *event,
+                                  gpointer user_data)
+{
+       GdaExGridPrivate *priv;
+
+       if (event->type == GDK_BUTTON_PRESS && event->button == 3)
+               {
+                       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+
+                       gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, NULL, NULL,
+                                       event->button, event->time);
+                       return TRUE;
+               }
+
+       return FALSE;
+}
+
+static gboolean
+gdaex_grid_on_popup_menu (GtkWidget *widget,
+                          gpointer user_data)
+{
+       GdaExGridPrivate *priv;
+
+       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+       gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, NULL, NULL,
+                       0, gtk_get_current_event_time ());
+
+       return TRUE;
+}
+
+static void
+gdaex_grid_on_menu_item_toggled (GtkCheckMenuItem *checkmenuitem,
+                                 gpointer user_data)
+{
+       GdaExGridPrivate *priv;
+
+       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+
+       GdaExGridColumn *gcolumn = g_object_get_data (G_OBJECT (checkmenuitem), "GdaExGridColumn");
+
+       gdaex_grid_column_set_visible (gcolumn,
+                                      gtk_check_menu_item_get_active (checkmenuitem));
+}
diff --git a/src/grid.h b/src/grid.h
new file mode 100644 (file)
index 0000000..cd41e42
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ *  grid.h
+ *
+ *  Copyright (C) 2010-2015 Andrea Zagli <azagli@libero.it>
+ *
+ *  This file is part of libgdaexgrid.
+ *
+ *  libgdaex is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  libgdaex 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with libgdaex; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __GDAEX_GRID_H__
+#define __GDAEX_GRID_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#ifdef SOLIPA_FOUND
+       #include <libsolipa/libsolipa.h>
+#endif
+
+#include <libgdaex/libgdaex.h>
+#include "gridcolumn.h"
+
+G_BEGIN_DECLS
+
+
+#define GDAEX_TYPE_GRID                 (gdaex_grid_get_type ())
+#define GDAEX_GRID(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDAEX_TYPE_GRID, GdaExGrid))
+#define GDAEX_GRID_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GDAEX_TYPE_GRID, GdaExGridClass))
+#define GDAEX_IS_GRID(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDAEX_TYPE_GRID))
+#define GDAEX_IS_GRID_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GDAEX_TYPE_GRID))
+#define GDAEX_GRID_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GDAEX_TYPE_GRID, GdaExGridClass))
+
+
+typedef struct _GdaExGrid GdaExGrid;
+typedef struct _GdaExGridClass GdaExGridClass;
+
+struct _GdaExGrid
+       {
+               GObject parent;
+       };
+
+struct _GdaExGridClass
+       {
+               GObjectClass parent_class;
+       };
+
+GType gdaex_grid_get_type (void) G_GNUC_CONST;
+
+
+GdaExGrid *gdaex_grid_new (void);
+
+void gdaex_grid_set_title (GdaExGrid *grid, const gchar *title);
+const gchar *gdaex_grid_get_title (GdaExGrid *grid);
+
+void gdaex_grid_add_column (GdaExGrid *grid, GdaExGridColumn *column);
+void gdaex_grid_add_columns (GdaExGrid *grid, GSList *columns);
+
+void gdaex_grid_clear (GdaExGrid *grid);
+
+GtkWidget *gdaex_grid_get_widget (GdaExGrid *grid);
+
+typedef void (*GdaExGridFillListStoreMissingFunc) (GtkListStore *lstore, GtkTreeIter *iter, gpointer user_data);
+
+gboolean gdaex_grid_fill_from_sql_with_missing_func (GdaExGrid *grid,
+                                                     GdaEx *gdaex,
+                                                     const gchar *sql,
+                                                     GdaExGridFillListStoreMissingFunc missing_func, gpointer user_data,
+                                                     GError **error);
+gboolean gdaex_grid_fill_from_datamodel_with_missing_func (GdaExGrid *grid,
+                                                           GdaDataModel *dm,
+                                                           GdaExGridFillListStoreMissingFunc missing_func, gpointer user_data,
+                                                           GError **error);
+
+gboolean gdaex_grid_fill_from_sql (GdaExGrid *grid, GdaEx *gdaex, const gchar *sql, GError **error);
+gboolean gdaex_grid_fill_from_datamodel (GdaExGrid *grid, GdaDataModel *dm, GError **error);
+
+#ifdef SOLIPA_FOUND
+void gdaex_grid_set_solipa (GdaExGrid *grid, Solipa *solipa);
+#endif
+
+
+G_END_DECLS
+
+#endif /* __GDAEX_GRID_H__ */
diff --git a/src/gridcolumn.c b/src/gridcolumn.c
new file mode 100644 (file)
index 0000000..65ce2fa
--- /dev/null
@@ -0,0 +1,407 @@
+/*
+ *  gridcolumn.c
+ *
+ *  Copyright (C) 2010-2015 Andrea Zagli <azagli@libero.it>
+ *
+ *  This file is part of libgdaexgrid.
+ *
+ *  libgdaex_grid_column is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  libgdaex_grid_column 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with libgdaex; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <libgda/libgda.h>
+
+#include "gridcolumn.h"
+
+static void gdaex_grid_column_class_init (GdaExGridColumnClass *klass);
+static void gdaex_grid_column_init (GdaExGridColumn *gdaex_grid_column);
+
+static void gdaex_grid_column_set_property (GObject *object,
+                               guint property_id,
+                               const GValue *value,
+                               GParamSpec *pspec);
+static void gdaex_grid_column_get_property (GObject *object,
+                               guint property_id,
+                               GValue *value,
+                               GParamSpec *pspec);
+
+#define GDAEX_GRID_COLUMN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDAEX_TYPE_GRID_COLUMN, GdaExGridColumnPrivate))
+
+typedef struct _GdaExGridColumnPrivate GdaExGridColumnPrivate;
+struct _GdaExGridColumnPrivate
+       {
+               gchar *title;
+               gchar *field_name;
+               GType type;
+               gboolean visible;
+               gboolean resizable;
+               gboolean sortable;
+               gboolean reorderable;
+               gint decimals;
+
+               GtkTreeViewColumn *vcolumn;
+       };
+
+G_DEFINE_TYPE (GdaExGridColumn, gdaex_grid_column, G_TYPE_OBJECT)
+
+static void
+gdaex_grid_column_class_init (GdaExGridColumnClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (object_class, sizeof (GdaExGridColumnPrivate));
+
+       object_class->set_property = gdaex_grid_column_set_property;
+       object_class->get_property = gdaex_grid_column_get_property;
+}
+
+static void
+gdaex_grid_column_init (GdaExGridColumn *gdaex_grid_column)
+{
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (gdaex_grid_column);
+
+       priv->title = NULL;
+       priv->field_name = NULL;
+       priv->type = G_TYPE_NONE;
+       priv->visible = FALSE;
+       priv->resizable = FALSE;
+       priv->sortable = FALSE;
+       priv->reorderable = FALSE;
+       priv->decimals = -1;
+       priv->vcolumn = NULL;
+}
+
+GdaExGridColumn
+*gdaex_grid_column_new (const gchar *title,
+                        const gchar *field_name,
+                        GType type,
+                        gboolean visible,
+                        gboolean resizable,
+                        gboolean sortable,
+                        gboolean reorderable,
+                        gint decimals)
+{
+       GdaExGridColumn *gdaex_grid_column = GDAEX_GRID_COLUMN (g_object_new (gdaex_grid_column_get_type (), NULL));
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (gdaex_grid_column);
+
+       gdaex_grid_column_set_title (gdaex_grid_column, title);
+       gdaex_grid_column_set_field_name (gdaex_grid_column, field_name);
+       gdaex_grid_column_set_gtype (gdaex_grid_column, type);
+       gdaex_grid_column_set_visible (gdaex_grid_column, visible);
+       gdaex_grid_column_set_resizable (gdaex_grid_column, resizable);
+       gdaex_grid_column_set_sortable (gdaex_grid_column, sortable);
+       gdaex_grid_column_set_reorderable (gdaex_grid_column, reorderable);
+       gdaex_grid_column_set_decimals (gdaex_grid_column, decimals);
+
+       return gdaex_grid_column;
+}
+
+GdaExGridColumn
+*gdaex_grid_column_new_defaults (const gchar *title,
+                                 const gchar *field_name,
+                                 GType type)
+{
+       return gdaex_grid_column_new (title,
+                                     field_name,
+                                     type,
+                                     TRUE,
+                                     TRUE,
+                                     TRUE,
+                                     TRUE,
+                                     type == G_TYPE_FLOAT || type == G_TYPE_DOUBLE ? 2 : 0);
+}
+
+void
+gdaex_grid_column_set_title (GdaExGridColumn *column, const gchar *title)
+{
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       g_free (priv->title);
+       priv->title = g_strdup (title);
+
+       if (priv->vcolumn != NULL)
+               {
+                       gtk_tree_view_column_set_title (priv->vcolumn, priv->title);
+               }
+}
+
+const gchar
+*gdaex_grid_column_get_title (GdaExGridColumn *column)
+{
+       g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), NULL);
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       return (const gchar *)g_strdup (priv->title);
+}
+
+void
+gdaex_grid_column_set_field_name (GdaExGridColumn *column, const gchar *field_name)
+{
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       g_free (priv->field_name);
+       priv->field_name = g_strdup (field_name);
+}
+
+const gchar
+*gdaex_grid_column_get_field_name (GdaExGridColumn *column)
+{
+       g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), NULL);
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       return (const gchar *)g_strdup (priv->field_name);
+}
+
+void
+gdaex_grid_column_set_gtype (GdaExGridColumn *column, GType type)
+{
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       priv->type = type;
+}
+
+GType
+gdaex_grid_column_get_gtype (GdaExGridColumn *column)
+{
+       g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), G_TYPE_NONE);
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       return priv->type;
+}
+
+void
+gdaex_grid_column_set_visible (GdaExGridColumn *column, gboolean visible)
+{
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       priv->visible = visible;
+
+       if (priv->vcolumn != NULL)
+               {
+                       gtk_tree_view_column_set_visible (priv->vcolumn, priv->visible);
+               }
+}
+
+gboolean
+gdaex_grid_column_get_visible (GdaExGridColumn *column)
+{
+       g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       return priv->visible;
+}
+
+void
+gdaex_grid_column_set_resizable (GdaExGridColumn *column, gboolean resizable)
+{
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       priv->resizable = resizable;
+
+       if (priv->vcolumn != NULL)
+               {
+                       gtk_tree_view_column_set_resizable (priv->vcolumn, priv->resizable);
+               }
+}
+
+gboolean
+gdaex_grid_column_get_resizable (GdaExGridColumn *column)
+{
+       g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       return priv->resizable;
+}
+
+void
+gdaex_grid_column_set_sortable (GdaExGridColumn *column, gboolean sortable)
+{
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       priv->sortable = sortable;
+
+       if (priv->vcolumn != NULL)
+               {
+                       gtk_tree_view_column_set_clickable (priv->vcolumn, priv->sortable);
+               }
+}
+
+gboolean
+gdaex_grid_column_get_sortable (GdaExGridColumn *column)
+{
+       g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       return priv->sortable;
+}
+
+void
+gdaex_grid_column_set_reorderable (GdaExGridColumn *column, gboolean reorderable)
+{
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       priv->reorderable = reorderable;
+
+       if (priv->vcolumn != NULL)
+               {
+                       gtk_tree_view_column_set_reorderable (priv->vcolumn, priv->reorderable);
+               }
+}
+
+gboolean
+gdaex_grid_column_get_reorderable (GdaExGridColumn *column)
+{
+       g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       return priv->reorderable;
+}
+
+void
+gdaex_grid_column_set_decimals (GdaExGridColumn *column, gint decimals)
+{
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       priv->decimals = decimals;
+}
+
+gint
+gdaex_grid_column_get_decimals (GdaExGridColumn *column)
+{
+       g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
+
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       return priv->decimals;
+}
+
+GtkTreeViewColumn
+*gdaex_grid_column_get_column (GdaExGridColumn *column)
+{
+       GdaExGridColumnPrivate *priv;
+
+       GtkCellRenderer *renderer;
+
+       g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), NULL);
+
+       priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+       renderer = NULL;
+       if (priv->type == G_TYPE_STRING
+           || priv->type == G_TYPE_DATE
+           || priv->type == G_TYPE_DATE_TIME
+           || priv->type == GDA_TYPE_TIMESTAMP)
+               {
+                       renderer = gtk_cell_renderer_text_new ();
+               }
+       else if (priv->type == G_TYPE_INT
+           || priv->type == G_TYPE_FLOAT
+           || priv->type == G_TYPE_DOUBLE)
+               {
+                       if (priv->decimals > -1)
+                               {
+                                       renderer = gtk_cell_renderer_text_new ();
+                               }
+                       else
+                               {
+                                       renderer = gtk_cell_renderer_spin_new ();
+                               }
+                       gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
+               }
+       else if (priv->type == G_TYPE_BOOLEAN)
+               {
+                       renderer = gtk_cell_renderer_toggle_new ();
+                       gtk_cell_renderer_set_alignment (renderer, 0.5, 0.5);
+               }
+       else
+               {
+                       g_warning ("Error on creating the renderer for column «%s».", priv->title);
+                       return NULL;
+               }
+
+       if (priv->vcolumn != NULL)
+               {
+                       g_object_unref (priv->vcolumn);
+               }
+       priv->vcolumn = gtk_tree_view_column_new ();
+
+       gtk_tree_view_column_pack_start (priv->vcolumn, renderer, TRUE);
+
+       gtk_tree_view_column_set_title (priv->vcolumn, priv->title);
+       gtk_tree_view_column_set_resizable (priv->vcolumn, priv->resizable);
+       gtk_tree_view_column_set_clickable (priv->vcolumn, priv->sortable);
+       gtk_tree_view_column_set_reorderable (priv->vcolumn, priv->reorderable);
+
+       gtk_tree_view_column_set_visible (priv->vcolumn, priv->visible);
+
+       return priv->vcolumn;
+}
+
+/* PRIVATE */
+static void
+gdaex_grid_column_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+       GdaExGridColumn *gdaex_grid_column = GDAEX_GRID_COLUMN (object);
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (gdaex_grid_column);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+gdaex_grid_column_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+       GdaExGridColumn *gdaex_grid_column = GDAEX_GRID_COLUMN (object);
+       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (gdaex_grid_column);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
diff --git a/src/gridcolumn.h b/src/gridcolumn.h
new file mode 100644 (file)
index 0000000..df17572
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ *  gridcolumn.h
+ *
+ *  Copyright (C) 2010-2015 Andrea Zagli <azagli@libero.it>
+ *
+ *  This file is part of libgdaexgrid.
+ *
+ *  libgdaex is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  libgdaex 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with libgdaex; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __GDAEX_GRID_COLUMN_H__
+#define __GDAEX_GRID_COLUMN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+
+#define GDAEX_TYPE_GRID_COLUMN                 (gdaex_grid_column_get_type ())
+#define GDAEX_GRID_COLUMN(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDAEX_TYPE_GRID_COLUMN, GdaExGridColumn))
+#define GDAEX_GRID_COLUMN_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GDAEX_TYPE_GRID_COLUMN, GdaExGridColumnClass))
+#define GDAEX_IS_GRID_COLUMN(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDAEX_TYPE_GRID_COLUMN))
+#define GDAEX_IS_GRID_COLUMN_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GDAEX_TYPE_GRID_COLUMN))
+#define GDAEX_GRID_COLUMN_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GDAEX_TYPE_GRID_COLUMN, GdaExGridColumnClass))
+
+
+typedef struct _GdaExGridColumn GdaExGridColumn;
+typedef struct _GdaExGridColumnClass GdaExGridColumnClass;
+
+struct _GdaExGridColumn
+       {
+               GObject parent;
+       };
+
+struct _GdaExGridColumnClass
+       {
+               GObjectClass parent_class;
+       };
+
+GType gdaex_grid_column_get_type (void) G_GNUC_CONST;
+
+
+GdaExGridColumn *gdaex_grid_column_new (const gchar *title,
+                                        const gchar *field_name,
+                                        GType type,
+                                        gboolean visible,
+                                        gboolean resizable,
+                                        gboolean sortable,
+                                        gboolean reorderable,
+                                        gint decimals);
+
+GdaExGridColumn *gdaex_grid_column_new_defaults (const gchar *title,
+                                                 const gchar *field_name,
+                                                 GType type);
+
+void gdaex_grid_column_set_title (GdaExGridColumn *column, const gchar *title);
+const gchar *gdaex_grid_column_get_title (GdaExGridColumn *column);
+
+void gdaex_grid_column_set_field_name (GdaExGridColumn *column, const gchar *field_name);
+const gchar *gdaex_grid_column_get_field_name (GdaExGridColumn *column);
+
+void gdaex_grid_column_set_gtype (GdaExGridColumn *column, GType type);
+GType gdaex_grid_column_get_gtype (GdaExGridColumn *column);
+
+void gdaex_grid_column_set_visible (GdaExGridColumn *column, gboolean visible);
+gboolean gdaex_grid_column_get_visible (GdaExGridColumn *column);
+
+void gdaex_grid_column_set_resizable (GdaExGridColumn *column, gboolean resizable);
+gboolean gdaex_grid_column_get_resizable (GdaExGridColumn *column);
+
+void gdaex_grid_column_set_sortable (GdaExGridColumn *column, gboolean sortable);
+gboolean gdaex_grid_column_get_sortable (GdaExGridColumn *column);
+
+void gdaex_grid_column_set_reorderable (GdaExGridColumn *column, gboolean reorderable);
+gboolean gdaex_grid_column_get_reorderable (GdaExGridColumn *column);
+
+void gdaex_grid_column_set_decimals (GdaExGridColumn *column, gint decimals);
+gint gdaex_grid_column_get_decimals (GdaExGridColumn *column);
+
+GtkTreeViewColumn *gdaex_grid_column_get_column (GdaExGridColumn *column);
+
+
+G_END_DECLS
+
+#endif /* __GDAEX_GRID_COLUMN_H__ */
diff --git a/src/libgdaexgrid.h b/src/libgdaexgrid.h
new file mode 100644 (file)
index 0000000..2469d10
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ *
+ * 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 Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGDAEXGRID_H__
+#define __LIBGDAEXGRID_H__
+
+#include <libgdaexgrid/grid.h>
+#include <libgdaexgrid/gridcolumn.h>
+
+#endif /* __LIBGDAEXGRID_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..9b87529
--- /dev/null
@@ -0,0 +1,21 @@
+LIBS = $(GDAEX_LIBS) \
+       -export-dynamic
+
+AM_CPPFLAGS = $(GDAEX_CFLAGS) \
+              -I$(top_srcdir)/src \
+              -DTESTSDIR="\"@abs_builddir@\""
+
+if LIBSOLIPA_FOUND
+AM_CPPFLAGS += \
+               $(SOLIPA_CFLAGS) \
+               -DSOLIPA_FOUND=1
+
+LIBS += \
+        $(SOLIPA_LIBS)
+endif
+
+noinst_PROGRAMS = grid
+
+LDADD = $(top_builddir)/src/libgdaexgrid.la
+
+EXTRA_DIST = grid.db
diff --git a/tests/grid.c b/tests/grid.c
new file mode 100644 (file)
index 0000000..57e1e04
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2011-2015 Andrea Zagli <azagli@libero.it>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <libgdaex/libgdaex.h>
+
+#include "grid.h"
+#include "gridcolumn.h"
+
+GdaExGridColumn *gcol_birthday;
+
+static void
+missing_func (GtkListStore *lstore, GtkTreeIter *iter, gpointer user_data)
+{
+       gtk_list_store_set (lstore, iter,
+                           7, "missing",
+                           -1);
+}
+
+static void
+on_btn_birthday_clicked (GtkButton *button,
+                         gpointer user_data)
+{
+       gdaex_grid_column_set_visible (gcol_birthday, !gdaex_grid_column_get_visible (gcol_birthday));
+}
+
+int
+main (int argc, char **argv)
+{
+       GdaEx *gdaex;
+
+       GtkWidget *w;
+       GtkWidget *vbox;
+       GtkWidget *scrolledw;
+       GtkWidget *hbtnbox;
+       GtkWidget *btn;
+
+       GdaExGrid *grid;
+       GdaExGridColumn *gcol;
+       GtkWidget *wgrid;
+
+       gtk_init (&argc, &argv);
+
+       gdaex = gdaex_new_from_string (g_strdup_printf ("SQLite://DB_DIR=%s;DB_NAME=grid.db", TESTSDIR));
+       if (gdaex == NULL)
+               {
+                       g_error ("Unable to connect to the db.");
+               }
+
+       w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       gtk_window_set_default_size (GTK_WINDOW (w), 550, 350);
+       g_signal_connect (w, "delete-event",
+                         G_CALLBACK (gtk_false), NULL);
+       g_signal_connect (w, "destroy",
+                         G_CALLBACK (gtk_main_quit), NULL);
+
+       vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+       gtk_container_add (GTK_CONTAINER (w), vbox);
+
+       scrolledw = gtk_scrolled_window_new (NULL, NULL);
+       gtk_box_pack_start (GTK_BOX (vbox), scrolledw, TRUE, TRUE, 0);
+
+       grid = gdaex_grid_new ();
+       gdaex_grid_set_title (grid, "The grid title");
+
+#ifdef SOLIPA_FOUND
+       gdaex_grid_set_solipa (grid, solipa_new ());
+#endif
+
+       gcol = gdaex_grid_column_new ("ID", "id", G_TYPE_INT, TRUE, FALSE, FALSE, FALSE, -1);
+       gdaex_grid_add_column (grid, gcol);
+
+       gcol = gdaex_grid_column_new ("Name", "name", G_TYPE_STRING, TRUE, TRUE, TRUE, TRUE, -1);
+       gdaex_grid_add_column (grid, gcol);
+
+       gcol = gdaex_grid_column_new_defaults ("Surname", "surname", G_TYPE_STRING);
+       gdaex_grid_add_column (grid, gcol);
+
+       gcol = gdaex_grid_column_new_defaults ("Age", "age", G_TYPE_INT);
+       gdaex_grid_add_column (grid, gcol);
+
+       gcol_birthday = gdaex_grid_column_new ("Birthday", "birthday", G_TYPE_DATE, FALSE, TRUE, TRUE, TRUE, -1);
+       gdaex_grid_add_column (grid, gcol_birthday);
+
+       gcol = gdaex_grid_column_new_defaults ("Incoming", "incoming", G_TYPE_DOUBLE);
+       gdaex_grid_add_column (grid, gcol);
+
+       gcol = gdaex_grid_column_new ("Married", "married", G_TYPE_BOOLEAN, TRUE, TRUE, TRUE, TRUE, -1);
+       gdaex_grid_add_column (grid, gcol);
+
+       gcol = gdaex_grid_column_new_defaults ("Missing", "missing", G_TYPE_STRING);
+       gdaex_grid_add_column (grid, gcol);
+
+       wgrid = gdaex_grid_get_widget (grid);
+       gtk_container_add (GTK_CONTAINER (scrolledw), wgrid);
+
+       gdaex_grid_fill_from_sql_with_missing_func (grid, gdaex, "SELECT * FROM clients", missing_func, NULL, NULL);
+
+       hbtnbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
+       gtk_box_pack_start (GTK_BOX (vbox), hbtnbox, FALSE, FALSE, 0);
+
+       btn = gtk_button_new_with_label ("Hide/Show Birthday");
+       gtk_box_pack_start (GTK_BOX (hbtnbox), btn, TRUE, TRUE, 0);
+
+       g_signal_connect (G_OBJECT (btn), "clicked",
+                         G_CALLBACK (on_btn_birthday_clicked), NULL);
+
+       gtk_widget_show_all (w);
+
+       gtk_main ();
+
+       return 0;
+}
diff --git a/tests/grid.db b/tests/grid.db
new file mode 100644 (file)
index 0000000..abc3267
Binary files /dev/null and b/tests/grid.db differ