From: Alan Knowles Date: Mon, 13 Jun 2016 02:52:48 +0000 (+0800) Subject: initialize with copy of old builder X-Git-Tag: release-4.4.2~592 X-Git-Url: http://git.roojs.org/?p=roobuilder;a=commitdiff_plain;h=c55a8adafa47e52657fbe581c1de501bf7d3eeb8 initialize with copy of old builder --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 000000000..5088c1814 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,3 @@ +authors + +Alan Knowles diff --git a/COPYING b/COPYING new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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. + + + Copyright (C) + + 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 . + +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: + + Copyright (C) + 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 +. + + 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 +. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 000000000..e69de29bb diff --git a/INSTALL b/INSTALL new file mode 100644 index 000000000..209984075 --- /dev/null +++ b/INSTALL @@ -0,0 +1,370 @@ +Installation Instructions +************************* + +Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, +Inc. + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. + +Basic Installation +================== + + Briefly, the shell command `./configure && make && make install' +should configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + + The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package, generally using the just-built uninstalled binaries. + + 4. Type `make install' to install the programs and any data files and + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. + + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS + KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf limitation. Until the limitation is lifted, you can use +this workaround: + + CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. diff --git a/INSTALL.txt b/INSTALL.txt new file mode 100644 index 000000000..17bcd8632 --- /dev/null +++ b/INSTALL.txt @@ -0,0 +1,24 @@ + + +apt-cache search '^valac-[0-9.]+$' | sort -n -r | head -n 1 | awk ' { print "sudo apt-get install -y " $1 }' | sh +apt-cache search '^valac-[0-9.]+-vapi$' | sort -n -r | head -n 1 | awk ' { print "sudo apt-get install -y " $1 }' | sh +apt-cache search '^libvala-[0-9.]+-dev$' | sort -n -r | head -n1 | awk ' { print "sudo apt-get install -y " $1 }' | sh + + +apt-cache search '^libvte-[0-9.]+-dev$' | sort -n -r | head -n1 | awk ' { print "sudo apt-get install -y " $1 }' | sh + + +sudo apt-get install libgtk-3-dev libgtksourceview-3.0-dev libxml2-dev libjson-glib-dev libgee-dev \ + libgirepository1.0-dev + +# not sure why we are not using 4 yet? + +sudo apt-get install libwebkit2gtk-3.0-dev +sudo apt-get install libwebkit2gtk-4.0-dev +sudo apt-get install libclutter-gtk-1.0-dev libgladeui-dev libsoup2.4-dev \ + libjavascriptcoregtk-3.0-dev + +// test + + + \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index 60db30218..b94955203 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,6 @@ -SUBDIRS = src \ No newline at end of file +SUBDIRS = src pixmaps + +desktopdir = $(datadir)/applications +desktop_DATA =roobuilder.desktop diff --git a/NEWS b/NEWS new file mode 100644 index 000000000..4327969d6 --- /dev/null +++ b/NEWS @@ -0,0 +1 @@ +news diff --git a/README b/README new file mode 100644 index 000000000..8178c76d6 --- /dev/null +++ b/README @@ -0,0 +1 @@ +readme diff --git a/README.txt b/README.txt new file mode 100644 index 000000000..f912c7325 --- /dev/null +++ b/README.txt @@ -0,0 +1,106 @@ +App Builder + +This is a Seed based application builder.. - currently basically a prototype.. + + +The idea is that it can build applications both web based (using roojs) and Desktop based using Gtk +and the gobject introspection bindings. + +It's kind of like Glade on steroids.. + +---------------------------------------------------- +Usage: + +seed gtkrun.js Builder + +-> create a project +-> add a folder to the project +-> add a file to the project.. +Files are JSON data files at present.. + +----------------------------------------------------- +Where it is.. + +* basic builder app runs - you can build a tree of elements making up a interface for roo and gtk. +* listeners are created correctly. +* listeners with gtk prototypes +* Gtk properties that are enums - now show a combo selector.. +* application is used to write itself... +* Projects can be created and deleted (basically a directory) +* sourceview to uses spaces rather than tabs. (and autoindents..) +* Help view - load docs.. +* highlight in gtk preview - works but is klunky.. +* Support for extra code in Roo HTML is done by "Set extra HTML in rendere" + + +----------------------------------------------------- +INSTALL +GTK3 + +git clone git://github.com/roojs/app.Builder.js.git +cd app.Builder.js +git clone git://github.com/roojs/gir-1.2-gtk-3.4.git gir-1.2 +cd gir-1.2 +sh install-girs.sh +** This file may need running as root if sudo fails.. +cd .. + +seed gtkrun.js Builder3 + + + +----------------------------------------------------- + +TODO (Gtk) +* Tables are not rendering first time round.. +* Dialog buttons - need special rendering on preview. +* Icon-size (should be an enum...??) +* (Image|....??? ).stock - should be a list of stock icons.. +* fix pulldowns for types.. - it's a bit hap hazard with the delayed / loading of settings. +* packing - gather from methods to find out which match.. (including false) +* adding a file does not display on project tree straight awya.. +* templates for elements... - eg. defaults for classic elements. +* sort out add heirachy for Gtk.. +* Project Tree needs to work perhaps like a left hand popout. +* make heirachy editor... +* new file = should specify type (eg. gtk window etc..) +* Help view - next/back.. url? +----------------------------------------------------- + +TODO (Roo) +* file properties - title, parent etc.. + +----------------------------------------------------- + +Thoughts... +* Widget definition files.. (to replace our 'Usage.txt' files) +-> defaults { ... } +-> onAdd(name_of_parent, cfg) { modifies defaults.. } +-> validParents : [ .... ] +-> validChildren???: [ .... ] + +* how to handle stuff like GtkTable.. - + - needs cols,rows in constructor. + - child properties do not appear to work? -- investigate? + +* XObject - Use Buildable interface??? + +* Preview area - use glade widgets? + +----------------------------------------------------- +Concepts + +Basically both Roo and JS are built using a tree of elements (tagged with xtype/xns) +sub elements always go in the items array.. +we have some special properties of elements, eg. + +*prop (a property of the parent) +xtype (element type) eg. Window / Button etc.. +|xns (namespace) = eg. Gtk/Roo etc. + +|**** anything starting with a pipe is raw data field rather than quoted.. + + +each element can have a property listeners which is where the listeners go... + + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 000000000..f7996a97e --- /dev/null +++ b/autogen.sh @@ -0,0 +1,127 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +DIE=0 + +(test -f $srcdir/configure.ac) || { + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level package directory" + exit 1 +} + +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`autoconf' installed." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +#?? needed?? +(grep "^IT_PROG_INTLTOOL" $srcdir/configure.ac >/dev/null) && { + (intltoolize --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`intltool' installed." + echo "You can get it from:" + echo " ftp://ftp.gnome.org/pub/GNOME/" + DIE=1 + } +} + + +(grep "^LT_INIT" $srcdir/configure.ac >/dev/null) && { + (libtool --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`libtool' installed." + echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" + DIE=1 + } +} + +(automake --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`automake' installed." + echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" + DIE=1 + NO_AUTOMAKE=yes +} + + +# if no automake, don't bother testing for aclocal +test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: Missing \`aclocal'. The version of \`automake'" + echo "installed doesn't appear recent enough." + echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +if test "$DIE" -eq 1; then + exit 1 +fi + +if test -z "$*"; then + echo "**Warning**: I am going to run \`configure' with no arguments." + echo "If you wish to pass any to it, please specify them on the" + echo \`$0\'" command line." + echo +fi + +case $CC in +xlc ) + am_opt=--include-deps;; +esac + + +dr=$srcdir +if test -f $dr/NO-AUTO-GEN; then + echo skipping $dr -- flagged as no auto-gen +else + echo processing $dr + ( cd $dr + + aclocalinclude="$ACLOCAL_FLAGS" + + if grep "^AM_GLIB_GNU_GETTEXT" configure.ac >/dev/null; then + echo "Creating $dr/aclocal.m4 ..." + test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 + + echo "Making $dr/aclocal.m4 writable ..." + test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 + fi + + # if grep "^IT_PROG_INTLTOOL" configure.ac >/dev/null; then + # echo "Running intltoolize..." + #intltoolize --copy --force --automake + # fi + # + if grep "^LT_INIT" configure.ac >/dev/null; then + if test -z "$NO_LIBTOOLIZE" ; then + echo "Running libtoolize..." + libtoolize --force --copy + fi + fi + echo "Running aclocal $aclocalinclude ..." + aclocal $aclocalinclude + if grep "^A[CM]_CONFIG_HEADER" configure.ac >/dev/null; then + echo "Running autoheader..." + autoheader + fi + echo "Running automake $am_opt ..." + automake --add-missing --copy $am_opt + echo "Running autoconf ..." + autoconf + ) +fi + + +if test x$NOCONFIGURE = x; then + echo Running $srcdir/configure "$@" ... + $srcdir/configure "$@" \ + && echo Now type \`make\' to compile. || exit 1 +else + echo Skipping configure process. +fi \ No newline at end of file diff --git a/configure.ac b/configure.ac index aa100373f..7184541a4 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.68]) -AC_INIT([builder], [4.0.0]) +AC_INIT([roobuilder], [4.0.0]) AC_CONFIG_HEADERS([config.h]) @@ -20,7 +20,7 @@ AC_CHECK_LIB([m],[cos]) dnl we need to check these exist, then it will generate a compile string for them. -PKG_CHECK_MODULES(BUILDER, [ +PKG_CHECK_MODULES(ROOBUILDER, [ clutter-gtk-1.0 glib-2.0 >= 2.24.1 gobject-2.0 >= 2.24.1 @@ -29,48 +29,55 @@ PKG_CHECK_MODULES(BUILDER, [ json-glib-1.0 gee-1.0 libxml-2.0 - libsoup-2.4 + libsoup-2.4, + roojspacker-1.0 ]) dnl --- libvala -- needs to find matching really.. - -PKG_CHECK_MODULES(LIBVALA30, [libvala-0.30], - [vala_3_0_enabled=yes], - [vala_3_0_enabled=no]) -if test $vala_3_0_enabled = yes; then - AC_DEFINE(HAVE_LIBVALA30,1,[libvala 0.30 support]) -else - PKG_CHECK_MODULES(LIBVALA28, [libvala-0.28], - [vala_2_8_enabled=yes], - [vala_2_8_enabled=no]) - if test $vala_2_8_enabled = yes; then - AC_DEFINE(HAVE_LIBVALA28,1,[libvala 0.28 support]) - else - PKG_CHECK_MODULES(LIBVALA26, [libvala-0.26], - [vala_2_6_enabled=yes], - [vala_2_6_enabled=no]) - - if test $vala_2_6_enabled = yes; then - AC_DEFINE(HAVE_LIBVALA26,1,[libvala 0.26 support]) - else - PKG_CHECK_MODULES(LIBVALA24, [libvala-0.24], - [vala_2_4_enabled=yes], - [vala_2_4_enabled=no]) - - if test $vala_2_4_enabled = yes; then - AC_DEFINE(HAVE_LIBVALA24,1,[libvala 0.24 support]) - else - PKG_CHECK_MODULES(LIBVALA22, [libvala-0.22], - [vala_2_2_enabled=yes] ) - - AC_DEFINE(HAVE_LIBVALA22,1,[libvala 0.22 support]) - fi - fi +PKG_CHECK_MODULES(LIBVALA, [libvala-0.32], + [vala_3_2_enabled=yes], + [vala_3_2_enabled=no]) +if test $vala_3_2_enabled = yes; then + AC_DEFINE(HAVE_LIBVALA32,1,[libvala 0.32 support]) +else + PKG_CHECK_MODULES(LIBVALA, [libvala-0.30], + [vala_3_0_enabled=yes], + [vala_3_0_enabled=no]) + if test $vala_3_0_enabled = yes; then + AC_DEFINE(HAVE_LIBVALA30,1,[libvala 0.30 support]) + else + PKG_CHECK_MODULES(LIBVALA, [libvala-0.28], + [vala_2_8_enabled=yes], + [vala_2_8_enabled=no]) + if test $vala_2_8_enabled = yes; then + AC_DEFINE(HAVE_LIBVALA28,1,[libvala 0.28 support]) + else + PKG_CHECK_MODULES(LIBVALA, [libvala-0.26], + [vala_2_6_enabled=yes], + [vala_2_6_enabled=no]) + + if test $vala_2_6_enabled = yes; then + AC_DEFINE(HAVE_LIBVALA26,1,[libvala 0.26 support]) + else + PKG_CHECK_MODULES(LIBVALA, [libvala-0.24], + [vala_2_4_enabled=yes], + [vala_2_4_enabled=no]) + + if test $vala_2_4_enabled = yes; then + AC_DEFINE(HAVE_LIBVALA24,1,[libvala 0.24 support]) + else + PKG_CHECK_MODULES(LIBVALA, [libvala-0.22], + [vala_2_2_enabled=yes] ) + + AC_DEFINE(HAVE_LIBVALA22,1,[libvala 0.22 support]) + fi + fi + fi fi - fi +AM_CONDITIONAL(HAVE_LIBVALA32, test "$vala_3_2_enabled" = "yes") AM_CONDITIONAL(HAVE_LIBVALA30, test "$vala_3_0_enabled" = "yes") AM_CONDITIONAL(HAVE_LIBVALA28, test "$vala_2_8_enabled" = "yes") AM_CONDITIONAL(HAVE_LIBVALA26, test "$vala_2_6_enabled" = "yes") @@ -162,11 +169,12 @@ AM_CONDITIONAL(HAVE_VTE_2_91, test "$vte_2_91_enabled" = "yes") AC_CONFIG_FILES([ Makefile src/Makefile + pixmaps/Makefile ]) -AC_SUBST(BUILDER_CFLAGS) -AC_SUBST(BUILDER_LIBS) +AC_SUBST(ROOBUILDER_CFLAGS) +AC_SUBST(ROOBUILDER_LIBS) AC_OUTPUT diff --git a/pixmaps/16x16/apps/roobuilder.png b/pixmaps/16x16/apps/roobuilder.png new file mode 100644 index 000000000..8144c1b03 Binary files /dev/null and b/pixmaps/16x16/apps/roobuilder.png differ diff --git a/pixmaps/22x22/apps/roobuilder.png b/pixmaps/22x22/apps/roobuilder.png new file mode 100644 index 000000000..8144c1b03 Binary files /dev/null and b/pixmaps/22x22/apps/roobuilder.png differ diff --git a/pixmaps/24x24/apps/roobuilder.png b/pixmaps/24x24/apps/roobuilder.png new file mode 100644 index 000000000..8144c1b03 Binary files /dev/null and b/pixmaps/24x24/apps/roobuilder.png differ diff --git a/pixmaps/32x32/apps/roobuilder.png b/pixmaps/32x32/apps/roobuilder.png new file mode 100644 index 000000000..8144c1b03 Binary files /dev/null and b/pixmaps/32x32/apps/roobuilder.png differ diff --git a/pixmaps/48x48/apps/roobuilder.png b/pixmaps/48x48/apps/roobuilder.png new file mode 100644 index 000000000..8144c1b03 Binary files /dev/null and b/pixmaps/48x48/apps/roobuilder.png differ diff --git a/pixmaps/Makefile.am b/pixmaps/Makefile.am new file mode 100644 index 000000000..14d5f5cc6 --- /dev/null +++ b/pixmaps/Makefile.am @@ -0,0 +1,58 @@ +public_icons_themes = hicolor + +iconsdir = $(datadir)/icons/hicolor + +public_icon_dirs = \ + 16x16/apps \ + 22x22/apps \ + 24x24/apps \ + 32x32/apps \ + 48x48/apps + +public_icons = \ + 16x16/apps/roobuilder.png \ + 22x22/apps/roobuilder.png \ + 24x24/apps/roobuilder.png \ + 32x32/apps/roobuilder.png \ + 48x48/apps/roobuilder.png + +gtk_update_icon_cache = gtk-update-icon-cache -f -t + +EXTRA_DIST = \ + $(public_icons) + +install-data-hook: update-icon-cache +uninstall-hook: update-icon-cache + + + +update-icon-cache: + @-if test -z "$(DESTDIR)"; then \ + echo "Updating Gtk icon cache."; \ + for theme in $(public_icons_themes); do \ + $(gtk_update_icon_cache) $(datadir)/icons/$$theme; \ + done; \ + else \ + echo "*** Icon cache not updated. After (un)install, run this:"; \ + for theme in $(public_icons_themes); do \ + echo "*** $(gtk_update_icon_cache) $(datadir)/icons/$$theme"; \ + done; \ + fi + +install-icons: + for icon in $(public_icon_dirs); do \ + mkdir -p $(DESTDIR)$(datadir)/icons/hicolor/$$icon; \ + $(INSTALL_DATA) $(srcdir)/$$icon/roobuilder.png $(DESTDIR)$(datadir)/icons/hicolor/$$icon/roobuilder.png; \ + done; + +uninstall-icons: + -for icon in $(public_icons_dirs); do \ + rm -f $(DESTDIR)$(datadir)/icons/hicolor/$$icon/roobuilder.png; \ + done; + + +install-data-local: install-icons update-icon-cache + +uninstall-local: uninstall-icons update-icon-cache + + diff --git a/resources/Editors/Editor.Roo.GridPanel.bjs b/resources/Editors/Editor.Roo.GridPanel.bjs new file mode 100644 index 000000000..effbc0c09 --- /dev/null +++ b/resources/Editors/Editor.Roo.GridPanel.bjs @@ -0,0 +1,147 @@ +{ + "name" : "Editor.Roo.GridPanel", + "parent" : "", + "title" : "", + "path" : "/home/edward/gitlive/app.Builder.js/resources/Editors/Editor.Roo.GridPanel.bjs", + "permname" : "", + "modOrder" : "001", + "strings" : { + "4ce58cbe362a5d7b156992a496d55bf3" : "Database Column", + "b78a3223503896721cca1303f776159b" : "Title", + "2f616612593df62aeed112de4f03110e" : "Edit a Grid", + "0ccc2bf3fb98387c23b6ca5500244d6e" : "Use ", + "c671c787b49f50a3ace9fdc5bd597825" : "core_enum", + "32954654ac8fe66a1d09be19001de2d4" : "Width", + "a1fa27779242b4902f7ae3bdd5c6d508" : "Type", + "6e7376dca68a2386a8737944196ab491" : "Create / Edit Grid" + }, + "items" : [ + { + "listeners" : { + "|activate" : "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}" + }, + "| function loadData" : "function(data) { \n\n alert(\"IPC:TEST:\" + JSON.stringify(data,null,4));\n var ar = [];\n for (var k in data) { \n var r = data[k];\n var has_s = typeof(r.relates_to_schema) != 'undefined'\n ar.push([ !has_s , r.Field, r.Type, r.Field, 100] );\n if (!has_s) {\n continue;\n }\n for (var kk in r.relates_to_schema) { \n var rr = r.relates_to_schema[kk];\n if (rr.Field == r.relates_to_col) {\n continue;\n }\n ar.push([ false, r.Field + '_'+ rr.Field, rr.Type, rr.Field, 100] );\n }\n }\n \n alert(\"IPC:TEST:\" + JSON.stringify(ar));\n this.grid.dataSource.loadData(ar);\n}", + "| function toBJS" : "function() { \n\n// convert the selected cells into a BJS data ready to send back to the UI..\n \n this.table = \"XXX\";\n this.firstTxtCol = \"XXX\";\n \n \n var jreader = {};\n var colmodel = [];\n this.grid.dataSource.each(function(rec) {\n if (!rec.data.active) {\n return;\n }\n \n \n \n colmodel.push({\n \"xtype\": \"ColumnModel\",\n \"header\": rec.data.title,\n \"width\": rec.data.width * 1,\n \"dataIndex\": rec.data.dataIndex,\n \"|renderer\": !rec.data.type.match(/date/i) ? \n \"function(v) { return String.format('{0}', v); }\" :\n \"function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }\" , // special for date\n \"|xns\": \"Roo.grid\",\n \"*prop\": \"cm[]\"\n });\n });\n \n \n \n\n alert(\"IPC:OUT:\" + JSON.stringify({\n '|xns' : 'Roo',\n xtype : \"GridPanel\",\n \"title\": this.table,\n \"fitToframe\": true,\n \"fitContainer\": true,\n \"tableName\": this.table,\n \"background\": true,\n \"region\" : 'center',\n \"listeners\": {\n \"|activate\": \"function() {\\n _this.panel = this;\\n if (_this.grid) {\\n _this.grid.footer.onClick('first');\\n }\\n}\"\n },\n \"items\": [\n {\n \"*prop\": \"grid\",\n \"xtype\": \"Grid\",\n \"autoExpandColumn\": this.firstTxtCol,\n \"loadMask\": true,\n \"listeners\": {\n \"|render\": \"function() \\n\" +\n \"{\\n\" +\n \" _this.grid = this; \\n\" +\n \" //_this.dialog = Pman.Dialog.FILL_IN\\n\" +\n \" if (_this.panel.active) {\\n\" +\n \" this.footer.onClick('first');\\n\" +\n \" }\\n\" +\n \"}\",\n \"|rowdblclick\": \"function (_self, rowIndex, e)\\n\" + \n \"{\\n\" + \n \" if (!_this.dialog) return;\\n\" + \n \" _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\\n\" + \n \" _this.grid.footer.onClick('first');\\n\" + \n \" }); \\n\" + \n \"}\\n\"\n },\n \"|xns\": \"Roo.grid\",\n\n \"items\": [\n {\n \"*prop\": \"dataSource\",\n \"xtype\": \"Store\",\n remoteSort : true,\n '|sortInfo' : \"{ field : '\" + this.firstTxtCol + \"', direction: 'ASC' }\", \n \"|xns\": \"Roo.data\",\n \"items\": [\n \n {\n \"*prop\": \"proxy\",\n \"xtype\": \"HttpProxy\",\n \"method\": \"GET\",\n \"|url\": \"baseURL + '/Roo/\" + this.table + \".php'\",\n \"|xns\": \"Roo.data\"\n },\n {\n '*prop' : 'reader',\n 'xtype' : 'JsonReader',\n '|xns' : 'Roo.data',\n 'id' : 'id',\n 'root' : 'data',\n 'totalProperty' : 'total'\n }\n ]\n },\n {\n \"*prop\": \"footer\",\n \"xtype\": \"PagingToolbar\",\n \"pageSize\": 25,\n \"displayInfo\": true,\n \"displayMsg\": \"Displaying \" + this.table + \"{0} - {1} of {2}\",\n \"emptyMsg\": \"No \" + this.table + \" found\",\n \"|xns\": \"Roo\"\n },\n {\n \"*prop\": \"toolbar\",\n \"xtype\": \"Toolbar\",\n \"|xns\": \"Roo\",\n \"items\": [\n {\n \"text\": \"Add\",\n \"xtype\": \"Button\",\n \"cls\": \"x-btn-text-icon\",\n \"|icon\": \"Roo.rootURL + 'images/default/dd/drop-add.gif'\",\n \"listeners\": {\n \"|click\": \"function()\\n\"+\n \"{\\n\"+\n \" if (!_this.dialog) return;\\n\" +\n \" _this.dialog.show( { id : 0 } , function() {\\n\"+\n \" _this.grid.footer.onClick('first');\\n\"+\n \" }); \\n\"+\n \"}\\n\"\n },\n \"|xns\": \"Roo.Toolbar\"\n },\n // fill ????\n {\n \"text\": \"Delete\",\n \"cls\": \"x-btn-text-icon\",\n \"|icon\": \"rootURL + '/Pman/templates/images/trash.gif'\",\n \"xtype\": \"Button\",\n \"listeners\": {\n \"|click\": \"function()\\n\"+\n \"{\\n\"+\n \" Pman.genericDelete(_this, '\" + this.table + \"'); \\n\"+\n \"}\\n\"+\n \" \"\n },\n \"|xns\": \"Roo.Toolbar\"\n }\n ]\n }, // end toolbar\n ].concat( colmodel)\n }\n ]\n \n \n }, null, 4));\n\n}", + "fitToframe" : true, + "background" : false, + "region" : "center", + "title" : "core_enum", + "xtype" : "GridPanel", + "$ xns" : "Roo", + "fitContainer" : true, + "String title" : "Create / Edit Grid", + "tableName" : "core_enum", + "items" : [ + { + "listeners" : { + "|rowdblclick" : "function (_self, rowIndex, e)\n{\n if (!_this.dialog) return;\n \n}\n", + "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n\n var di = this.colModel.getDataIndex(columnIndex);\n if (di != 'active') {\n return;\n }\n \n var rec = _this.grid.ds.getAt(rowIndex);\n \n rec.set('active', rec.data.active * 1 ? 0 : 1);\n rec.commit();\n \n \n}", + "|render" : "function() \n{\n _this.grid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n\n}" + }, + "Number clicksToEdit" : 1, + "autoExpandColumn" : "title", + "xtype" : "EditorGrid", + "loadMask" : true, + "$ xns" : "Roo.grid", + "* prop" : "grid", + "items" : [ + { + "$ Array fields" : "[ 'active', 'dataIndex', 'type','title', 'width' ]", + "$ Array data" : "[\n [ 1, 'test', 'test', 110 ]\n \n\n]", + "Number id" : "'dataIndex'", + "xtype" : "SimpleStore", + "$ xns" : "Roo.data", + "* prop" : "ds" + }, + { + "xtype" : "Toolbar", + "$ xns" : "Roo", + "* prop" : "toolbar", + "items" : [ + { + "string text" : "Edit a Grid", + "xtype" : "TextItem", + "$ xns" : "Roo.Toolbar" + } + ] + }, + { + "xtype" : "ColumnModel", + "header" : "Use ", + "width" : 75, + "$ renderer" : "function(v) { \n var state = v *1 > 0 ? '-checked' : '';\n\n return '';\n \n }", + "$ xns" : "Roo.grid", + "* prop" : "cm[]", + "dataIndex" : "active" + }, + { + "xtype" : "ColumnModel", + "width" : 150, + "header" : "Database Column", + "$ renderer" : "function(v) { return String.format('{0}', v); }", + "$ xns" : "Roo.grid", + "* prop" : "cm[]", + "dataIndex" : "dataIndex" + }, + { + "xtype" : "ColumnModel", + "header" : "Type", + "width" : 100, + "$ renderer" : "function(v) { return String.format('{0}', v); }", + "$ xns" : "Roo.grid", + "* prop" : "cm[]", + "dataIndex" : "type" + }, + { + "xtype" : "ColumnModel", + "width" : 75, + "header" : "Title", + "$ renderer" : "function(v) { return String.format('{0}', v); }", + "$ xns" : "Roo.grid", + "* prop" : "cm[]", + "dataIndex" : "title", + "items" : [ + { + "xtype" : "GridEditor", + "$ xns" : "Roo.grid", + "* prop" : "editor", + "items" : [ + { + "xtype" : "TextField", + "$ xns" : "Roo.form", + "* prop" : "field" + } + ] + } + ] + }, + { + "xtype" : "ColumnModel", + "header" : "Width", + "width" : 75, + "$ renderer" : "function(v) { return String.format('{0}', v); }", + "$ xns" : "Roo.grid", + "* prop" : "cm[]", + "dataIndex" : "width", + "items" : [ + { + "xtype" : "GridEditor", + "$ xns" : "Roo.grid", + "* prop" : "editor", + "items" : [ + { + "xtype" : "NumberField", + "Number decimalPrecision" : 0, + "$ xns" : "Roo.form", + "* prop" : "field" + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/resources/Editors/Editor.Roo.GridPanel.js b/resources/Editors/Editor.Roo.GridPanel.js new file mode 100644 index 000000000..762941183 --- /dev/null +++ b/resources/Editors/Editor.Roo.GridPanel.js @@ -0,0 +1,384 @@ +// + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/mailer.builder.html b/resources/mailer.builder.html new file mode 100644 index 000000000..14901b3a3 --- /dev/null +++ b/resources/mailer.builder.html @@ -0,0 +1,42 @@ + + + + + + + + Gtk Builder App Runner. + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/roo.builder.html b/resources/roo.builder.html new file mode 100644 index 000000000..a327a91e5 --- /dev/null +++ b/resources/roo.builder.html @@ -0,0 +1,44 @@ + + + + + + + Gtk Builder App Runner. + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/roo.builder.js b/resources/roo.builder.js new file mode 100644 index 000000000..a53f114af --- /dev/null +++ b/resources/roo.builder.js @@ -0,0 +1,373 @@ +//\\n\" ;\n\n print(runhtml);\n // fix to make sure they are the same..\n \n // need to modify paths\n\n string inhtml;\n try {\n GLib.FileUtils.get_contents(\n BuilderApplication.configDirectory() + \"/resources/roo.builder.html\"\n , out inhtml);\n \n } catch (Error e) {\n inhtml = \"\";\n }\n // fetch the json from the database...\n \n //print(runhtml);\n \n var html = inhtml.replace(\"\", runhtml + // + this.runhtml + \n \"\" + \n \n \n \"\");\n //print(\"LOAD HTML \" + html);\n \n //var rootURL = _this.file.project.rootURL;\n \n \n \n this.webview.el.load_html( html , \n //fixme - should be a config option!\n \"xhttp://localhost/app.Builder.js/\"\n );\n \n \n \n \n var response_id = this.el.run();\n \n if (response_id == 1) { // OK...\n var loop = new MainLoop();\n // run toBJS to get the data... (calls back into alert handler)\n _this.result_json = \"\";\n this.webview.el.run_javascript.begin(\"Editor.\" + cls + \".panel.toBJS();\", null, (obj, res) => {\n try {\n this.webview.el.run_javascript.end(res);\n } catch(Error e) {\n \n }\n loop.quit();\n });\n loop.run();\n ret = _this.result_json;\n \n \n // print(\"LOOP END?\");\n // try and get the resopse...\n break;\n }\n if (response_id < 1) {\n this.el.hide();\n return \"\";\n }\n // keep showing...?\n continue;\n }\n \n // now we save it..\n this.el.hide();\n \n return ret;\n \n \n \n}\n", + "| bool has_plugin" : "(string cls) {\n\n return GLib.FileUtils.test(\n BuilderApplication.configDirectory() + \"/resources/Editors/Editor.\" + cls + \".js\",\n GLib.FileTest.IS_REGULAR\n );\n \n\n\n}\n", + "$ xns" : "Gtk", + "gint default_width" : 750, + "gboolean modal" : true, + "string result_json" : "", + "items" : [ + { + "xtype" : "Box", + "$ pack" : "get_content_area().add", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "* pack" : "pack_start,false,true,3", + "xtype" : "ScrolledWindow", + "gboolean expand" : true, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "script_dialog" : " (dialog) => {\n if (this.el == null) {\n return true;\n }\n \n var msg = dialog.get_message();\n if (msg.length < 4) {\n return false;\n }\n if (msg.substring(0,4) != \"IPC:\") {\n return false;\n }\n var ar = msg.split(\":\", 3);\n if (ar.length < 3) {\n return false;\n }\n print(\"CMD: %s\\n\",ar[1]);\n print(\"ARGS: %s\\n\",ar[2]);\n switch(ar[1]) {\n \n case \"SAVEHTML\":\n // print(\"%sw\",ar[2]);\n // _this.file.saveHTML(ar[2]);\n return true;\n \n case \"OUT\":\n _this.result_json = ar[2];\n return true;\n \n default:\n return true;\n }\n \n}" + }, + "id" : "webview", + "* init" : " {\n // this may not work!?\n var settings = this.el.get_settings();\n settings.enable_write_console_messages_to_stdout = true;\n \n var fs= new FakeServer(this.el);\n fs.ref();\n // this was an attempt to change the url perms.. did not work..\n // settings.enable_file_access_from_file_uris = true;\n // settings.enable_offline_web_application_cache - true;\n // settings.enable_universal_access_from_file_uris = true;\n \n \n \n \n \n\n // FIXME - base url of script..\n // we need it so some of the database features work.\n this.el.load_html( \"Render not ready\" , \n //fixme - should be a config option!\n // or should we catch stuff and fix it up..\n \"xhttp://localhost/app.Builder/\"\n );\n \n \n \n \n}\n", + "xtype" : "WebView", + "* pack" : "add", + "$ xns" : "WebKit" + } + ] + } + ] + }, + { + "label" : "Reload", + "xtype" : "Button", + "* pack" : "add_action_widget,3", + "$ xns" : "Gtk" + }, + { + "label" : "Cancel", + "* pack" : "add_action_widget,0", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "label" : "OK", + "xtype" : "Button", + "* pack" : "add_action_widget,1", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/DialogPluginWebkit.vala b/src/Builder4/DialogPluginWebkit.vala new file mode 100644 index 000000000..e4c46f440 --- /dev/null +++ b/src/Builder4/DialogPluginWebkit.vala @@ -0,0 +1,415 @@ +static Xcls_DialogPluginWebkit _DialogPluginWebkit; + +public class Xcls_DialogPluginWebkit : Object +{ + public Gtk.Dialog el; + private Xcls_DialogPluginWebkit _this; + + public static Xcls_DialogPluginWebkit singleton() + { + if (_DialogPluginWebkit == null) { + _DialogPluginWebkit= new Xcls_DialogPluginWebkit(); + } + return _DialogPluginWebkit; + } + public Xcls_webview webview; + + // my vars (def) + public string tmpjs; + public string result_json; + + // ctor + public Xcls_DialogPluginWebkit() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + + // set gobject values + this.el.title = "Add / Edit Component"; + this.el.default_height = 500; + this.el.default_width = 750; + this.el.deletable = true; + this.el.modal = true; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button5( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 3 ); + var child_2 = new Xcls_Button6( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 0 ); + var child_3 = new Xcls_Button7( _this ); + child_3.ref(); + this.el.add_action_widget ( child_3.el , 1 ); + + //listeners + this.el.delete_event.connect( (self, event) => { + this.el.hide(); + return true; + //test + }); + } + + // user defined functions + public string show (Gtk.Window ?parent, Project.Project project, string cls, string tbl) {// JsRender.Node node) { + + if (parent != null) { + this.el.set_transient_for(parent); + this.el.modal = true; + } + this.result_json = ""; + var db = project.roo_database; + + + this.el.show_all(); + var ret = ""; + while (true) { + + var runhtml = "\n" ; + + print(runhtml); + // fix to make sure they are the same.. + + // need to modify paths + + string inhtml; + try { + GLib.FileUtils.get_contents( + BuilderApplication.configDirectory() + "/resources/roo.builder.html" + , out inhtml); + + } catch (Error e) { + inhtml = ""; + } + // fetch the json from the database... + + //print(runhtml); + + var html = inhtml.replace("", runhtml + // + this.runhtml + + "" + + + + ""); + //print("LOAD HTML " + html); + + //var rootURL = _this.file.project.rootURL; + + + + this.webview.el.load_html( html , + //fixme - should be a config option! + "xhttp://localhost/app.Builder.js/" + ); + + + + + var response_id = this.el.run(); + + if (response_id == 1) { // OK... + var loop = new MainLoop(); + // run toBJS to get the data... (calls back into alert handler) + _this.result_json = ""; + this.webview.el.run_javascript.begin("Editor." + cls + ".panel.toBJS();", null, (obj, res) => { + try { + this.webview.el.run_javascript.end(res); + } catch(Error e) { + + } + loop.quit(); + }); + loop.run(); + ret = _this.result_json; + + + // print("LOOP END?"); + // try and get the resopse... + break; + } + if (response_id < 1) { + this.el.hide(); + return ""; + } + // keep showing...? + continue; + } + + // now we save it.. + this.el.hide(); + + return ret; + + + + } + public bool has_plugin (string cls) { + + return GLib.FileUtils.test( + BuilderApplication.configDirectory() + "/resources/Editors/Editor." + cls + ".js", + GLib.FileTest.IS_REGULAR + ); + + + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private Xcls_DialogPluginWebkit _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(Xcls_DialogPluginWebkit _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_ScrolledWindow3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,3 ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow3 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_DialogPluginWebkit _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.expand = true; + var child_0 = new Xcls_webview( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + } + public class Xcls_webview : Object + { + public WebKit.WebView el; + private Xcls_DialogPluginWebkit _this; + + + // my vars (def) + + // ctor + public Xcls_webview(Xcls_DialogPluginWebkit _owner ) + { + _this = _owner; + _this.webview = this; + this.el = new WebKit.WebView(); + + // my vars (dec) + + // set gobject values + + // init method + + { + // this may not work!? + var settings = this.el.get_settings(); + settings.enable_write_console_messages_to_stdout = true; + + var fs= new FakeServer(this.el); + fs.ref(); + // this was an attempt to change the url perms.. did not work.. + // settings.enable_file_access_from_file_uris = true; + // settings.enable_offline_web_application_cache - true; + // settings.enable_universal_access_from_file_uris = true; + + + + + + + // FIXME - base url of script.. + // we need it so some of the database features work. + this.el.load_html( "Render not ready" , + //fixme - should be a config option! + // or should we catch stuff and fix it up.. + "xhttp://localhost/app.Builder/" + ); + + + + + } + + //listeners + this.el.script_dialog.connect( (dialog) => { + if (this.el == null) { + return true; + } + + var msg = dialog.get_message(); + if (msg.length < 4) { + return false; + } + if (msg.substring(0,4) != "IPC:") { + return false; + } + var ar = msg.split(":", 3); + if (ar.length < 3) { + return false; + } + print("CMD: %s\n",ar[1]); + print("ARGS: %s\n",ar[2]); + switch(ar[1]) { + + case "SAVEHTML": + // print("%sw",ar[2]); + // _this.file.saveHTML(ar[2]); + return true; + + case "OUT": + _this.result_json = ar[2]; + return true; + + default: + return true; + } + + }); + } + + // user defined functions + } + + + + public class Xcls_Button5 : Object + { + public Gtk.Button el; + private Xcls_DialogPluginWebkit _this; + + + // my vars (def) + + // ctor + public Xcls_Button5(Xcls_DialogPluginWebkit _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Reload"; + } + + // user defined functions + } + + public class Xcls_Button6 : Object + { + public Gtk.Button el; + private Xcls_DialogPluginWebkit _this; + + + // my vars (def) + + // ctor + public Xcls_Button6(Xcls_DialogPluginWebkit _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + } + + // user defined functions + } + + public class Xcls_Button7 : Object + { + public Gtk.Button el; + private Xcls_DialogPluginWebkit _this; + + + // my vars (def) + + // ctor + public Xcls_Button7(Xcls_DialogPluginWebkit _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } + +} diff --git a/src/Builder4/DialogSaveModule.bjs b/src/Builder4/DialogSaveModule.bjs new file mode 100644 index 000000000..ec71f654f --- /dev/null +++ b/src/Builder4/DialogSaveModule.bjs @@ -0,0 +1,58 @@ +{ + "name" : "DialogSaveModule", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/DialogSaveModule.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "listeners" : { + "delete_event" : " (self, event) => {\n this.el.response(Gtk.ResponseType.CANCEL);\n return true;\n} " + }, + "default_width" : 400, + "# Project.Project project" : "", + "xtype" : "Dialog", + "default_height" : 200, + "$ modal" : true, + "# JsRender.Node data" : "", + "| string show" : " (Gtk.Window parent, Project.Project project, JsRender.Node data) {\n \n \n this.el.set_transient_for(parent);\n this.el.modal = true;\n \n this.data = data;\n this.project = project;\n this.name.el.set_text(\"\");\n this.el.show_all();\n var name = \"\";\n while (true) {\n var response_id = this.el.run();\n if (response_id < 1) {\n this.el.hide();\n return \"\";\n }\n \n name = _this.name.el.get_text();\n if (name.length < 1) {\n StandardErrorDialog.singleton().show(\n _this.el,\n \"You must give the template a name. \"\n );\n continue;\n }\n if (!Regex.match_simple (\"^[A-Za-z][A-Za-z0-9.]+$\", name) )\n {\n StandardErrorDialog.singleton().show(\n _this.el,\n \"Template Name must contain only letters dots\"\n );\n continue;\n }\n break;\n }\n var f = project.newFile(name);\n f.tree = _this.data.deepClone();\n f.save();\n \n // now we save it..\n this.el.hide();\n \n return name;\n \n \n \n}\n", + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "Box", + "$ pack" : " get_content_area().add\n\n", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "label" : "Name", + "xtype" : "Label", + "* pack" : "add", + "$ xns" : "Gtk" + }, + { + "id" : "name", + "xtype" : "Entry", + "* pack" : "add", + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "Cancel", + "xtype" : "Button", + "* pack" : "add_action_widget,0", + "$ xns" : "Gtk" + }, + { + "label" : "OK", + "xtype" : "Button", + "* pack" : "add_action_widget,1", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/DialogSaveModule.vala b/src/Builder4/DialogSaveModule.vala new file mode 100644 index 000000000..84c2f0852 --- /dev/null +++ b/src/Builder4/DialogSaveModule.vala @@ -0,0 +1,218 @@ +static DialogSaveModule _DialogSaveModule; + +public class DialogSaveModule : Object +{ + public Gtk.Dialog el; + private DialogSaveModule _this; + + public static DialogSaveModule singleton() + { + if (_DialogSaveModule == null) { + _DialogSaveModule= new DialogSaveModule(); + } + return _DialogSaveModule; + } + public Xcls_name name; + + // my vars (def) + public Project.Project project; + public JsRender.Node data; + + // ctor + public DialogSaveModule() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + + // set gobject values + this.el.default_height = 200; + this.el.default_width = 400; + this.el.modal = true; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button5( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 0 ); + var child_2 = new Xcls_Button6( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 1 ); + + //listeners + this.el.delete_event.connect( (self, event) => { + this.el.response(Gtk.ResponseType.CANCEL); + return true; + }); + } + + // user defined functions + public string show (Gtk.Window parent, Project.Project project, JsRender.Node data) { + + + this.el.set_transient_for(parent); + this.el.modal = true; + + this.data = data; + this.project = project; + this.name.el.set_text(""); + this.el.show_all(); + var name = ""; + while (true) { + var response_id = this.el.run(); + if (response_id < 1) { + this.el.hide(); + return ""; + } + + name = _this.name.el.get_text(); + if (name.length < 1) { + StandardErrorDialog.singleton().show( + _this.el, + "You must give the template a name. " + ); + continue; + } + if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9.]+$", name) ) + { + StandardErrorDialog.singleton().show( + _this.el, + "Template Name must contain only letters dots" + ); + continue; + } + break; + } + var f = project.newFile(name); + f.tree = _this.data.deepClone(); + f.save(); + + // now we save it.. + this.el.hide(); + + return name; + + + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(DialogSaveModule _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Label3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_name( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label3 : Object + { + public Gtk.Label el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_Label3(DialogSaveModule _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Name" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_name : Object + { + public Gtk.Entry el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_name(DialogSaveModule _owner ) + { + _this = _owner; + _this.name = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_Button5 : Object + { + public Gtk.Button el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_Button5(DialogSaveModule _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + } + + // user defined functions + } + + public class Xcls_Button6 : Object + { + public Gtk.Button el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_Button6(DialogSaveModule _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } + +} diff --git a/src/Builder4/DialogSaveTemplate.bjs b/src/Builder4/DialogSaveTemplate.bjs new file mode 100644 index 000000000..9800a5777 --- /dev/null +++ b/src/Builder4/DialogSaveTemplate.bjs @@ -0,0 +1,58 @@ +{ + "name" : "DialogSaveTemplate", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/DialogSaveTemplate.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "listeners" : { + "delete_event" : " (self, event) => {\n this.el.response(Gtk.ResponseType.CANCEL);\n return true;\n \n}" + }, + "default_width" : 400, + "| void show" : " (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) {\n \n \n this.el.set_transient_for(parent);\n this.el.modal = true;\n \n this.name.el.set_text(\"\");\n this.el.show_all();\n var name = \"\";\n while (true) {\n var response_id = this.el.run();\n if (response_id < 1) {\n this.el.hide();\n return;\n }\n \n name = _this.name.el.get_text();\n if (name.length < 1) {\n StandardErrorDialog.singleton().show(\n _this.el,\n \"You must give the template a name. \"\n );\n continue;\n }\n if (!Regex.match_simple (\"^[A-Za-z][A-Za-z0-9. ]+$\", name) )\n {\n StandardErrorDialog.singleton().show(\n _this.el,\n \"Template Name must contain only letters dots\"\n );\n continue;\n }\n break;\n }\n palete.saveTemplate(name, data);\n \n // now we save it..\n this.el.hide();\n \n \n \n \n}\n", + "xtype" : "Dialog", + "default_height" : 200, + "# Palete.Palete palete" : "", + "$ modal" : true, + "# JsRender.Node data" : "", + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "Box", + "$ pack" : " get_content_area().add\n\n", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "label" : "Name", + "xtype" : "Label", + "* pack" : "add", + "$ xns" : "Gtk" + }, + { + "id" : "name", + "xtype" : "Entry", + "* pack" : "add", + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "Cancel", + "xtype" : "Button", + "* pack" : "add_action_widget,0", + "$ xns" : "Gtk" + }, + { + "label" : "OK", + "xtype" : "Button", + "* pack" : "add_action_widget,1", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/DialogSaveTemplate.vala b/src/Builder4/DialogSaveTemplate.vala new file mode 100644 index 000000000..1a0936c7d --- /dev/null +++ b/src/Builder4/DialogSaveTemplate.vala @@ -0,0 +1,214 @@ +static DialogSaveTemplate _DialogSaveTemplate; + +public class DialogSaveTemplate : Object +{ + public Gtk.Dialog el; + private DialogSaveTemplate _this; + + public static DialogSaveTemplate singleton() + { + if (_DialogSaveTemplate == null) { + _DialogSaveTemplate= new DialogSaveTemplate(); + } + return _DialogSaveTemplate; + } + public Xcls_name name; + + // my vars (def) + public Palete.Palete palete; + public JsRender.Node data; + + // ctor + public DialogSaveTemplate() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + + // set gobject values + this.el.default_height = 200; + this.el.default_width = 400; + this.el.modal = true; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button5( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 0 ); + var child_2 = new Xcls_Button6( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 1 ); + + //listeners + this.el.delete_event.connect( (self, event) => { + this.el.response(Gtk.ResponseType.CANCEL); + return true; + + }); + } + + // user defined functions + public void show (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) { + + + this.el.set_transient_for(parent); + this.el.modal = true; + + this.name.el.set_text(""); + this.el.show_all(); + var name = ""; + while (true) { + var response_id = this.el.run(); + if (response_id < 1) { + this.el.hide(); + return; + } + + name = _this.name.el.get_text(); + if (name.length < 1) { + StandardErrorDialog.singleton().show( + _this.el, + "You must give the template a name. " + ); + continue; + } + if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9. ]+$", name) ) + { + StandardErrorDialog.singleton().show( + _this.el, + "Template Name must contain only letters dots" + ); + continue; + } + break; + } + palete.saveTemplate(name, data); + + // now we save it.. + this.el.hide(); + + + + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(DialogSaveTemplate _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Label3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_name( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label3 : Object + { + public Gtk.Label el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_Label3(DialogSaveTemplate _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Name" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_name : Object + { + public Gtk.Entry el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_name(DialogSaveTemplate _owner ) + { + _this = _owner; + _this.name = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_Button5 : Object + { + public Gtk.Button el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_Button5(DialogSaveTemplate _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + } + + // user defined functions + } + + public class Xcls_Button6 : Object + { + public Gtk.Button el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_Button6(DialogSaveTemplate _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } + +} diff --git a/src/Builder4/DialogTemplateSelect.bjs b/src/Builder4/DialogTemplateSelect.bjs new file mode 100644 index 000000000..4fb7c03d0 --- /dev/null +++ b/src/Builder4/DialogTemplateSelect.bjs @@ -0,0 +1,129 @@ +{ + "name" : "DialogTemplateSelect", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/DialogTemplateSelect.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "listeners" : { + "delete_event" : " (self, event) =>{\n this.el.hide();\n return true;\n} " + }, + "default_width" : 400, + "title" : "Add an Object", + "xtype" : "Dialog", + "default_height" : 200, + "$ modal" : true, + "$ xns" : "Gtk", + "| JsRender.Node? show" : " (Xcls_MainWindow mwindow, Palete.Palete pal, JsRender.Node node, Project.Project project) {\n \n this.el.show_all();\n var opts = pal.listTemplates(node);\n if (opts.length() < 1) {\n this.el.hide();\n return node;\n }\n this.el.set_attached_to( mwindow.el);\n this.el.set_transient_for( mwindow.el);\n \n //opts.unshift({ path: '' , name :'Just add Element' });\n _this.model.loadData(opts);\n _this.combo.el.set_active(-1);\n \n \n var db = new Palete.RooDatabase.from_project(project);\n _this.dbmodel.loadData(db.readTablesGee());\n \n var plug = mwindow.windowstate.webkit_plugin;\n \n _this.dbcombo.el.set_active(-1);\n \n \n \n var res = this.el.run();\n this.el.hide(); \n //var ix = _this.combo.el.get_active();\n if (res < 1 ) {\n return null; // 0 = cancel.\n }\n if (res < 2 ) {\n return node; // 1 = just add it..\n }\n \n // have they selected a table??\n \n Gtk.TreeIter iter; \n Value vfname; \n if (_this.dbcombo.el.get_active_iter (out iter)) { \n this.dbmodel.el.get_value (iter, 0, out vfname);\n if (((string)vfname).length > 0 && plug.has_plugin(node.fqn())) {\n var json_str = plug.show(mwindow.el, project, node.fqn(), (string)vfname);\n print(\"json_str = %s\\n\", json_str);\n if (json_str.length < 1) {\n\n return node;\n }\n var pa = new Json.Parser();\n try {\n\n\t pa.load_from_data(json_str);\n\t } catch(Error e) {\n\t return node;\n\t }\n\t var new_node = pa.get_root();\n \n\t if (new_node.get_node_type () != Json.NodeType.OBJECT) {\n\t\t return node;\n\t }\n\t var obj = new_node.get_object ();\n\n\t var ret = new JsRender.Node();\n\n\t ret.loadFromJson(obj, 1);\n\t return ret;\n }\n \n }\n\n if (!_this.combo.el.get_active_iter (out iter)) {\n\n return node; // nothing selected...\n }\n \n this.model.el.get_value (iter, 0, out vfname);\n \n \n return pal.loadTemplate((string)vfname);\n\n}\n", + "items" : [ + { + "xtype" : "Box", + "$ pack" : "get_content_area().add ", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "* pack" : "pack_start,false,false,0", + "xtype" : "Box", + "gint margin" : 3, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "label" : "Select Template : ", + "xtype" : "Label", + "* pack" : "pack_start,false,false", + "$ xns" : "Gtk" + }, + { + "id" : "combo", + "* init" : "this.el.add_attribute(_this.cellrenderer.el , \"markup\", 1 );", + "xtype" : "ComboBox", + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "cellrenderer", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + }, + { + "id" : "model", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadData" : " (GLib.List data) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n \n for (var i = 0; i < data.length();i++) {\n \n\n el.append(out iter);\n var str = data.nth_data(i);\n var fn = Path.get_basename (str);\n fn.replace(\".json\", \"\");\n \n el.set_value(iter, 0, str);\n el.set_value(iter, 1, fn);\n \n }\n this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING); \n \n}\n" + } + ] + } + ] + }, + { + "* pack" : "pack_start,false,false,0", + "xtype" : "Box", + "gint margin" : 3, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "label" : "Select Database Table : ", + "xtype" : "Label", + "* pack" : "pack_start,false,false", + "$ xns" : "Gtk" + }, + { + "id" : "dbcombo", + "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );", + "xtype" : "ComboBox", + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "dbcellrenderer", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + }, + { + "id" : "dbmodel", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadData" : " (Gee.ArrayList data) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a table --\");\n \n \n for (var i = 0; i < data.size;i++) {\n \n\n el.append(out iter);\n \n el.set_value(iter, 0, data.get(i));\n el.set_value(iter, 1, data.get(i));\n \n }\n this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n" + } + ] + } + ] + } + ] + }, + { + "label" : "Cancel", + "xtype" : "Button", + "* pack" : "add_action_widget,0", + "$ xns" : "Gtk" + }, + { + "label" : "Just add it", + "* pack" : "add_action_widget,1", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "label" : "OK", + "xtype" : "Button", + "* pack" : "add_action_widget,2", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/DialogTemplateSelect.vala b/src/Builder4/DialogTemplateSelect.vala new file mode 100644 index 000000000..02b788c8d --- /dev/null +++ b/src/Builder4/DialogTemplateSelect.vala @@ -0,0 +1,552 @@ +static DialogTemplateSelect _DialogTemplateSelect; + +public class DialogTemplateSelect : Object +{ + public Gtk.Dialog el; + private DialogTemplateSelect _this; + + public static DialogTemplateSelect singleton() + { + if (_DialogTemplateSelect == null) { + _DialogTemplateSelect= new DialogTemplateSelect(); + } + return _DialogTemplateSelect; + } + public Xcls_combo combo; + public Xcls_cellrenderer cellrenderer; + public Xcls_model model; + public Xcls_dbcombo dbcombo; + public Xcls_dbcellrenderer dbcellrenderer; + public Xcls_dbmodel dbmodel; + + // my vars (def) + + // ctor + public DialogTemplateSelect() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + + // set gobject values + this.el.title = "Add an Object"; + this.el.default_height = 200; + this.el.default_width = 400; + this.el.modal = true; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button13( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 0 ); + var child_2 = new Xcls_Button14( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 1 ); + var child_3 = new Xcls_Button15( _this ); + child_3.ref(); + this.el.add_action_widget ( child_3.el , 2 ); + + //listeners + this.el.delete_event.connect( (self, event) =>{ + this.el.hide(); + return true; + }); + } + + // user defined functions + public JsRender.Node? show (Xcls_MainWindow mwindow, Palete.Palete pal, JsRender.Node node, Project.Project project) { + + this.el.show_all(); + var opts = pal.listTemplates(node); + if (opts.length() < 1) { + this.el.hide(); + return node; + } + this.el.set_attached_to( mwindow.el); + this.el.set_transient_for( mwindow.el); + + //opts.unshift({ path: '' , name :'Just add Element' }); + _this.model.loadData(opts); + _this.combo.el.set_active(-1); + + + var db = new Palete.RooDatabase.from_project(project); + _this.dbmodel.loadData(db.readTablesGee()); + + var plug = mwindow.windowstate.webkit_plugin; + + _this.dbcombo.el.set_active(-1); + + + + var res = this.el.run(); + this.el.hide(); + //var ix = _this.combo.el.get_active(); + if (res < 1 ) { + return null; // 0 = cancel. + } + if (res < 2 ) { + return node; // 1 = just add it.. + } + + // have they selected a table?? + + Gtk.TreeIter iter; + Value vfname; + if (_this.dbcombo.el.get_active_iter (out iter)) { + this.dbmodel.el.get_value (iter, 0, out vfname); + if (((string)vfname).length > 0 && plug.has_plugin(node.fqn())) { + var json_str = plug.show(mwindow.el, project, node.fqn(), (string)vfname); + print("json_str = %s\n", json_str); + if (json_str.length < 1) { + + return node; + } + var pa = new Json.Parser(); + try { + + pa.load_from_data(json_str); + } catch(Error e) { + return node; + } + var new_node = pa.get_root(); + + if (new_node.get_node_type () != Json.NodeType.OBJECT) { + return node; + } + var obj = new_node.get_object (); + + var ret = new JsRender.Node(); + + ret.loadFromJson(obj, 1); + return ret; + } + + } + + if (!_this.combo.el.get_active_iter (out iter)) { + + return node; // nothing selected... + } + + this.model.el.get_value (iter, 0, out vfname); + + + return pal.loadTemplate((string)vfname); + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Box3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_Box8( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + } + + // user defined functions + } + public class Xcls_Box3 : Object + { + public Gtk.Box el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Box3(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.margin = 3; + var child_0 = new Xcls_Label4( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false ); + var child_1 = new Xcls_combo( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label4 : Object + { + public Gtk.Label el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Label4(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Select Template : " ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_combo : Object + { + public Gtk.ComboBox el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_combo(DialogTemplateSelect _owner ) + { + _this = _owner; + _this.combo = this; + this.el = new Gtk.ComboBox(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_cellrenderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_model( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + + this.el.add_attribute(_this.cellrenderer.el , "markup", 1 ); + } + + // user defined functions + } + public class Xcls_cellrenderer : Object + { + public Gtk.CellRendererText el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_cellrenderer(DialogTemplateSelect _owner ) + { + _this = _owner; + _this.cellrenderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_model : Object + { + public Gtk.ListStore el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_model(DialogTemplateSelect _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadData (GLib.List data) { + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + /// el.append(out iter); + + + // el.set_value(iter, 0, ""); + // el.set_value(iter, 1, "aaa - Just add Element - aaa"); + + for (var i = 0; i < data.length();i++) { + + + el.append(out iter); + var str = data.nth_data(i); + var fn = Path.get_basename (str); + fn.replace(".json", ""); + + el.set_value(iter, 0, str); + el.set_value(iter, 1, fn); + + } + this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING); + + } + } + + + + public class Xcls_Box8 : Object + { + public Gtk.Box el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Box8(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.margin = 3; + var child_0 = new Xcls_Label9( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false ); + var child_1 = new Xcls_dbcombo( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label9 : Object + { + public Gtk.Label el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Label9(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Select Database Table : " ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_dbcombo : Object + { + public Gtk.ComboBox el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_dbcombo(DialogTemplateSelect _owner ) + { + _this = _owner; + _this.dbcombo = this; + this.el = new Gtk.ComboBox(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_dbcellrenderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_dbmodel( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + + this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 ); + } + + // user defined functions + } + public class Xcls_dbcellrenderer : Object + { + public Gtk.CellRendererText el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_dbcellrenderer(DialogTemplateSelect _owner ) + { + _this = _owner; + _this.dbcellrenderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_dbmodel : Object + { + public Gtk.ListStore el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_dbmodel(DialogTemplateSelect _owner ) + { + _this = _owner; + _this.dbmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadData (Gee.ArrayList data) { + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + /// el.append(out iter); + + + // el.set_value(iter, 0, ""); + // el.set_value(iter, 1, "aaa - Just add Element - aaa"); + + el.append(out iter); + + + el.set_value(iter, 0, ""); + el.set_value(iter, 1, "-- select a table --"); + + + for (var i = 0; i < data.size;i++) { + + + el.append(out iter); + + el.set_value(iter, 0, data.get(i)); + el.set_value(iter, 1, data.get(i)); + + } + this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); + + } + } + + + + + public class Xcls_Button13 : Object + { + public Gtk.Button el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Button13(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + } + + // user defined functions + } + + public class Xcls_Button14 : Object + { + public Gtk.Button el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Button14(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Just add it"; + } + + // user defined functions + } + + public class Xcls_Button15 : Object + { + public Gtk.Button el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Button15(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } + +} diff --git a/src/Builder4/EditProject.bjs b/src/Builder4/EditProject.bjs new file mode 100644 index 000000000..b55233e4c --- /dev/null +++ b/src/Builder4/EditProject.bjs @@ -0,0 +1,100 @@ +{ + "name" : "EditProject", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/EditProject.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "listeners" : { + "destroy_event" : "(self, event) => {\n\tthis.el.response(0);\n// this.el.hide();\n return false;\n}" + }, + "default_width" : 600, + "$ deletable" : true, + "title" : "Project Properties", + "xtype" : "Dialog", + "default_height" : 500, + "| Project.Project? show" : "() {\n \n\n //[ 'xtype' ].forEach(function(k) {\n // _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);\n //});\n\t// shouild set path..\n _this.model.loadData();\n this.el.show_all();\n \n var err_dialog = StandardErrorDialog.singleton();\n\n var id = -1;\n while (id < 0) {\n id = this.el.run();\n if (id < 1) {\n this.el.hide();\n return null;\n }\n \n \n if (_this.xtype.getValue().length < 1) {\n \n err_dialog.show(_this.el,\"You have to set Project type\"); \n id = -1;\n continue;\n }\n if (_this.dir.el.get_filename().length < 1) {\n \n err_dialog.show(_this.el,\"You have to select a folder\"); \n id = -1;\n continue;\n }\n \n }\n \n this.el.hide();\n \n \n \n \n var fn = _this.dir.el.get_filename();\n print(\"add %s\\n\" , fn);\n \n var project = Project.Project.factory(_this.xtype.getValue(), fn);\n project.save();\n Project.projects.set(project.name,project);\n \n //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);\n \n return project;\n\n \n //this.success = c.success;\n}\n", + "$ modal" : true, + "$ xns" : "Gtk", + "border_width" : 3, + "name" : "EditProject", + "items" : [ + { + "bool expand" : true, + "xtype" : "Box", + "$ pack" : " get_content_area().add \n \n", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "$ homogeneous" : false, + "items" : [ + { + "xtype" : "Box", + "* pack" : "pack_start,false,true,3", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "$ homogeneous" : false, + "items" : [ + { + "label" : "Project type :", + "xtype" : "Label", + "* pack" : "pack_start,false,true,3", + "$ xns" : "Gtk" + }, + { + "| string getValue" : " () {\n var ix = this.el.get_active();\n if (ix < 0 ) {\n return \"\";\n }\n switch(ix) {\n case 0:\n return \"Roo\";\n case 1:\n return \"Gtk\";\n }\n return \"\";\n}\n", + "id" : "xtype", + "* init" : " this.el.add_attribute(_this.cellrender.el , \"markup\", 1 ); \n ", + "xtype" : "ComboBox", + "* pack" : "pack_end,true,true,3", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "cellrender", + "* pack" : "pack_start,true", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + }, + { + "id" : "model", + "xtype" : "ListStore", + "* pack" : "set_model", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadData" : " ( ) {\n this.el.clear();\n \n Gtk.TreeIter iter;\n \n el.append(out iter);\n \n el.set_value(iter, 0, \"Roo\");\n el.set_value(iter, 1, \"Roo Project\");\n el.append(out iter);\n \n el.set_value(iter, 0, \"Gtk\");\n el.set_value(iter, 1, \"Gtk Project\");\n \n \n \n}\n" + } + ] + } + ] + }, + { + "$ create_folders" : false, + "id" : "dir", + "$ action" : "Gtk.FileChooserAction.SELECT_FOLDER", + "bool expand" : true, + "* pack" : "pack_end,true,true,5", + "xtype" : "FileChooserWidget", + "$ xns" : "Gtk", + "$ select_multiple" : false + } + ] + }, + { + "label" : "OK", + "* pack" : "add_action_widget,1", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "label" : "Cancel", + "xtype" : "Button", + "* pack" : "add_action_widget,0", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/EditProject.vala b/src/Builder4/EditProject.vala new file mode 100644 index 000000000..af626275b --- /dev/null +++ b/src/Builder4/EditProject.vala @@ -0,0 +1,374 @@ +static EditProject _EditProject; + +public class EditProject : Object +{ + public Gtk.Dialog el; + private EditProject _this; + + public static EditProject singleton() + { + if (_EditProject == null) { + _EditProject= new EditProject(); + } + return _EditProject; + } + public Xcls_xtype xtype; + public Xcls_cellrender cellrender; + public Xcls_model model; + public Xcls_dir dir; + + // my vars (def) + + // ctor + public EditProject() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + + // set gobject values + this.el.title = "Project Properties"; + this.el.name = "EditProject"; + this.el.border_width = 3; + this.el.default_height = 500; + this.el.default_width = 600; + this.el.deletable = true; + this.el.modal = true; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button9( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 1 ); + var child_2 = new Xcls_Button10( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 0 ); + + //listeners + this.el.destroy_event.connect( (self, event) => { + this.el.response(0); + // this.el.hide(); + return false; + }); + } + + // user defined functions + public Project.Project? show () { + + + //[ 'xtype' ].forEach(function(k) { + // _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]); + //}); + // shouild set path.. + _this.model.loadData(); + this.el.show_all(); + + var err_dialog = StandardErrorDialog.singleton(); + + var id = -1; + while (id < 0) { + id = this.el.run(); + if (id < 1) { + this.el.hide(); + return null; + } + + + if (_this.xtype.getValue().length < 1) { + + err_dialog.show(_this.el,"You have to set Project type"); + id = -1; + continue; + } + if (_this.dir.el.get_filename().length < 1) { + + err_dialog.show(_this.el,"You have to select a folder"); + id = -1; + continue; + } + + } + + this.el.hide(); + + + + + var fn = _this.dir.el.get_filename(); + print("add %s\n" , fn); + + var project = Project.Project.factory(_this.xtype.getValue(), fn); + project.save(); + Project.projects.set(project.name,project); + + //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project); + + return project; + + + //this.success = c.success; + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private EditProject _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.expand = true; + var child_0 = new Xcls_Box3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,3 ); + var child_1 = new Xcls_dir( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,5 ); + } + + // user defined functions + } + public class Xcls_Box3 : Object + { + public Gtk.Box el; + private EditProject _this; + + + // my vars (def) + + // ctor + public Xcls_Box3(EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_Label4( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,3 ); + var child_1 = new Xcls_xtype( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,3 ); + } + + // user defined functions + } + public class Xcls_Label4 : Object + { + public Gtk.Label el; + private EditProject _this; + + + // my vars (def) + + // ctor + public Xcls_Label4(EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Project type :" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_xtype : Object + { + public Gtk.ComboBox el; + private EditProject _this; + + + // my vars (def) + + // ctor + public Xcls_xtype(EditProject _owner ) + { + _this = _owner; + _this.xtype = this; + this.el = new Gtk.ComboBox(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_cellrender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_model( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + + this.el.add_attribute(_this.cellrender.el , "markup", 1 ); + } + + // user defined functions + public string getValue () { + var ix = this.el.get_active(); + if (ix < 0 ) { + return ""; + } + switch(ix) { + case 0: + return "Roo"; + case 1: + return "Gtk"; + } + return ""; + } + } + public class Xcls_cellrender : Object + { + public Gtk.CellRendererText el; + private EditProject _this; + + + // my vars (def) + + // ctor + public Xcls_cellrender(EditProject _owner ) + { + _this = _owner; + _this.cellrender = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_model : Object + { + public Gtk.ListStore el; + private EditProject _this; + + + // my vars (def) + + // ctor + public Xcls_model(EditProject _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadData ( ) { + this.el.clear(); + + Gtk.TreeIter iter; + + el.append(out iter); + + el.set_value(iter, 0, "Roo"); + el.set_value(iter, 1, "Roo Project"); + el.append(out iter); + + el.set_value(iter, 0, "Gtk"); + el.set_value(iter, 1, "Gtk Project"); + + + + } + } + + + + public class Xcls_dir : Object + { + public Gtk.FileChooserWidget el; + private EditProject _this; + + + // my vars (def) + + // ctor + public Xcls_dir(EditProject _owner ) + { + _this = _owner; + _this.dir = this; + this.el = new Gtk.FileChooserWidget( Gtk.FileChooserAction.SELECT_FOLDER ); + + // my vars (dec) + + // set gobject values + this.el.expand = true; + this.el.create_folders = false; + this.el.select_multiple = false; + } + + // user defined functions + } + + + public class Xcls_Button9 : Object + { + public Gtk.Button el; + private EditProject _this; + + + // my vars (def) + + // ctor + public Xcls_Button9(EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } + + public class Xcls_Button10 : Object + { + public Gtk.Button el; + private EditProject _this; + + + // my vars (def) + + // ctor + public Xcls_Button10(EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + } + + // user defined functions + } + +} diff --git a/src/Builder4/Editor.bjs b/src/Builder4/Editor.bjs new file mode 100644 index 000000000..547bff845 --- /dev/null +++ b/src/Builder4/Editor.bjs @@ -0,0 +1,111 @@ +{ + "name" : "Editor", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/Editor.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "# Xcls_MainWindow window" : "null", + "| bool saveContents" : " () {\n \n \n if (_this.file == null) {\n return true;\n }\n \n \n \n \n \n var str = _this.buffer.toString();\n \n _this.buffer.checkSyntax();\n \n \n \n // LeftPanel.model.changed( str , false);\n _this.dirty = false;\n _this.save_button.el.sensitive = false;\n \n // find the text for the node..\n if (_this.file.xtype != \"PlainFile\") {\n if (ptype == \"listener\") {\n this.node.listeners.set(key,str);\n \n } else {\n this.node.props.set(key,str);\n }\n } else {\n _this.file.setSource( str );\n }\n \n // call the signal..\n this.save();\n \n return true;\n\n} ", + "# string activeEditor" : "\"\"", + "| void scroll_to_line" : "(int line) {\n\n\tGLib.Timeout.add(500, () => {\n \n\t\tvar buf = this.view.el.get_buffer();\n\n\t\tvar sbuf = (Gtk.SourceBuffer) buf;\n\n\n\t\tGtk.TextIter iter; \n\t\tsbuf.get_iter_at_line(out iter, line);\n\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t\treturn false;\n\t}); \n}\n", + "# int pos_root_x" : "", + "# int pos_root_y" : "", + "# string ptype" : "\"\"", + "bool hexpand" : true, + "| int search" : "(string txt) {\n\n\tvar s = new Gtk.SourceSearchSettings();\n\t\n\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);\n\tthis.searchcontext .set_highlight(true);\n\ts.set_search_text(txt);\n\tGtk.TextIter beg, st,en;\n\t \n\tthis.buffer.el.get_start_iter(out beg);\n\tthis.searchcontext.forward(beg, out st, out en);\n\tthis.last_search_end = 0;\n\t\n\treturn this.searchcontext.get_occurrences_count();\n\n \n \n\n}\n", + "int last_search_end" : 0, + "# string key" : "\"\"", + "* pack" : "add", + "xtype" : "Box", + "Gtk.SourceSearchContext searchcontext" : "null", + "| void show" : "(JsRender.JsRender file, JsRender.Node? node, string ptype, string key)\n{\n this.file = file; \n this.ptype = \"\";\n this.key = \"\";\n this.node = null;\n\tthis.searchcontext = null;\n \n if (file.xtype != \"PlainFile\") {\n \n this.ptype = ptype;\n this.key = key;\n this.node = node;\n string val = \"\";\n // find the text for the node..\n if (ptype == \"listener\") {\n val = node.listeners.get(key);\n \n } else {\n val = node.props.get(key);\n }\n this.view.load(val);\n this.key_edit.el.show();\n this.key_edit.el.text = key; \n \n } else {\n this.view.load( file.toSource() );\n this.key_edit.el.hide();\n }\n\n \n}", + "# JsRender.JsRender file" : "null", + "# bool pos" : false, + "string id" : "Editor", + "# bool dirty" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "@ void save" : "()", + "$ homogeneous" : false, + "| void forwardSearch" : "(bool change_focus) {\n\n\tif (this.searchcontext == null) {\n\t\treturn;\n\t}\n\t\n\tGtk.TextIter beg, st,en;\n\t \n\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);\n\tif (!this.searchcontext.forward(beg, out st, out en)) {\n\t\n\t\tthis.last_search_end = 0;\n\t} else {\n\t\tthis.last_search_end = en.get_offset();\n\t\tif (change_focus) {\n\t\t\tthis.view.el.grab_focus();\n\t\t}\n\t\tthis.buffer.el.place_cursor(st);\n\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);\n\t}\n\n}\n", + "# JsRender.Node node" : "null", + "items" : [ + { + "* pack" : "pack_start,false,true", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "$ homogeneous" : false, + "items" : [ + { + "listeners" : { + "clicked" : " () => { \n _this.saveContents();\n}\n " + }, + "label" : "Save", + "id" : "save_button", + "* pack" : "pack_start,false,false", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "id" : "key_edit", + "* pack" : "pack_end,true,true", + "xtype" : "Entry", + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "RightEditor", + "* init" : "this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", + "xtype" : "ScrolledWindow", + "* pack" : "pack_end,true,true", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "key_release_event" : " (event) => {\n \n if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n print(\"SAVE: ctrl-S pressed\");\n _this.saveContents();\n return false;\n }\n // print(event.key.keyval)\n \n return false;\n\n} \n\n " + }, + "gboolean show_line_marks" : true, + "id" : "view", + "* init" : " \n\n\t\tvar description = Pango.FontDescription.from_string(\"monospace\");\n\t\tdescription.set_size(8000);\n\n\t\t this.el.override_font(description);\n\n\ttry { \n\t\tthis.el.completion.add_provider(new Palete.CompletionProvider(_this));\n } catch (GLib.Error e) {}\n \n\tthis.el.completion.unblock_interactive();\n\tthis.el.completion.select_on_show\t\t\t= true; // select\n\tthis.el.completion.show_headers\t\t\t= false;\n\tthis.el.completion.remember_info_visibility\t\t= true;\n \n \n var attrs = new Gtk.SourceMarkAttributes();\n var pink = Gdk.RGBA();\n pink.parse ( \"pink\");\n attrs.set_background ( pink);\n attrs.set_icon_name ( \"process-stop\"); \n attrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"ERR\", attrs, 1);\n \n var wattrs = new Gtk.SourceMarkAttributes();\n var blue = Gdk.RGBA();\n blue.parse ( \"#ABF4EB\");\n wattrs.set_background ( blue);\n wattrs.set_icon_name ( \"process-stop\"); \n wattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"WARN\", wattrs, 1);\n \n \n \n var dattrs = new Gtk.SourceMarkAttributes();\n var purple = Gdk.RGBA();\n purple.parse ( \"#EEA9FF\");\n dattrs.set_background ( purple);\n dattrs.set_icon_name ( \"process-stop\"); \n dattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"DEPR\", dattrs, 1);\n \n ", + "uint tab_width" : 4, + "$ Gtk.SourceDrawSpacesFlags draw_spaces" : "Gtk.SourceDrawSpacesFlags.LEADING + Gtk.SourceDrawSpacesFlags.TRAILING + Gtk.SourceDrawSpacesFlags.TAB + Gtk.SourceDrawSpacesFlags.SPACE", + "* pack" : "add", + "xtype" : "SourceView", + "gboolean highlight_current_line" : true, + "$ gboolean auto_indent" : true, + "$ xns" : "Gtk", + "| void load" : " (string str) {\n\n// show the help page for the active node..\n //this.get('/Help').show();\n\n\n // this.get('/BottomPane').el.set_current_page(0);\n var buf = (Gtk.SourceBuffer)this.el.get_buffer();\n buf.set_text(str, str.length);\n buf.set_undo_manager(null);\n \n var lm = Gtk.SourceLanguageManager.get_default();\n var lang = \"vala\";\n if (_this.file != null) {\n lang = _this.file.language;\n }\n print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);\n var lg = _this.file.content_type.length > 0 ?\n lm.guess_language(_this.file.path, _this.file.content_type) :\n lm.get_language(lang);\n \n \n ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lg); \n\n this.el.insert_spaces_instead_of_tabs = true;\n if (lg != null) {\n\t\tprint(\"sourcelanguage = %s\\n\", lg.name);\n\t\tif (lg.name == \"Vala\") {\n\t\t this.el.insert_spaces_instead_of_tabs = false;\n\t\t}\n }\n _this.dirty = false;\n this.el.grab_focus();\n _this.save_button.el.sensitive = false;\n}", + "bool insert_spaces_instead_of_tabs" : true, + "indent_width" : 4, + "$ show_line_numbers" : true, + "items" : [ + { + "listeners" : { + "changed" : " () => {\n // check syntax??\n // ??needed..??\n _this.save_button.el.sensitive = true;\n print(\"EDITOR CHANGED\");\n this.checkSyntax();\n \n _this.dirty = true;\n\n // this.get('/LeftPanel.model').changed( str , false);\n return ;\n}\n\n \n" + }, + "bool check_queued" : false, + "int error_line" : "-1", + "id" : "buffer", + "| bool highlightErrors" : "( Gee.HashMap validate_res) {\n \n this.error_line = validate_res.size;\n\n if (this.error_line < 1) {\n return true;\n }\n var tlines = this.el.get_line_count ();\n Gtk.TextIter iter;\n var valiter = validate_res.map_iterator();\n while (valiter.next()) {\n \n // print(\"get inter\\n\");\n var eline = valiter.get_key();\n if (eline > tlines) {\n continue;\n }\n this.el.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);\n } \n return false;\n }", + "| string toString" : " () {\n \n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_start_iter(out s);\n this.el.get_end_iter(out e);\n var ret = this.el.get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n ", + "| bool checkSyntax" : " () {\n \n if (this.check_running) {\n print(\"Check is running\\n\");\n if (this.check_queued) { \n print(\"Check is already queued\");\n return true;\n }\n this.check_queued = true;\n print(\"Adding queued Check \");\n GLib.Timeout.add_seconds(1, () => {\n this.check_queued = false;\n \n this.checkSyntax();\n return false;\n });\n \n\n return true;\n }\n var str = this.toString();\n \n // needed???\n if (this.error_line > 0) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n this.el.get_bounds (out start, out end);\n\n this.el.remove_source_marks (start, end, null);\n }\n if (str.length < 1) {\n print(\"checkSyntax - empty string?\\n\");\n return true;\n }\n \n if (_this.file.xtype == \"PlainFile\") {\n \n // assume it's gtk...\n this.check_running = true;\n \n if (!_this.window.windowstate.valasource.checkPlainFileSpawn(\n\t _this.file,\n\t str\n\t )) {\n this.check_running = false;\n }\n\t\n return true;\n \n }\n if (_this.file == null) {\n return true;\n }\n var p = Palete.factory(_this.file.xtype); \n \n\n \n this.check_running = true;\n \n \n if (_this.file.language == \"js\") {\n this.check_running = false;\n print(\"calling validate javascript\\n\"); \n Gee.HashMap errors;\n p.javascriptHasErrors(\n \t\t_this.window.windowstate,\n str, \n _this.key, \n _this.ptype,\n _this.file,\n \n out errors\n );\n return this.highlightErrors(errors); \n \n }\n \n \n print(\"calling validate vala\\n\"); \n // clear the buttons.\n \n \n if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(\n _this.file,\n _this.node,\n _this.key, \n _this.ptype,\n str\n )) {\n this.check_running = false;\n } \n \n \n \n //print(\"done mark line\\n\");\n \n return true; // at present allow saving - even if it's invalid..\n}\n", + "* pack" : "set_buffer", + "xtype" : "SourceBuffer", + "bool check_running" : false, + "$ xns" : "Gtk", + "| bool highlightErrorsJson" : "(string type, Json.Object obj) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n this.el.get_bounds (out start, out end);\n \n this.el.remove_source_marks (start, end, type);\n \n \n // we should highlight other types of errors..\n \n if (!obj.has_member(type)) {\n print(\"Return has no errors\\n\");\n return true;\n }\n \n if (_this.window.windowstate.state != WindowState.State.CODEONLY && \n _this.window.windowstate.state != WindowState.State.CODE\n ) {\n return true;\n } \n \n \n var err = obj.get_object_member(type);\n \n \n if (_this.file == null) {\n return true;\n \n }\n var valafn = _this.file.path;\n \n if (_this.file.xtype != \"PlainFile\") {\n\n\n \n \n valafn = \"\";\n try { \n var regex = new Regex(\"\\\\.bjs$\");\n // should not happen\n \n \n valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");\n } catch (GLib.RegexError e) {\n return true;\n } \n\n\n\n }\n if (!err.has_member(valafn)) {\n print(\"File path has no errors\\n\");\n return true;\n }\n\n var lines = err.get_object_member(valafn);\n \n var offset = 1;\n if (obj.has_member(\"line_offset\")) {\n offset = (int)obj.get_int_member(\"line_offset\") + 1;\n }\n \n\n \n \n var tlines = this.el.get_line_count () +1;\n \n lines.foreach_member((obj, line, node) => {\n \n Gtk.TextIter iter;\n // print(\"get inter\\n\");\n var eline = int.parse(line) - offset;\n print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);\n \n \n if (eline > tlines || eline < 0) {\n return;\n }\n this.el.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n var msg = \"Line: %d\".printf(eline+1);\n var ar = lines.get_array_member(line);\n for (var i = 0 ; i < ar.get_length(); i++) {\n\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";\n\t\t msg += ar.get_string_element(i);\n\t }\n \n \n this.el.create_source_mark(msg, type, iter);\n } );\n return false;\n \n\n\n\n\n}\n" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala new file mode 100644 index 000000000..3b4d09b35 --- /dev/null +++ b/src/Builder4/Editor.vala @@ -0,0 +1,713 @@ +static Editor _Editor; + +public class Editor : Object +{ + public Gtk.Box el; + private Editor _this; + + public static Editor singleton() + { + if (_Editor == null) { + _Editor= new Editor(); + } + return _Editor; + } + public Xcls_save_button save_button; + public Xcls_key_edit key_edit; + public Xcls_RightEditor RightEditor; + public Xcls_view view; + public Xcls_buffer buffer; + + // my vars (def) + public Xcls_MainWindow window; + public string activeEditor; + public int pos_root_x; + public int pos_root_y; + public string ptype; + public int last_search_end; + public string key; + public Gtk.SourceSearchContext searchcontext; + public JsRender.JsRender file; + public bool pos; + public bool dirty; + public signal void save (); + public JsRender.Node node; + + // ctor + public Editor() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.window = null; + this.activeEditor = ""; + this.ptype = ""; + this.last_search_end = 0; + this.key = ""; + this.searchcontext = null; + this.file = null; + this.pos = false; + this.dirty = false; + this.node = null; + + // set gobject values + this.el.homogeneous = false; + this.el.hexpand = true; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true ); + var child_1 = new Xcls_RightEditor( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true ); + } + + // user defined functions + public bool saveContents () { + + + if (_this.file == null) { + return true; + } + + + + + + var str = _this.buffer.toString(); + + _this.buffer.checkSyntax(); + + + + // LeftPanel.model.changed( str , false); + _this.dirty = false; + _this.save_button.el.sensitive = false; + + // find the text for the node.. + if (_this.file.xtype != "PlainFile") { + if (ptype == "listener") { + this.node.listeners.set(key,str); + + } else { + this.node.props.set(key,str); + } + } else { + _this.file.setSource( str ); + } + + // call the signal.. + this.save(); + + return true; + + } + public void scroll_to_line (int line) { + + GLib.Timeout.add(500, () => { + + var buf = this.view.el.get_buffer(); + + var sbuf = (Gtk.SourceBuffer) buf; + + + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, line); + this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + return false; + }); + } + public int search (string txt) { + + var s = new Gtk.SourceSearchSettings(); + + this.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s); + this.searchcontext .set_highlight(true); + s.set_search_text(txt); + Gtk.TextIter beg, st,en; + + this.buffer.el.get_start_iter(out beg); + this.searchcontext.forward(beg, out st, out en); + this.last_search_end = 0; + + return this.searchcontext.get_occurrences_count(); + + + + + } + public void show (JsRender.JsRender file, JsRender.Node? node, string ptype, string key) + { + this.file = file; + this.ptype = ""; + this.key = ""; + this.node = null; + this.searchcontext = null; + + if (file.xtype != "PlainFile") { + + this.ptype = ptype; + this.key = key; + this.node = node; + string val = ""; + // find the text for the node.. + if (ptype == "listener") { + val = node.listeners.get(key); + + } else { + val = node.props.get(key); + } + this.view.load(val); + this.key_edit.el.show(); + this.key_edit.el.text = key; + + } else { + this.view.load( file.toSource() ); + this.key_edit.el.hide(); + } + + + } + public void forwardSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + + Gtk.TextIter beg, st,en; + + this.buffer.el.get_iter_at_offset(out beg, this.last_search_end); + if (!this.searchcontext.forward(beg, out st, out en)) { + + this.last_search_end = 0; + } else { + this.last_search_end = en.get_offset(); + if (change_focus) { + this.view.el.grab_focus(); + } + this.buffer.el.place_cursor(st); + this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); + } + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_save_button( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false ); + var child_1 = new Xcls_key_edit( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true ); + } + + // user defined functions + } + public class Xcls_save_button : Object + { + public Gtk.Button el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_save_button(Editor _owner ) + { + _this = _owner; + _this.save_button = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save"; + + //listeners + this.el.clicked.connect( () => { + _this.saveContents(); + }); + } + + // user defined functions + } + + public class Xcls_key_edit : Object + { + public Gtk.Entry el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_key_edit(Editor _owner ) + { + _this = _owner; + _this.key_edit = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_RightEditor : Object + { + public Gtk.ScrolledWindow el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_RightEditor(Editor _owner ) + { + _this = _owner; + _this.RightEditor = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.SourceView el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_view(Editor _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.SourceView(); + + // my vars (dec) + + // set gobject values + this.el.auto_indent = true; + this.el.indent_width = 4; + this.el.show_line_marks = true; + this.el.insert_spaces_instead_of_tabs = true; + this.el.show_line_numbers = true; + this.el.draw_spaces = Gtk.SourceDrawSpacesFlags.LEADING + Gtk.SourceDrawSpacesFlags.TRAILING + Gtk.SourceDrawSpacesFlags.TAB + Gtk.SourceDrawSpacesFlags.SPACE; + this.el.tab_width = 4; + this.el.highlight_current_line = true; + var child_0 = new Xcls_buffer( _this ); + child_0.ref(); + this.el.set_buffer ( child_0.el ); + + // init method + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(8000); + + this.el.override_font(description); + + try { + this.el.completion.add_provider(new Palete.CompletionProvider(_this)); + } catch (GLib.Error e) {} + + this.el.completion.unblock_interactive(); + this.el.completion.select_on_show = true; // select + this.el.completion.show_headers = false; + this.el.completion.remember_info_visibility = true; + + + var attrs = new Gtk.SourceMarkAttributes(); + var pink = Gdk.RGBA(); + pink.parse ( "pink"); + attrs.set_background ( pink); + attrs.set_icon_name ( "process-stop"); + attrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("ERR", attrs, 1); + + var wattrs = new Gtk.SourceMarkAttributes(); + var blue = Gdk.RGBA(); + blue.parse ( "#ABF4EB"); + wattrs.set_background ( blue); + wattrs.set_icon_name ( "process-stop"); + wattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("WARN", wattrs, 1); + + + + var dattrs = new Gtk.SourceMarkAttributes(); + var purple = Gdk.RGBA(); + purple.parse ( "#EEA9FF"); + dattrs.set_background ( purple); + dattrs.set_icon_name ( "process-stop"); + dattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("DEPR", dattrs, 1); + + //listeners + this.el.key_release_event.connect( (event) => { + + if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + print("SAVE: ctrl-S pressed"); + _this.saveContents(); + return false; + } + // print(event.key.keyval) + + return false; + + }); + } + + // user defined functions + public void load (string str) { + + // show the help page for the active node.. + //this.get('/Help').show(); + + + // this.get('/BottomPane').el.set_current_page(0); + var buf = (Gtk.SourceBuffer)this.el.get_buffer(); + buf.set_text(str, str.length); + buf.set_undo_manager(null); + + var lm = Gtk.SourceLanguageManager.get_default(); + var lang = "vala"; + if (_this.file != null) { + lang = _this.file.language; + } + print("lang=%s, content_type = %s\n", lang, _this.file.content_type); + var lg = _this.file.content_type.length > 0 ? + lm.guess_language(_this.file.path, _this.file.content_type) : + lm.get_language(lang); + + + ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lg); + + this.el.insert_spaces_instead_of_tabs = true; + if (lg != null) { + print("sourcelanguage = %s\n", lg.name); + if (lg.name == "Vala") { + this.el.insert_spaces_instead_of_tabs = false; + } + } + _this.dirty = false; + this.el.grab_focus(); + _this.save_button.el.sensitive = false; + } + } + public class Xcls_buffer : Object + { + public Gtk.SourceBuffer el; + private Editor _this; + + + // my vars (def) + public bool check_queued; + public int error_line; + public bool check_running; + + // ctor + public Xcls_buffer(Editor _owner ) + { + _this = _owner; + _this.buffer = this; + this.el = new Gtk.SourceBuffer( null ); + + // my vars (dec) + this.check_queued = false; + this.error_line = -1; + this.check_running = false; + + // set gobject values + + //listeners + this.el.changed.connect( () => { + // check syntax?? + // ??needed..?? + _this.save_button.el.sensitive = true; + print("EDITOR CHANGED"); + this.checkSyntax(); + + _this.dirty = true; + + // this.get('/LeftPanel.model').changed( str , false); + return ; + }); + } + + // user defined functions + public bool highlightErrors ( Gee.HashMap validate_res) { + + this.error_line = validate_res.size; + + if (this.error_line < 1) { + return true; + } + var tlines = this.el.get_line_count (); + Gtk.TextIter iter; + var valiter = validate_res.map_iterator(); + while (valiter.next()) { + + // print("get inter\n"); + var eline = valiter.get_key(); + if (eline > tlines) { + continue; + } + this.el.get_iter_at_line( out iter, eline); + //print("mark line\n"); + this.el.create_source_mark(valiter.get_value(), "ERR", iter); + } + return false; + } + public string toString () { + + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_start_iter(out s); + this.el.get_end_iter(out e); + var ret = this.el.get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + public bool checkSyntax () { + + if (this.check_running) { + print("Check is running\n"); + if (this.check_queued) { + print("Check is already queued"); + return true; + } + this.check_queued = true; + print("Adding queued Check "); + GLib.Timeout.add_seconds(1, () => { + this.check_queued = false; + + this.checkSyntax(); + return false; + }); + + + return true; + } + var str = this.toString(); + + // needed??? + if (this.error_line > 0) { + Gtk.TextIter start; + Gtk.TextIter end; + this.el.get_bounds (out start, out end); + + this.el.remove_source_marks (start, end, null); + } + if (str.length < 1) { + print("checkSyntax - empty string?\n"); + return true; + } + + if (_this.file.xtype == "PlainFile") { + + // assume it's gtk... + this.check_running = true; + + if (!_this.window.windowstate.valasource.checkPlainFileSpawn( + _this.file, + str + )) { + this.check_running = false; + } + + return true; + + } + if (_this.file == null) { + return true; + } + var p = Palete.factory(_this.file.xtype); + + + + this.check_running = true; + + + if (_this.file.language == "js") { + this.check_running = false; + print("calling validate javascript\n"); + Gee.HashMap errors; + p.javascriptHasErrors( + _this.window.windowstate, + str, + _this.key, + _this.ptype, + _this.file, + + out errors + ); + return this.highlightErrors(errors); + + } + + + print("calling validate vala\n"); + // clear the buttons. + + + if (! _this.window.windowstate.valasource.checkFileWithNodePropChange( + _this.file, + _this.node, + _this.key, + _this.ptype, + str + )) { + this.check_running = false; + } + + + + //print("done mark line\n"); + + return true; // at present allow saving - even if it's invalid.. + } + public bool highlightErrorsJson (string type, Json.Object obj) { + Gtk.TextIter start; + Gtk.TextIter end; + this.el.get_bounds (out start, out end); + + this.el.remove_source_marks (start, end, type); + + + // we should highlight other types of errors.. + + if (!obj.has_member(type)) { + print("Return has no errors\n"); + return true; + } + + if (_this.window.windowstate.state != WindowState.State.CODEONLY && + _this.window.windowstate.state != WindowState.State.CODE + ) { + return true; + } + + + var err = obj.get_object_member(type); + + + if (_this.file == null) { + return true; + + } + var valafn = _this.file.path; + + if (_this.file.xtype != "PlainFile") { + + + + + valafn = ""; + try { + var regex = new Regex("\\.bjs$"); + // should not happen + + + valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala"); + } catch (GLib.RegexError e) { + return true; + } + + + + } + if (!err.has_member(valafn)) { + print("File path has no errors\n"); + return true; + } + + var lines = err.get_object_member(valafn); + + var offset = 1; + if (obj.has_member("line_offset")) { + offset = (int)obj.get_int_member("line_offset") + 1; + } + + + + + var tlines = this.el.get_line_count () +1; + + lines.foreach_member((obj, line, node) => { + + Gtk.TextIter iter; + // print("get inter\n"); + var eline = int.parse(line) - offset; + print("GOT ERROR on line %s -- converted to %d\n", line,eline); + + + if (eline > tlines || eline < 0) { + return; + } + this.el.get_iter_at_line( out iter, eline); + //print("mark line\n"); + var msg = "Line: %d".printf(eline+1); + var ar = lines.get_array_member(line); + for (var i = 0 ; i < ar.get_length(); i++) { + msg += (msg.length > 0) ? "\n" : ""; + msg += ar.get_string_element(i); + } + + + this.el.create_source_mark(msg, type, iter); + } ); + return false; + + + + + + } + } + + + +} diff --git a/src/Builder4/FakeServer.vala b/src/Builder4/FakeServer.vala new file mode 100644 index 000000000..b788213f1 --- /dev/null +++ b/src/Builder4/FakeServer.vala @@ -0,0 +1,239 @@ +/** + * Originally this was supposed to intercept http calls and redirect them + * but that is not supported in webkit2 (without using the extension api) + * + * so for now we have modified our server to serve use a base url of xhttp: + * + * so all relative urls are based on that + * + * Idea is to serve the files from the file system, so no need to setup apache etc... + * This should work for the static content like css / javascript etc.. but + * will cause issues with 'dynamic' xhr files (eg. the php stuff) + * + * the idea is nicked from geary. + * + * At present this serves from ~/gitlive/**** - that probably needs more thought.. + * + * + */ +public errordomain FakeServerError { + FILE_DOES_NOT_EXIST +} + +public class FakeServerCache : Object +{ + public string fname; + public uint8[] data; + public string content_type; + public int64 size; + + public static Gee.HashMap cache; + + public static FakeServerCache factory(string fname, string scheme) + { + if (cache == null) { + cache = new Gee.HashMap(); + } + + // print ("CACHE look for ==%s==\n", fname); + if (scheme == "resources") { + return new FakeServerCache.from_resource(fname); + } + + if (cache.has_key(fname)) { + print ("CACHE got %s\n", fname); + return cache.get(fname); + } + print ("CACHE create %s\n", fname); + + var el = new FakeServerCache(fname); + + cache.set(fname, el); + return el; + } + // called onload to clear the temporary cached file.. + public static void remove(string fname) { + if (cache == null) { + return; + } + if (!cache.has_key(fname)) { + return; + } + + + FakeServerCache v; + + cache.unset(fname, out v); + + + + } + public static void clear() + { + if (cache == null) { + return; + } + cache.clear(); + } + + public static FakeServerCache factory_with_data(string data) { + if (cache == null) { + cache = new Gee.HashMap(); + } + var el = new FakeServerCache.with_data(data); + print("CACHE - store %s\n", el.fname); + cache.set(el.fname, el); + return el; + } + + + + + public FakeServerCache.with_data( string data ) + { + this.fname = "/" + GLib.Checksum.compute_for_string(GLib.ChecksumType.MD5, data, data.length) + ".js"; + this.data = data.data; + this.content_type = "text/javascript"; + this.size= data.length; + + + } + public FakeServerCache.from_resource( string fname ) + { + + + + this.fname = fname; + + var file = File.new_for_path ( BuilderApplication.configDirectory() + "/resources/" + fname); + if (!file.query_exists()) { + this.data = "".data; + this.content_type = ""; + this.size = 0; + return; + } + try { + var info = file.query_info( + "standard::*", + FileQueryInfoFlags.NONE + ); + + this.content_type = info.get_content_type(); + this.size = info.get_size(); + uint8[] data; + + + GLib.FileUtils.get_data(file.get_path(), out data); + this.data = data; + } catch (Error e) { + this.data = "".data; + this.size = 0; + this.content_type = ""; + return; + } + + + + } + public FakeServerCache( string fname ) { + + this.fname = fname; + + var file = File.new_for_path ( GLib.Environment.get_home_dir() + "/gitlive" + fname); + if (!file.query_exists()) { + this.data = "".data; + this.content_type = ""; + this.size = 0; + return; + } + try { + var info = file.query_info( + "standard::*", + FileQueryInfoFlags.NONE + ); + this.content_type = info.get_content_type(); + this.size = info.get_size(); + uint8[] data; + + + GLib.FileUtils.get_data(file.get_path(), out data); + this.data = data; + } catch (Error e) { + this.data = "".data; + this.size = 0; + this.content_type = ""; + return; + } + + + + print("FakeServerCache :%s, %s (%s/%d)\n", fname , + this.content_type, this.size.to_string(), this.data.length); + + + } + + + public void run(WebKit.URISchemeRequest request, Cancellable? cancellable) + { + var stream = new GLib.MemoryInputStream.from_data (this.data, GLib.free); + print("SEND %s\nwe", this.size.to_string()); + + request.finish(stream, + this.size, + this.content_type); + + + + return; + + } + + +} + +public class FakeServer : Object +{ + WebKit.WebView view; + + public FakeServer(WebKit.WebView wkview) + { + this.view = wkview; + + + var cx = WebKit.WebContext.get_default(); + //var cx = this.view.get_context(); + cx.register_uri_scheme("xhttp", serve); + cx.register_uri_scheme("resources", serve); + cx.set_cache_model (WebKit.CacheModel.DOCUMENT_VIEWER); + + // these do not help for cross domain requests.. + + //cx.get_security_manager().register_uri_scheme_as_cors_enabled("xhttp"); + //cx.get_security_manager().register_uri_scheme_as_cors_enabled("http"); + //cx.register_uri_scheme_as_cors_enabled("xhttp"); + // = crash cx.set_process_model (WebKit.ProcessModel.MULTIPLE_SECONDARY_PROCESSES ); + } + + + public void serve(WebKit.URISchemeRequest request) + { + // request is URISchemeRequest + + print("REQ: %s\n",request.get_path()); + var cdata = FakeServerCache.factory(request.get_path() , request.get_scheme()); + + if (cdata.size < 1 ) { + print("Skip file missing = %s/gitlive%s\n", GLib.Environment.get_home_dir() , request.get_path()); + request.finish_error(new FakeServerError.FILE_DOES_NOT_EXIST ("My error msg")); + return; + } + + print("Send :%s, %s (%s/%d)", request.get_path(), + cdata.content_type, cdata.size.to_string(), cdata.data.length); + cdata.run(request, null); + + } + + +} diff --git a/src/Builder4/GladeExtras.vala b/src/Builder4/GladeExtras.vala new file mode 100644 index 000000000..ce8c8fdd8 --- /dev/null +++ b/src/Builder4/GladeExtras.vala @@ -0,0 +1,12 @@ + + + + +public class GladeExtras : Object +{ + + static void init() + { + + + } \ No newline at end of file diff --git a/src/Builder4/GladeView.bjs b/src/Builder4/GladeView.bjs new file mode 100644 index 000000000..c59b8e480 --- /dev/null +++ b/src/Builder4/GladeView.bjs @@ -0,0 +1,19 @@ +{ + "name" : "GladeView", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/GladeView.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "* ctor" : "new Glade.DesignView(new Glade.Project())", + "id" : "GladeView", + "| void createThumb" : "() {\n \n \n if (this.file == null) {\n return;\n }\n var filename = this.file.getIconFileName(false);\n \n var win = this.el.get_parent_window();\n var width = win.get_width();\n var height = win.get_height();\n\n Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?\n\n screenshot.save(filename,\"png\");\n return;\n \n \n \n \n \n \n \n // should we hold until it's printed...\n \n \n\n \n \n\n\n \n \n}\n", + "| void loadFile" : "(JsRender.JsRender file)\n{\n \n\n this.file = file;\n \n\n // clear existing elements from project?\n \n var p = this.el.get_project();\n var li = p.get_objects().copy();\n // should remove all..\n for (var i =0; i < li.length(); i++) { \n p.remove_object(li.nth_data(i)); \n }\n\n if (file.tree == null) {\n return;\n }\n\n// print(\"%s\\n\",tf.tree.toJsonString());\n\tvar x = new JsRender.NodeToGlade(file.tree, \"\");\n\n\t \n\tFileIOStream iostream;\n\tvar f = File.new_tmp (\"tpl-XXXXXX.glade\", out iostream);\n\tvar ostream = iostream.output_stream;\n\tvar dostream = new DataOutputStream (ostream);\n\tdostream.put_string (x.munge());\n\tthis.el.show();\n\t print(\"LOADING %s\\n\",f.get_path ());\n p.load_from_file(f.get_path ());\n \n \n\n}", + "xtype" : "DesignView", + "# JsRender.JsRender file" : "null", + "$ xns" : "Glade" + } + ] +} \ No newline at end of file diff --git a/src/Builder4/GladeView.vala b/src/Builder4/GladeView.vala new file mode 100644 index 000000000..921ac96c7 --- /dev/null +++ b/src/Builder4/GladeView.vala @@ -0,0 +1,102 @@ +static Xcls_GladeView _GladeView; + +public class Xcls_GladeView : Object +{ + public Glade.DesignView el; + private Xcls_GladeView _this; + + public static Xcls_GladeView singleton() + { + if (_GladeView == null) { + _GladeView= new Xcls_GladeView(); + } + return _GladeView; + } + + // my vars (def) + public JsRender.JsRender file; + + // ctor + public Xcls_GladeView() + { + _this = this; + this.el = new Glade.DesignView(new Glade.Project()); + + // my vars (dec) + this.file = null; + + // set gobject values + } + + // user defined functions + public void createThumb () { + + + if (this.file == null) { + return; + } + var filename = this.file.getIconFileName(false); + + var win = this.el.get_parent_window(); + var width = win.get_width(); + var height = win.get_height(); + + Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position? + + screenshot.save(filename,"png"); + return; + + + + + + + + // should we hold until it's printed... + + + + + + + + + + } + public void loadFile (JsRender.JsRender file) + { + + + this.file = file; + + + // clear existing elements from project? + + var p = this.el.get_project(); + var li = p.get_objects().copy(); + // should remove all.. + for (var i =0; i < li.length(); i++) { + p.remove_object(li.nth_data(i)); + } + + if (file.tree == null) { + return; + } + + // print("%s\n",tf.tree.toJsonString()); + var x = new JsRender.NodeToGlade(file.tree, ""); + + + FileIOStream iostream; + var f = File.new_tmp ("tpl-XXXXXX.glade", out iostream); + var ostream = iostream.output_stream; + var dostream = new DataOutputStream (ostream); + dostream.put_string (x.munge()); + this.el.show(); + print("LOADING %s\n",f.get_path ()); + p.load_from_file(f.get_path ()); + + + + } +} diff --git a/src/Builder4/GtkView.bjs b/src/Builder4/GtkView.bjs new file mode 100644 index 000000000..88f215d7f --- /dev/null +++ b/src/Builder4/GtkView.bjs @@ -0,0 +1,102 @@ +{ + "name" : "GtkView", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/GtkView.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "listeners" : { + "size_allocate" : "(aloc) => {\n \n this.width = aloc.width;\n this.height =aloc.height;\n}\n " + }, + "| void scroll_to_line" : "(int line) {\n this.notebook.el.page = 1;// code preview...\n \n GLib.Timeout.add(500, () => {\n \n \n\t \n\t \n\t\t var buf = this.sourceview.el.get_buffer();\n\t \n\t\tvar sbuf = (Gtk.SourceBuffer) buf;\n\n\n\t\tGtk.TextIter iter; \n\t\tsbuf.get_iter_at_line(out iter, line);\n\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t\treturn false;\n\t}); \n\n \n}\n", + "id" : "GtkView", + "# Gtk.Widget lastObj" : "null", + "| void createThumb" : "() {\n \n \n if (this.file == null) {\n return;\n }\n // only screenshot the gtk preview..\n if (this.notebook.el.page > 0 ) {\n return;\n }\n \n \n var filename = this.file.getIconFileName(false);\n \n var win = this.el.get_parent_window();\n var width = win.get_width();\n var height = win.get_height();\n try {\n Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?\n screenshot.save(filename,\"png\");\n } catch (Error e) {\n \n }\n\n \n return;\n \n \n \n \n \n // should we hold until it's printed...\n \n \n\n \n \n\n\n \n \n}\n", + "| void loadFile" : "(JsRender.JsRender file) \n{\n this.file = null;\n \n if (file.tree == null) {\n return;\n }\n this.notebook.el.page = 0;// gtk preview \n \n \n \n this.file = file; \n this.sourceview.loadFile();\n this.searchcontext = null;\n \n\n if (this.lastObj != null) {\n this.container.el.remove(this.lastObj);\n }\n \n // hide the compile view at present..\n \n \n var w = this.width;\n var h = this.height;\n \n print(\"ALLOC SET SIZES %d, %d\\n\", w,h); \n \n // set the container size min to 500/500 or 20 px less than max..\n w = int.max (w-20, 500);\n h = int.max (h-20, 500); \n \n print(\"SET SIZES %d, %d\\n\", w,h); \n _this.container.el.set_size_request(w,h);\n \n _this.view_layout.el.set_size(w,h); // should be baded on calc.. -- see update_scrolled.\n var rgba = Gdk.RGBA ();\n rgba.parse (\"#ccc\");\n _this.view_layout.el.override_background_color(Gtk.StateFlags.NORMAL, rgba);\n \n \n\tvar x = new JsRender.NodeToGtk(file.tree);\n var obj = x.munge() as Gtk.Widget;\n this.lastObj = null;\n\tif (obj == null) {\n \treturn;\n\t}\n\tthis.lastObj = obj;\n \n this.container.el.add(obj);\n obj.show_all();\n \n \n \n}\n ", + "int width" : 0, + "bool hexpand" : true, + "| int search" : "(string txt) {\n\tthis.notebook.el.page = 1;\n \tvar s = new Gtk.SourceSearchSettings();\n\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();\n\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);\n\tthis.searchcontext.set_highlight(true);\n\ts.set_search_text(txt);\n\t\n\tGtk.TextIter beg, st,en;\n\t \n\tbuf.get_start_iter(out beg);\n\tthis.searchcontext.forward(beg, out st, out en);\n\tthis.last_search_end = 0;\n\treturn this.searchcontext.get_occurrences_count();\n\n \n}\n", + "int last_search_end" : 0, + "xtype" : "Box", + "Gtk.SourceSearchContext searchcontext" : "", + "# JsRender.JsRender file" : "null", + "int height" : 0, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "# Xcls_MainWindow main_window" : "", + "| void forwardSearch" : "(bool change_focus) {\n\n\tif (this.searchcontext == null) {\n\t\treturn;\n\t}\n\tthis.notebook.el.page = 1;\n\tGtk.TextIter beg, st,en, stl;\n\t\n\tvar buf = this.sourceview.el.get_buffer();\n\tbuf.get_iter_at_offset(out beg, this.last_search_end);\n\tif (!this.searchcontext.forward(beg, out st, out en)) {\n\t\tthis.last_search_end = 0;\n\t} else { \n\t\tthis.last_search_end = en.get_offset();\n\t\tif (change_focus) {\n\t\t\tthis.sourceview.el.grab_focus();\t\n\t\t}\n\t\tbuf.place_cursor(st);\n\t\tvar ln = st.get_line();\n\t\tbuf.get_iter_at_line(out stl,ln);\n\t\t \n\t\tthis.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);\n\t}\n\n}\n", + "items" : [ + { + "id" : "notebook", + "* pack" : "pack_start,true,true,0", + "xtype" : "Notebook", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "label_preview", + "* pack" : false, + "xtype" : "Label", + "$ xns" : "Gtk", + "utf8 label" : "Preview" + }, + { + "id" : "label_code", + "xtype" : "Label", + "* pack" : false, + "$ xns" : "Gtk", + "utf8 label" : "Preview Generated Code" + }, + { + "* pack" : "append_page,_this.label_preview.el", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "view_layout", + "xtype" : "Layout", + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "container", + "* pack" : "put,10,10", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL" + } + ] + } + ] + }, + { + "xtype" : "ScrolledWindow", + "* pack" : "append_page,_this.label_code.el", + "$ xns" : "Gtk", + "items" : [ + { + "gboolean show_line_marks" : true, + "id" : "sourceview", + "* init" : "{\n \n var description = Pango.FontDescription.from_string(\"monospace\");\n description.set_size(8000);\n this.el.override_font(description);\n\n this.loading = true;\n var buf = this.el.get_buffer();\n buf.notify.connect((ps) => {\n if (this.loading) {\n return;\n }\n if (ps.name != \"cursor-position\") {\n return;\n }\n print(\"cursor changed : %d\\n\", buf.cursor_position);\n Gtk.TextIter cpos;\n buf.get_iter_at_offset(out cpos, buf.cursor_position);\n \n var ln = cpos.get_line();\n \n var node = _this.file.lineToNode(ln);\n \n if (node == null) {\n print(\"can not find node\\n\");\n return;\n }\n var ltree = _this.main_window.windowstate.left_tree;\n var tp = ltree.model.treePathFromNode(node);\n print(\"got tree path %s\\n\", tp);\n if (tp != \"\") {\n\t this.allow_node_scroll = false; \n\t print(\"changing cursor on tree..\\n\");\n ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);\n // scrolling is disabled... as node selection calls scroll 10ms after it changes.\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n\t this.allow_node_scroll = true;\n\t return false;\n });\n }\n \n // highlight the node..\n \n });\n \n \n \n var attrs = new Gtk.SourceMarkAttributes();\n var pink = Gdk.RGBA();\n pink.parse ( \"pink\");\n attrs.set_background ( pink);\n attrs.set_icon_name ( \"process-stop\"); \n attrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"ERR\", attrs, 1);\n \n var wattrs = new Gtk.SourceMarkAttributes();\n var blue = Gdk.RGBA();\n blue.parse ( \"#ABF4EB\");\n wattrs.set_background ( blue);\n wattrs.set_icon_name ( \"process-stop\"); \n wattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"WARN\", wattrs, 1);\n \n \n \n var dattrs = new Gtk.SourceMarkAttributes();\n var purple = Gdk.RGBA();\n purple.parse ( \"#EEA9FF\");\n dattrs.set_background ( purple);\n dattrs.set_icon_name ( \"process-stop\"); \n dattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"DEPR\", dattrs, 1);\n \n \n var gattrs = new Gtk.SourceMarkAttributes();\n var grey = Gdk.RGBA();\n grey.parse ( \"#ccc\");\n gattrs.set_background ( grey);\n \n \n this.el.set_mark_attributes (\"grey\", gattrs, 1);\n \n \n \n \n \n \n}\n ", + "| void nodeSelected" : "(JsRender.Node? sel) {\n \n \n \n // this is connected in widnowstate\n print(\"Roo-view - node selected\\n\");\n var buf = this.el.get_buffer();\n \n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n while(Gtk.events_pending()) {\n Gtk.main_iteration();\n }\n \n \n // clear all the marks..\n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, \"grey\");\n \n \n if (sel == null) {\n // no highlighting..\n return;\n }\n Gtk.TextIter iter; \n sbuf.get_iter_at_line(out iter, sel.line_start);\n \n \n Gtk.TextIter cur_iter;\n sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);\n \n //var cur_line = cur_iter.get_line();\n //if (cur_line > sel.line_start && cur_line < sel.line_end) {\n \n //} else {\n if (this.allow_node_scroll) {\n\t\t \n \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t}\n \n \n \n for (var i = 0; i < buf.get_line_count();i++) {\n if (i < sel.line_start || i > sel.line_end) {\n \n sbuf.get_iter_at_line(out iter, i);\n sbuf.create_source_mark(null, \"grey\", iter);\n \n }\n \n }\n \n\n}\n", + "bool loading" : true, + "| string toString" : "() {\n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_buffer().get_start_iter(out s);\n this.el.get_buffer().get_end_iter(out e);\n var ret = this.el.get_buffer().get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n", + "| void loadFile" : "( ) {\n this.loading = true;\n var buf = this.el.get_buffer();\n buf.set_text(\"\",0);\n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n\n if (_this.file == null || _this.file.xtype != \"Gtk\") {\n print(\"xtype != Gtk\");\n this.loading = false;\n return;\n }\n \n var valafn = \"\";\n try { \n var regex = new Regex(\"\\\\.bjs$\");\n \n \n valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");\n } catch (GLib.RegexError e) {\n this.loading = false;\n return;\n } \n \n\n if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {\n print(\"File path has no errors\\n\");\n this.loading = false;\n return ;\n }\n \n string str;\n try {\n \n GLib.FileUtils.get_contents (valafn, out str);\n } catch (Error e) {\n this.loading = false;\n return ;\n }\n\n// print(\"setting str %d\\n\", str.length);\n buf.set_text(str, str.length);\n var lm = Gtk.SourceLanguageManager.get_default();\n \n //?? is javascript going to work as js?\n \n ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));\n \n \n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, null); // remove all marks..\n \n \n if (_this.main_window.windowstate.last_compile_result != null) {\n var obj = _this.main_window.windowstate.last_compile_result;\n this.highlightErrorsJson(\"ERR\", obj);\n this.highlightErrorsJson(\"WARN\", obj);\n this.highlightErrorsJson(\"DEPR\", obj);\t\t\t\n }\n //while (Gtk.events_pending()) {\n // Gtk.main_iteration();\n // }\n \n this.loading = false; \n}\n", + "* pack" : "add", + "xtype" : "SourceView", + "bool allow_node_scroll" : true, + "| void highlightErrorsJson" : " (string type, Json.Object obj) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n \n var buf = this.el.get_buffer();\n var sbuf = (Gtk.SourceBuffer)buf;\n buf.get_bounds (out start, out end);\n \n sbuf.remove_source_marks (start, end, type);\n \n \n // we should highlight other types of errors..\n \n if (!obj.has_member(type)) {\n print(\"Return has no errors\\n\");\n return ;\n }\n var err = obj.get_object_member(type);\n \n if (_this.file == null) { \n return; // just in case the file has not loaded yet?\n }\n \n\n var valafn = \"\";\n try { \n var regex = new Regex(\"\\\\.bjs$\");\n \n \n valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");\n } catch (GLib.RegexError e) {\n return;\n } \n\n if (!err.has_member(valafn)) {\n print(\"File path has no errors\\n\");\n return ;\n }\n var lines = err.get_object_member(valafn);\n \n \n \n var tlines = buf.get_line_count () +1;\n \n lines.foreach_member((obj, line, node) => {\n \n Gtk.TextIter iter;\n // print(\"get inter\\n\");\n var eline = int.parse(line) -1 ;\n print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);\n \n \n if (eline > tlines || eline < 0) {\n return;\n }\n sbuf.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n var msg = type + \" on line: %d - %s\".printf(eline+1, valafn);\n var ar = lines.get_array_member(line);\n for (var i = 0 ; i < ar.get_length(); i++) {\n\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";\n\t\t msg += ar.get_string_element(i);\n\t }\n \n \n sbuf.create_source_mark(msg, type, iter);\n } );\n return ;\n \n \n\n\n}", + "$ xns" : "Gtk", + "gboolean show_line_numbers" : true, + "gboolean editable" : false + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/GtkView.vala b/src/Builder4/GtkView.vala new file mode 100644 index 000000000..9851abb76 --- /dev/null +++ b/src/Builder4/GtkView.vala @@ -0,0 +1,739 @@ +static Xcls_GtkView _GtkView; + +public class Xcls_GtkView : Object +{ + public Gtk.Box el; + private Xcls_GtkView _this; + + public static Xcls_GtkView singleton() + { + if (_GtkView == null) { + _GtkView= new Xcls_GtkView(); + } + return _GtkView; + } + public Xcls_notebook notebook; + public Xcls_label_preview label_preview; + public Xcls_label_code label_code; + public Xcls_view_layout view_layout; + public Xcls_container container; + public Xcls_sourceview sourceview; + + // my vars (def) + public Gtk.Widget lastObj; + public int width; + public int last_search_end; + public Gtk.SourceSearchContext searchcontext; + public JsRender.JsRender file; + public int height; + public Xcls_MainWindow main_window; + + // ctor + public Xcls_GtkView() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.lastObj = null; + this.width = 0; + this.last_search_end = 0; + this.file = null; + this.height = 0; + + // set gobject values + this.el.hexpand = true; + var child_0 = new Xcls_notebook( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + + //listeners + this.el.size_allocate.connect( (aloc) => { + + this.width = aloc.width; + this.height =aloc.height; + }); + } + + // user defined functions + public void scroll_to_line (int line) { + this.notebook.el.page = 1;// code preview... + + GLib.Timeout.add(500, () => { + + + + + var buf = this.sourceview.el.get_buffer(); + + var sbuf = (Gtk.SourceBuffer) buf; + + + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, line); + this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + return false; + }); + + + } + public void createThumb () { + + + if (this.file == null) { + return; + } + // only screenshot the gtk preview.. + if (this.notebook.el.page > 0 ) { + return; + } + + + var filename = this.file.getIconFileName(false); + + var win = this.el.get_parent_window(); + var width = win.get_width(); + var height = win.get_height(); + try { + Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position? + screenshot.save(filename,"png"); + } catch (Error e) { + + } + + + return; + + + + + + // should we hold until it's printed... + + + + + + + + + + } + public void loadFile (JsRender.JsRender file) + { + this.file = null; + + if (file.tree == null) { + return; + } + this.notebook.el.page = 0;// gtk preview + + + + this.file = file; + this.sourceview.loadFile(); + this.searchcontext = null; + + + if (this.lastObj != null) { + this.container.el.remove(this.lastObj); + } + + // hide the compile view at present.. + + + var w = this.width; + var h = this.height; + + print("ALLOC SET SIZES %d, %d\n", w,h); + + // set the container size min to 500/500 or 20 px less than max.. + w = int.max (w-20, 500); + h = int.max (h-20, 500); + + print("SET SIZES %d, %d\n", w,h); + _this.container.el.set_size_request(w,h); + + _this.view_layout.el.set_size(w,h); // should be baded on calc.. -- see update_scrolled. + var rgba = Gdk.RGBA (); + rgba.parse ("#ccc"); + _this.view_layout.el.override_background_color(Gtk.StateFlags.NORMAL, rgba); + + + var x = new JsRender.NodeToGtk(file.tree); + var obj = x.munge() as Gtk.Widget; + this.lastObj = null; + if (obj == null) { + return; + } + this.lastObj = obj; + + this.container.el.add(obj); + obj.show_all(); + + + + } + public int search (string txt) { + this.notebook.el.page = 1; + var s = new Gtk.SourceSearchSettings(); + var buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer(); + this.searchcontext = new Gtk.SourceSearchContext(buf,s); + this.searchcontext.set_highlight(true); + s.set_search_text(txt); + + Gtk.TextIter beg, st,en; + + buf.get_start_iter(out beg); + this.searchcontext.forward(beg, out st, out en); + this.last_search_end = 0; + return this.searchcontext.get_occurrences_count(); + + + } + public void forwardSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + this.notebook.el.page = 1; + Gtk.TextIter beg, st,en, stl; + + var buf = this.sourceview.el.get_buffer(); + buf.get_iter_at_offset(out beg, this.last_search_end); + if (!this.searchcontext.forward(beg, out st, out en)) { + this.last_search_end = 0; + } else { + this.last_search_end = en.get_offset(); + if (change_focus) { + this.sourceview.el.grab_focus(); + } + buf.place_cursor(st); + var ln = st.get_line(); + buf.get_iter_at_line(out stl,ln); + + this.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f); + } + + } + public class Xcls_notebook : Object + { + public Gtk.Notebook el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_notebook(Xcls_GtkView _owner ) + { + _this = _owner; + _this.notebook = this; + this.el = new Gtk.Notebook(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_label_preview( _this ); + child_0.ref(); + var child_1 = new Xcls_label_code( _this ); + child_1.ref(); + var child_2 = new Xcls_ScrolledWindow5( _this ); + child_2.ref(); + this.el.append_page ( child_2.el , _this.label_preview.el ); + var child_3 = new Xcls_ScrolledWindow8( _this ); + child_3.ref(); + this.el.append_page ( child_3.el , _this.label_code.el ); + } + + // user defined functions + } + public class Xcls_label_preview : Object + { + public Gtk.Label el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_label_preview(Xcls_GtkView _owner ) + { + _this = _owner; + _this.label_preview = this; + this.el = new Gtk.Label( "Preview" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_label_code : Object + { + public Gtk.Label el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_label_code(Xcls_GtkView _owner ) + { + _this = _owner; + _this.label_code = this; + this.el = new Gtk.Label( "Preview Generated Code" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_ScrolledWindow5 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow5(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_view_layout( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_view_layout : Object + { + public Gtk.Layout el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_view_layout(Xcls_GtkView _owner ) + { + _this = _owner; + _this.view_layout = this; + this.el = new Gtk.Layout( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_container( _this ); + child_0.ref(); + this.el.put ( child_0.el , 10,10 ); + } + + // user defined functions + } + public class Xcls_container : Object + { + public Gtk.Box el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_container(Xcls_GtkView _owner ) + { + _this = _owner; + _this.container = this; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_ScrolledWindow8 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow8(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_sourceview( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_sourceview : Object + { + public Gtk.SourceView el; + private Xcls_GtkView _this; + + + // my vars (def) + public bool loading; + public bool allow_node_scroll; + + // ctor + public Xcls_sourceview(Xcls_GtkView _owner ) + { + _this = _owner; + _this.sourceview = this; + this.el = new Gtk.SourceView(); + + // my vars (dec) + this.loading = true; + this.allow_node_scroll = true; + + // set gobject values + this.el.editable = false; + this.el.show_line_marks = true; + this.el.show_line_numbers = true; + + // init method + + { + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(8000); + this.el.override_font(description); + + this.loading = true; + var buf = this.el.get_buffer(); + buf.notify.connect((ps) => { + if (this.loading) { + return; + } + if (ps.name != "cursor-position") { + return; + } + print("cursor changed : %d\n", buf.cursor_position); + Gtk.TextIter cpos; + buf.get_iter_at_offset(out cpos, buf.cursor_position); + + var ln = cpos.get_line(); + + var node = _this.file.lineToNode(ln); + + if (node == null) { + print("can not find node\n"); + return; + } + var ltree = _this.main_window.windowstate.left_tree; + var tp = ltree.model.treePathFromNode(node); + print("got tree path %s\n", tp); + if (tp != "") { + this.allow_node_scroll = false; + print("changing cursor on tree..\n"); + ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); + // scrolling is disabled... as node selection calls scroll 10ms after it changes. + GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { + this.allow_node_scroll = true; + return false; + }); + } + + // highlight the node.. + + }); + + + + var attrs = new Gtk.SourceMarkAttributes(); + var pink = Gdk.RGBA(); + pink.parse ( "pink"); + attrs.set_background ( pink); + attrs.set_icon_name ( "process-stop"); + attrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("ERR", attrs, 1); + + var wattrs = new Gtk.SourceMarkAttributes(); + var blue = Gdk.RGBA(); + blue.parse ( "#ABF4EB"); + wattrs.set_background ( blue); + wattrs.set_icon_name ( "process-stop"); + wattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("WARN", wattrs, 1); + + + + var dattrs = new Gtk.SourceMarkAttributes(); + var purple = Gdk.RGBA(); + purple.parse ( "#EEA9FF"); + dattrs.set_background ( purple); + dattrs.set_icon_name ( "process-stop"); + dattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("DEPR", dattrs, 1); + + + var gattrs = new Gtk.SourceMarkAttributes(); + var grey = Gdk.RGBA(); + grey.parse ( "#ccc"); + gattrs.set_background ( grey); + + + this.el.set_mark_attributes ("grey", gattrs, 1); + + + + + + + } + } + + // user defined functions + public void nodeSelected (JsRender.Node? sel) { + + + + // this is connected in widnowstate + print("Roo-view - node selected\n"); + var buf = this.el.get_buffer(); + + var sbuf = (Gtk.SourceBuffer) buf; + + + while(Gtk.events_pending()) { + Gtk.main_iteration(); + } + + + // clear all the marks.. + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, "grey"); + + + if (sel == null) { + // no highlighting.. + return; + } + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, sel.line_start); + + + Gtk.TextIter cur_iter; + sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position); + + //var cur_line = cur_iter.get_line(); + //if (cur_line > sel.line_start && cur_line < sel.line_end) { + + //} else { + if (this.allow_node_scroll) { + + this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + } + + + + for (var i = 0; i < buf.get_line_count();i++) { + if (i < sel.line_start || i > sel.line_end) { + + sbuf.get_iter_at_line(out iter, i); + sbuf.create_source_mark(null, "grey", iter); + + } + + } + + + } + public string toString () { + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_buffer().get_start_iter(out s); + this.el.get_buffer().get_end_iter(out e); + var ret = this.el.get_buffer().get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + public void loadFile ( ) { + this.loading = true; + var buf = this.el.get_buffer(); + buf.set_text("",0); + var sbuf = (Gtk.SourceBuffer) buf; + + + + if (_this.file == null || _this.file.xtype != "Gtk") { + print("xtype != Gtk"); + this.loading = false; + return; + } + + var valafn = ""; + try { + var regex = new Regex("\\.bjs$"); + + + valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala"); + } catch (GLib.RegexError e) { + this.loading = false; + return; + } + + + if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) { + print("File path has no errors\n"); + this.loading = false; + return ; + } + + string str; + try { + + GLib.FileUtils.get_contents (valafn, out str); + } catch (Error e) { + this.loading = false; + return ; + } + + // print("setting str %d\n", str.length); + buf.set_text(str, str.length); + var lm = Gtk.SourceLanguageManager.get_default(); + + //?? is javascript going to work as js? + + ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language)); + + + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, null); // remove all marks.. + + + if (_this.main_window.windowstate.last_compile_result != null) { + var obj = _this.main_window.windowstate.last_compile_result; + this.highlightErrorsJson("ERR", obj); + this.highlightErrorsJson("WARN", obj); + this.highlightErrorsJson("DEPR", obj); + } + //while (Gtk.events_pending()) { + // Gtk.main_iteration(); + // } + + this.loading = false; + } + public void highlightErrorsJson (string type, Json.Object obj) { + Gtk.TextIter start; + Gtk.TextIter end; + + var buf = this.el.get_buffer(); + var sbuf = (Gtk.SourceBuffer)buf; + buf.get_bounds (out start, out end); + + sbuf.remove_source_marks (start, end, type); + + + // we should highlight other types of errors.. + + if (!obj.has_member(type)) { + print("Return has no errors\n"); + return ; + } + var err = obj.get_object_member(type); + + if (_this.file == null) { + return; // just in case the file has not loaded yet? + } + + + var valafn = ""; + try { + var regex = new Regex("\\.bjs$"); + + + valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala"); + } catch (GLib.RegexError e) { + return; + } + + if (!err.has_member(valafn)) { + print("File path has no errors\n"); + return ; + } + var lines = err.get_object_member(valafn); + + + + var tlines = buf.get_line_count () +1; + + lines.foreach_member((obj, line, node) => { + + Gtk.TextIter iter; + // print("get inter\n"); + var eline = int.parse(line) -1 ; + print("GOT ERROR on line %s -- converted to %d\n", line,eline); + + + if (eline > tlines || eline < 0) { + return; + } + sbuf.get_iter_at_line( out iter, eline); + //print("mark line\n"); + var msg = type + " on line: %d - %s".printf(eline+1, valafn); + var ar = lines.get_array_member(line); + for (var i = 0 ; i < ar.get_length(); i++) { + msg += (msg.length > 0) ? "\n" : ""; + msg += ar.get_string_element(i); + } + + + sbuf.create_source_mark(msg, type, iter); + } ); + return ; + + + + + } + } + + + +} diff --git a/src/Builder4/MainWindow.bjs b/src/Builder4/MainWindow.bjs new file mode 100644 index 000000000..c1ec4a3e9 --- /dev/null +++ b/src/Builder4/MainWindow.bjs @@ -0,0 +1,755 @@ +{ + "name" : "MainWindow", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/MainWindow.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "listeners" : { + "delete_event" : " ( event) => {\n return false;\n} ", + "destroy" : "() => {\n Xcls_MainWindow.singleton().no_windows--;\n \n Resources.singleton().disconnect(_this.statusbar.handler_id);\n \n \n if (Xcls_MainWindow.singleton().no_windows < 1) {\n\n Gtk.main_quit();\n }\n}", + "show" : " ( ) => {\n // hide the file editing..\n \n //this.hideViewEditing();\n _this.statusbar.el.hide();\n _this.statusbar_errors.el.hide();\n _this.statusbar_warnings.el.hide();\n _this.statusbar_depricated.el.hide();\n \n \n Resources.singleton().checkResources();\n\n}", + "key_release_event" : " (event) => {\n \n if (this.search_entry.el.is_visible()) {\n\t\tif (event.keyval == Gdk.Key.f && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n\t\t print(\"SAVE: ctrl-f pressed\");\n\t\t\tthis.search_entry.el.grab_focus();\n\t\t return false;\n\t\t}\n\t\t\n\t\tif (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n\t\t print(\"SAVE: ctrl-g pressed\");\n\t\t\tthis.search_entry.forwardSearch(true);\n\t\t return false;\n\t\t}\n\t\t\n\t} \n\t\n\tif (event.keyval == Gdk.Key.n && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n\t\tprint(\"SAVE: ctrl-n pressed\");\n\t\tthis.openNewWindow();\n\t\treturn false;\n\t}\n\t\n // print(event.key.keyval)\n \n return false;\n\n} \n\n" + }, + "id" : "MainWindow", + "default_width" : 800, + "* init" : " \n\t \n //this.el.show_all();\n //try {\n this.el.set_icon_name(\"roobuilder\");\n\t//} catch (Exception e) {\n\t//\tprint(\"no icon found\");\n//\t}", + "| void openNewWindow" : "() {\n\tXcls_MainWindow.singleton().no_windows++;\n var w = new Xcls_MainWindow();\n w.ref();\n\n w.el.show_all();\n w.initChildren();\n w.windowstate.switchState(WindowState.State.FILES);\n}\n", + "# Project.Project project" : "null", + "# string title" : "\"Application Builder\"", + "xtype" : "Window", + "# int no_windows" : 1, + "default_height" : 500, + "| void initChildren" : " () {\n // this needs putting in a better place..\n this.windowstate = new WindowState(this);\n \n\n //w.el.show_all();\n var tl = new Clutter.Timeline(6000);\n tl.set_repeat_count(-1);\n tl.start();\n tl.ref();\n\n \n\n\n\n}\n", + "$ xns" : "Gtk", + "| void show" : "() {\n \n this.el.show_all();\n\n}", + "# WindowState windowstate" : "null", + "border_width" : 0, + "$ type" : "Gtk.WindowType.TOPLEVEL", + "| void setTitle" : " (string str) {\n this.headerbar.el.set_title(this.title + \" - \" + str);\n} \n", + "items" : [ + { + "id" : "headerbar", + "xtype" : "HeaderBar", + "* pack" : "set_titlebar", + "bool show_close_button" : true, + "$ xns" : "Gtk", + "string title" : "Application Builder", + "items" : [ + { + "* pack" : "pack_start", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "bool use_popover" : false, + "xtype" : "MenuButton", + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "topbarmenu", + "* init" : "{\n this.el.show_all();\n}\n", + "xtype" : "Menu", + "* pack" : "set_popup", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : "( ) => {\n _this.openNewWindow();\n}" + }, + "string label" : "Open a new Window", + "* pack" : "append", + "xtype" : "MenuItem", + "$ xns" : "Gtk" + }, + { + "* pack" : "append", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) => {\n Resources.singleton().fetchStart();\n}" + }, + "xtype" : "MenuItem", + "string label" : "Download updated Resources", + "* pack" : "append", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : "() => {\n About.singleton().el.show();\n }" + }, + "* pack" : "append", + "xtype" : "MenuItem", + "string label" : "About the Builder", + "$ xns" : "Gtk" + } + ] + }, + { + "utf8 icon_name" : "help-about", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + }, + { + "listeners" : { + "clicked" : " ( ) => {\n _this.windowstate.switchState(WindowState.State.FILES);\n \n\n}" + }, + "id" : "openbtn", + "* pack" : "add", + "xtype" : "Button", + "$ xns" : "Gtk", + "$ tooltop_text" : "\"Open File\"", + "items" : [ + { + "xtype" : "Image", + "utf8 icon_name" : "document-open", + "* pack" : "set_image", + "$ xns" : "Gtk" + } + ] + }, + { + "listeners" : { + "clicked" : " ( ) => {\n \n _this.windowstate.switchState(WindowState.State.PREVIEW);\n \n\n}" + }, + "id" : "openbackbtn", + "utf8 tooltip_text" : "Back", + "xtype" : "Button", + "* pack" : "add", + "$ xns" : "Gtk", + "bool visible" : false, + "items" : [ + { + "* pack" : "set_image", + "xtype" : "Image", + "utf8 icon_name" : "go-previous", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "vbox", + "* pack" : "add", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "$ homogeneous" : false, + "items" : [ + { + "id" : "mainpane", + "position" : 400, + "* pack" : "pack_start,true,true,0", + "# int lastWidth" : 0, + "xtype" : "Paned", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "id" : "leftpane", + "xtype" : "Box", + "* pack" : "add1", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "id" : "editpane", + "xtype" : "Paned", + "* pack" : "pack_start,true,true,0", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "id" : "tree", + "xtype" : "Box", + "* pack" : "add1", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL" + }, + { + "id" : "props", + "xtype" : "Box", + "* pack" : "add2", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL" + } + ] + } + ] + }, + { + "* pack" : "add2", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "listeners" : { + "size_allocate" : " ( alloc) => {\n if (_this.windowstate == null) {\n return;\n }\n _this.windowstate.resizeCanvas(); \n \n}" + }, + "id" : "clutterembed", + "* init" : " var stage = this.el.get_stage();\n stage.set_background_color( Clutter.Color.from_string(\"#000\"));\n \n \n", + "xtype" : "Embed", + "* pack" : "pack_start,true,true,0", + "$ xns" : "GtkClutter", + "items" : [ + { + "id" : "rooview", + "* init" : "{\n \n \n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 1.0f\n )\n );\n \n //this.el.set_position(100,100);\n this.el.set_pivot_point(1.0f,1.0f);\n \n this.el.set_size(_this.clutterembed.el.get_stage().width-50,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "objectview", + "* init" : "{\n \n /*\n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n */\n this.el.fixed_x = 50.0f;\n this.el.fixed_y = 0.0f;\n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(0.0f,1.0f);\n this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "codeeditview", + "* init" : "{\n \n /*\n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n */\n this.el.fixed_x = 50.0f;\n this.el.fixed_y = 0.0f;\n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(0.0f,1.0f);\n this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "addpropsview", + "* init" : "{\n \n /*\n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n */\n this.el.fixed_x = 50.0f;\n this.el.fixed_y = 0.0f;\n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(0.0f,1.0f);\n this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "projecteditview", + "* init" : "{\n \n \n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 1.0f\n )\n );\n \n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(1.0f,0.0f);\n this.el.set_size(_this.clutterembed.el.get_stage().width-50,\n _this.clutterembed.el.get_stage().height /2);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "buttonlayout", + "* init" : "{\n \n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n \n \n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.5f,0.5f);\n this.el.set_size(50,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "Clutter", + "items" : [ + { + "$ orientation" : "Clutter.Orientation.VERTICAL", + "xtype" : "BoxLayout", + "$ xns" : "Clutter", + "* prop" : "layout_manager" + }, + { + "id" : "backbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n if (_this.windowstate.state == WindowState.State.FILEPROJECT) {\n \n\t _this.windowstate.switchState(WindowState.State.FILES);\n } else { \n\t _this.windowstate.switchState(WindowState.State.PREVIEW);\n }\n \n\n}" + }, + "utf8 tooltip_text" : "Back", + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "height_request" : 50, + "items" : [ + { + "xtype" : "Image", + "utf8 icon_name" : "go-previous", + "* pack" : "set_image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "editfilebutton", + "* init" : "this.el.set_size(50.0f,50.0f);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n // create a new file in project..\n if (_this.project == null || _this.windowstate.file == null) {\n return ;\n }\n _this.windowstate.file_details.show(\n _this.windowstate.file, this.el\n );\n \n return ; \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"File Details\"", + "height_request" : 50, + "items" : [ + { + "utf8 icon_name" : "document-properties", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "projecteditbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n if (_this.windowstate.state == WindowState.State.FILES) {\n \n\t _this.windowstate.switchState(WindowState.State.FILEPROJECT);\n } else {\n \t _this.windowstate.switchState(WindowState.State.PROJECT);\n\t } \n \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Project Details\"", + "height_request" : 50, + "items" : [ + { + "xtype" : "Image", + "utf8 icon_name" : "emblem-system", + "* pack" : "set_image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "listeners" : { + "enter_event" : "( event) => {\n this.el.background_color = Clutter.Color.from_string(\"#333\");\n return false;\n}", + "leave_event" : "( event) => {\n this.el.background_color = Clutter.Color.from_string(\"#000\");\n return false;\n}" + }, + "id" : "objectshowbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n _this.windowstate.switchState(WindowState.State.OBJECT);\n \n \n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Add Child Element\"", + "height_request" : 50, + "items" : [ + { + "* pack" : "set_image", + "xtype" : "Image", + "utf8 icon_name" : "list-add", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "addpropbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n _this.windowstate.switchState(WindowState.State.PROP);\n \n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Add Property\"", + "height_request" : 50, + "items" : [ + { + "utf8 icon_name" : "format-justify-left", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "addlistenerbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n _this.windowstate.switchState(WindowState.State.LISTENER);\n \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Add Event Code\"", + "height_request" : 50, + "items" : [ + { + "xtype" : "Image", + "utf8 icon_name" : "appointment-new", + "* pack" : "set_image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "addprojectbutton", + "* init" : "this.el.set_size(50.0f,50.0f);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n // create a new file in project..\n //Xcls_DialogNewComponent.singleton().show(\n var pe = EditProject.singleton();\n pe.el.set_transient_for(_this.el);\n pe.el.set_modal(true); \n \n var p = pe.show();\n\n if (p == null) {\n return;\n }\n \n \n _this.windowstate.left_projects.is_loaded = false; \n _this.windowstate.left_projects.load();\n _this.windowstate.left_projects.selectProject(p);\n return ; \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"New\\nProj.\"", + "height_request" : 50, + "items" : [ + { + "utf8 icon_name" : "folder-new", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "addfilebutton", + "* init" : "this.el.set_size(50.0f,50.0f);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " () => {\n // create a new file in project..\n print(\"add file selected\\n\");\n // what's the currently selected project...\n var proj = _this.windowstate.left_projects.getSelectedProject();\n \n if (proj == null) {\n\t\tprint(\"no project selected?\\n\");\n return ;\n }\n \n print(\"creating file?\");\n \n var f = JsRender.JsRender.factory(proj.xtype, proj, \"\");\n _this.project = proj;\n print(\"showing popup?\");\n _this.windowstate.file_details.show(\n f, this.el\n );\n \n \n return ; \n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Add File\"", + "height_request" : 50, + "items" : [ + { + "* pack" : "set_image", + "xtype" : "Image", + "utf8 icon_name" : "document-new", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "delprojectbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n var cd = DialogConfirm.singleton();\n cd.el.set_transient_for(_this.el);\n cd.el.set_modal(true);\n\n var project = _this.windowstate.left_projects.getSelectedProject();\n if (project == null) {\n print(\"SKIP - no project\\n\");\n return;\n }\n \n \n if (Gtk.ResponseType.YES != cd.show(\"Confirm\", \n \"Are you sure you want to delete project %s\".printf(project.name))) {\n return;\n }\n \n\n // confirm?\n Project.Project.remove(project);\n _this.project = null;\n \n _this.windowstate.left_projects.is_loaded = false;\n _this.windowstate.left_projects.load();\n _this.windowstate.clutterfiles.clearFiles();\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Delete Project\"", + "height_request" : 50, + "items" : [ + { + "utf8 icon_name" : "user-trash", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "bool homogeneous" : false, + "xtype" : "Box", + "* pack" : "pack_end,false,true,0", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "* pack" : "pack_start,true,true,0", + "xtype" : "Label", + "string label" : " ", + "$ xns" : "Gtk" + }, + { + "bool show_text" : true, + "id" : "statusbar", + "ulong handler_id" : "-1", + "* init" : "{\n this.handler_id = Resources.singleton().updateProgress.connect((pos,total) => {\n if (pos < 1) {\n this.el.hide();\n _this.mainpane.el.set_sensitive(true);\n \n return;\n }\n _this.mainpane.el.set_sensitive(false);\n this.el.show();\n this.el.set_fraction ((1.0f * pos) / (1.0f * total));\n this.el.set_text(\"Fetching Resource : %s/%s\".printf(pos.to_string(), total.to_string()));\n \n });\n}\n", + "xtype" : "ProgressBar", + "* pack" : "pack_start,true,true,0", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "key_press_event" : "(event) => {\n \n \tif (event.keyval == Gdk.Key.Return) {\n\t\tthis.forwardSearch(false);\n\t return true;\n\n\t} \n // print(event.key.keyval)\n \n return false;\n\n} ", + "changed" : "() => {\n\tif (this.el.text == \"\") {\n\t\t_this.search_results.el.hide();\n\t\treturn;\n\t}\n\tvar res = 0;\n\tswitch(_this.windowstate.state) {\n\t\tcase WindowState.State.CODEONLY:\n\t\tcase WindowState.State.CODE:\n\t\t\t// search the code being edited..\n\t\t\tres = _this.windowstate.code_editor.search(this.el.text);\n\t\t\t\n\t\t\tbreak;\n\t\tcase WindowState.State.PREVIEW:\n\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {\n\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);\n\t\t\t} else { \n\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t\n\t\t\t}\n\t\t\n\t\t\n\t\t\tbreak;\n\t}\n\t_this.search_results.el.show();\n\tif (res > 0) {\n\t\t_this.search_results.el.label = \"%d Matches\".printf(res);\n\t} else {\n\t\t_this.search_results.el.label = \"No Matches\";\n\t}\n\t\t\n\t\n\t\n}\n" + }, + "id" : "search_entry", + "* init" : "var description = Pango.FontDescription.from_string(\"monospace\");\n\tdescription.set_size(8000);\n\t this.el.override_font(description);\n\n", + "* pack" : "pack_start,false,true,0", + "xtype" : "SearchEntry", + "$ xns" : "Gtk", + "| void forwardSearch" : "(bool change_focus) {\n\tswitch(_this.windowstate.state) {\n\t\tcase WindowState.State.CODEONLY:\n\t\tcase WindowState.State.CODE:\n\t\t\t// search the code being edited..\n\t\t\t_this.windowstate.code_editor.forwardSearch(change_focus);\n\t\t\t\n\t\t\tbreak;\n\t\tcase WindowState.State.PREVIEW:\n\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {\n\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);\n\t\t\t} else { \n\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);\n\t\t\t}\n\t\t\n\t\t\tbreak;\n\t}\n\t\n}\n" + }, + { + "* pack" : "pack_end,false,true,0", + "xtype" : "MenuBar", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_press_event" : "() => {\n/*\n if (this.popup == null) {\n this.popup = new Xcls_ValaCompileErrors();\n this.popup.window = _this;\n }\n \n \n this.popup.show(this.notices, this.el);\n */\n return true;\n}" + }, + "bool always_show_image" : true, + "id" : "search_results", + "Xcls_ValaCompileErrors popup" : "", + "string label" : "Matches", + "* pack" : "add", + "xtype" : "ImageMenuItem", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "set_image", + "xtype" : "Image", + "utf8 icon_name" : "system-search", + "bool sensitive" : false, + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "statusbar_compilestatus_label", + "* pack" : "add", + "xtype" : "MenuItem", + "string label" : "Compile Status:", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "button_press_event" : "() => {\n if (this.popup == null) {\n this.popup = new Xcls_ValaCompileErrors();\n this.popup.window = _this;\n }\n \n \n this.popup.show(this.notices, this.el);\n return true;\n}" + }, + "bool always_show_image" : true, + "id" : "statusbar_errors", + "| void setNotices" : "(Json.Object nots, int qty) {\n this.el.show();\n this.el.label = qty.to_string() + \" Errors\";\n this.notices = nots;\n\n}\n", + "Xcls_ValaCompileErrors popup" : "", + "string label" : "Errors", + "* pack" : "add", + "xtype" : "ImageMenuItem", + "# Json.Object notices" : "new Json.Object() ", + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "Image", + "utf8 icon_name" : "dialog-error", + "* pack" : "set_image", + "$ xns" : "Gtk" + } + ] + }, + { + "listeners" : { + "button_press_event" : "() => {\n if (this.popup == null) {\n this.popup = new Xcls_ValaCompileErrors();\n this.popup.window = _this;\n }\n \n this.popup.show(this.notices, this.el);\n return true;\n}" + }, + "bool always_show_image" : true, + "id" : "statusbar_warnings", + "| void setNotices" : "(Json.Object nots, int qty) {\n this.el.show();\n this.el.label = qty.to_string() + \" Warnings\";\n this.notices = nots;\n\n}\n", + "Xcls_ValaCompileErrors popup" : "", + "* pack" : "add", + "string label" : "Warnings", + "xtype" : "ImageMenuItem", + "# Json.Object notices" : "new Json.Object()", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "set_image", + "xtype" : "Image", + "utf8 icon_name" : "dialog-warning", + "$ xns" : "Gtk" + } + ] + }, + { + "listeners" : { + "button_press_event" : "() => {\n if (this.popup == null) {\n this.popup = new Xcls_ValaCompileErrors();\n this.popup.window = _this;\n }\n \n \n this.popup.show(this.notices, this.el);\n return true;\n}" + }, + "bool always_show_image" : true, + "id" : "statusbar_depricated", + "| void setNotices" : "(Json.Object nots, int qty) {\n this.el.show();\n this.el.label = qty.to_string() + \" Depricated\";\n this.notices = nots;\n\n}\n", + "Xcls_ValaCompileErrors popup" : "", + "string label" : "Depricated", + "* pack" : "add", + "xtype" : "ImageMenuItem", + "# Json.Object notices" : "new Json.Object()", + "$ xns" : "Gtk", + "items" : [ + { + "utf8 icon_name" : "dialog-information", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + }, + { + "listeners" : { + "button_press_event" : "() => {\n\tif (_this.windowstate.file == null) {\n\t\treturn true;\n\t}\n\t_this.windowstate.valasource.spawnExecute(_this.windowstate.file);\n\t\n\t_this.windowstate.compile_results.show(this.el,true);\n\t\n\treturn true;\n}" + }, + "bool always_show_image" : true, + "id" : "statusbar_run", + "Xcls_ValaCompileErrors popup" : "", + "string label" : "Run", + "* pack" : "add", + "xtype" : "ImageMenuItem", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "set_image", + "xtype" : "Image", + "utf8 icon_name" : "media-playback-start", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/MainWindow.vala b/src/Builder4/MainWindow.vala new file mode 100644 index 000000000..d62b8db73 --- /dev/null +++ b/src/Builder4/MainWindow.vala @@ -0,0 +1,2861 @@ +static Xcls_MainWindow _MainWindow; + +public class Xcls_MainWindow : Object +{ + public Gtk.Window el; + private Xcls_MainWindow _this; + + public static Xcls_MainWindow singleton() + { + if (_MainWindow == null) { + _MainWindow= new Xcls_MainWindow(); + } + return _MainWindow; + } + public Xcls_headerbar headerbar; + public Xcls_topbarmenu topbarmenu; + public Xcls_openbtn openbtn; + public Xcls_openbackbtn openbackbtn; + public Xcls_vbox vbox; + public Xcls_mainpane mainpane; + public Xcls_leftpane leftpane; + public Xcls_editpane editpane; + public Xcls_tree tree; + public Xcls_props props; + public Xcls_clutterembed clutterembed; + public Xcls_rooview rooview; + public Xcls_objectview objectview; + public Xcls_codeeditview codeeditview; + public Xcls_addpropsview addpropsview; + public Xcls_projecteditview projecteditview; + public Xcls_buttonlayout buttonlayout; + public Xcls_backbutton backbutton; + public Xcls_editfilebutton editfilebutton; + public Xcls_projecteditbutton projecteditbutton; + public Xcls_objectshowbutton objectshowbutton; + public Xcls_addpropbutton addpropbutton; + public Xcls_addlistenerbutton addlistenerbutton; + public Xcls_addprojectbutton addprojectbutton; + public Xcls_addfilebutton addfilebutton; + public Xcls_delprojectbutton delprojectbutton; + public Xcls_statusbar statusbar; + public Xcls_search_entry search_entry; + public Xcls_search_results search_results; + public Xcls_statusbar_compilestatus_label statusbar_compilestatus_label; + public Xcls_statusbar_errors statusbar_errors; + public Xcls_statusbar_warnings statusbar_warnings; + public Xcls_statusbar_depricated statusbar_depricated; + public Xcls_statusbar_run statusbar_run; + + // my vars (def) + public Project.Project project; + public string title; + public int no_windows; + public WindowState windowstate; + + // ctor + public Xcls_MainWindow() + { + _this = this; + this.el = new Gtk.Window( Gtk.WindowType.TOPLEVEL ); + + // my vars (dec) + this.project = null; + this.title = "Application Builder"; + this.no_windows = 1; + this.windowstate = null; + + // set gobject values + this.el.border_width = 0; + this.el.default_height = 500; + this.el.default_width = 800; + var child_0 = new Xcls_headerbar( _this ); + child_0.ref(); + this.el.set_titlebar ( child_0.el ); + var child_1 = new Xcls_vbox( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + + // init method + + //this.el.show_all(); + //try { + this.el.set_icon_name("roobuilder"); + //} catch (Exception e) { + // print("no icon found"); + // } + + //listeners + this.el.delete_event.connect( ( event) => { + return false; + }); + this.el.destroy.connect( () => { + Xcls_MainWindow.singleton().no_windows--; + + Resources.singleton().disconnect(_this.statusbar.handler_id); + + + if (Xcls_MainWindow.singleton().no_windows < 1) { + + Gtk.main_quit(); + } + }); + this.el.show.connect( ( ) => { + // hide the file editing.. + + //this.hideViewEditing(); + _this.statusbar.el.hide(); + _this.statusbar_errors.el.hide(); + _this.statusbar_warnings.el.hide(); + _this.statusbar_depricated.el.hide(); + + + Resources.singleton().checkResources(); + + }); + this.el.key_release_event.connect( (event) => { + + if (this.search_entry.el.is_visible()) { + if (event.keyval == Gdk.Key.f && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + print("SAVE: ctrl-f pressed"); + this.search_entry.el.grab_focus(); + return false; + } + + if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + print("SAVE: ctrl-g pressed"); + this.search_entry.forwardSearch(true); + return false; + } + + } + + if (event.keyval == Gdk.Key.n && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + print("SAVE: ctrl-n pressed"); + this.openNewWindow(); + return false; + } + + // print(event.key.keyval) + + return false; + + }); + } + + // user defined functions + public void openNewWindow () { + Xcls_MainWindow.singleton().no_windows++; + var w = new Xcls_MainWindow(); + w.ref(); + + w.el.show_all(); + w.initChildren(); + w.windowstate.switchState(WindowState.State.FILES); + } + public void initChildren () { + // this needs putting in a better place.. + this.windowstate = new WindowState(this); + + + //w.el.show_all(); + var tl = new Clutter.Timeline(6000); + tl.set_repeat_count(-1); + tl.start(); + tl.ref(); + + + + + + } + public void show () { + + this.el.show_all(); + + } + public void setTitle (string str) { + this.headerbar.el.set_title(this.title + " - " + str); + } + public class Xcls_headerbar : Object + { + public Gtk.HeaderBar el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_headerbar(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.headerbar = this; + this.el = new Gtk.HeaderBar(); + + // my vars (dec) + + // set gobject values + this.el.title = "Application Builder"; + this.el.show_close_button = true; + var child_0 = new Xcls_Box3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el ); + } + + // user defined functions + } + public class Xcls_Box3 : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Box3(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuButton4( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_openbtn( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_openbackbtn( _this ); + child_2.ref(); + this.el.add ( child_2.el ); + } + + // user defined functions + } + public class Xcls_MenuButton4 : Object + { + public Gtk.MenuButton el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_MenuButton4(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.MenuButton(); + + // my vars (dec) + + // set gobject values + this.el.use_popover = false; + var child_0 = new Xcls_topbarmenu( _this ); + child_0.ref(); + this.el.set_popup ( child_0.el ); + var child_1 = new Xcls_Image10( _this ); + child_1.ref(); + this.el.set_image ( child_1.el ); + } + + // user defined functions + } + public class Xcls_topbarmenu : Object + { + public Gtk.Menu el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_topbarmenu(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.topbarmenu = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem6( _this ); + child_0.ref(); + this.el.append ( child_0.el ); + var child_1 = new Xcls_SeparatorMenuItem7( _this ); + child_1.ref(); + this.el.append ( child_1.el ); + var child_2 = new Xcls_MenuItem8( _this ); + child_2.ref(); + this.el.append ( child_2.el ); + var child_3 = new Xcls_MenuItem9( _this ); + child_3.ref(); + this.el.append ( child_3.el ); + + // init method + + { + this.el.show_all(); + } + } + + // user defined functions + } + public class Xcls_MenuItem6 : Object + { + public Gtk.MenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem6(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Open a new Window"; + + //listeners + this.el.activate.connect( ( ) => { + _this.openNewWindow(); + }); + } + + // user defined functions + } + + public class Xcls_SeparatorMenuItem7 : Object + { + public Gtk.SeparatorMenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem7(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_MenuItem8 : Object + { + public Gtk.MenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem8(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Download updated Resources"; + + //listeners + this.el.activate.connect( ( ) => { + Resources.singleton().fetchStart(); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem9 : Object + { + public Gtk.MenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem9(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "About the Builder"; + + //listeners + this.el.activate.connect( () => { + About.singleton().el.show(); + }); + } + + // user defined functions + } + + + public class Xcls_Image10 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image10(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "help-about"; + } + + // user defined functions + } + + + public class Xcls_openbtn : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_openbtn(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.openbtn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Image12( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + _this.windowstate.switchState(WindowState.State.FILES); + + + }); + } + + // user defined functions + } + public class Xcls_Image12 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image12(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "document-open"; + } + + // user defined functions + } + + + public class Xcls_openbackbtn : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_openbackbtn(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.openbackbtn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_text = "Back"; + this.el.visible = false; + var child_0 = new Xcls_Image14( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + + _this.windowstate.switchState(WindowState.State.PREVIEW); + + + }); + } + + // user defined functions + } + public class Xcls_Image14 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image14(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "go-previous"; + } + + // user defined functions + } + + + + + public class Xcls_vbox : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_vbox(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.vbox = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_mainpane( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + var child_1 = new Xcls_Box66( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , false,true,0 ); + } + + // user defined functions + } + public class Xcls_mainpane : Object + { + public Gtk.Paned el; + private Xcls_MainWindow _this; + + + // my vars (def) + public int lastWidth; + + // ctor + public Xcls_mainpane(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.mainpane = this; + this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + this.lastWidth = 0; + + // set gobject values + this.el.position = 400; + var child_0 = new Xcls_leftpane( _this ); + child_0.ref(); + this.el.add1 ( child_0.el ); + var child_1 = new Xcls_Box21( _this ); + child_1.ref(); + this.el.add2 ( child_1.el ); + } + + // user defined functions + } + public class Xcls_leftpane : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_leftpane(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.leftpane = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_editpane( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_editpane : Object + { + public Gtk.Paned el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_editpane(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.editpane = this; + this.el = new Gtk.Paned( Gtk.Orientation.VERTICAL ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_tree( _this ); + child_0.ref(); + this.el.add1 ( child_0.el ); + var child_1 = new Xcls_props( _this ); + child_1.ref(); + this.el.add2 ( child_1.el ); + } + + // user defined functions + } + public class Xcls_tree : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_tree(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.tree = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_props : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_props(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.props = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_Box21 : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Box21(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_clutterembed( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_clutterembed : Object + { + public GtkClutter.Embed el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_clutterembed(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.clutterembed = this; + this.el = new GtkClutter.Embed(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_rooview( _this ); + child_0.ref(); + this.el.get_stage().add_child ( child_0.el ); + var child_1 = new Xcls_objectview( _this ); + child_1.ref(); + this.el.get_stage().add_child ( child_1.el ); + var child_2 = new Xcls_codeeditview( _this ); + child_2.ref(); + this.el.get_stage().add_child ( child_2.el ); + var child_3 = new Xcls_addpropsview( _this ); + child_3.ref(); + this.el.get_stage().add_child ( child_3.el ); + var child_4 = new Xcls_projecteditview( _this ); + child_4.ref(); + this.el.get_stage().add_child ( child_4.el ); + var child_5 = new Xcls_buttonlayout( _this ); + child_5.ref(); + this.el.get_stage().add_child ( child_5.el ); + + // init method + + var stage = this.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + + //listeners + this.el.size_allocate.connect( ( alloc) => { + if (_this.windowstate == null) { + return; + } + _this.windowstate.resizeCanvas(); + + }); + } + + // user defined functions + } + public class Xcls_rooview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_rooview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.rooview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 1.0f + ) + ); + + //this.el.set_position(100,100); + this.el.set_pivot_point(1.0f,1.0f); + + this.el.set_size(_this.clutterembed.el.get_stage().width-50, + _this.clutterembed.el.get_stage().height); + + } + } + + // user defined functions + } + + public class Xcls_objectview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_objectview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.objectview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + /* + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 0.0f + ) + ); + */ + this.el.fixed_x = 50.0f; + this.el.fixed_y = 0.0f; + //this.el.set_position(100,100); + this.el.set_pivot_point(0.0f,0.0f); + this.el.set_scale(0.0f,1.0f); + this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2, + _this.clutterembed.el.get_stage().height); + + } + } + + // user defined functions + } + + public class Xcls_codeeditview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_codeeditview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.codeeditview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + /* + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 0.0f + ) + ); + */ + this.el.fixed_x = 50.0f; + this.el.fixed_y = 0.0f; + //this.el.set_position(100,100); + this.el.set_pivot_point(0.0f,0.0f); + this.el.set_scale(0.0f,1.0f); + this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2, + _this.clutterembed.el.get_stage().height); + + } + } + + // user defined functions + } + + public class Xcls_addpropsview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addpropsview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addpropsview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + /* + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 0.0f + ) + ); + */ + this.el.fixed_x = 50.0f; + this.el.fixed_y = 0.0f; + //this.el.set_position(100,100); + this.el.set_pivot_point(0.0f,0.0f); + this.el.set_scale(0.0f,1.0f); + this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2, + _this.clutterembed.el.get_stage().height); + + } + } + + // user defined functions + } + + public class Xcls_projecteditview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_projecteditview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.projecteditview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 1.0f + ) + ); + + //this.el.set_position(100,100); + this.el.set_pivot_point(0.0f,0.0f); + this.el.set_scale(1.0f,0.0f); + this.el.set_size(_this.clutterembed.el.get_stage().width-50, + _this.clutterembed.el.get_stage().height /2); + + } + } + + // user defined functions + } + + public class Xcls_buttonlayout : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_buttonlayout(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.buttonlayout = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_BoxLayout29( _this ); + child_0.ref(); + this.el.layout_manager = child_0.el; + var child_1 = new Xcls_backbutton( _this ); + child_1.ref(); + this.el.add_child ( child_1.el ); + var child_2 = new Xcls_editfilebutton( _this ); + child_2.ref(); + this.el.add_child ( child_2.el ); + var child_3 = new Xcls_projecteditbutton( _this ); + child_3.ref(); + this.el.add_child ( child_3.el ); + var child_4 = new Xcls_objectshowbutton( _this ); + child_4.ref(); + this.el.add_child ( child_4.el ); + var child_5 = new Xcls_addpropbutton( _this ); + child_5.ref(); + this.el.add_child ( child_5.el ); + var child_6 = new Xcls_addlistenerbutton( _this ); + child_6.ref(); + this.el.add_child ( child_6.el ); + var child_7 = new Xcls_addprojectbutton( _this ); + child_7.ref(); + this.el.add_child ( child_7.el ); + var child_8 = new Xcls_addfilebutton( _this ); + child_8.ref(); + this.el.add_child ( child_8.el ); + var child_9 = new Xcls_delprojectbutton( _this ); + child_9.ref(); + this.el.add_child ( child_9.el ); + + // init method + + { + + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 0.0f + ) + ); + + + //this.el.set_position(100,100); + this.el.set_pivot_point(0.5f,0.5f); + this.el.set_size(50, + _this.clutterembed.el.get_stage().height); + + } + } + + // user defined functions + } + public class Xcls_BoxLayout29 : Object + { + public Clutter.BoxLayout el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_BoxLayout29(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Clutter.BoxLayout(); + + // my vars (dec) + + // set gobject values + this.el.orientation = Clutter.Orientation.VERTICAL; + } + + // user defined functions + } + + public class Xcls_backbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_backbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.backbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor31( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); + } + + // user defined functions + } + public class Xcls_Actor31 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor31(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button32( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); + } + + // user defined functions + } + public class Xcls_Button32 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button32(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Back"; + var child_0 = new Xcls_Image33( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + if (_this.windowstate.state == WindowState.State.FILEPROJECT) { + + _this.windowstate.switchState(WindowState.State.FILES); + } else { + _this.windowstate.switchState(WindowState.State.PREVIEW); + } + + + }); + } + + // user defined functions + } + public class Xcls_Image33 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image33(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "go-previous"; + } + + // user defined functions + } + + + + + public class Xcls_editfilebutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_editfilebutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.editfilebutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor35( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50.0f,50.0f); + } + + // user defined functions + } + public class Xcls_Actor35 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor35(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button36( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); + } + + // user defined functions + } + public class Xcls_Button36 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button36(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "File Details"; + var child_0 = new Xcls_Image37( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + + // create a new file in project.. + if (_this.project == null || _this.windowstate.file == null) { + return ; + } + _this.windowstate.file_details.show( + _this.windowstate.file, this.el + ); + + return ; + + + }); + } + + // user defined functions + } + public class Xcls_Image37 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image37(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "document-properties"; + } + + // user defined functions + } + + + + + public class Xcls_projecteditbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_projecteditbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.projecteditbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor39( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); + } + + // user defined functions + } + public class Xcls_Actor39 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor39(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button40( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); + } + + // user defined functions + } + public class Xcls_Button40 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button40(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Project Details"; + var child_0 = new Xcls_Image41( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + + if (_this.windowstate.state == WindowState.State.FILES) { + + _this.windowstate.switchState(WindowState.State.FILEPROJECT); + } else { + _this.windowstate.switchState(WindowState.State.PROJECT); + } + + + + }); + } + + // user defined functions + } + public class Xcls_Image41 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image41(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "emblem-system"; + } + + // user defined functions + } + + + + + public class Xcls_objectshowbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_objectshowbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.objectshowbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor43( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); + + //listeners + this.el.enter_event.connect( ( event) => { + this.el.background_color = Clutter.Color.from_string("#333"); + return false; + }); + this.el.leave_event.connect( ( event) => { + this.el.background_color = Clutter.Color.from_string("#000"); + return false; + }); + } + + // user defined functions + } + public class Xcls_Actor43 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor43(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button44( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); + } + + // user defined functions + } + public class Xcls_Button44 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button44(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Add Child Element"; + var child_0 = new Xcls_Image45( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + + _this.windowstate.switchState(WindowState.State.OBJECT); + + + }); + } + + // user defined functions + } + public class Xcls_Image45 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image45(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "list-add"; + } + + // user defined functions + } + + + + + public class Xcls_addpropbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addpropbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addpropbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor47( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); + } + + // user defined functions + } + public class Xcls_Actor47 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor47(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button48( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); + } + + // user defined functions + } + public class Xcls_Button48 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button48(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Add Property"; + var child_0 = new Xcls_Image49( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + + _this.windowstate.switchState(WindowState.State.PROP); + + + }); + } + + // user defined functions + } + public class Xcls_Image49 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image49(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "format-justify-left"; + } + + // user defined functions + } + + + + + public class Xcls_addlistenerbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addlistenerbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addlistenerbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor51( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); + } + + // user defined functions + } + public class Xcls_Actor51 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor51(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button52( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); + } + + // user defined functions + } + public class Xcls_Button52 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button52(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Add Event Code"; + var child_0 = new Xcls_Image53( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + + _this.windowstate.switchState(WindowState.State.LISTENER); + + + + }); + } + + // user defined functions + } + public class Xcls_Image53 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image53(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "appointment-new"; + } + + // user defined functions + } + + + + + public class Xcls_addprojectbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addprojectbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addprojectbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor55( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50.0f,50.0f); + } + + // user defined functions + } + public class Xcls_Actor55 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor55(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button56( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); + } + + // user defined functions + } + public class Xcls_Button56 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button56(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "New\nProj."; + var child_0 = new Xcls_Image57( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + + // create a new file in project.. + //Xcls_DialogNewComponent.singleton().show( + var pe = EditProject.singleton(); + pe.el.set_transient_for(_this.el); + pe.el.set_modal(true); + + var p = pe.show(); + + if (p == null) { + return; + } + + + _this.windowstate.left_projects.is_loaded = false; + _this.windowstate.left_projects.load(); + _this.windowstate.left_projects.selectProject(p); + return ; + + + }); + } + + // user defined functions + } + public class Xcls_Image57 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image57(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "folder-new"; + } + + // user defined functions + } + + + + + public class Xcls_addfilebutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addfilebutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addfilebutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor59( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50.0f,50.0f); + } + + // user defined functions + } + public class Xcls_Actor59 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor59(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button60( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); + } + + // user defined functions + } + public class Xcls_Button60 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button60(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Add File"; + var child_0 = new Xcls_Image61( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( () => { + // create a new file in project.. + print("add file selected\n"); + // what's the currently selected project... + var proj = _this.windowstate.left_projects.getSelectedProject(); + + if (proj == null) { + print("no project selected?\n"); + return ; + } + + print("creating file?"); + + var f = JsRender.JsRender.factory(proj.xtype, proj, ""); + _this.project = proj; + print("showing popup?"); + _this.windowstate.file_details.show( + f, this.el + ); + + + return ; + }); + } + + // user defined functions + } + public class Xcls_Image61 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image61(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "document-new"; + } + + // user defined functions + } + + + + + public class Xcls_delprojectbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_delprojectbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.delprojectbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor63( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); + } + + // user defined functions + } + public class Xcls_Actor63 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor63(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button64( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); + } + + // user defined functions + } + public class Xcls_Button64 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button64(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Delete Project"; + var child_0 = new Xcls_Image65( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.clicked.connect( ( ) => { + + var cd = DialogConfirm.singleton(); + cd.el.set_transient_for(_this.el); + cd.el.set_modal(true); + + var project = _this.windowstate.left_projects.getSelectedProject(); + if (project == null) { + print("SKIP - no project\n"); + return; + } + + + if (Gtk.ResponseType.YES != cd.show("Confirm", + "Are you sure you want to delete project %s".printf(project.name))) { + return; + } + + + // confirm? + Project.Project.remove(project); + _this.project = null; + + _this.windowstate.left_projects.is_loaded = false; + _this.windowstate.left_projects.load(); + _this.windowstate.clutterfiles.clearFiles(); + + }); + } + + // user defined functions + } + public class Xcls_Image65 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image65(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "user-trash"; + } + + // user defined functions + } + + + + + + + + + public class Xcls_Box66 : Object + { + public Gtk.Box el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Box66(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_Label67( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + var child_1 = new Xcls_statusbar( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , true,true,0 ); + var child_2 = new Xcls_search_entry( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , false,true,0 ); + var child_3 = new Xcls_MenuBar70( _this ); + child_3.ref(); + this.el.pack_end ( child_3.el , false,true,0 ); + } + + // user defined functions + } + public class Xcls_Label67 : Object + { + public Gtk.Label el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Label67(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Label( " " ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_statusbar : Object + { + public Gtk.ProgressBar el; + private Xcls_MainWindow _this; + + + // my vars (def) + public ulong handler_id; + + // ctor + public Xcls_statusbar(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar = this; + this.el = new Gtk.ProgressBar(); + + // my vars (dec) + this.handler_id = -1; + + // set gobject values + this.el.show_text = true; + + // init method + + { + this.handler_id = Resources.singleton().updateProgress.connect((pos,total) => { + if (pos < 1) { + this.el.hide(); + _this.mainpane.el.set_sensitive(true); + + return; + } + _this.mainpane.el.set_sensitive(false); + this.el.show(); + this.el.set_fraction ((1.0f * pos) / (1.0f * total)); + this.el.set_text("Fetching Resource : %s/%s".printf(pos.to_string(), total.to_string())); + + }); + } + } + + // user defined functions + } + + public class Xcls_search_entry : Object + { + public Gtk.SearchEntry el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_search_entry(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.search_entry = this; + this.el = new Gtk.SearchEntry(); + + // my vars (dec) + + // set gobject values + + // init method + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(8000); + this.el.override_font(description); + + //listeners + this.el.key_press_event.connect( (event) => { + + if (event.keyval == Gdk.Key.Return) { + this.forwardSearch(false); + return true; + + } + // print(event.key.keyval) + + return false; + + }); + this.el.changed.connect( () => { + if (this.el.text == "") { + _this.search_results.el.hide(); + return; + } + var res = 0; + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + case WindowState.State.CODE: + // search the code being edited.. + res = _this.windowstate.code_editor.search(this.el.text); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + res = _this.windowstate.window_gladeview.search(this.el.text); + } else { + res = _this.windowstate.window_rooview.search(this.el.text); + } + + + break; + } + _this.search_results.el.show(); + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + } else { + _this.search_results.el.label = "No Matches"; + } + + + + }); + } + + // user defined functions + public void forwardSearch (bool change_focus) { + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + case WindowState.State.CODE: + // search the code being edited.. + _this.windowstate.code_editor.forwardSearch(change_focus); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + _this.windowstate.window_gladeview.forwardSearch(change_focus); + } else { + _this.windowstate.window_rooview.forwardSearch(change_focus); + } + + break; + } + + } + } + + public class Xcls_MenuBar70 : Object + { + public Gtk.MenuBar el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_MenuBar70(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.MenuBar(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_search_results( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_statusbar_compilestatus_label( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_statusbar_errors( _this ); + child_2.ref(); + this.el.add ( child_2.el ); + var child_3 = new Xcls_statusbar_warnings( _this ); + child_3.ref(); + this.el.add ( child_3.el ); + var child_4 = new Xcls_statusbar_depricated( _this ); + child_4.ref(); + this.el.add ( child_4.el ); + var child_5 = new Xcls_statusbar_run( _this ); + child_5.ref(); + this.el.add ( child_5.el ); + } + + // user defined functions + } + public class Xcls_search_results : Object + { + public Gtk.ImageMenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + + // ctor + public Xcls_search_results(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.search_results = this; + this.el = new Gtk.ImageMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Matches"; + var child_0 = new Xcls_Image72( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.button_press_event.connect( () => { + /* + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + } + + + this.popup.show(this.notices, this.el); + */ + return true; + }); + } + + // user defined functions + } + public class Xcls_Image72 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image72(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "system-search"; + this.el.sensitive = false; + } + + // user defined functions + } + + + public class Xcls_statusbar_compilestatus_label : Object + { + public Gtk.MenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_statusbar_compilestatus_label(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_compilestatus_label = this; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Compile Status:"; + } + + // user defined functions + } + + public class Xcls_statusbar_errors : Object + { + public Gtk.ImageMenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + public Json.Object notices; + + // ctor + public Xcls_statusbar_errors(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_errors = this; + this.el = new Gtk.ImageMenuItem(); + + // my vars (dec) + this.notices = new Json.Object() ; + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Errors"; + var child_0 = new Xcls_Image75( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.button_press_event.connect( () => { + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + } + + + this.popup.show(this.notices, this.el); + return true; + }); + } + + // user defined functions + public void setNotices (Json.Object nots, int qty) { + this.el.show(); + this.el.label = qty.to_string() + " Errors"; + this.notices = nots; + + } + } + public class Xcls_Image75 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image75(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "dialog-error"; + } + + // user defined functions + } + + + public class Xcls_statusbar_warnings : Object + { + public Gtk.ImageMenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + public Json.Object notices; + + // ctor + public Xcls_statusbar_warnings(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_warnings = this; + this.el = new Gtk.ImageMenuItem(); + + // my vars (dec) + this.notices = new Json.Object(); + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Warnings"; + var child_0 = new Xcls_Image77( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.button_press_event.connect( () => { + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + } + + this.popup.show(this.notices, this.el); + return true; + }); + } + + // user defined functions + public void setNotices (Json.Object nots, int qty) { + this.el.show(); + this.el.label = qty.to_string() + " Warnings"; + this.notices = nots; + + } + } + public class Xcls_Image77 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image77(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "dialog-warning"; + } + + // user defined functions + } + + + public class Xcls_statusbar_depricated : Object + { + public Gtk.ImageMenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + public Json.Object notices; + + // ctor + public Xcls_statusbar_depricated(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_depricated = this; + this.el = new Gtk.ImageMenuItem(); + + // my vars (dec) + this.notices = new Json.Object(); + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Depricated"; + var child_0 = new Xcls_Image79( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.button_press_event.connect( () => { + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + } + + + this.popup.show(this.notices, this.el); + return true; + }); + } + + // user defined functions + public void setNotices (Json.Object nots, int qty) { + this.el.show(); + this.el.label = qty.to_string() + " Depricated"; + this.notices = nots; + + } + } + public class Xcls_Image79 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image79(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "dialog-information"; + } + + // user defined functions + } + + + public class Xcls_statusbar_run : Object + { + public Gtk.ImageMenuItem el; + private Xcls_MainWindow _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + + // ctor + public Xcls_statusbar_run(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.statusbar_run = this; + this.el = new Gtk.ImageMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Run"; + var child_0 = new Xcls_Image81( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.button_press_event.connect( () => { + if (_this.windowstate.file == null) { + return true; + } + _this.windowstate.valasource.spawnExecute(_this.windowstate.file); + + _this.windowstate.compile_results.show(this.el,true); + + return true; + }); + } + + // user defined functions + } + public class Xcls_Image81 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image81(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "media-playback-start"; + } + + // user defined functions + } + + + + + +} diff --git a/src/Builder4/PopoverFileDetails.bjs b/src/Builder4/PopoverFileDetails.bjs new file mode 100644 index 000000000..9368eacb3 --- /dev/null +++ b/src/Builder4/PopoverFileDetails.bjs @@ -0,0 +1,297 @@ +{ + "name" : "PopoverFileDetails", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/PopoverFileDetails.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "listeners" : { + "closed" : "() => {\n if (!this.done) {\n _this.el.show();\n \n }\n} " + }, + "| void updateFileFromEntry" : "() {\n\n _this.file.title = _this.title.el.get_text();\n _this.file.region = _this.region.el.get_text(); \n _this.file.parent = _this.parent.el.get_text(); \n _this.file.permname = _this.permname.el.get_text(); \n _this.file.modOrder = _this.modOrder.el.get_text();\n \n if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {\n _this.file.renameTo(_this.name.el.get_text());\n }\n // store the module...\n _this.file.build_module = \"\"; \n Gtk.TreeIter iter; \n if (_this.build_module.el.get_active_iter (out iter)) {\n Value vfname;\n this.dbmodel.el.get_value (iter, 0, out vfname);\n if (((string)vfname).length > 0) {\n _this.file.build_module = (string)vfname;\n }\n \n }\n \n \n\n \n} ", + "@ void success" : "(Project.Project pr, JsRender.JsRender file)", + "id" : "PopoverFileDetails", + "| void show" : "(JsRender.JsRender c, Gtk.Widget btn) \n{\n this.project = c.project;\n this.done = false;\n \n \n //if (!this.el) {\n //this.init();\n //}\n \n _this.name.el.set_text(c.name);\n _this.title.el.set_text(c.title);\n _this.parent.el.set_text(c.parent); \n _this.region.el.set_text(c.region);\n _this.modOrder.el.set_text(c.modOrder);\n _this.permname.el.set_text(c.permname);\n \n \n \n \n \n \n \n \n var ar = new Gee.ArrayList();\n _this.dbmodel.loadData(ar,\"\");\n // load the modules... if relivant..\n if (this.project.xtype == \"Gtk\") {\n var p = (Project.Gtk)c.project;\n var cg = p.compilegroups;\n\n var iter = cg.map_iterator();\n while(iter.next()) {\n var key = iter.get_key();\n if (key == \"_default_\") {\n continue;\n }\n ar.add(key);\n };\n _this.dbmodel.loadData(ar, c.build_module);\n\n }\n \n \n _this.file = c;\n //console.log('show all');\n this.el.set_modal(true);\n this.el.set_relative_to(btn);\n\n this.el.set_position(Gtk.PositionType.RIGHT);\n \n // window + header?\n print(\"SHOWALL - POPIP\\n\");\n this.el.show_all();\n this.name.el.grab_focus();\n \n \n \n if (c.path.length > 0) {\n\t this.save_btn.el.set_label(\"Save\");\n\t\t_this.filetype.el.hide();\n\t\t_this.filetypelbl.el.hide();\n\t\t_this.filetype.showhide(true); // as we only work on bjs files currently\n } else {\n this.save_btn.el.set_label(\"Create\");\n _this.ftdbmodel.loadData(\"bjs\"); // fixme - need to determine type..\n\t _this.filetype.el.show();\n\t _this.filetypelbl.el.show();\n }\n \n \n //this.success = c.success;\n \n \n}", + "bool done" : false, + "# Project.Project project" : "", + "xtype" : "Popover", + "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", + "# JsRender.JsRender file" : "null", + "$ xns" : "Gtk", + "Xcls_MainWindow mainwindow" : "null", + "bool modal" : true, + "uint border_width" : 0, + "items" : [ + { + "bool homogeneous" : false, + "xtype" : "Box", + "$ pack" : "add", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "* pack" : "pack_start,false,true,0", + "xtype" : "HeaderBar", + "$ xns" : "Gtk", + "string title" : "Add / Edit File" + }, + { + "id" : "grid", + "int margin_right" : 4, + "* pack" : "pack_start,false,false,4", + "xtype" : "Grid", + "uint row_spacing" : 2, + "n_columns" : 2, + "$ xns" : "Gtk", + "n_rows" : 7, + "$ homogeneous" : true, + "int margin_left" : 4, + "items" : [ + { + "label" : "File type", + "id" : "filetypelbl", + "xalign" : 0.90000000000000002, + "* pack" : "attach,0,0,1,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "listeners" : { + "changed" : "() => {\n\tGtk.TreeIter iter;\n\tbool is_bjs = true;\n\tif (this.el.get_active_iter(out iter)) {\n\t\tValue vfname;\n\t\t_this.ftdbmodel.el.get_value (iter, 0, out vfname);\n\t\t is_bjs = ((string)vfname) == \"bjs\";\n\t}\n \n \n // directory is only available for non-bjs \n this.showhide(is_bjs);\n\n\n}\n" + }, + "id" : "filetype", + "* init" : "this.el.add_attribute(_this.ftdbcellrenderer.el , \"markup\", 1 );", + "* pack" : "attach,1,0,1,1", + "xtype" : "ComboBox", + "| void showhide" : "(bool is_bjs) {\n\tfor (var i = 2; i < 9;i++) {\n\t\tvar el = _this.grid.el.get_child_at(0,i);\n\t\t\n\t\tvar showhide= is_bjs;\n\t\tif (i> 7) {\n\t\t\tshowhide = !showhide;\n\t\t}\n\t\t\n\t\tif (showhide) {\n\t\t el.show();\n\t\t} else {\n\t\t\tel.hide();\n\t\t}\n\t\t el = _this.grid.el.get_child_at(1,i);\n\t\tif (showhide) {\n\t\t el.show();\n\t\t} else {\n\t\t\tel.hide();\n\t\t} \n }\n // load up the directories\n //??? why can we not create bjs files in other directories??\n\tif (!is_bjs && _this.file.path.length < 1) {\n\t\t_this.dirmodel.loadData();\n\t\t\n\t\t\n\t}\n \n \n}\n", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "ftdbcellrenderer", + "* pack" : "pack_start,true", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + }, + { + "id" : "ftdbmodel", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadData" : " (string cur) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n el.append(out iter);\n\n \n el.set_value(iter, 0, \"bjs\");\n el.set_value(iter, 1, \"User Interface File (bjs)\");\n _this.filetype.el.set_active_iter(iter);\n\n el.append(out iter);\n \n el.set_value(iter, 0, \"vala\");\n el.set_value(iter, 1, \"Vala\");\n\tif (cur == \"vala\") {\n\t _this.filetype.el.set_active_iter(iter);\n }\n\n\n\n el.append(out iter);\n \n el.set_value(iter, 0, \"js\");\n el.set_value(iter, 1, \"Javascript\");\n\n\tif (cur == \"js\") {\n\t _this.filetype.el.set_active_iter(iter);\n }\n\n el.append(out iter);\n \n el.set_value(iter, 0, \"css\");\n el.set_value(iter, 1, \"CSS\");\n\n\tif (cur == \"css\") {\n\t _this.filetype.el.set_active_iter(iter);\n }\n \n}\n" + } + ] + }, + { + "label" : "Component Name", + "xalign" : 0.90000000000000002, + "* pack" : "attach,0,1,1,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "name", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach,1,1,1,1", + "$ xns" : "Gtk" + }, + { + "label" : "Title", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach,0,2,1,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "title", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach,1,2,1,1", + "$ xns" : "Gtk" + }, + { + "label" : "Region", + "$ visible" : true, + "tooltip_text" : "center, north, south, east, west", + "xalign" : 0.90000000000000002, + "* pack" : "attach,0,3,1,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "region", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach,1,3,1,1", + "$ xns" : "Gtk" + }, + { + "label" : "Parent Name", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach,0,4,1,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "parent", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach,1,4,1,1", + "$ xns" : "Gtk" + }, + { + "label" : "Permission Name", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach,0,5,1,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "permname", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach,1,5,1,1", + "$ xns" : "Gtk" + }, + { + "label" : "Order (for tabs)", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach,0,6,1,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "modOrder", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach,1,6,1,1", + "$ xns" : "Gtk" + }, + { + "label" : "Module to build (Vala only)", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach,0,7,1,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "build_module", + "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );", + "* pack" : "attach,1,7,1,1", + "xtype" : "ComboBox", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "dbcellrenderer", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + }, + { + "id" : "dbmodel", + "xtype" : "ListStore", + "* pack" : "set_model", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadData" : " (Gee.ArrayList data, string cur) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a module --\");\n _this.build_module.el.set_active_iter(iter);\n \n for (var i = 0; i < data.size;i++) {\n \n\n el.append(out iter);\n \n el.set_value(iter, 0, data.get(i));\n el.set_value(iter, 1, data.get(i));\n \n if (data.get(i) == cur) {\n _this.build_module.el.set_active_iter(iter);\n }\n \n }\n this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n" + } + ] + }, + { + "label" : "Directory", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach,0,8", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "dir", + "* init" : "this.el.add_attribute(_this.dircellrenderer.el , \"markup\", 1 );", + "* pack" : "attach,1,8", + "xtype" : "ComboBox", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "dircellrenderer", + "* pack" : "pack_start,true", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + }, + { + "id" : "dirmodel", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadData" : " () {\n\t\n\t\n \n this.el.clear(); \n \n if (!(_this.project is Project.Gtk)) {\n\t\treturn;\n\t}\n var sd = ((Project.Gtk)_this.project).sourcedirs();\n \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n// el.append(out iter);\n\n \n// el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"-- select a directoyr --\");\n //_this.build_module.el.set_active_iter(iter);\n \n for (var i = 0; i < sd.length;i++) {\n \n\n el.append(out iter);\n \n el.set_value(iter, 0, sd[i]);\n el.set_value(iter, 1, sd[i]);\n \n //if (data.get(i) == cur) {\n // _this.build_module.el.set_active_iter(iter);\n // }\n \n }\n // this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n" + } + ] + } + ] + }, + { + "int margin_bottom" : 4, + "int margin_right" : 4, + "* pack" : "pack_end,false,true,0", + "xtype" : "HButtonBox", + "$ xns" : "Gtk", + "int margin_left" : 4, + "items" : [ + { + "listeners" : { + "clicked" : "() => { \n\n _this.done = true;\n _this.el.hide(); \n}" + }, + "string label" : "Cancel", + "* pack" : "add", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "clicked" : "( ) => { \n\n \n\n\n\tif (_this.name.el.get_text().length < 1) {\n\t StandardErrorDialog.show(\n\t _this.mainwindow.el,\n\t \"You have to set Component name \"\n\t );\n\t \n\t return;\n\t}\n\t// what does this do?\n\t\n\tvar isNew = _this.file.name.length > 0 ? false : true;\n\t/*\n\tif (!isNew && this.file.name != _this.name.el.get_text()) {\n\t Xcls_StandardErrorDialog.singleton().show(\n\t this.el,\n\t \"Sorry changing names does not work yet. \"\n\t );\n\t \n\t return;\n\t}\n\t*/\n\t \n\t\n \n\t// FIXME - this may be more complicated...\n\t//for (var i in this.def) {\n\t// this.file[i] = this.get(i).el.get_text();\n\t//}\n\n\tif (!isNew) {\n\t try {\n\t _this.updateFileFromEntry();\n\t } catch( JsRender.Error.RENAME_FILE_EXISTS er) {\n\t Xcls_StandardErrorDialog.singleton().show(\n\t _this.mainwindow.el,\n\t \"The name you used already exists \"\n\t );\n\t return;\n\t \n\t }\n\n\t _this.done = true;\n\t _this.file.save();\n\t _this.el.hide();\n\t return;\n\t}\n\t\n\t// ---------------- NEW FILES...\n\tGtk.TreeIter iter;\n\n\tif (!_this.filetype.el.get_active_iter(out iter)) {\n\t\t// should not happen...\n\t\t// so we are jut going to return without \n\t\tStandardErrorDialog.show(\n\t _this.mainwindow.el,\n\t \"You must select a file type. \"\n\t );\n\t return;\n\t\t \n\t}\n\t\n\t\n\tvar fn = _this.name.el.get_text();\n\t\n\tValue ftypename;\n\t_this.ftdbmodel.el.get_value (iter, 0, out ftypename);\n\tvar ext = ((string)ftypename);\n\tvar dir = _this.project.firstPath(); \n\tif (ext != \"bjs\") {\n\t \n\t\tif (!_this.dir.el.get_active_iter(out iter)) {\n\t\t\t// should not happen...\n\t\t\t// so we are jut going to return without \n\t\t\tStandardErrorDialog.show(\n\t\t\t _this.mainwindow.el,\n\t\t\t \"You must select a directory \"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tValue vdir;\n\t\t_this.dirmodel.el.get_value (iter, 0, out vdir);\n\t\tdir = (string)vdir;\n\t}\n\t\n\tvar targetfile = dir + \"/\" + fn;\n\t\n\t// strip the file type off the end..\n\t\n\t\n var rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);\n targetfile = rx.replace(targetfile, targetfile.length, 0, \"\"); \n \n\tif (GLib.FileUtils.test(targetfile + \".\" + ext, GLib.FileTest.EXISTS)) {\n\t Xcls_StandardErrorDialog.singleton().show(\n\t _this.mainwindow.el,\n\t \"That file already exists\"\n\t ); \n\t return;\n\t}\n \n var f = JsRender.JsRender.factory(\n\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\", \n\t\t_this.file.project, \n\t\ttargetfile + \".\" + ext);\n\n\t_this.file = f;\n\t\n\n\t\n\t_this.updateFileFromEntry();\n\t_this.file.loaded = true;\n\t_this.file.save();\n\tif (ext == \"bjs\") {\n\t\t_this.file.project.addFile(_this.file);\n\t}\n\t\n \n\t// what about .js ?\n _this.done = true;\n\t_this.el.hide();\n\n// hopefull this will work with bjs files..\n\t\n\t_this.success(_this.project, _this.file);\n \n}" + }, + "id" : "save_btn", + "xtype" : "Button", + "* pack" : "add", + "string label" : "Save", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/PopoverFileDetails.vala b/src/Builder4/PopoverFileDetails.vala new file mode 100644 index 000000000..9bfab0a8e --- /dev/null +++ b/src/Builder4/PopoverFileDetails.vala @@ -0,0 +1,1303 @@ +static Xcls_PopoverFileDetails _PopoverFileDetails; + +public class Xcls_PopoverFileDetails : Object +{ + public Gtk.Popover el; + private Xcls_PopoverFileDetails _this; + + public static Xcls_PopoverFileDetails singleton() + { + if (_PopoverFileDetails == null) { + _PopoverFileDetails= new Xcls_PopoverFileDetails(); + } + return _PopoverFileDetails; + } + public Xcls_grid grid; + public Xcls_filetypelbl filetypelbl; + public Xcls_filetype filetype; + public Xcls_ftdbcellrenderer ftdbcellrenderer; + public Xcls_ftdbmodel ftdbmodel; + public Xcls_name name; + public Xcls_title title; + public Xcls_region region; + public Xcls_parent parent; + public Xcls_permname permname; + public Xcls_modOrder modOrder; + public Xcls_build_module build_module; + public Xcls_dbcellrenderer dbcellrenderer; + public Xcls_dbmodel dbmodel; + public Xcls_dir dir; + public Xcls_dircellrenderer dircellrenderer; + public Xcls_dirmodel dirmodel; + public Xcls_save_btn save_btn; + + // my vars (def) + public signal void success (Project.Project pr, JsRender.JsRender file); + public bool done; + public Project.Project project; + public JsRender.JsRender file; + public Xcls_MainWindow mainwindow; + + // ctor + public Xcls_PopoverFileDetails() + { + _this = this; + this.el = new Gtk.Popover( null ); + + // my vars (dec) + this.done = false; + this.file = null; + this.mainwindow = null; + + // set gobject values + this.el.border_width = 0; + this.el.modal = true; + this.el.position = Gtk.PositionType.RIGHT; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + //listeners + this.el.closed.connect( () => { + if (!this.done) { + _this.el.show(); + + } + }); + } + + // user defined functions + public void updateFileFromEntry () { + + _this.file.title = _this.title.el.get_text(); + _this.file.region = _this.region.el.get_text(); + _this.file.parent = _this.parent.el.get_text(); + _this.file.permname = _this.permname.el.get_text(); + _this.file.modOrder = _this.modOrder.el.get_text(); + + if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) { + _this.file.renameTo(_this.name.el.get_text()); + } + // store the module... + _this.file.build_module = ""; + Gtk.TreeIter iter; + if (_this.build_module.el.get_active_iter (out iter)) { + Value vfname; + this.dbmodel.el.get_value (iter, 0, out vfname); + if (((string)vfname).length > 0) { + _this.file.build_module = (string)vfname; + } + + } + + + + + } + public void show (JsRender.JsRender c, Gtk.Widget btn) + { + this.project = c.project; + this.done = false; + + + //if (!this.el) { + //this.init(); + //} + + _this.name.el.set_text(c.name); + _this.title.el.set_text(c.title); + _this.parent.el.set_text(c.parent); + _this.region.el.set_text(c.region); + _this.modOrder.el.set_text(c.modOrder); + _this.permname.el.set_text(c.permname); + + + + + + + + + var ar = new Gee.ArrayList(); + _this.dbmodel.loadData(ar,""); + // load the modules... if relivant.. + if (this.project.xtype == "Gtk") { + var p = (Project.Gtk)c.project; + var cg = p.compilegroups; + + var iter = cg.map_iterator(); + while(iter.next()) { + var key = iter.get_key(); + if (key == "_default_") { + continue; + } + ar.add(key); + }; + _this.dbmodel.loadData(ar, c.build_module); + + } + + + _this.file = c; + //console.log('show all'); + this.el.set_modal(true); + this.el.set_relative_to(btn); + + this.el.set_position(Gtk.PositionType.RIGHT); + + // window + header? + print("SHOWALL - POPIP\n"); + this.el.show_all(); + this.name.el.grab_focus(); + + + + if (c.path.length > 0) { + this.save_btn.el.set_label("Save"); + _this.filetype.el.hide(); + _this.filetypelbl.el.hide(); + _this.filetype.showhide(true); // as we only work on bjs files currently + } else { + this.save_btn.el.set_label("Create"); + _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type.. + _this.filetype.el.show(); + _this.filetypelbl.el.show(); + } + + + //this.success = c.success; + + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_HeaderBar3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,0 ); + var child_1 = new Xcls_grid( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,4 ); + var child_2 = new Xcls_HButtonBox29( _this ); + child_2.ref(); + this.el.pack_end ( child_2.el , false,true,0 ); + } + + // user defined functions + } + public class Xcls_HeaderBar3 : Object + { + public Gtk.HeaderBar el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.HeaderBar(); + + // my vars (dec) + + // set gobject values + this.el.title = "Add / Edit File"; + } + + // user defined functions + } + + public class Xcls_grid : Object + { + public Gtk.Grid el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_grid(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.grid = this; + this.el = new Gtk.Grid(); + + // my vars (dec) + + // set gobject values + this.el.margin_right = 4; + this.el.margin_left = 4; + this.el.row_spacing = 2; + var child_0 = new Xcls_filetypelbl( _this ); + child_0.ref(); + this.el.attach ( child_0.el , 0,0,1,1 ); + var child_1 = new Xcls_filetype( _this ); + child_1.ref(); + this.el.attach ( child_1.el , 1,0,1,1 ); + var child_2 = new Xcls_Label9( _this ); + child_2.ref(); + this.el.attach ( child_2.el , 0,1,1,1 ); + var child_3 = new Xcls_name( _this ); + child_3.ref(); + this.el.attach ( child_3.el , 1,1,1,1 ); + var child_4 = new Xcls_Label11( _this ); + child_4.ref(); + this.el.attach ( child_4.el , 0,2,1,1 ); + var child_5 = new Xcls_title( _this ); + child_5.ref(); + this.el.attach ( child_5.el , 1,2,1,1 ); + var child_6 = new Xcls_Label13( _this ); + child_6.ref(); + this.el.attach ( child_6.el , 0,3,1,1 ); + var child_7 = new Xcls_region( _this ); + child_7.ref(); + this.el.attach ( child_7.el , 1,3,1,1 ); + var child_8 = new Xcls_Label15( _this ); + child_8.ref(); + this.el.attach ( child_8.el , 0,4,1,1 ); + var child_9 = new Xcls_parent( _this ); + child_9.ref(); + this.el.attach ( child_9.el , 1,4,1,1 ); + var child_10 = new Xcls_Label17( _this ); + child_10.ref(); + this.el.attach ( child_10.el , 0,5,1,1 ); + var child_11 = new Xcls_permname( _this ); + child_11.ref(); + this.el.attach ( child_11.el , 1,5,1,1 ); + var child_12 = new Xcls_Label19( _this ); + child_12.ref(); + this.el.attach ( child_12.el , 0,6,1,1 ); + var child_13 = new Xcls_modOrder( _this ); + child_13.ref(); + this.el.attach ( child_13.el , 1,6,1,1 ); + var child_14 = new Xcls_Label21( _this ); + child_14.ref(); + this.el.attach ( child_14.el , 0,7,1,1 ); + var child_15 = new Xcls_build_module( _this ); + child_15.ref(); + this.el.attach ( child_15.el , 1,7,1,1 ); + var child_16 = new Xcls_Label25( _this ); + child_16.ref(); + this.el.attach ( child_16.el , 0,8 ); + var child_17 = new Xcls_dir( _this ); + child_17.ref(); + this.el.attach ( child_17.el , 1,8 ); + } + + // user defined functions + } + public class Xcls_filetypelbl : Object + { + public Gtk.Label el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.filetypelbl = this; + this.el = new Gtk.Label( "File type" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + } + + // user defined functions + } + + public class Xcls_filetype : Object + { + public Gtk.ComboBox el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_filetype(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.filetype = this; + this.el = new Gtk.ComboBox(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_ftdbcellrenderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_ftdbmodel( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + + this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 ); + + //listeners + this.el.changed.connect( () => { + Gtk.TreeIter iter; + bool is_bjs = true; + if (this.el.get_active_iter(out iter)) { + Value vfname; + _this.ftdbmodel.el.get_value (iter, 0, out vfname); + is_bjs = ((string)vfname) == "bjs"; + } + + + // directory is only available for non-bjs + this.showhide(is_bjs); + + + }); + } + + // user defined functions + public void showhide (bool is_bjs) { + for (var i = 2; i < 9;i++) { + var el = _this.grid.el.get_child_at(0,i); + + var showhide= is_bjs; + if (i> 7) { + showhide = !showhide; + } + + if (showhide) { + el.show(); + } else { + el.hide(); + } + el = _this.grid.el.get_child_at(1,i); + if (showhide) { + el.show(); + } else { + el.hide(); + } + } + // load up the directories + //??? why can we not create bjs files in other directories?? + if (!is_bjs && _this.file.path.length < 1) { + _this.dirmodel.loadData(); + + + } + + + } + } + public class Xcls_ftdbcellrenderer : Object + { + public Gtk.CellRendererText el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.ftdbcellrenderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_ftdbmodel : Object + { + public Gtk.ListStore el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.ftdbmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadData (string cur) { + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + /// el.append(out iter); + + + // el.set_value(iter, 0, ""); + // el.set_value(iter, 1, "aaa - Just add Element - aaa"); + + el.append(out iter); + + + el.set_value(iter, 0, "bjs"); + el.set_value(iter, 1, "User Interface File (bjs)"); + _this.filetype.el.set_active_iter(iter); + + el.append(out iter); + + el.set_value(iter, 0, "vala"); + el.set_value(iter, 1, "Vala"); + if (cur == "vala") { + _this.filetype.el.set_active_iter(iter); + } + + + + el.append(out iter); + + el.set_value(iter, 0, "js"); + el.set_value(iter, 1, "Javascript"); + + if (cur == "js") { + _this.filetype.el.set_active_iter(iter); + } + + el.append(out iter); + + el.set_value(iter, 0, "css"); + el.set_value(iter, 1, "CSS"); + + if (cur == "css") { + _this.filetype.el.set_active_iter(iter); + } + + } + } + + + public class Xcls_Label9 : Object + { + public Gtk.Label el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Label9(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Component Name" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + } + + // user defined functions + } + + public class Xcls_name : Object + { + public Gtk.Entry el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_name(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.name = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label11 : Object + { + public Gtk.Label el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Label11(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Title" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_title : Object + { + public Gtk.Entry el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_title(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.title = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label13 : Object + { + public Gtk.Label el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Label13(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Region" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.tooltip_text = "center, north, south, east, west"; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_region : Object + { + public Gtk.Entry el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_region(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.region = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label15 : Object + { + public Gtk.Label el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Label15(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Parent Name" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_parent : Object + { + public Gtk.Entry el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_parent(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.parent = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label17 : Object + { + public Gtk.Label el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Label17(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Permission Name" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_permname : Object + { + public Gtk.Entry el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_permname(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.permname = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label19 : Object + { + public Gtk.Label el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Label19(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Order (for tabs)" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_modOrder : Object + { + public Gtk.Entry el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_modOrder(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.modOrder = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label21 : Object + { + public Gtk.Label el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Label21(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Module to build (Vala only)" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_build_module : Object + { + public Gtk.ComboBox el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_build_module(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.build_module = this; + this.el = new Gtk.ComboBox(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_dbcellrenderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_dbmodel( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + + this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 ); + } + + // user defined functions + } + public class Xcls_dbcellrenderer : Object + { + public Gtk.CellRendererText el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.dbcellrenderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_dbmodel : Object + { + public Gtk.ListStore el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_dbmodel(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.dbmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadData (Gee.ArrayList data, string cur) { + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + /// el.append(out iter); + + + // el.set_value(iter, 0, ""); + // el.set_value(iter, 1, "aaa - Just add Element - aaa"); + + el.append(out iter); + + + el.set_value(iter, 0, ""); + el.set_value(iter, 1, "-- select a module --"); + _this.build_module.el.set_active_iter(iter); + + for (var i = 0; i < data.size;i++) { + + + el.append(out iter); + + el.set_value(iter, 0, data.get(i)); + el.set_value(iter, 1, data.get(i)); + + if (data.get(i) == cur) { + _this.build_module.el.set_active_iter(iter); + } + + } + this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); + + } + } + + + public class Xcls_Label25 : Object + { + public Gtk.Label el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Label25(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Directory" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_dir : Object + { + public Gtk.ComboBox el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_dir(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.dir = this; + this.el = new Gtk.ComboBox(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_dircellrenderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_dirmodel( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + + this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 ); + } + + // user defined functions + } + public class Xcls_dircellrenderer : Object + { + public Gtk.CellRendererText el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_dircellrenderer(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.dircellrenderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_dirmodel : Object + { + public Gtk.ListStore el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_dirmodel(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.dirmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadData () { + + + + this.el.clear(); + + if (!(_this.project is Project.Gtk)) { + return; + } + var sd = ((Project.Gtk)_this.project).sourcedirs(); + + Gtk.TreeIter iter; + var el = this.el; + + /// el.append(out iter); + + + // el.set_value(iter, 0, ""); + // el.set_value(iter, 1, "aaa - Just add Element - aaa"); + + // el.append(out iter); + + + // el.set_value(iter, 0, ""); + // el.set_value(iter, 1, "-- select a directoyr --"); + //_this.build_module.el.set_active_iter(iter); + + for (var i = 0; i < sd.length;i++) { + + + el.append(out iter); + + el.set_value(iter, 0, sd[i]); + el.set_value(iter, 1, sd[i]); + + //if (data.get(i) == cur) { + // _this.build_module.el.set_active_iter(iter); + // } + + } + // this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); + + } + } + + + + public class Xcls_HButtonBox29 : Object + { + public Gtk.HButtonBox el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_HButtonBox29(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.HButtonBox(); + + // my vars (dec) + + // set gobject values + this.el.margin_right = 4; + this.el.margin_left = 4; + this.el.margin_bottom = 4; + var child_0 = new Xcls_Button30( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_save_btn( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Button30 : Object + { + public Gtk.Button el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_Button30(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + + //listeners + this.el.clicked.connect( () => { + + _this.done = true; + _this.el.hide(); + }); + } + + // user defined functions + } + + public class Xcls_save_btn : Object + { + public Gtk.Button el; + private Xcls_PopoverFileDetails _this; + + + // my vars (def) + + // ctor + public Xcls_save_btn(Xcls_PopoverFileDetails _owner ) + { + _this = _owner; + _this.save_btn = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save"; + + //listeners + this.el.clicked.connect( ( ) => { + + + + + if (_this.name.el.get_text().length < 1) { + StandardErrorDialog.show( + _this.mainwindow.el, + "You have to set Component name " + ); + + return; + } + // what does this do? + + var isNew = _this.file.name.length > 0 ? false : true; + /* + if (!isNew && this.file.name != _this.name.el.get_text()) { + Xcls_StandardErrorDialog.singleton().show( + this.el, + "Sorry changing names does not work yet. " + ); + + return; + } + */ + + + + // FIXME - this may be more complicated... + //for (var i in this.def) { + // this.file[i] = this.get(i).el.get_text(); + //} + + if (!isNew) { + try { + _this.updateFileFromEntry(); + } catch( JsRender.Error.RENAME_FILE_EXISTS er) { + Xcls_StandardErrorDialog.singleton().show( + _this.mainwindow.el, + "The name you used already exists " + ); + return; + + } + + _this.done = true; + _this.file.save(); + _this.el.hide(); + return; + } + + // ---------------- NEW FILES... + Gtk.TreeIter iter; + + if (!_this.filetype.el.get_active_iter(out iter)) { + // should not happen... + // so we are jut going to return without + StandardErrorDialog.show( + _this.mainwindow.el, + "You must select a file type. " + ); + return; + + } + + + var fn = _this.name.el.get_text(); + + Value ftypename; + _this.ftdbmodel.el.get_value (iter, 0, out ftypename); + var ext = ((string)ftypename); + var dir = _this.project.firstPath(); + if (ext != "bjs") { + + if (!_this.dir.el.get_active_iter(out iter)) { + // should not happen... + // so we are jut going to return without + StandardErrorDialog.show( + _this.mainwindow.el, + "You must select a directory " + ); + return; + } + Value vdir; + _this.dirmodel.el.get_value (iter, 0, out vdir); + dir = (string)vdir; + } + + var targetfile = dir + "/" + fn; + + // strip the file type off the end.. + + + var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS); + targetfile = rx.replace(targetfile, targetfile.length, 0, ""); + + if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) { + Xcls_StandardErrorDialog.singleton().show( + _this.mainwindow.el, + "That file already exists" + ); + return; + } + + var f = JsRender.JsRender.factory( + ext == "bjs" ? _this.file.project.xtype : "PlainFile", + _this.file.project, + targetfile + "." + ext); + + _this.file = f; + + + + _this.updateFileFromEntry(); + _this.file.loaded = true; + _this.file.save(); + if (ext == "bjs") { + _this.file.project.addFile(_this.file); + } + + + // what about .js ? + _this.done = true; + _this.el.hide(); + + // hopefull this will work with bjs files.. + + _this.success(_this.project, _this.file); + + }); + } + + // user defined functions + } + + + +} diff --git a/src/Builder4/PopoverProperty.bjs b/src/Builder4/PopoverProperty.bjs new file mode 100644 index 000000000..c22f64986 --- /dev/null +++ b/src/Builder4/PopoverProperty.bjs @@ -0,0 +1,129 @@ +{ + "name" : "PopoverProperty", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/PopoverProperty.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "listeners" : { + "closed" : "() => {\n \n \n var newtext = \"\";\n Gtk.TreeIter citer;\n GLib.Value gval;\n this.kflag.el.get_active_iter(out citer);\n this.dbmodel.el.get_value(citer, 0, out gval);\n \n var ktype = this.ktype.el.get_text().strip(); \n var kname = this.kname.el.get_text().strip(); \n newtext += ((string)gval).strip(); \n newtext += ktype.length > 0 && newtext.length > 0 ? \" \" :\"\";\n newtext += ktype;\n newtext += kname.length > 0 && newtext.length > 0 ? \" \" :\"\";\n newtext += kname;\n \n \n var lp = _this.mainwindow.windowstate.left_props;\n \n switch(this.key_type) {\n case \"listener\":\n var ov = _this.node.listeners.get(this.old_keyname);\n _this.node.listeners.set(newtext, ov);\n if (this.old_keyname != newtext) { \n\t _this.node.listeners.unset(this.old_keyname);\n }\n \n \n lp.updateKey(this.old_keyname, this.key_type, newtext);\n \n break;\n case \"props\":\n var ov = _this.node.props.get(this.old_keyname);\n _this.node.props.set(newtext, ov);\n\t\t\tif (this.old_keyname != newtext) { \n\t _this.node.props.unset(this.old_keyname);\n }\n lp.updateKey(this.old_keyname, this.key_type, newtext);\n break;\n }\n \n \n \n} " + }, + "string old_keyname" : "", + "@ void success" : "(Project.Project pr, JsRender.JsRender file)", + "id" : "PopoverProperty", + "| void show" : "(Gtk.Widget btn, JsRender.Node node, string key_type, string key) \n\t{\n\t\n\tstring kname = \"\", kflag = \"\", ktype = \"\";\n\tif (key.length > 0) {\n\t\tnode.normalize_key( key, out kname, out kflag, out ktype);\n\t}\n\n\tif (key_type == \"listener\") {\n\t\tthis.header.el.title = \"Modify Event Listener\";\n\t} else {\n\t\tthis.header.el.title = \"Modify Property\";\n\t}\n\t\n\tthis.key_type = key_type;\n\tthis.old_keyname = key;\n\tthis.node = node;\n\t\n\t_this.kname.el.set_text(kname);\n\t_this.ktype.el.set_text(ktype);\n\t\n\t_this.dbmodel.loadData(kflag);\n\t// does node have this property...\n\n\n\t \n\n\t_this.node = node;\n\t//console.log('show all');\n\tthis.el.set_modal(true);\n\tthis.el.set_relative_to(btn);\n\n\tthis.el.set_position(Gtk.PositionType.TOP);\n\n\t// window + header?\n\t print(\"SHOWALL - POPIP\\n\");\n\tthis.el.show_all();\n\tthis.kname.el.grab_focus();\n\n\t//this.success = c.success;\n \n}", + "bool done" : false, + "| void updateNodeFromValues" : "() {\n\n /* _this.file.title = _this.title.el.get_text();\n _this.file.region = _this.region.el.get_text(); \n _this.file.parent = _this.parent.el.get_text(); \n _this.file.permname = _this.permname.el.get_text(); \n _this.file.modOrder = _this.modOrder.el.get_text();\n \n if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {\n _this.file.renameTo(_this.name.el.get_text());\n }\n // store the module...\n _this.file.build_module = \"\"; \n Gtk.TreeIter iter; \n if (_this.build_module.el.get_active_iter (out iter)) {\n Value vfname;\n this.dbmodel.el.get_value (iter, 0, out vfname);\n if (((string)vfname).length > 0) {\n _this.file.build_module = (string)vfname;\n }\n \n }\n */\n \n \n\n \n} ", + "xtype" : "Popover", + "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", + "$ xns" : "Gtk", + "Xcls_MainWindow mainwindow" : "null", + "bool modal" : true, + "string key_type" : "", + "uint border_width" : 0, + "JsRender.Node node" : "", + "items" : [ + { + "bool homogeneous" : false, + "$ pack" : "add", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "id" : "header", + "* pack" : "pack_start,false,true,0", + "xtype" : "HeaderBar", + "$ xns" : "Gtk", + "string title" : "Modify / Create Property" + }, + { + "int margin_right" : 4, + "* pack" : "pack_start,false,false,4", + "xtype" : "Table", + "uint row_spacing" : 2, + "n_columns" : 2, + "$ xns" : "Gtk", + "n_rows" : 3, + "$ homogeneous" : true, + "int margin_left" : 4, + "items" : [ + { + "label" : "Special Flags", + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,0,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "kflag", + "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );", + "* pack" : "attach_defaults,1,2,0,1", + "xtype" : "ComboBox", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "dbcellrenderer", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + }, + { + "id" : "dbmodel", + "xtype" : "ListStore", + "* pack" : "set_model", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadData" : " (string kflag) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n \n // vala signal.. '@'\n // raw value '$'\n // user defined property '#'\n // user defined method '|'\n // special property '*' => prop |args|ctor|init\n \n \n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n el.append(out iter);\n el.set(iter, 0, \"\", 1, \"Normal Property\", -1);\n\t \n\tif (_this.mainwindow.windowstate.file.xtype == \"Gtk\") {\n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"$\", 1, \"($) Raw Property (not escaped)\", -1);\n\t\t \n\t\t\n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"#\", 1, \"(#) User defined property\", -1);\n\t\t \n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"|\", 1, \"(|) User defined method\", -1);\n\t\t \n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"*\", 1, \"(*) Special property (eg. prop | args | ctor | init )\", -1);\n\t\t \n\t\t\n\t\tel.append(out iter);\n\t el.set(iter, 0, \"@\", 1, \"(@) Vala Signal\", -1);\n\t\t \n\t\t\n\t} else { \n\t\t// javascript\n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"$\", 1, \"($) Raw Property (not escaped)\", -1);\n\t\t \n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"|\", 1, \"(|) User defined method\", -1);\n\t \n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"*\", 1, \"(*) Special property (eg. prop )\", -1);\n\t\t \n\t\n\t}\n\tel.foreach((tm, tp, titer) => {\n\t\tGLib.Value val;\n\t\tel.get_value(titer, 0, out val);\n\t\t \n\t\tprint(\"check %s against %s\\n\", (string)val, kflag);\n\t\tif (((string)val) == kflag) {\n\t\t\t_this.kflag.el.set_active_iter(titer);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t});\n\t\n\n \n}\n" + } + ] + }, + { + "label" : "Type or Return Type", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,1,2", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "ktype", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach_defaults,1,2,1,2", + "$ xns" : "Gtk" + }, + { + "label" : "Name", + "tooltip_text" : "center, north, south, east, west", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,2,3", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "kname", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach_defaults,1,2,2,3", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/PopoverProperty.vala b/src/Builder4/PopoverProperty.vala new file mode 100644 index 000000000..e32938c92 --- /dev/null +++ b/src/Builder4/PopoverProperty.vala @@ -0,0 +1,535 @@ +static Xcls_PopoverProperty _PopoverProperty; + +public class Xcls_PopoverProperty : Object +{ + public Gtk.Popover el; + private Xcls_PopoverProperty _this; + + public static Xcls_PopoverProperty singleton() + { + if (_PopoverProperty == null) { + _PopoverProperty= new Xcls_PopoverProperty(); + } + return _PopoverProperty; + } + public Xcls_header header; + public Xcls_kflag kflag; + public Xcls_dbcellrenderer dbcellrenderer; + public Xcls_dbmodel dbmodel; + public Xcls_ktype ktype; + public Xcls_kname kname; + + // my vars (def) + public string old_keyname; + public signal void success (Project.Project pr, JsRender.JsRender file); + public bool done; + public Xcls_MainWindow mainwindow; + public string key_type; + public JsRender.Node node; + + // ctor + public Xcls_PopoverProperty() + { + _this = this; + this.el = new Gtk.Popover( null ); + + // my vars (dec) + this.done = false; + this.mainwindow = null; + + // set gobject values + this.el.border_width = 0; + this.el.modal = true; + this.el.position = Gtk.PositionType.RIGHT; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + //listeners + this.el.closed.connect( () => { + + + var newtext = ""; + Gtk.TreeIter citer; + GLib.Value gval; + this.kflag.el.get_active_iter(out citer); + this.dbmodel.el.get_value(citer, 0, out gval); + + var ktype = this.ktype.el.get_text().strip(); + var kname = this.kname.el.get_text().strip(); + newtext += ((string)gval).strip(); + newtext += ktype.length > 0 && newtext.length > 0 ? " " :""; + newtext += ktype; + newtext += kname.length > 0 && newtext.length > 0 ? " " :""; + newtext += kname; + + + var lp = _this.mainwindow.windowstate.left_props; + + switch(this.key_type) { + case "listener": + var ov = _this.node.listeners.get(this.old_keyname); + _this.node.listeners.set(newtext, ov); + if (this.old_keyname != newtext) { + _this.node.listeners.unset(this.old_keyname); + } + + + lp.updateKey(this.old_keyname, this.key_type, newtext); + + break; + case "props": + var ov = _this.node.props.get(this.old_keyname); + _this.node.props.set(newtext, ov); + if (this.old_keyname != newtext) { + _this.node.props.unset(this.old_keyname); + } + lp.updateKey(this.old_keyname, this.key_type, newtext); + break; + } + + + + }); + } + + // user defined functions + public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key) + { + + string kname = "", kflag = "", ktype = ""; + if (key.length > 0) { + node.normalize_key( key, out kname, out kflag, out ktype); + } + + if (key_type == "listener") { + this.header.el.title = "Modify Event Listener"; + } else { + this.header.el.title = "Modify Property"; + } + + this.key_type = key_type; + this.old_keyname = key; + this.node = node; + + _this.kname.el.set_text(kname); + _this.ktype.el.set_text(ktype); + + _this.dbmodel.loadData(kflag); + // does node have this property... + + + + + _this.node = node; + //console.log('show all'); + this.el.set_modal(true); + this.el.set_relative_to(btn); + + this.el.set_position(Gtk.PositionType.TOP); + + // window + header? + print("SHOWALL - POPIP\n"); + this.el.show_all(); + this.kname.el.grab_focus(); + + //this.success = c.success; + + } + public void updateNodeFromValues () { + + /* _this.file.title = _this.title.el.get_text(); + _this.file.region = _this.region.el.get_text(); + _this.file.parent = _this.parent.el.get_text(); + _this.file.permname = _this.permname.el.get_text(); + _this.file.modOrder = _this.modOrder.el.get_text(); + + if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) { + _this.file.renameTo(_this.name.el.get_text()); + } + // store the module... + _this.file.build_module = ""; + Gtk.TreeIter iter; + if (_this.build_module.el.get_active_iter (out iter)) { + Value vfname; + this.dbmodel.el.get_value (iter, 0, out vfname); + if (((string)vfname).length > 0) { + _this.file.build_module = (string)vfname; + } + + } + */ + + + + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_header( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,0 ); + var child_1 = new Xcls_Table4( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,4 ); + } + + // user defined functions + } + public class Xcls_header : Object + { + public Gtk.HeaderBar el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_header(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.header = this; + this.el = new Gtk.HeaderBar(); + + // my vars (dec) + + // set gobject values + this.el.title = "Modify / Create Property"; + } + + // user defined functions + } + + public class Xcls_Table4 : Object + { + public Gtk.Table el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_Table4(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.Table( 3, 2, true ); + + // my vars (dec) + + // set gobject values + this.el.margin_right = 4; + this.el.margin_left = 4; + this.el.row_spacing = 2; + var child_0 = new Xcls_Label5( _this ); + child_0.ref(); + this.el.attach_defaults ( child_0.el , 0,1,0,1 ); + var child_1 = new Xcls_kflag( _this ); + child_1.ref(); + this.el.attach_defaults ( child_1.el , 1,2,0,1 ); + var child_2 = new Xcls_Label9( _this ); + child_2.ref(); + this.el.attach_defaults ( child_2.el , 0,1,1,2 ); + var child_3 = new Xcls_ktype( _this ); + child_3.ref(); + this.el.attach_defaults ( child_3.el , 1,2,1,2 ); + var child_4 = new Xcls_Label11( _this ); + child_4.ref(); + this.el.attach_defaults ( child_4.el , 0,1,2,3 ); + var child_5 = new Xcls_kname( _this ); + child_5.ref(); + this.el.attach_defaults ( child_5.el , 1,2,2,3 ); + } + + // user defined functions + } + public class Xcls_Label5 : Object + { + public Gtk.Label el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_Label5(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Special Flags" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + } + + // user defined functions + } + + public class Xcls_kflag : Object + { + public Gtk.ComboBox el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_kflag(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.kflag = this; + this.el = new Gtk.ComboBox(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_dbcellrenderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_dbmodel( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + + this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 ); + } + + // user defined functions + } + public class Xcls_dbcellrenderer : Object + { + public Gtk.CellRendererText el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.dbcellrenderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_dbmodel : Object + { + public Gtk.ListStore el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_dbmodel(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.dbmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadData (string kflag) { + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + + // vala signal.. '@' + // raw value '$' + // user defined property '#' + // user defined method '|' + // special property '*' => prop |args|ctor|init + + + + /// el.append(out iter); + + + // el.set_value(iter, 0, ""); + // el.set_value(iter, 1, "aaa - Just add Element - aaa"); + + el.append(out iter); + el.set(iter, 0, "", 1, "Normal Property", -1); + + if (_this.mainwindow.windowstate.file.xtype == "Gtk") { + el.append(out iter); + el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1); + + + el.append(out iter); + el.set(iter, 0, "#", 1, "(#) User defined property", -1); + + el.append(out iter); + el.set(iter, 0, "|", 1, "(|) User defined method", -1); + + el.append(out iter); + el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1); + + + el.append(out iter); + el.set(iter, 0, "@", 1, "(@) Vala Signal", -1); + + + } else { + // javascript + el.append(out iter); + el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1); + + el.append(out iter); + el.set(iter, 0, "|", 1, "(|) User defined method", -1); + + el.append(out iter); + el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1); + + + } + el.foreach((tm, tp, titer) => { + GLib.Value val; + el.get_value(titer, 0, out val); + + print("check %s against %s\n", (string)val, kflag); + if (((string)val) == kflag) { + _this.kflag.el.set_active_iter(titer); + return true; + } + return false; + }); + + + + } + } + + + public class Xcls_Label9 : Object + { + public Gtk.Label el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_Label9(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Type or Return Type" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_ktype : Object + { + public Gtk.Entry el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_ktype(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.ktype = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label11 : Object + { + public Gtk.Label el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_Label11(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Name" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.tooltip_text = "center, north, south, east, west"; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_kname : Object + { + public Gtk.Entry el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_kname(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.kname = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + + +} diff --git a/src/Builder4/ProjectSettings.bjs b/src/Builder4/ProjectSettings.bjs new file mode 100644 index 000000000..c22819a52 --- /dev/null +++ b/src/Builder4/ProjectSettings.bjs @@ -0,0 +1,250 @@ +{ + "name" : "ProjectSettings", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/ProjectSettings.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "@ void buttonPressed" : "(string btn)", + "id" : "ProjectSettings", + "| void show" : " (Project.Project project) {\n _this.project = project;\n _this.path.el.label = project.firstPath();\n // get the active project.\n var lm = Gtk.SourceLanguageManager.get_default();\n \n ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(\n \n lm.get_language(\"html\"));\n \n //print (project.fn);\n //project.runhtml = project.runhtml || '';\n _this.view.el.get_buffer().set_text(project.runhtml);\n \n \n _this.rootURL.el.set_text( _this.project.rootURL );\n _this.base_template.el.set_text(_this.project.base_template); \n var js = _this.project;\n _this.database_DBTYPE.el.set_text( js.get_string_member(\"DBTYPE\") );\n _this.database_DBNAME.el.set_text( js.get_string_member(\"DBNAME\") );\n _this.database_DBUSERNAME.el.set_text( js.get_string_member(\"DBUSERNAME\") );\n _this.database_DBPASSWORD.el.set_text( js.get_string_member(\"DBPASSWORD\") );\n //this.el.show_all();\n}\n", + "# Project.Project project" : "", + "xtype" : "Box", + "| void save" : "()\n{\n var buf = _this.view.el.get_buffer();\n Gtk.TextIter s;\n Gtk.TextIter e;\n buf.get_start_iter(out s);\n buf.get_end_iter(out e);\n _this.project.runhtml = buf.get_text(s,e,true);\n \n _this.project.rootURL = _this.rootURL.el.get_text();\n _this.project.base_template = _this.base_template.el.get_text(); \n \n var js = _this.project.json_project_data;\n js.set_string_member(\"DBTYPE\", _this.database_DBTYPE.el.get_text());\n js.set_string_member(\"DBNAME\", _this.database_DBNAME.el.get_text());\n js.set_string_member(\"DBUSERNAME\", _this.database_DBUSERNAME.el.get_text());\n js.set_string_member(\"DBPASSWORD\", _this.database_DBPASSWORD.el.get_text());\n// _this.project.set_string_member(\"DBHOST\", _this.DBTYPE.el.get_text()); \n \n // need to re-init the database \n \n _this.project.initRooDatabase();\n \n \n}", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "border_width" : 5, + "$ homogeneous" : false, + "items" : [ + { + "* pack" : "pack_start,false,false,0", + "xtype" : "Box", + "gboolean expand" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "$ homogeneous" : true, + "gboolean vexpand" : false, + "items" : [ + { + "listeners" : { + "button_press_event" : "() => {\n _this.save();\n \n _this.buttonPressed(\"apply\");\n return false;\n}" + }, + "label" : "Apply", + "* pack" : "add", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "button_press_event" : "() => {\n _this.save();\n \n _this.buttonPressed(\"save\");\n return false;\n}" + }, + "label" : "Save", + "* pack" : "add", + "xtype" : "Button", + "$ xns" : "Gtk" + } + ] + }, + { + "* pack" : "pack_end,true,true,0", + "xtype" : "Notebook", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "label_global", + "xtype" : "Label", + "* pack" : false, + "$ xns" : "Gtk", + "utf8 label" : "Global" + }, + { + "id" : "label_database", + "* pack" : false, + "xtype" : "Label", + "$ xns" : "Gtk", + "utf8 label" : "Database" + }, + { + "* pack" : "append_page,_this.label_global.el", + "xtype" : "Box", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "label" : "filename", + "id" : "path", + "xalign" : 0, + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "gint margin" : 3, + "$ xns" : "Gtk" + }, + { + "* pack" : "pack_start,false,false,0", + "xtype" : "Box", + "gboolean expand" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "$ homogeneous" : false, + "items" : [ + { + "label" : "HTML template file", + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "gint margin" : 3, + "$ xns" : "Gtk" + }, + { + "id" : "base_template", + "xtype" : "Entry", + "* pack" : "add", + "$ xns" : "Gtk" + } + ] + }, + { + "* pack" : "pack_start,false,false,0", + "xtype" : "Box", + "gboolean expand" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "$ homogeneous" : false, + "items" : [ + { + "label" : "root URL", + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "gint margin" : 3, + "$ xns" : "Gtk" + }, + { + "id" : "rootURL", + "xtype" : "Entry", + "* pack" : "add", + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "HTML To insert at end of ", + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + }, + { + "* pack" : "pack_start,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "key_release_event" : " ( event) =>{\n if (event.keyval != 115) {\n return false;\n \n }\n if ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {\n return false;\n }\n var buf = this.el.get_buffer();\n Gtk.TextIter s;\n Gtk.TextIter e;\n buf.get_start_iter(out s);\n buf.get_end_iter(out e);\n _this.project.runhtml = buf.get_text(s,e,true);\n \n \n _this.buttonPressed(\"save\");\n \n return false;\n \n}" + }, + "id" : "view", + "* init" : " \n var description = Pango.FontDescription.from_string(\"monospace\");\n description.set_size(9000);\n this.el.override_font(description);", + "xtype" : "View", + "* pack" : "add", + "$ xns" : "GtkSource" + } + ] + } + ] + }, + { + "* pack" : "append_page,_this.label_database.el", + "xtype" : "Box", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "label" : "Type (eg. MySQL or PostgreSQL)", + "xalign" : 0, + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "key_press_event" : "(ev) => {\n\n if (ev.keyval == Gdk.Key.Tab) {\n _this.database_DBNAME.el.grab_focus();\n return true;\n }\n\n\n return false;\n}\n" + }, + "id" : "database_DBTYPE", + "* pack" : "pack_start,false,false,0", + "xtype" : "Entry", + "$ xns" : "Gtk" + }, + { + "label" : "Name", + "xalign" : 0, + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "key_press_event" : "(ev) => {\n\n if (ev.keyval == Gdk.Key.Tab) {\n _this.database_DBUSERNAME.el.grab_focus();\n return true;\n }\n\n\n return false;\n}\n" + }, + "id" : "database_DBNAME", + "xtype" : "Entry", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + }, + { + "label" : "Username", + "xalign" : 0, + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "key_press_event" : "(ev) => {\n\n if (ev.keyval == Gdk.Key.Tab) {\n _this.database_DBPASSWORD.el.grab_focus();\n return true;\n }\n\n\n return false;\n}\n" + }, + "id" : "database_DBUSERNAME", + "* pack" : "pack_start,false,false,0", + "xtype" : "Entry", + "$ xns" : "Gtk" + }, + { + "label" : "Password", + "xalign" : 0, + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "$ xns" : "Gtk" + }, + { + "id" : "database_DBPASSWORD", + "xtype" : "Entry", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "clicked" : "() => {\n\n\n _this.database_ERROR.el.label = \"\";\n Gda.Connection cnc;\n try {\n // assumes localhost...\n cnc = Gda.Connection.open_from_string (\n\t\t\t_this.database_DBTYPE.el.get_text(),\n\t\t\t\"DB_NAME=\" + _this.database_DBNAME.el.get_text(), \n\t\t\t\"USERNAME=\" + _this.database_DBUSERNAME.el.get_text() + \n\t\t\t\";PASSWORD=\" + _this.database_DBPASSWORD.el.get_text(),\n\t\t\tGda.ConnectionOptions.NONE\n\t\t);\n //} catch (Gda.ConnectionError ce) { \n // _this.database_ERROR.el.label = ce.message; \n } catch(Gda.ConnectionError ue) {\n _this.database_ERROR.el.label = ue.message;\n return;\n } catch(Gda.ConfigError ue) {\n _this.database_ERROR.el.label = ue.message;\n return;\n }\n _this.database_ERROR.el.label = \"Connection Succeeded\";\n cnc.close();\n}" + }, + "* pack" : "pack_start,false,false,0", + "xtype" : "Button", + "$ xns" : "Gtk", + "utf8 label" : "Check Connection" + }, + { + "label" : " ", + "id" : "database_ERROR", + "xalign" : 0, + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "gint margin" : 3, + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/ProjectSettings.vala b/src/Builder4/ProjectSettings.vala new file mode 100644 index 000000000..29890456a --- /dev/null +++ b/src/Builder4/ProjectSettings.vala @@ -0,0 +1,904 @@ +static Xcls_ProjectSettings _ProjectSettings; + +public class Xcls_ProjectSettings : Object +{ + public Gtk.Box el; + private Xcls_ProjectSettings _this; + + public static Xcls_ProjectSettings singleton() + { + if (_ProjectSettings == null) { + _ProjectSettings= new Xcls_ProjectSettings(); + } + return _ProjectSettings; + } + public Xcls_label_global label_global; + public Xcls_label_database label_database; + public Xcls_path path; + public Xcls_base_template base_template; + public Xcls_rootURL rootURL; + public Xcls_view view; + public Xcls_database_DBTYPE database_DBTYPE; + public Xcls_database_DBNAME database_DBNAME; + public Xcls_database_DBUSERNAME database_DBUSERNAME; + public Xcls_database_DBPASSWORD database_DBPASSWORD; + public Xcls_database_ERROR database_ERROR; + + // my vars (def) + public signal void buttonPressed (string btn); + public Project.Project project; + + // ctor + public Xcls_ProjectSettings() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.border_width = 5; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_Notebook5( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,0 ); + } + + // user defined functions + public void show (Project.Project project) { + _this.project = project; + _this.path.el.label = project.firstPath(); + // get the active project. + var lm = Gtk.SourceLanguageManager.get_default(); + + ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language( + + lm.get_language("html")); + + //print (project.fn); + //project.runhtml = project.runhtml || ''; + _this.view.el.get_buffer().set_text(project.runhtml); + + + _this.rootURL.el.set_text( _this.project.rootURL ); + _this.base_template.el.set_text(_this.project.base_template); + var js = _this.project; + _this.database_DBTYPE.el.set_text( js.get_string_member("DBTYPE") ); + _this.database_DBNAME.el.set_text( js.get_string_member("DBNAME") ); + _this.database_DBUSERNAME.el.set_text( js.get_string_member("DBUSERNAME") ); + _this.database_DBPASSWORD.el.set_text( js.get_string_member("DBPASSWORD") ); + //this.el.show_all(); + } + public void save () + { + var buf = _this.view.el.get_buffer(); + Gtk.TextIter s; + Gtk.TextIter e; + buf.get_start_iter(out s); + buf.get_end_iter(out e); + _this.project.runhtml = buf.get_text(s,e,true); + + _this.project.rootURL = _this.rootURL.el.get_text(); + _this.project.base_template = _this.base_template.el.get_text(); + + var js = _this.project.json_project_data; + js.set_string_member("DBTYPE", _this.database_DBTYPE.el.get_text()); + js.set_string_member("DBNAME", _this.database_DBNAME.el.get_text()); + js.set_string_member("DBUSERNAME", _this.database_DBUSERNAME.el.get_text()); + js.set_string_member("DBPASSWORD", _this.database_DBPASSWORD.el.get_text()); + // _this.project.set_string_member("DBHOST", _this.DBTYPE.el.get_text()); + + // need to re-init the database + + _this.project.initRooDatabase(); + + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = true; + this.el.expand = false; + this.el.vexpand = false; + var child_0 = new Xcls_Button3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_Button4( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Button3 : Object + { + public Gtk.Button el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Button3(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Apply"; + + // listeners + this.el.button_press_event.connect( () => { + _this.save(); + + _this.buttonPressed("apply"); + return false; + }); + } + + // user defined functions + } + public class Xcls_Button4 : Object + { + public Gtk.Button el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Button4(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save"; + + // listeners + this.el.button_press_event.connect( () => { + _this.save(); + + _this.buttonPressed("save"); + return false; + }); + } + + // user defined functions + } + public class Xcls_Notebook5 : Object + { + public Gtk.Notebook el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Notebook5(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Notebook(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_label_global( _this ); + child_0.ref(); + var child_1 = new Xcls_label_database( _this ); + child_1.ref(); + var child_2 = new Xcls_Box8( _this ); + child_2.ref(); + this.el.append_page ( child_2.el , _this.label_global.el ); + var child_3 = new Xcls_Box19( _this ); + child_3.ref(); + this.el.append_page ( child_3.el , _this.label_database.el ); + } + + // user defined functions + } + public class Xcls_label_global : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_label_global(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.label_global = this; + this.el = new Gtk.Label( "Global" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_label_database : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_label_database(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.label_database = this; + this.el = new Gtk.Label( "Database" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_Box8 : Object + { + public Gtk.Box el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Box8(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_path( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_Box10( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_Box13( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , false,false,0 ); + var child_3 = new Xcls_Label16( _this ); + child_3.ref(); + this.el.pack_start ( child_3.el , false,false,0 ); + var child_4 = new Xcls_ScrolledWindow17( _this ); + child_4.ref(); + this.el.pack_start ( child_4.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_path : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_path(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.path = this; + this.el = new Gtk.Label( "filename" ); + + // my vars (dec) + + // set gobject values + this.el.margin = 3; + this.el.xalign = 0f; + } + + // user defined functions + } + public class Xcls_Box10 : Object + { + public Gtk.Box el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Box10(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.expand = false; + var child_0 = new Xcls_Label11( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_base_template( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label11 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label11(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "HTML template file" ); + + // my vars (dec) + + // set gobject values + this.el.margin = 3; + } + + // user defined functions + } + public class Xcls_base_template : Object + { + public Gtk.Entry el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_base_template(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.base_template = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_Box13 : Object + { + public Gtk.Box el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Box13(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.expand = false; + var child_0 = new Xcls_Label14( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_rootURL( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label14 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label14(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "root URL" ); + + // my vars (dec) + + // set gobject values + this.el.margin = 3; + } + + // user defined functions + } + public class Xcls_rootURL : Object + { + public Gtk.Entry el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_rootURL(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.rootURL = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_Label16 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label16(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "HTML To insert at end of " ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_ScrolledWindow17 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow17(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.SourceView el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_view(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.SourceView(); + + // my vars (dec) + + // init method + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(9000); + this.el.override_font(description); + + // listeners + this.el.key_release_event.connect( ( event) =>{ + if (event.keyval != 115) { + return false; + + } + if ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) { + return false; + } + var buf = this.el.get_buffer(); + Gtk.TextIter s; + Gtk.TextIter e; + buf.get_start_iter(out s); + buf.get_end_iter(out e); + _this.project.runhtml = buf.get_text(s,e,true); + + + _this.buttonPressed("save"); + + return false; + + }); + } + + // user defined functions + } + public class Xcls_Box19 : Object + { + public Gtk.Box el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Box19(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_Label20( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_database_DBTYPE( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_Label22( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , false,false,0 ); + var child_3 = new Xcls_database_DBNAME( _this ); + child_3.ref(); + this.el.pack_start ( child_3.el , false,false,0 ); + var child_4 = new Xcls_Label24( _this ); + child_4.ref(); + this.el.pack_start ( child_4.el , false,false,0 ); + var child_5 = new Xcls_database_DBUSERNAME( _this ); + child_5.ref(); + this.el.pack_start ( child_5.el , false,false,0 ); + var child_6 = new Xcls_Label26( _this ); + child_6.ref(); + this.el.pack_start ( child_6.el , false,false,0 ); + var child_7 = new Xcls_database_DBPASSWORD( _this ); + child_7.ref(); + this.el.pack_start ( child_7.el , false,false,0 ); + var child_8 = new Xcls_Button28( _this ); + child_8.ref(); + this.el.pack_start ( child_8.el , false,false,0 ); + var child_9 = new Xcls_database_ERROR( _this ); + child_9.ref(); + this.el.pack_start ( child_9.el , false,false,0 ); + } + + // user defined functions + } + public class Xcls_Label20 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label20(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Type (eg. MySQL or PostgreSQL)" ); + + // my vars (dec) + + // set gobject values + this.el.xalign = 0f; + } + + // user defined functions + } + public class Xcls_database_DBTYPE : Object + { + public Gtk.Entry el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_database_DBTYPE(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.database_DBTYPE = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + + // listeners + this.el.key_press_event.connect( (ev) => { + + if (ev.keyval == Gdk.Key.Tab) { + _this.database_DBNAME.el.grab_focus(); + return true; + } + + + return false; + }); + } + + // user defined functions + } + public class Xcls_Label22 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label22(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Name" ); + + // my vars (dec) + + // set gobject values + this.el.xalign = 0f; + } + + // user defined functions + } + public class Xcls_database_DBNAME : Object + { + public Gtk.Entry el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_database_DBNAME(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.database_DBNAME = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + + // listeners + this.el.key_press_event.connect( (ev) => { + + if (ev.keyval == Gdk.Key.Tab) { + _this.database_DBUSERNAME.el.grab_focus(); + return true; + } + + + return false; + }); + } + + // user defined functions + } + public class Xcls_Label24 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label24(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Username" ); + + // my vars (dec) + + // set gobject values + this.el.xalign = 0f; + } + + // user defined functions + } + public class Xcls_database_DBUSERNAME : Object + { + public Gtk.Entry el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_database_DBUSERNAME(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.database_DBUSERNAME = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + + // listeners + this.el.key_press_event.connect( (ev) => { + + if (ev.keyval == Gdk.Key.Tab) { + _this.database_DBPASSWORD.el.grab_focus(); + return true; + } + + + return false; + }); + } + + // user defined functions + } + public class Xcls_Label26 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label26(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Password" ); + + // my vars (dec) + + // set gobject values + this.el.xalign = 0f; + } + + // user defined functions + } + public class Xcls_database_DBPASSWORD : Object + { + public Gtk.Entry el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_database_DBPASSWORD(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.database_DBPASSWORD = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_Button28 : Object + { + public Gtk.Button el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Button28(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Check Connection"; + + // listeners + this.el.clicked.connect( () => { + + + _this.database_ERROR.el.label = ""; + Gda.Connection cnc; + try { + // assumes localhost... + cnc = Gda.Connection.open_from_string ( + _this.database_DBTYPE.el.get_text(), + "DB_NAME=" + _this.database_DBNAME.el.get_text(), + "USERNAME=" + _this.database_DBUSERNAME.el.get_text() + + ";PASSWORD=" + _this.database_DBPASSWORD.el.get_text(), + Gda.ConnectionOptions.NONE + ); + //} catch (Gda.ConnectionError ce) { + // _this.database_ERROR.el.label = ce.message; + } catch(Gda.ConnectionError ue) { + _this.database_ERROR.el.label = ue.message; + return; + } catch(Gda.ConfigError ue) { + _this.database_ERROR.el.label = ue.message; + return; + } + _this.database_ERROR.el.label = "Connection Succeeded"; + cnc.close(); + }); + } + + // user defined functions + } + public class Xcls_database_ERROR : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_database_ERROR(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.database_ERROR = this; + this.el = new Gtk.Label( " " ); + + // my vars (dec) + + // set gobject values + this.el.margin = 3; + this.el.xalign = 0f; + } + + // user defined functions + } +} diff --git a/src/Builder4/RooProjectProperties.bjs b/src/Builder4/RooProjectProperties.bjs new file mode 100644 index 000000000..96d82e37d --- /dev/null +++ b/src/Builder4/RooProjectProperties.bjs @@ -0,0 +1,65 @@ +{ + "name" : "RooProjectProperties", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/RooProjectProperties.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "", + "items" : [ + { + "listeners" : { + "delete_event" : " (self, event) => {\n this.el.hide();\n return true;\n}", + "response" : " (self, response_id) => {\n //print(response_id);\n if (response_id< 1 ) {\n this.el.hide();\n \n return;\n }\n \n var buf = view.el.get_buffer();\n Gtk.TextIter s;\n Gtk.TextIter e;\n buf.get_start_iter(out s);\n buf.get_end_iter(out e);\n var str = buf.get_text(s,e,true);\n // ideally we should syntax check it.. but it's html!?\n \n //var project = this.get('/Window.LeftTree').getActiveFile().project;\n \n \n _this.project.runhtml = str;\n _this.project.save();\n \n // imports.Builder.Provider.ProjectManager.ProjectManager.saveConfig();\n// print (str);\n // this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length);\n // ok pressed..\n this.el.hide();\n}" + }, + "default_width" : 500, + "| void show" : " (Project.Project project) {\n _this.project = project;\n // get the active project.\n \n //print (project.fn);\n //project.runhtml = project.runhtml || '';\n _this.view.el.get_buffer().set_text(project.runhtml);\n \n this.el.show_all();\n}\n", + "# Project.Project project" : "", + "xtype" : "Dialog", + "$ modal" : true, + "$ xns" : "Gtk", + "items" : [ + { + "$ pack" : " get_content_area().add\n", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "border_width" : 5, + "items" : [ + { + "label" : "HTML To insert at end of ", + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "$ xns" : "Gtk" + }, + { + "* pack" : "pack_end,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "view", + "* pack" : "add", + "xtype" : "SourceView", + "$ xns" : "Gtk" + } + ] + } + ] + }, + { + "label" : "OK", + "* pack" : "add_action_widget,1", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "label" : "Cancel", + "* pack" : "add_action_widget,0", + "xtype" : "Button", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/RooProjectProperties.vala b/src/Builder4/RooProjectProperties.vala new file mode 100644 index 000000000..b5842dd15 --- /dev/null +++ b/src/Builder4/RooProjectProperties.vala @@ -0,0 +1,232 @@ +static RooProjectProperties _RooProjectProperties; + +public class RooProjectProperties : Object +{ + public Gtk.Dialog el; + private RooProjectProperties _this; + + public static RooProjectProperties singleton() + { + if (_RooProjectProperties == null) { + _RooProjectProperties= new RooProjectProperties(); + } + return _RooProjectProperties; + } + public Xcls_view view; + + // my vars (def) + public Project.Project project; + + // ctor + public RooProjectProperties() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + + // set gobject values + this.el.default_width = 500; + this.el.modal = true; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button6( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 1 ); + var child_2 = new Xcls_Button7( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 0 ); + + //listeners + this.el.delete_event.connect( (self, event) => { + this.el.hide(); + return true; + }); + this.el.response.connect( (self, response_id) => { + //print(response_id); + if (response_id< 1 ) { + this.el.hide(); + + return; + } + + var buf = view.el.get_buffer(); + Gtk.TextIter s; + Gtk.TextIter e; + buf.get_start_iter(out s); + buf.get_end_iter(out e); + var str = buf.get_text(s,e,true); + // ideally we should syntax check it.. but it's html!? + + //var project = this.get('/Window.LeftTree').getActiveFile().project; + + + _this.project.runhtml = str; + _this.project.save(); + + // imports.Builder.Provider.ProjectManager.ProjectManager.saveConfig(); + // print (str); + // this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length); + // ok pressed.. + this.el.hide(); + }); + } + + // user defined functions + public void show (Project.Project project) { + _this.project = project; + // get the active project. + + //print (project.fn); + //project.runhtml = project.runhtml || ''; + _this.view.el.get_buffer().set_text(project.runhtml); + + this.el.show_all(); + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private RooProjectProperties _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(RooProjectProperties _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.border_width = 5; + var child_0 = new Xcls_Label3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_ScrolledWindow4( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_Label3 : Object + { + public Gtk.Label el; + private RooProjectProperties _this; + + + // my vars (def) + + // ctor + public Xcls_Label3(RooProjectProperties _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "HTML To insert at end of " ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_ScrolledWindow4 : Object + { + public Gtk.ScrolledWindow el; + private RooProjectProperties _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow4(RooProjectProperties _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.SourceView el; + private RooProjectProperties _this; + + + // my vars (def) + + // ctor + public Xcls_view(RooProjectProperties _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.SourceView(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_Button6 : Object + { + public Gtk.Button el; + private RooProjectProperties _this; + + + // my vars (def) + + // ctor + public Xcls_Button6(RooProjectProperties _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } + + public class Xcls_Button7 : Object + { + public Gtk.Button el; + private RooProjectProperties _this; + + + // my vars (def) + + // ctor + public Xcls_Button7(RooProjectProperties _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + } + + // user defined functions + } + +} diff --git a/src/Builder4/StandardErrorDialog.bjs b/src/Builder4/StandardErrorDialog.bjs new file mode 100644 index 000000000..b9c35eaba --- /dev/null +++ b/src/Builder4/StandardErrorDialog.bjs @@ -0,0 +1,25 @@ +{ + "id": "file-gtk-14", + "name": "StandardErrorDialog", + "parent": "", + "title": false, + "path": "/home/alan/gitlive/app.Builder.js/Builder4/StandardErrorDialog.bjs", + "items": [ + { + "listeners": { + "delete_event": " (self, event) => {\n this.el.hide();\n return true;\n \n} \n", + "response": " (self, response_id) => {\n this.el.hide();\n}" + }, + "text": "fixme", + "xtype": "MessageDialog", + "|buttons": "Gtk.ButtonsType.OK", + "|message_type": "Gtk.MessageType.ERROR", + "|modal": "true", + "|use_markup": "true", + "|void:show": " (Gtk.Window win, string msg) {\n\n this.el.set_transient_for(win);\n this.el.modal = true;\n this.el.text = msg;\n this.el.show_all();\n}\n", + "|xns": "Gtk" + } + ], + "permname": "", + "modOrder": "" +} \ No newline at end of file diff --git a/src/Builder4/StandardErrorDialog.vala b/src/Builder4/StandardErrorDialog.vala new file mode 100644 index 000000000..ec34380f7 --- /dev/null +++ b/src/Builder4/StandardErrorDialog.vala @@ -0,0 +1,69 @@ +/* -- to compile +valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0 --pkg libwnck-3.0 \ + /tmp/StandardErrorDialog.vala -o /tmp/StandardErrorDialog +*/ + + +/* -- to test class +static int main (string[] args) { + Gtk.init (ref args); + new Xcls_StandardErrorDialog(); + StandardErrorDialog.show_all(); + Gtk.main (); + return 0; +} +*/ + + +public static Xcls_StandardErrorDialog StandardErrorDialog; + +public class Xcls_StandardErrorDialog : Object +{ + public Gtk.MessageDialog el; + private Xcls_StandardErrorDialog _this; + + public static Xcls_StandardErrorDialog singleton() + { + if (StandardErrorDialog == null) { + StandardErrorDialog= new Xcls_StandardErrorDialog(); + } + return StandardErrorDialog; + } + + // my vars + + // ctor + public Xcls_StandardErrorDialog() + { + _this = this; + this.el = new Gtk.MessageDialog( null, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, "fixme" ); + + // my vars + + // set gobject values + this.el.modal = true; + this.el.use_markup = true; + + // listeners + this.el.delete_event.connect( (self, event) => { + this.el.hide(); + return true; + + } + ); + this.el.response.connect( (self, response_id) => { + this.el.hide(); + } ); + } + + // userdefined functions + public void show (Gtk.Window win, string msg) { + + this.el.set_transient_for(win); + this.el.modal = true; + this.el.text = msg; + this.el.show_all(); + } + + // skip |xns - no return type +} diff --git a/src/Builder4/ValaCompileErrors.bjs b/src/Builder4/ValaCompileErrors.bjs new file mode 100644 index 000000000..07e1661c5 --- /dev/null +++ b/src/Builder4/ValaCompileErrors.bjs @@ -0,0 +1,97 @@ +{ + "name" : "ValaCompileErrors", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/ValaCompileErrors.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "int height_request" : 800, + "id" : "ValaCompileErrors", + "Xcls_MainWindow window" : "", + "| void show" : "(Json.Object tree, Gtk.Widget onbtn) {\n\n \n this.file = null;\n this.notices = tree;\n \n //print(\"looking for %s\\n\", id);\n // loop through parent childnre\n \n \n var store = this.compile_result_store.el; \n \n store.clear();\n \n \n tree.foreach_member((obj, file, node) => {\n // id line \"display text\", file\n \n var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + \"/\" + GLib.Path.get_basename( file) ;\n Gtk.TreeIter iter;\n print(\"Add file %s\", title);\n store.append(out iter, null);\n var lines = tree.get_object_member(file);\n title += \" (\" + lines.get_size().to_string() + \")\";\n store.set(iter, 0, file, 1, -1, 2, title, 3, file,-1);\n \n lines.foreach_member((obja, line, nodea) => {\n var msg = \"\";\n var ar = lines.get_array_member(line);\n for (var i = 0 ; i < ar.get_length(); i++) {\n \t\t msg += (msg.length > 0) ? \"\\n\" : \"\";\n \t\t msg += ar.get_string_element(i);\n\t }\n Gtk.TreeIter citer; \n print(\"Add line %s\", line);\n store.append(out citer, iter);\n store.set(citer, \n 0, file + \":\" + line, \n 1, int.parse(line), \n 2, GLib.Markup.escape_text(line + \": \" + msg), \n 3, file,-1);\n \n });\n \n \n \n });\n \n int w,h;\n this.window.el.get_size(out w, out h);\n \n // left tree = 250, editor area = 500?\n \n var new_w = int.min(250, w-100);\n if (new_w > (w-100)) {\n new_w = w-100;\n }\n this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));\n\n \n\n if (this.el.relative_to == null) {\n this.el.set_relative_to(onbtn);\n }\n this.el.show_all();\n \n while(Gtk.events_pending()) { \n Gtk.main_iteration();\n } \n // this.hpane.el.set_position( 0);\n}\n", + "bool hexpand" : false, + "xtype" : "Popover", + "Gtk.PositionType position" : "Gtk.PositionType.TOP", + "bool active" : false, + "int width_request" : 900, + "$ xns" : "Gtk", + "JsRender.JsRender? file" : "", + "Json.Object notices" : "", + "bool modal" : true, + "items" : [ + { + "id" : "compile_view", + "bool hexpand" : false, + "xtype" : "Box", + "* pack" : "add", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "xtype" : "Box", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "* pack" : "pack_start,true,true,0", + "xtype" : "Button", + "$ xns" : "Gtk", + "utf8 label" : "Compile and Run " + } + ] + }, + { + "* init" : "{\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n\n}\n", + "xtype" : "ScrolledWindow", + "* pack" : "pack_end,true,true,0", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_press_event" : " ( ev) => {\n \n Gtk.TreeViewColumn col;\n int cell_x;\n int cell_y;\n Gtk.TreePath path;\n if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {\n print(\"nothing selected on click\");\n \n return false; //not on a element.\n }\n \n \n // right click.\n if (ev.type != Gdk.EventType.2BUTTON_PRESS || ev.button != 1 ) { \n // show popup!. \n \n \n return false;\n }\n Gtk.TreeIter iter;\n var mod = _this.compile_result_store.el;\n mod.get_iter (out iter, path);\n \n \n \n // var val = \"\";\n GLib.Value value;\n _this.compile_result_store.el.get_value(iter, 3, out value);\n var fname = (string)value;\n GLib.Value lvalue;\n _this.compile_result_store.el.get_value(iter, 1, out lvalue);\n var line = (int) lvalue;\n \n print(\"open %s @ %d\\n\", fname, line);\n \n \n var bjsf = \"\";\n try { \n var regex = new Regex(\"\\\\.vala$\");\n \n \n bjsf = regex.replace(fname,fname.length , 0 , \".bjs\");\n } catch (GLib.RegexError e) {\n return false;\n } \n var p = _this.window.project;\n \n \n \n var jsr = p.getByPath(bjsf);\n if (jsr != null) {\n _this.window.windowstate.fileViewOpen(jsr, line);\n \n return false;\n \n }\n \n var pf = JsRender.JsRender.factory(\"PlainFile\", p, fname);\n _this.window.windowstate.fileViewOpen(pf,line);\n \n // try hiding the left nav..\n \n return false;\n \n }\n " + }, + "id" : "compile_tree", + "* init" : "{\n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.override_font(description);\n\n}\n", + "* pack" : "add", + "xtype" : "TreeView", + "$ xns" : "Gtk", + "items" : [ + { + "gint n_columns" : 4, + "id" : "compile_result_store", + "columns" : " typeof(string), typeof(int), typeof(string), typeof(string) ", + "* pack" : "set_model", + "xtype" : "TreeStore", + "$ xns" : "Gtk" + }, + { + "utf8 title" : "Compile output", + "* init" : "{\n this.el.add_attribute(_this.renderer.el , \"markup\", 2 );\n \n}\n", + "xtype" : "TreeViewColumn", + "* pack" : "append_column", + "string id" : "column", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "renderer", + "* pack" : "pack_start,true", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/Builder4/ValaCompileErrors.vala b/src/Builder4/ValaCompileErrors.vala new file mode 100644 index 000000000..7989b43df --- /dev/null +++ b/src/Builder4/ValaCompileErrors.vala @@ -0,0 +1,415 @@ +static Xcls_ValaCompileErrors _ValaCompileErrors; + +public class Xcls_ValaCompileErrors : Object +{ + public Gtk.Popover el; + private Xcls_ValaCompileErrors _this; + + public static Xcls_ValaCompileErrors singleton() + { + if (_ValaCompileErrors == null) { + _ValaCompileErrors= new Xcls_ValaCompileErrors(); + } + return _ValaCompileErrors; + } + public Xcls_compile_view compile_view; + public Xcls_compile_tree compile_tree; + public Xcls_compile_result_store compile_result_store; + public Xcls_renderer renderer; + + // my vars (def) + public Xcls_MainWindow window; + public bool active; + public JsRender.JsRender? file; + public Json.Object notices; + + // ctor + public Xcls_ValaCompileErrors() + { + _this = this; + this.el = new Gtk.Popover( null ); + + // my vars (dec) + this.active = false; + + // set gobject values + this.el.width_request = 900; + this.el.height_request = 800; + this.el.hexpand = false; + this.el.modal = true; + this.el.position = Gtk.PositionType.TOP; + var child_0 = new Xcls_compile_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + public void show (Json.Object tree, Gtk.Widget onbtn) { + + + this.file = null; + this.notices = tree; + + //print("looking for %s\n", id); + // loop through parent childnre + + + var store = this.compile_result_store.el; + + store.clear(); + + + tree.foreach_member((obj, file, node) => { + // id line "display text", file + + var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + "/" + GLib.Path.get_basename( file) ; + Gtk.TreeIter iter; + print("Add file %s", title); + store.append(out iter, null); + var lines = tree.get_object_member(file); + title += " (" + lines.get_size().to_string() + ")"; + store.set(iter, 0, file, 1, -1, 2, title, 3, file,-1); + + lines.foreach_member((obja, line, nodea) => { + var msg = ""; + var ar = lines.get_array_member(line); + for (var i = 0 ; i < ar.get_length(); i++) { + msg += (msg.length > 0) ? "\n" : ""; + msg += ar.get_string_element(i); + } + Gtk.TreeIter citer; + print("Add line %s", line); + store.append(out citer, iter); + store.set(citer, + 0, file + ":" + line, + 1, int.parse(line), + 2, GLib.Markup.escape_text(line + ": " + msg), + 3, file,-1); + + }); + + + + }); + + int w,h; + this.window.el.get_size(out w, out h); + + // left tree = 250, editor area = 500? + + var new_w = int.min(250, w-100); + if (new_w > (w-100)) { + new_w = w-100; + } + this.el.set_size_request( int.max(100, new_w), int.max(100, h-120)); + + + + if (this.el.relative_to == null) { + this.el.set_relative_to(onbtn); + } + this.el.show_all(); + + while(Gtk.events_pending()) { + Gtk.main_iteration(); + } + // this.hpane.el.set_position( 0); + } + public class Xcls_compile_view : Object + { + public Gtk.Box el; + private Xcls_ValaCompileErrors _this; + + + // my vars (def) + + // ctor + public Xcls_compile_view(Xcls_ValaCompileErrors _owner ) + { + _this = _owner; + _this.compile_view = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.hexpand = false; + var child_0 = new Xcls_Box3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_ScrolledWindow5( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_Box3 : Object + { + public Gtk.Box el; + private Xcls_ValaCompileErrors _this; + + + // my vars (def) + + // ctor + public Xcls_Box3(Xcls_ValaCompileErrors _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button4( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_Button4 : Object + { + public Gtk.Button el; + private Xcls_ValaCompileErrors _this; + + + // my vars (def) + + // ctor + public Xcls_Button4(Xcls_ValaCompileErrors _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Compile and Run "; + } + + // user defined functions + } + + + public class Xcls_ScrolledWindow5 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_ValaCompileErrors _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow5(Xcls_ValaCompileErrors _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_compile_tree( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + { + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + + + } + } + + // user defined functions + } + public class Xcls_compile_tree : Object + { + public Gtk.TreeView el; + private Xcls_ValaCompileErrors _this; + + + // my vars (def) + + // ctor + public Xcls_compile_tree(Xcls_ValaCompileErrors _owner ) + { + _this = _owner; + _this.compile_tree = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_compile_result_store( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_column( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + { + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.override_font(description); + + } + + //listeners + this.el.button_press_event.connect( ( ev) => { + + Gtk.TreeViewColumn col; + int cell_x; + int cell_y; + Gtk.TreePath path; + if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) { + print("nothing selected on click"); + + return false; //not on a element. + } + + + // right click. + if (ev.type != Gdk.EventType.2BUTTON_PRESS || ev.button != 1 ) { + // show popup!. + + + return false; + } + Gtk.TreeIter iter; + var mod = _this.compile_result_store.el; + mod.get_iter (out iter, path); + + + + // var val = ""; + GLib.Value value; + _this.compile_result_store.el.get_value(iter, 3, out value); + var fname = (string)value; + GLib.Value lvalue; + _this.compile_result_store.el.get_value(iter, 1, out lvalue); + var line = (int) lvalue; + + print("open %s @ %d\n", fname, line); + + + var bjsf = ""; + try { + var regex = new Regex("\\.vala$"); + + + bjsf = regex.replace(fname,fname.length , 0 , ".bjs"); + } catch (GLib.RegexError e) { + return false; + } + var p = _this.window.project; + + + + var jsr = p.getByPath(bjsf); + if (jsr != null) { + _this.window.windowstate.fileViewOpen(jsr, line); + + return false; + + } + + var pf = JsRender.JsRender.factory("PlainFile", p, fname); + _this.window.windowstate.fileViewOpen(pf,line); + + // try hiding the left nav.. + + return false; + + }); + } + + // user defined functions + } + public class Xcls_compile_result_store : Object + { + public Gtk.TreeStore el; + private Xcls_ValaCompileErrors _this; + + + // my vars (def) + + // ctor + public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner ) + { + _this = _owner; + _this.compile_result_store = this; + this.el = new Gtk.TreeStore( 4, typeof(string), typeof(int), typeof(string), typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_column : Object + { + public Gtk.TreeViewColumn el; + private Xcls_ValaCompileErrors _this; + + + // my vars (def) + + // ctor + public Xcls_column(Xcls_ValaCompileErrors _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Compile output"; + var child_0 = new Xcls_renderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + { + this.el.add_attribute(_this.renderer.el , "markup", 2 ); + + } + } + + // user defined functions + } + public class Xcls_renderer : Object + { + public Gtk.CellRendererText el; + private Xcls_ValaCompileErrors _this; + + + // my vars (def) + + // ctor + public Xcls_renderer(Xcls_ValaCompileErrors _owner ) + { + _this = _owner; + _this.renderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + + +} diff --git a/src/Builder4/ValaCompileResults.bjs b/src/Builder4/ValaCompileResults.bjs new file mode 100644 index 000000000..9df207897 --- /dev/null +++ b/src/Builder4/ValaCompileResults.bjs @@ -0,0 +1,54 @@ +{ + "name" : "ValaCompileResults", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/ValaCompileResults.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "int height_request" : 400, + "id" : "ValaCompileResults", + "| void show" : "( Gtk.Widget onbtn, bool reset) {\n\tint w, h;\n \n\tthis.window.el.get_size(out w, out h);\n \n // left tree = 250, editor area = 500?\n \n var new_w = int.min(750, w-100);\n if (new_w > (w-100)) {\n new_w = w-100;\n }\n this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));\n \n\n if (this.el.relative_to == null) {\n this.el.set_relative_to(onbtn);\n }\n this.el.show_all();\n // not sure why..\n \n if (reset) {\n\t\tvar buf = (Gtk.SourceBuffer)this.sourceview.el.get_buffer();\n\t\tbuf.set_text(\"\",0);\n\t}\n \n while(Gtk.events_pending()) { \n Gtk.main_iteration();\n }\n \n \n \n}\n", + "Xcls_MainWindow window" : "", + "xtype" : "Popover", + "Gtk.PositionType position" : "Gtk.PositionType.TOP", + "bool active" : true, + "int width_request" : 600, + "$ xns" : "Gtk", + "| void addLine" : "(string str) {\n\tvar buf = (Gtk.SourceBuffer)this.sourceview.el.get_buffer();\n\tGtk.TextIter iter;\n\tbuf.get_end_iter (out iter);\n\tbuf.insert(ref iter, str, str.length);\n\t/// scroll..\n\tbuf.get_end_iter (out iter);\n\tthis.sourceview.el.scroll_to_iter(iter, 0.0f, true, 0.0f, 1.0f);\n\t\n\n}\n", + "bool modal" : true, + "items" : [ + { + "id" : "compile_view", + "* pack" : "add", + "xtype" : "Box", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "* init" : "{\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n\n}\n", + "bool hexpand" : true, + "* pack" : "pack_end,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "sourceview", + "* init" : "{\n\n var description = Pango.FontDescription.from_string(\"monospace\");\n description.set_size(8000);\n this.el.override_font(description);\n\n\n}\n", + "xtype" : "SourceView", + "* pack" : "add", + "bool editable" : false, + "$ xns" : "Gtk", + "bool show_line_numbers" : false + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/ValaCompileResults.vala b/src/Builder4/ValaCompileResults.vala new file mode 100644 index 000000000..65a8194e9 --- /dev/null +++ b/src/Builder4/ValaCompileResults.vala @@ -0,0 +1,182 @@ +static Xcls_ValaCompileResults _ValaCompileResults; + +public class Xcls_ValaCompileResults : Object +{ + public Gtk.Popover el; + private Xcls_ValaCompileResults _this; + + public static Xcls_ValaCompileResults singleton() + { + if (_ValaCompileResults == null) { + _ValaCompileResults= new Xcls_ValaCompileResults(); + } + return _ValaCompileResults; + } + public Xcls_compile_view compile_view; + public Xcls_sourceview sourceview; + + // my vars (def) + public Xcls_MainWindow window; + public bool active; + + // ctor + public Xcls_ValaCompileResults() + { + _this = this; + this.el = new Gtk.Popover( null ); + + // my vars (dec) + this.active = true; + + // set gobject values + this.el.width_request = 600; + this.el.height_request = 400; + this.el.modal = true; + this.el.position = Gtk.PositionType.TOP; + var child_0 = new Xcls_compile_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + public void show ( Gtk.Widget onbtn, bool reset) { + int w, h; + + this.window.el.get_size(out w, out h); + + // left tree = 250, editor area = 500? + + var new_w = int.min(750, w-100); + if (new_w > (w-100)) { + new_w = w-100; + } + this.el.set_size_request( int.max(100, new_w), int.max(100, h-120)); + + + if (this.el.relative_to == null) { + this.el.set_relative_to(onbtn); + } + this.el.show_all(); + // not sure why.. + + if (reset) { + var buf = (Gtk.SourceBuffer)this.sourceview.el.get_buffer(); + buf.set_text("",0); + } + + while(Gtk.events_pending()) { + Gtk.main_iteration(); + } + + + + } + public void addLine (string str) { + var buf = (Gtk.SourceBuffer)this.sourceview.el.get_buffer(); + Gtk.TextIter iter; + buf.get_end_iter (out iter); + buf.insert(ref iter, str, str.length); + /// scroll.. + buf.get_end_iter (out iter); + this.sourceview.el.scroll_to_iter(iter, 0.0f, true, 0.0f, 1.0f); + + + } + public class Xcls_compile_view : Object + { + public Gtk.Box el; + private Xcls_ValaCompileResults _this; + + + // my vars (def) + + // ctor + public Xcls_compile_view(Xcls_ValaCompileResults _owner ) + { + _this = _owner; + _this.compile_view = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_ScrolledWindow3( _this ); + child_0.ref(); + this.el.pack_end ( child_0.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow3 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_ValaCompileResults _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow3(Xcls_ValaCompileResults _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + var child_0 = new Xcls_sourceview( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + { + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + + + } + } + + // user defined functions + } + public class Xcls_sourceview : Object + { + public Gtk.SourceView el; + private Xcls_ValaCompileResults _this; + + + // my vars (def) + + // ctor + public Xcls_sourceview(Xcls_ValaCompileResults _owner ) + { + _this = _owner; + _this.sourceview = this; + this.el = new Gtk.SourceView(); + + // my vars (dec) + + // set gobject values + this.el.editable = false; + this.el.show_line_numbers = false; + + // init method + + { + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(8000); + this.el.override_font(description); + + + } + } + + // user defined functions + } + + + +} diff --git a/src/Builder4/ValaProjectSettings.bjs b/src/Builder4/ValaProjectSettings.bjs new file mode 100644 index 000000000..a72c3d8c9 --- /dev/null +++ b/src/Builder4/ValaProjectSettings.bjs @@ -0,0 +1,443 @@ +{ + "name" : "ValaProjectSettings", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/ValaProjectSettings.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "# Project.Gtk project" : "null", + "# Xcls_MainWindow window" : "null", + "| void show" : "(Project.Gtk project) {\n \n \n print(\"ValaProjectSettings show\\n\");\n \n this.project= project;\n\n this.compile_flags.el.text = _this.project.compilegroups.get(\"_default_\").compile_flags;\n \n this.default_directory_tree_store.load(); \n this.default_packages_tree_store.load(); \n this.targets_tree_store.load();\n this.files_tree_store.load();\n\n}\n", + "bool hexpand" : true, + "xtype" : "Box", + "string id" : "ValaProjectSettings", + "| void save" : "() {\n this.project.writeConfig();\n}", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "* pack" : "pack_start,true,true,0", + "xtype" : "Notebook", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "label_global", + "* pack" : false, + "xtype" : "Label", + "$ xns" : "Gtk", + "utf8 label" : "Global" + }, + { + "id" : "label_targets", + "xtype" : "Label", + "* pack" : false, + "$ xns" : "Gtk", + "utf8 label" : "Targets" + }, + { + "xtype" : "Box", + "* pack" : "append_page,_this.label_global.el", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "compile flags" + }, + { + "listeners" : { + "changed" : "() => {\n \n _this.project.compilegroups.get(\"_default_\").compile_flags = this.el.text;\n _this.project.writeConfig();\n// _this.project.save();\n\n}" + }, + "id" : "compile_flags", + "* pack" : "pack_start,false,false,0", + "xtype" : "Entry", + "$ xns" : "Gtk", + "utf8 placeholder_text" : "eg. -g --valasrc $BASEDIR " + }, + { + "* pack" : "pack_start,true,true,0", + "xtype" : "Paned", + "$ xns" : "Gtk", + "int position" : 300, + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "bool hexpand" : true, + "* pack" : "add", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "gboolean headers_visible" : true, + "xtype" : "TreeView", + "* pack" : "add", + "string id" : "default_packages_tree", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "default_packages_tree_store", + "xtype" : "ListStore", + "* pack" : "set_model", + "$ n_columns" : 2, + "| void load" : "() {\n \n var def = _this.project.compilegroups.get(\"_default_\");\n var items = def.packages;\n \n this.el.clear();\n var pal = (Palete.Gtk) Palete.factory(\"Gtk\");\n var pkgs = pal.packages(_this.project);\n print(\"ValaProjectSettings:packages load %d\\n\", pkgs.size);\n\n Gtk.TreeIter citer;\n\n for(var i =0 ; i < pkgs.size; i++) {\n this.el.append(out citer); \n \n this.el.set_value(citer, 0, pkgs.get(i) ); // title \n this.el.set_value(citer, 1, items.contains(pkgs.get(i)) );\n }\n this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n", + "$ columns" : " typeof(string), // 0 key type\n typeof(bool)", + "$ xns" : "Gtk" + }, + { + "utf8 title" : "package name", + "* init" : " \n this.el.add_attribute(_this.packages_render.el , \"text\", 0 );\n ", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : true, + "gboolean expand" : true, + "$ xns" : "Gtk", + "items" : [ + { + "id" : "packages_render", + "xtype" : "CellRendererText", + "* pack" : "pack_start,false", + "$ xns" : "Gtk" + } + ] + }, + { + "utf8 title" : "use", + "* init" : "{\n this.el.add_attribute(_this.packages_render_use.el , \"active\", 1 );\n }", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : false, + "$ xns" : "Gtk", + "gint fixed_width" : 50, + "items" : [ + { + "listeners" : { + "toggled" : "( path_string) => { \n var m = _this.default_packages_tree_store.el;\n Gtk.TreeIter iter;\n Gtk.TreePath path = new Gtk.TreePath.from_string (path_string);\n m.get_iter (out iter, path);\n GLib.Value val;\n m.get_value(iter, 1, out val);\n m.set_value(iter, 1, ((bool) val) ? false :true); \n GLib.Value fval; \n m.get_value(iter, 0, out fval);\n var fn = (string)fval;\n \n var def = _this.project.compilegroups.get(\"_default_\");\n var items = def.packages;\n if ((bool)val) {\n // renive\n items.remove(fn);\n } else {\n items.add(fn);\n }\n \n}" + }, + "id" : "packages_render_use", + "* pack" : "pack_start,false", + "xtype" : "CellRendererToggle", + "$ xns" : "Gtk", + "gboolean activatable" : true + } + ] + } + ] + } + ] + }, + { + "bool hexpand" : true, + "* pack" : "add2", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_press_event" : " ( ev) => {\n //console.log(\"button press?\");\n \n \n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {\n //print(\"click\" + ev.type);\n return false;\n }\n //Gtk.TreePath res;\n //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n // return true;\n //}\n \n // this.el.get_selection().select_path(res);\n \n //if (!this.get('/LeftTreeMenu').el) { \n // this.get('/LeftTreeMenu').init(); \n // }\n \n _this.default_directory_menu.el.set_screen(Gdk.Screen.get_default());\n _this.default_directory_menu.el.show_all();\n _this.default_directory_menu.el.popup(null, null, null, 3, ev.time);\n // print(\"click:\" + res.path.to_string());\n return true;\n}" + }, + "gboolean headers_visible" : true, + "id" : "default_directory_tree", + "* pack" : "add", + "xtype" : "TreeView", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "default_directory_tree_store", + "xtype" : "ListStore", + "* pack" : "set_model", + "$ n_columns" : 1, + "| void load" : "() {\n \n this.el.clear();\n \n \n var def = _this.project.compilegroups.get(\"_default_\");\n var items = def.sources;\n \n \n Gtk.TreeIter citer;\n\n for(var i =0 ; i < items.size; i++) {\n this.el.append(out citer); \n \n this.el.set_value(citer, 0, items.get(i) ); // title \n //this.el.set_value(citer, 1, items.get(i) );\n }\n this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n", + "$ columns" : " typeof(string)\n ", + "$ xns" : "Gtk" + }, + { + "utf8 title" : "Available Directories (right click to add)", + "* init" : "\n this.el.add_attribute(_this.directory_render.el , \"text\", 0 );\n ", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "id" : "directory_render", + "xtype" : "CellRendererText", + "* pack" : "pack_start,false", + "$ xns" : "Gtk" + } + ] + } + ] + }, + { + "id" : "default_directory_menu", + "xtype" : "Menu", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : "() => {\n \n var chooser = new Gtk.FileChooserDialog (\n\t\"Add a directory\", _this.window.el, Gtk.FileChooserAction.SELECT_FOLDER ,\n\t\"_Cancel\",\n\tGtk.ResponseType.CANCEL,\n\t\"_Add\",\n\tGtk.ResponseType.ACCEPT);\n if (chooser.run () != Gtk.ResponseType.ACCEPT) {\n chooser.close ();\n return;\n }\n chooser.close ();\n // add the directory..\n var fn = _this.project.relPath(chooser.get_filename());\n _this.project.compilegroups.get(\"_default_\").sources.add(fn);\n _this.default_directory_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Add Directory" + }, + { + "listeners" : { + "activate" : "() => {\n \n var chooser = new Gtk.FileChooserDialog (\n\t\"Add a directory\", _this.window.el, Gtk.FileChooserAction.OPEN ,\n\t\"_Cancel\",\n\tGtk.ResponseType.CANCEL,\n\t\"_Add\",\n\tGtk.ResponseType.ACCEPT);\n if (chooser.run () != Gtk.ResponseType.ACCEPT) {\n chooser.close ();\n return;\n }\n chooser.close ();\n // add the directory..\n var fn = _this.project.relPath(chooser.get_filename());\n _this.project.compilegroups.get(\"_default_\").sources.add(fn);\n _this.default_directory_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Add File" + }, + { + "* pack" : "add", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : "() => {\n \n //\n Gtk.TreeModel mod;\n Gtk.TreeIter iter;\n if (!_this.default_directory_tree.el.get_selection().get_selected(out mod, out iter)) {\n print(\"nothing selected\\n\");\n return;\n }\n\n \n // add the directory..\n \n \n GLib.Value val;\n mod.get_value(iter,0, out val);\n var fn = (string) val;\n \n print(\"remove: %s\\n\", fn);\n if (!_this.project.compilegroups.get(\"_default_\").sources.remove(fn)) {\n print(\"remove failed\");\n }\n _this.default_directory_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Remove File/Directory" + } + ] + } + ] + } + ] + } + ] + }, + { + "gint position" : 300, + "* pack" : "append_page,_this.label_targets.el", + "xtype" : "Paned", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "* init" : "{ \nthis.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n\n}\n", + "* pack" : "add1", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "targets_tree_menu", + "xtype" : "Menu", + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : "() => {\n \n if (_this.project.compilegroups.has_key(\"NEW GROUP\")) {\n return;\n }\n \n // add the directory..\n \n _this.project.compilegroups.set(\"NEW GROUP\", new Project.GtkValaSettings(\"NEW GROUP\"));\n _this.targets_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Add Compile Target" + }, + { + "* pack" : "add", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : "() => {\n \n //\n Gtk.TreeModel mod;\n Gtk.TreeIter iter;\n if (!_this.targets_tree.el.get_selection().get_selected(out mod, out iter)) {\n print(\"nothing selected\\n\");\n return;\n }\n\n \n // add the directory..\n \n \n GLib.Value val;\n mod.get_value(iter,0, out val);\n var fn = (string) val;\n \n print(\"remove: %s\\n\", fn);\n if (!_this.project.compilegroups.unset(fn)) {\n print(\"remove failed\");\n }\n _this.targets_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Remove Target" + } + ] + }, + { + "listeners" : { + "button_press_event" : " ( ev) => {\n //console.log(\"button press?\");\n \n \n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {\n //print(\"click\" + ev.type);\n return false;\n }\n //Gtk.TreePath res;\n //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n // return true;\n //}\n \n // this.el.get_selection().select_path(res);\n \n //if (!this.get('/LeftTreeMenu').el) { \n // this.get('/LeftTreeMenu').init(); \n // }\n \n _this.targets_tree_menu.el.set_screen(Gdk.Screen.get_default());\n _this.targets_tree_menu.el.show_all();\n _this.targets_tree_menu.el.popup(null, null, null, 3, ev.time);\n // print(\"click:\" + res.path.to_string());\n return true;\n}", + "cursor_changed" : " ( ) => {\n\n if (this.cursor != \"\") {\n // save the values..\n }\n \n // load the new values.\n \n\n Gtk.TreeModel mod;\n Gtk.TreeIter iter;\n if (!this.el.get_selection().get_selected(out mod, out iter)) {\n print(\"nothing selected\\n\");\n // should disable the right hand side..\n _this.set_vbox.el.hide();\n return;\n }\n _this.set_vbox.el.show();\n \n // add the directory..\n \n \n GLib.Value val;\n mod.get_value(iter,0, out val);\n var fn = (string) val;\n \n this.cursor = fn;\n var cg = _this.project.compilegroups.get(fn);\n \n _this.build_pack_target.el.set_text(cg.target_bin);\n _this.build_compile_flags.el.set_text(cg.compile_flags);\n\t\t_this.build_execute_args.el.set_text(cg.execute_args);\n \n _this.set_vbox.cgroup = cg;\n _this.files_tree_store.update();\n \n // load the srouces\n \n\n }" + }, + "id" : "targets_tree", + "# string cursor" : "", + "* pack" : "add", + "xtype" : "TreeView", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "targets_tree_store", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ n_columns" : 2, + "| void load" : "() {\n \n this.el.clear();\n \n \n var cg = _this.project.compilegroups;\n \n _this.targets_tree.cursor = \"\";\n Gtk.TreeIter citer;\n var iter = cg.map_iterator();\n while(iter.next()) {\n var key = iter.get_key();\n if (key == \"_default_\") {\n continue;\n }\n \n this.el.append(out citer); \n \n this.el.set_value(citer, 0, key ); // title \n //this.el.set_value(citer, 1, items.get(i) );\n };\n this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n _this.set_vbox.el.hide();\n}\n", + "$ columns" : " typeof(string), // 0 key type\n typeof(string) // ??\n ", + "$ xns" : "Gtk" + }, + { + "utf8 title" : "name", + "* init" : " {\n this.el.add_attribute(_this.targets_render.el , \"text\", 0 );\n }", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "edited" : " (path, newtext) => {\n \n Gtk.TreeIter iter;\n _this.targets_tree_store.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n _this.targets_tree_store.el.get_value(iter,0, out gval);\n var oldval = (string)gval;\n if (oldval == newtext) {\n return;\n }\n var cg = _this.project.compilegroups.get(oldval);\n cg.name = newtext;\n _this.project.compilegroups.unset(oldval);\n _this.project.compilegroups.set(newtext, cg);\n _this.targets_tree_store.load();\n }" + }, + "id" : "targets_render", + "* pack" : "pack_start,false", + "xtype" : "CellRendererText", + "$ xns" : "Gtk", + "gboolean editable" : true + } + ] + } + ] + } + ] + }, + { + "id" : "set_vbox", + "* pack" : "add2", + "xtype" : "Box", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "# Project.GtkValaSettings cgroup" : "null", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "target filename" + }, + { + "listeners" : { + "changed" : "() => {\n if (_this.targets_tree.cursor.length < 1) {\n return;\n }\n _this.project.compilegroups.get(_this.targets_tree.cursor).target_bin = this.el.text;\n}" + }, + "id" : "build_pack_target", + "* pack" : "pack_start,false,false,0", + "xtype" : "Entry", + "$ xns" : "Gtk" + }, + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "compile flags" + }, + { + "listeners" : { + "changed" : "() => {\n if (_this.targets_tree.cursor.length < 1) {\n return;\n }\n _this.project.compilegroups.get(_this.targets_tree.cursor).compile_flags = this.el.text;\n}" + }, + "id" : "build_compile_flags", + "* pack" : "pack_start,false,false,0", + "xtype" : "Entry", + "$ xns" : "Gtk" + }, + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "test argments - when run after a build" + }, + { + "listeners" : { + "changed" : "() => {\n if (_this.targets_tree.cursor.length < 1) {\n return;\n }\n _this.project.compilegroups.get(_this.targets_tree.cursor).execute_args = this.el.text;\n}" + }, + "id" : "build_execute_args", + "string placeholder_text" : "eg. -f somefile -g ", + "xtype" : "Entry", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + }, + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "Files to compile" + }, + { + "* pack" : "pack_start,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "TreeView", + "* pack" : "add", + "string id" : "files_tree", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "files_tree_store", + "* pack" : "set_model", + "xtype" : "ListStore", + "| void updateDir" : "(string dname, bool bval) {\n \n Gtk.TreeIter citer;\n\n var cg = _this.set_vbox.cgroup;\n for(var i =0 ; i < this.el.iter_n_children(null); i++) {\n this.el.iter_nth_child(out citer,null,i);\n\n GLib.Value val;\n this.el.get_value(citer,0, out val);\n var fn = (string) val;\n \n if ( Path.get_dirname (fn) == dname) {\n \n this.el.set_value(citer, 3, bval ); // checked \n \n \n \n if (!bval) {\n // renive\n if (cg.sources.contains(fn)) {\n cg.sources.remove(fn);\n }\n } else {\n if (!cg.sources.contains(fn)) {\n cg.sources.add(fn);\n }\n }\n \n \n }\n }\n\n}\n", + "$ n_columns" : 4, + "| void load" : "() {\n \n this.el.clear();\n \n \n var def = _this.project.compilegroups.get(\"_default_\");\n var items = def.sources;\n \n \n \n \n \n Gtk.TreeIter citer;\n\n for(var i =0 ; i < items.size; i++) {\n \n var files = _this.project.filesForCompile(items.get(i), false);\n if (files.size < 1) {\n continue;\n }\n \n this.el.append(out citer); \n \n this.el.set_value(citer, 0, items.get(i) ); // title \n this.el.set_value(citer, 1, \"\" + \n GLib.Markup.escape_text(items.get(i)) + \"\"\n ); // title \n print(\"ADD item %s\", items.get(i));\n this.el.set_value(citer, 2, \"dir\"); // type \n this.el.set_value(citer, 3, false ); // checked \n\n \n \n for(var j =0 ; j < files.size; j++) {\n this.el.append(out citer); \n print(\"ADD item %s\", files.get(j));\n this.el.set_value(citer, 0, files.get(j) ); // title \n this.el.set_value(citer, 1, GLib.Markup.escape_text( Path.get_basename (files.get(j))) ); // title \n this.el.set_value(citer, 2, \"file\"); // type \n this.el.set_value(citer, 3, false ); // checked \n\n }\n \n \n //this.el.set_value(citer, 1, items.get(i) );\n }\n this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n ", + "$ columns" : " typeof(string), // 0 file name\n typeof(string), // 0 basename\n typeof(string), // type (dir orfile)\n typeof(bool) // is checked.\n ", + "$ xns" : "Gtk", + "| void update" : "() {\n\n\n Gtk.TreeIter citer;\n\n for(var i =0 ; i < this.el.iter_n_children(null); i++) {\n this.el.iter_nth_child(out citer,null,i);\n\n GLib.Value val;\n this.el.get_value(citer,0, out val);\n var fn = (string) val;\n \n var active = false;\n if (_this.set_vbox.cgroup.sources.contains(fn)) {\n active = true;\n }\n \n this.el.set_value(citer, 3, active ); // checked \n }\n\n\n}\n" + }, + { + "utf8 title" : "name", + "* init" : "\n this.el.add_attribute(_this.files_render.el , \"markup\", 1 ); // basnemae\n \n/* this.el.add_attribute(_this.files_render.el , \"markup\", 2 );\n*/", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "id" : "files_render", + "xtype" : "CellRendererText", + "* pack" : "pack_start,false", + "$ xns" : "Gtk" + } + ] + }, + { + "utf8 title" : "use", + "* init" : "{\n this.el.add_attribute(_this.files_render_use.el , \"active\", 3 );\n }", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : false, + "$ xns" : "Gtk", + "gint fixed_width" : 50, + "items" : [ + { + "listeners" : { + "toggled" : "( path_string) => { \n\n\n\n var m = _this.files_tree_store.el;\n Gtk.TreeIter iter;\n Gtk.TreePath path = new Gtk.TreePath.from_string (path_string);\n m.get_iter (out iter, path);\n GLib.Value val;\n m.get_value(iter, 3, out val);\n m.set_value(iter, 3, ((bool) val) ? false :true); \n \n // type.\n GLib.Value ftval; \n m.get_value(iter, 2, out ftval);\n var ftype = (string)ftval; \n \n // full name... \n GLib.Value fval; \n m.get_value(iter, 0, out fval);\n var fn = (string)fval;\n \n \n var cg = _this.set_vbox.cgroup;\n // what's the sleected target?\n // update the list..\n // if ftype is a dir == then toggle all the bellow.\n \n if (ftype == \"dir\") {\n _this.files_tree_store.updateDir(fn, ((bool) val) ? false :true);\n }\n \n // if ftype is a file .. see if all the files in that directory are check and check the dir.\n\n \n if ((bool)val) {\n // renive\n cg.sources.remove(fn);\n } else {\n cg.sources.add(fn);\n }\n \n}" + }, + "id" : "files_render_use", + "* pack" : "pack_start,false", + "xtype" : "CellRendererToggle", + "$ xns" : "Gtk", + "gboolean activatable" : true + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/ValaProjectSettings.vala b/src/Builder4/ValaProjectSettings.vala new file mode 100644 index 000000000..b61cc6d25 --- /dev/null +++ b/src/Builder4/ValaProjectSettings.vala @@ -0,0 +1,1890 @@ +static ValaProjectSettings _ValaProjectSettings; + +public class ValaProjectSettings : Object +{ + public Gtk.Box el; + private ValaProjectSettings _this; + + public static ValaProjectSettings singleton() + { + if (_ValaProjectSettings == null) { + _ValaProjectSettings= new ValaProjectSettings(); + } + return _ValaProjectSettings; + } + public Xcls_label_global label_global; + public Xcls_label_targets label_targets; + public Xcls_compile_flags compile_flags; + public Xcls_default_packages_tree_store default_packages_tree_store; + public Xcls_packages_render packages_render; + public Xcls_packages_render_use packages_render_use; + public Xcls_default_directory_tree default_directory_tree; + public Xcls_default_directory_tree_store default_directory_tree_store; + public Xcls_directory_render directory_render; + public Xcls_default_directory_menu default_directory_menu; + public Xcls_targets_tree_menu targets_tree_menu; + public Xcls_targets_tree targets_tree; + public Xcls_targets_tree_store targets_tree_store; + public Xcls_targets_render targets_render; + public Xcls_set_vbox set_vbox; + public Xcls_build_pack_target build_pack_target; + public Xcls_build_compile_flags build_compile_flags; + public Xcls_build_execute_args build_execute_args; + public Xcls_files_tree_store files_tree_store; + public Xcls_files_render files_render; + public Xcls_files_render_use files_render_use; + + // my vars (def) + public Project.Gtk project; + public Xcls_MainWindow window; + + // ctor + public ValaProjectSettings() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.project = null; + this.window = null; + + // set gobject values + this.el.hexpand = true; + var child_0 = new Xcls_Notebook2( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + public void show (Project.Gtk project) { + + + print("ValaProjectSettings show\n"); + + this.project= project; + + this.compile_flags.el.text = _this.project.compilegroups.get("_default_").compile_flags; + + this.default_directory_tree_store.load(); + this.default_packages_tree_store.load(); + this.targets_tree_store.load(); + this.files_tree_store.load(); + + } + public void save () { + this.project.writeConfig(); + } + public class Xcls_Notebook2 : Object + { + public Gtk.Notebook el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Notebook2(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Notebook(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_label_global( _this ); + child_0.ref(); + var child_1 = new Xcls_label_targets( _this ); + child_1.ref(); + var child_2 = new Xcls_Box5( _this ); + child_2.ref(); + this.el.append_page ( child_2.el , _this.label_global.el ); + var child_3 = new Xcls_Paned26( _this ); + child_3.ref(); + this.el.append_page ( child_3.el , _this.label_targets.el ); + } + + // user defined functions + } + public class Xcls_label_global : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_label_global(ValaProjectSettings _owner ) + { + _this = _owner; + _this.label_global = this; + this.el = new Gtk.Label( "Global" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_label_targets : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_label_targets(ValaProjectSettings _owner ) + { + _this = _owner; + _this.label_targets = this; + this.el = new Gtk.Label( "Targets" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_Box5 : Object + { + public Gtk.Box el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Box5(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_Label6( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_compile_flags( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_Paned8( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_Label6 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label6(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "compile flags" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_compile_flags : Object + { + public Gtk.Entry el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_compile_flags(ValaProjectSettings _owner ) + { + _this = _owner; + _this.compile_flags = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.placeholder_text = "eg. -g --valasrc $BASEDIR "; + + //listeners + this.el.changed.connect( () => { + + _this.project.compilegroups.get("_default_").compile_flags = this.el.text; + _this.project.writeConfig(); + // _this.project.save(); + + }); + } + + // user defined functions + } + + public class Xcls_Paned8 : Object + { + public Gtk.Paned el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Paned8(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + + // set gobject values + this.el.position = 300; + var child_0 = new Xcls_ScrolledWindow9( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_ScrolledWindow16( _this ); + child_1.ref(); + this.el.add2 ( child_1.el ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow9 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow9(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + var child_0 = new Xcls_default_packages_tree( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_default_packages_tree : Object + { + public Gtk.TreeView el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_packages_tree(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.headers_visible = true; + var child_0 = new Xcls_default_packages_tree_store( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn12( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + var child_2 = new Xcls_TreeViewColumn14( _this ); + child_2.ref(); + this.el.append_column ( child_2.el ); + } + + // user defined functions + } + public class Xcls_default_packages_tree_store : Object + { + public Gtk.ListStore el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_packages_tree_store(ValaProjectSettings _owner ) + { + _this = _owner; + _this.default_packages_tree_store = this; + this.el = new Gtk.ListStore( 2, typeof(string), // 0 key type + typeof(bool) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void load () { + + var def = _this.project.compilegroups.get("_default_"); + var items = def.packages; + + this.el.clear(); + var pal = (Palete.Gtk) Palete.factory("Gtk"); + var pkgs = pal.packages(_this.project); + print("ValaProjectSettings:packages load %d\n", pkgs.size); + + Gtk.TreeIter citer; + + for(var i =0 ; i < pkgs.size; i++) { + this.el.append(out citer); + + this.el.set_value(citer, 0, pkgs.get(i) ); // title + this.el.set_value(citer, 1, items.contains(pkgs.get(i)) ); + } + this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + } + + public class Xcls_TreeViewColumn12 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn12(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "package name"; + this.el.expand = true; + this.el.resizable = true; + var child_0 = new Xcls_packages_render( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + this.el.add_attribute(_this.packages_render.el , "text", 0 ); + } + + // user defined functions + } + public class Xcls_packages_render : Object + { + public Gtk.CellRendererText el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_packages_render(ValaProjectSettings _owner ) + { + _this = _owner; + _this.packages_render = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_TreeViewColumn14 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn14(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "use"; + this.el.resizable = false; + this.el.fixed_width = 50; + var child_0 = new Xcls_packages_render_use( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + { + this.el.add_attribute(_this.packages_render_use.el , "active", 1 ); + } + } + + // user defined functions + } + public class Xcls_packages_render_use : Object + { + public Gtk.CellRendererToggle el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_packages_render_use(ValaProjectSettings _owner ) + { + _this = _owner; + _this.packages_render_use = this; + this.el = new Gtk.CellRendererToggle(); + + // my vars (dec) + + // set gobject values + this.el.activatable = true; + + //listeners + this.el.toggled.connect( ( path_string) => { + var m = _this.default_packages_tree_store.el; + Gtk.TreeIter iter; + Gtk.TreePath path = new Gtk.TreePath.from_string (path_string); + m.get_iter (out iter, path); + GLib.Value val; + m.get_value(iter, 1, out val); + m.set_value(iter, 1, ((bool) val) ? false :true); + GLib.Value fval; + m.get_value(iter, 0, out fval); + var fn = (string)fval; + + var def = _this.project.compilegroups.get("_default_"); + var items = def.packages; + if ((bool)val) { + // renive + items.remove(fn); + } else { + items.add(fn); + } + + }); + } + + // user defined functions + } + + + + + public class Xcls_ScrolledWindow16 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow16(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + var child_0 = new Xcls_default_directory_tree( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_default_directory_menu( _this ); + child_1.ref(); + } + + // user defined functions + } + public class Xcls_default_directory_tree : Object + { + public Gtk.TreeView el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_directory_tree(ValaProjectSettings _owner ) + { + _this = _owner; + _this.default_directory_tree = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.headers_visible = true; + var child_0 = new Xcls_default_directory_tree_store( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn19( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + //listeners + this.el.button_press_event.connect( ( ev) => { + //console.log("button press?"); + + + if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) { + //print("click" + ev.type); + return false; + } + //Gtk.TreePath res; + //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) { + // return true; + //} + + // this.el.get_selection().select_path(res); + + //if (!this.get('/LeftTreeMenu').el) { + // this.get('/LeftTreeMenu').init(); + // } + + _this.default_directory_menu.el.set_screen(Gdk.Screen.get_default()); + _this.default_directory_menu.el.show_all(); + _this.default_directory_menu.el.popup(null, null, null, 3, ev.time); + // print("click:" + res.path.to_string()); + return true; + }); + } + + // user defined functions + } + public class Xcls_default_directory_tree_store : Object + { + public Gtk.ListStore el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_directory_tree_store(ValaProjectSettings _owner ) + { + _this = _owner; + _this.default_directory_tree_store = this; + this.el = new Gtk.ListStore( 1, typeof(string) + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void load () { + + this.el.clear(); + + + var def = _this.project.compilegroups.get("_default_"); + var items = def.sources; + + + Gtk.TreeIter citer; + + for(var i =0 ; i < items.size; i++) { + this.el.append(out citer); + + this.el.set_value(citer, 0, items.get(i) ); // title + //this.el.set_value(citer, 1, items.get(i) ); + } + this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + } + + public class Xcls_TreeViewColumn19 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn19(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Available Directories (right click to add)"; + this.el.resizable = true; + var child_0 = new Xcls_directory_render( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + this.el.add_attribute(_this.directory_render.el , "text", 0 ); + } + + // user defined functions + } + public class Xcls_directory_render : Object + { + public Gtk.CellRendererText el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_directory_render(ValaProjectSettings _owner ) + { + _this = _owner; + _this.directory_render = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_default_directory_menu : Object + { + public Gtk.Menu el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_directory_menu(ValaProjectSettings _owner ) + { + _this = _owner; + _this.default_directory_menu = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem22( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_MenuItem23( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_SeparatorMenuItem24( _this ); + child_2.ref(); + this.el.add ( child_2.el ); + var child_3 = new Xcls_MenuItem25( _this ); + child_3.ref(); + this.el.add ( child_3.el ); + } + + // user defined functions + } + public class Xcls_MenuItem22 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem22(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Add Directory"; + + //listeners + this.el.activate.connect( () => { + + var chooser = new Gtk.FileChooserDialog ( + "Add a directory", _this.window.el, Gtk.FileChooserAction.SELECT_FOLDER , + "_Cancel", + Gtk.ResponseType.CANCEL, + "_Add", + Gtk.ResponseType.ACCEPT); + if (chooser.run () != Gtk.ResponseType.ACCEPT) { + chooser.close (); + return; + } + chooser.close (); + // add the directory.. + var fn = _this.project.relPath(chooser.get_filename()); + _this.project.compilegroups.get("_default_").sources.add(fn); + _this.default_directory_tree_store.load(); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem23 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem23(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Add File"; + + //listeners + this.el.activate.connect( () => { + + var chooser = new Gtk.FileChooserDialog ( + "Add a directory", _this.window.el, Gtk.FileChooserAction.OPEN , + "_Cancel", + Gtk.ResponseType.CANCEL, + "_Add", + Gtk.ResponseType.ACCEPT); + if (chooser.run () != Gtk.ResponseType.ACCEPT) { + chooser.close (); + return; + } + chooser.close (); + // add the directory.. + var fn = _this.project.relPath(chooser.get_filename()); + _this.project.compilegroups.get("_default_").sources.add(fn); + _this.default_directory_tree_store.load(); + }); + } + + // user defined functions + } + + public class Xcls_SeparatorMenuItem24 : Object + { + public Gtk.SeparatorMenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem24(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_MenuItem25 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem25(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Remove File/Directory"; + + //listeners + this.el.activate.connect( () => { + + // + Gtk.TreeModel mod; + Gtk.TreeIter iter; + if (!_this.default_directory_tree.el.get_selection().get_selected(out mod, out iter)) { + print("nothing selected\n"); + return; + } + + + // add the directory.. + + + GLib.Value val; + mod.get_value(iter,0, out val); + var fn = (string) val; + + print("remove: %s\n", fn); + if (!_this.project.compilegroups.get("_default_").sources.remove(fn)) { + print("remove failed"); + } + _this.default_directory_tree_store.load(); + }); + } + + // user defined functions + } + + + + + + public class Xcls_Paned26 : Object + { + public Gtk.Paned el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Paned26(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); + + // my vars (dec) + + // set gobject values + this.el.position = 300; + var child_0 = new Xcls_ScrolledWindow27( _this ); + child_0.ref(); + this.el.add1 ( child_0.el ); + var child_1 = new Xcls_set_vbox( _this ); + child_1.ref(); + this.el.add2 ( child_1.el ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow27 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow27(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_targets_tree_menu( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_targets_tree( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + + // init method + + { + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + + } + } + + // user defined functions + } + public class Xcls_targets_tree_menu : Object + { + public Gtk.Menu el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_targets_tree_menu(ValaProjectSettings _owner ) + { + _this = _owner; + _this.targets_tree_menu = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem29( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_SeparatorMenuItem30( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_MenuItem31( _this ); + child_2.ref(); + this.el.add ( child_2.el ); + } + + // user defined functions + } + public class Xcls_MenuItem29 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem29(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Add Compile Target"; + + //listeners + this.el.activate.connect( () => { + + if (_this.project.compilegroups.has_key("NEW GROUP")) { + return; + } + + // add the directory.. + + _this.project.compilegroups.set("NEW GROUP", new Project.GtkValaSettings("NEW GROUP")); + _this.targets_tree_store.load(); + }); + } + + // user defined functions + } + + public class Xcls_SeparatorMenuItem30 : Object + { + public Gtk.SeparatorMenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem30(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_MenuItem31 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem31(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Remove Target"; + + //listeners + this.el.activate.connect( () => { + + // + Gtk.TreeModel mod; + Gtk.TreeIter iter; + if (!_this.targets_tree.el.get_selection().get_selected(out mod, out iter)) { + print("nothing selected\n"); + return; + } + + + // add the directory.. + + + GLib.Value val; + mod.get_value(iter,0, out val); + var fn = (string) val; + + print("remove: %s\n", fn); + if (!_this.project.compilegroups.unset(fn)) { + print("remove failed"); + } + _this.targets_tree_store.load(); + }); + } + + // user defined functions + } + + + public class Xcls_targets_tree : Object + { + public Gtk.TreeView el; + private ValaProjectSettings _this; + + + // my vars (def) + public string cursor; + + // ctor + public Xcls_targets_tree(ValaProjectSettings _owner ) + { + _this = _owner; + _this.targets_tree = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_targets_tree_store( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn34( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + //listeners + this.el.button_press_event.connect( ( ev) => { + //console.log("button press?"); + + + if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) { + //print("click" + ev.type); + return false; + } + //Gtk.TreePath res; + //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) { + // return true; + //} + + // this.el.get_selection().select_path(res); + + //if (!this.get('/LeftTreeMenu').el) { + // this.get('/LeftTreeMenu').init(); + // } + + _this.targets_tree_menu.el.set_screen(Gdk.Screen.get_default()); + _this.targets_tree_menu.el.show_all(); + _this.targets_tree_menu.el.popup(null, null, null, 3, ev.time); + // print("click:" + res.path.to_string()); + return true; + }); + this.el.cursor_changed.connect( ( ) => { + + if (this.cursor != "") { + // save the values.. + } + + // load the new values. + + + Gtk.TreeModel mod; + Gtk.TreeIter iter; + if (!this.el.get_selection().get_selected(out mod, out iter)) { + print("nothing selected\n"); + // should disable the right hand side.. + _this.set_vbox.el.hide(); + return; + } + _this.set_vbox.el.show(); + + // add the directory.. + + + GLib.Value val; + mod.get_value(iter,0, out val); + var fn = (string) val; + + this.cursor = fn; + var cg = _this.project.compilegroups.get(fn); + + _this.build_pack_target.el.set_text(cg.target_bin); + _this.build_compile_flags.el.set_text(cg.compile_flags); + _this.build_execute_args.el.set_text(cg.execute_args); + + _this.set_vbox.cgroup = cg; + _this.files_tree_store.update(); + + // load the srouces + + + }); + } + + // user defined functions + } + public class Xcls_targets_tree_store : Object + { + public Gtk.ListStore el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_targets_tree_store(ValaProjectSettings _owner ) + { + _this = _owner; + _this.targets_tree_store = this; + this.el = new Gtk.ListStore( 2, typeof(string), // 0 key type + typeof(string) // ?? + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void load () { + + this.el.clear(); + + + var cg = _this.project.compilegroups; + + _this.targets_tree.cursor = ""; + Gtk.TreeIter citer; + var iter = cg.map_iterator(); + while(iter.next()) { + var key = iter.get_key(); + if (key == "_default_") { + continue; + } + + this.el.append(out citer); + + this.el.set_value(citer, 0, key ); // title + //this.el.set_value(citer, 1, items.get(i) ); + }; + this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + _this.set_vbox.el.hide(); + } + } + + public class Xcls_TreeViewColumn34 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn34(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "name"; + this.el.resizable = true; + var child_0 = new Xcls_targets_render( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + { + this.el.add_attribute(_this.targets_render.el , "text", 0 ); + } + } + + // user defined functions + } + public class Xcls_targets_render : Object + { + public Gtk.CellRendererText el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_targets_render(ValaProjectSettings _owner ) + { + _this = _owner; + _this.targets_render = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + this.el.editable = true; + + //listeners + this.el.edited.connect( (path, newtext) => { + + Gtk.TreeIter iter; + _this.targets_tree_store.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + _this.targets_tree_store.el.get_value(iter,0, out gval); + var oldval = (string)gval; + if (oldval == newtext) { + return; + } + var cg = _this.project.compilegroups.get(oldval); + cg.name = newtext; + _this.project.compilegroups.unset(oldval); + _this.project.compilegroups.set(newtext, cg); + _this.targets_tree_store.load(); + }); + } + + // user defined functions + } + + + + + public class Xcls_set_vbox : Object + { + public Gtk.Box el; + private ValaProjectSettings _this; + + + // my vars (def) + public Project.GtkValaSettings cgroup; + + // ctor + public Xcls_set_vbox(ValaProjectSettings _owner ) + { + _this = _owner; + _this.set_vbox = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.cgroup = null; + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_Label37( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_build_pack_target( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_Label39( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , false,false,0 ); + var child_3 = new Xcls_build_compile_flags( _this ); + child_3.ref(); + this.el.pack_start ( child_3.el , false,false,0 ); + var child_4 = new Xcls_Label41( _this ); + child_4.ref(); + this.el.pack_start ( child_4.el , false,false,0 ); + var child_5 = new Xcls_build_execute_args( _this ); + child_5.ref(); + this.el.pack_start ( child_5.el , false,false,0 ); + var child_6 = new Xcls_Label43( _this ); + child_6.ref(); + this.el.pack_start ( child_6.el , false,false,0 ); + var child_7 = new Xcls_ScrolledWindow44( _this ); + child_7.ref(); + this.el.pack_start ( child_7.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_Label37 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label37(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "target filename" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_build_pack_target : Object + { + public Gtk.Entry el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_build_pack_target(ValaProjectSettings _owner ) + { + _this = _owner; + _this.build_pack_target = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.changed.connect( () => { + if (_this.targets_tree.cursor.length < 1) { + return; + } + _this.project.compilegroups.get(_this.targets_tree.cursor).target_bin = this.el.text; + }); + } + + // user defined functions + } + + public class Xcls_Label39 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label39(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "compile flags" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_build_compile_flags : Object + { + public Gtk.Entry el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_build_compile_flags(ValaProjectSettings _owner ) + { + _this = _owner; + _this.build_compile_flags = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.changed.connect( () => { + if (_this.targets_tree.cursor.length < 1) { + return; + } + _this.project.compilegroups.get(_this.targets_tree.cursor).compile_flags = this.el.text; + }); + } + + // user defined functions + } + + public class Xcls_Label41 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label41(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "test argments - when run after a build" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_build_execute_args : Object + { + public Gtk.Entry el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_build_execute_args(ValaProjectSettings _owner ) + { + _this = _owner; + _this.build_execute_args = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.placeholder_text = "eg. -f somefile -g "; + + //listeners + this.el.changed.connect( () => { + if (_this.targets_tree.cursor.length < 1) { + return; + } + _this.project.compilegroups.get(_this.targets_tree.cursor).execute_args = this.el.text; + }); + } + + // user defined functions + } + + public class Xcls_Label43 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label43(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Files to compile" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_ScrolledWindow44 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow44(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_files_tree( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_files_tree : Object + { + public Gtk.TreeView el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_files_tree(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_files_tree_store( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn47( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + var child_2 = new Xcls_TreeViewColumn49( _this ); + child_2.ref(); + this.el.append_column ( child_2.el ); + } + + // user defined functions + } + public class Xcls_files_tree_store : Object + { + public Gtk.ListStore el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_files_tree_store(ValaProjectSettings _owner ) + { + _this = _owner; + _this.files_tree_store = this; + this.el = new Gtk.ListStore( 4, typeof(string), // 0 file name + typeof(string), // 0 basename + typeof(string), // type (dir orfile) + typeof(bool) // is checked. + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void updateDir (string dname, bool bval) { + + Gtk.TreeIter citer; + + var cg = _this.set_vbox.cgroup; + for(var i =0 ; i < this.el.iter_n_children(null); i++) { + this.el.iter_nth_child(out citer,null,i); + + GLib.Value val; + this.el.get_value(citer,0, out val); + var fn = (string) val; + + if ( Path.get_dirname (fn) == dname) { + + this.el.set_value(citer, 3, bval ); // checked + + + + if (!bval) { + // renive + if (cg.sources.contains(fn)) { + cg.sources.remove(fn); + } + } else { + if (!cg.sources.contains(fn)) { + cg.sources.add(fn); + } + } + + + } + } + + } + public void load () { + + this.el.clear(); + + + var def = _this.project.compilegroups.get("_default_"); + var items = def.sources; + + + + + + Gtk.TreeIter citer; + + for(var i =0 ; i < items.size; i++) { + + var files = _this.project.filesForCompile(items.get(i), false); + if (files.size < 1) { + continue; + } + + this.el.append(out citer); + + this.el.set_value(citer, 0, items.get(i) ); // title + this.el.set_value(citer, 1, "" + + GLib.Markup.escape_text(items.get(i)) + "" + ); // title + print("ADD item %s", items.get(i)); + this.el.set_value(citer, 2, "dir"); // type + this.el.set_value(citer, 3, false ); // checked + + + + for(var j =0 ; j < files.size; j++) { + this.el.append(out citer); + print("ADD item %s", files.get(j)); + this.el.set_value(citer, 0, files.get(j) ); // title + this.el.set_value(citer, 1, GLib.Markup.escape_text( Path.get_basename (files.get(j))) ); // title + this.el.set_value(citer, 2, "file"); // type + this.el.set_value(citer, 3, false ); // checked + + } + + + //this.el.set_value(citer, 1, items.get(i) ); + } + this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + public void update () { + + + Gtk.TreeIter citer; + + for(var i =0 ; i < this.el.iter_n_children(null); i++) { + this.el.iter_nth_child(out citer,null,i); + + GLib.Value val; + this.el.get_value(citer,0, out val); + var fn = (string) val; + + var active = false; + if (_this.set_vbox.cgroup.sources.contains(fn)) { + active = true; + } + + this.el.set_value(citer, 3, active ); // checked + } + + + } + } + + public class Xcls_TreeViewColumn47 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn47(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "name"; + this.el.resizable = true; + var child_0 = new Xcls_files_render( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + this.el.add_attribute(_this.files_render.el , "markup", 1 ); // basnemae + + /* this.el.add_attribute(_this.files_render.el , "markup", 2 ); + */ + } + + // user defined functions + } + public class Xcls_files_render : Object + { + public Gtk.CellRendererText el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_files_render(ValaProjectSettings _owner ) + { + _this = _owner; + _this.files_render = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_TreeViewColumn49 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn49(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "use"; + this.el.resizable = false; + this.el.fixed_width = 50; + var child_0 = new Xcls_files_render_use( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + { + this.el.add_attribute(_this.files_render_use.el , "active", 3 ); + } + } + + // user defined functions + } + public class Xcls_files_render_use : Object + { + public Gtk.CellRendererToggle el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_files_render_use(ValaProjectSettings _owner ) + { + _this = _owner; + _this.files_render_use = this; + this.el = new Gtk.CellRendererToggle(); + + // my vars (dec) + + // set gobject values + this.el.activatable = true; + + //listeners + this.el.toggled.connect( ( path_string) => { + + + + var m = _this.files_tree_store.el; + Gtk.TreeIter iter; + Gtk.TreePath path = new Gtk.TreePath.from_string (path_string); + m.get_iter (out iter, path); + GLib.Value val; + m.get_value(iter, 3, out val); + m.set_value(iter, 3, ((bool) val) ? false :true); + + // type. + GLib.Value ftval; + m.get_value(iter, 2, out ftval); + var ftype = (string)ftval; + + // full name... + GLib.Value fval; + m.get_value(iter, 0, out fval); + var fn = (string)fval; + + + var cg = _this.set_vbox.cgroup; + // what's the sleected target? + // update the list.. + // if ftype is a dir == then toggle all the bellow. + + if (ftype == "dir") { + _this.files_tree_store.updateDir(fn, ((bool) val) ? false :true); + } + + // if ftype is a file .. see if all the files in that directory are check and check the dir. + + + if ((bool)val) { + // renive + cg.sources.remove(fn); + } else { + cg.sources.add(fn); + } + + }); + } + + // user defined functions + } + + + + + + + +} diff --git a/src/Builder4/WindowAddProp.bjs b/src/Builder4/WindowAddProp.bjs new file mode 100644 index 000000000..423580f26 --- /dev/null +++ b/src/Builder4/WindowAddProp.bjs @@ -0,0 +1,62 @@ +{ + "name" : "WindowAddProp", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/WindowAddProp.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "id" : "WindowAddProp", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n ", + "| void show" : "(Palete.Palete pal, string etype, string xtype) {\n this.model.el.clear();\n\n Gtk.TreeIter iter;\n var elementList = pal.getPropertiesFor( xtype,etype);\n \n \n //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);\n // console.dump(elementList);\n \n var miter = elementList.map_iterator();\n while (miter.next()) {\n var p = miter.get_value();\n \n this.model.el.append(out iter);\n\n this.model.el.set(iter,\n 0, p.name, \n 1, p.type,\n 2, \"\" + p.name +\" \"+p.type+\"\\n\" + \n GLib.Markup.escape_text(p.doctxt),\n 3, p.sig,\n 4, \"\" + p.name +\" \"+p.type+\"\",\n 5, etype,\n -1\n );\n }\n this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n", + "xtype" : "ScrolledWindow", + "@ void select" : "(string key, string type, string skel, string etype)", + "$ xns" : "Gtk", + "| void clear" : "() {\n this.model.el.clear();\n\n}", + "items" : [ + { + "listeners" : { + "row_activated" : "(path, column) => {\n\n Gtk.TreeIter iter;\n\n\n var m = _this.model;\n \n m.el.get_iter(out iter,path);\n \n \n // var val = \"\";\n \n \n var key = m.getValue(iter, 0);\n \n var type = m.getValue(iter, 1);\n var skel = m.getValue(iter, 3);\n var etype = m.getValue(iter, 5);\n \n \n _this.select(key,etype == \"signals\" ? \"\" : type,skel, etype);\n \n}\n " + }, + "* init" : "{ \n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.override_font(description); \n \n this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE);\n \n\n \n \n \n}\n", + "tooltip_column" : 2, + "xtype" : "TreeView", + "* pack" : "add", + "$ enable_tree_lines" : true, + "$ headers_visible" : true, + "$ xns" : "Gtk", + "items" : [ + { + "| string getValue" : "(Gtk.TreeIter iter, int col)\n{\n\n GLib.Value value;\n this.el.get_value(iter, col, out value);\n\n return (string)value;\n \n}", + "id" : "model", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string), // 0 real key\ntypeof(string), // 1 real type\ntypeof(string), // 2 docs ?\ntypeof(string), // 3 visable desc\ntypeof(string), // 4 function desc\ntypeof(string) // 5 element type (event|prop)\n ", + "n_columns" : 6, + "$ xns" : "Gtk" + }, + { + "id" : "namecol", + "utf8 title" : "Double click to add", + "* init" : " this.el.add_attribute(_this.namerender.el , \"markup\", 4 );\n \n", + "xtype" : "TreeViewColumn", + "* pack" : "append_column", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "namerender", + "* pack" : "pack_start,true", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/WindowAddProp.vala b/src/Builder4/WindowAddProp.vala new file mode 100644 index 000000000..2117db7cf --- /dev/null +++ b/src/Builder4/WindowAddProp.vala @@ -0,0 +1,235 @@ +static Xcls_WindowAddProp _WindowAddProp; + +public class Xcls_WindowAddProp : Object +{ + public Gtk.ScrolledWindow el; + private Xcls_WindowAddProp _this; + + public static Xcls_WindowAddProp singleton() + { + if (_WindowAddProp == null) { + _WindowAddProp= new Xcls_WindowAddProp(); + } + return _WindowAddProp; + } + public Xcls_model model; + public Xcls_namecol namecol; + public Xcls_namerender namerender; + + // my vars (def) + public signal void select (string key, string type, string skel, string etype); + + // ctor + public Xcls_WindowAddProp() + { + _this = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_TreeView2( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + public void show (Palete.Palete pal, string etype, string xtype) { + this.model.el.clear(); + + Gtk.TreeIter iter; + var elementList = pal.getPropertiesFor( xtype,etype); + + + //print ("GOT " + elementList.length + " items for " + fullpath + "|" + type); + // console.dump(elementList); + + var miter = elementList.map_iterator(); + while (miter.next()) { + var p = miter.get_value(); + + this.model.el.append(out iter); + + this.model.el.set(iter, + 0, p.name, + 1, p.type, + 2, "" + p.name +" "+p.type+"\n" + + GLib.Markup.escape_text(p.doctxt), + 3, p.sig, + 4, "" + p.name +" "+p.type+"", + 5, etype, + -1 + ); + } + this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + public void clear () { + this.model.el.clear(); + + } + public class Xcls_TreeView2 : Object + { + public Gtk.TreeView el; + private Xcls_WindowAddProp _this; + + + // my vars (def) + + // ctor + public Xcls_TreeView2(Xcls_WindowAddProp _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_column = 2; + this.el.enable_tree_lines = true; + this.el.headers_visible = true; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_namecol( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + { + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.override_font(description); + + this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE); + + + + + + } + + // listeners + this.el.row_activated.connect( (path, column) => { + + Gtk.TreeIter iter; + + + var m = _this.model; + + m.el.get_iter(out iter,path); + + + // var val = ""; + + + var key = m.getValue(iter, 0); + + var type = m.getValue(iter, 1); + var skel = m.getValue(iter, 3); + var etype = m.getValue(iter, 5); + + + _this.select(key,etype == "signals" ? "" : type,skel, etype); + + }); + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private Xcls_WindowAddProp _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_WindowAddProp _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 6, typeof(string), // 0 real key +typeof(string), // 1 real type +typeof(string), // 2 docs ? +typeof(string), // 3 visable desc +typeof(string), // 4 function desc +typeof(string) // 5 element type (event|prop) + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public string getValue (Gtk.TreeIter iter, int col) + { + + GLib.Value value; + this.el.get_value(iter, col, out value); + + return (string)value; + + } + } + public class Xcls_namecol : Object + { + public Gtk.TreeViewColumn el; + private Xcls_WindowAddProp _this; + + + // my vars (def) + + // ctor + public Xcls_namecol(Xcls_WindowAddProp _owner ) + { + _this = _owner; + _this.namecol = this; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Double click to add"; + var child_0 = new Xcls_namerender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + this.el.add_attribute(_this.namerender.el , "markup", 4 ); + } + + // user defined functions + } + public class Xcls_namerender : Object + { + public Gtk.CellRendererText el; + private Xcls_WindowAddProp _this; + + + // my vars (def) + + // ctor + public Xcls_namerender(Xcls_WindowAddProp _owner ) + { + _this = _owner; + _this.namerender = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } +} diff --git a/src/Builder4/WindowLeftProjects.bjs b/src/Builder4/WindowLeftProjects.bjs new file mode 100644 index 000000000..e7029aaa2 --- /dev/null +++ b/src/Builder4/WindowLeftProjects.bjs @@ -0,0 +1,78 @@ +{ + "name" : "WindowLeftProjects", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/WindowLeftProjects.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "listeners" : { + "show" : " ( ) => {\n this.load();\n}" + }, + "@ void project_selected" : "(Project.Project project)", + "id" : "WindowLeftProjects", + "| void load" : "() {\n // clear list...\n \n if (_this.is_loaded) {\n return;\n }\n _this.is_loading = true;\n \n _this.is_loaded = true;\n \n Project.Project.loadAll();\n var projects = Project.Project.allProjectsByName();\n \n Gtk.TreeIter iter;\n var m = this.model.el;\n m.clear();\n \n for (var i = 0; i < projects.size; i++) {\n m.append(out iter);\n m.set(iter, 0,projects.get(i).name );\n \n var o = GLib.Value(typeof(Object));\n o.set_object((Object)projects.get(i));\n \n m.set_value(iter, 1, o);\n \n }\n m.set_sort_column_id(0, Gtk.SortType.ASCENDING);\n _this.is_loading = false; \n}\n", + "# bool is_loaded" : false, + "* pack" : "add", + "xtype" : "Box", + "| Project.Project? getSelectedProject" : "() { \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n var s = this.view.el.get_selection();\n if (!s.get_selected(out mod, out iter)) {\n return null;\n }\n \n GLib.Value gval;\n\n mod.get_value(iter, 1 , out gval);\n var project = (Project.Project)gval.get_object();\n \n return project;\n}", + "| void selectProject" : "(Project.Project project) {\n \n var sel = _this.view.el.get_selection();\n \n sel.unselect_all();\n \n var found = false;\n _this.model.el.foreach((mod, path, iter) => {\n GLib.Value val;\n \n mod.get_value(iter, 1, out val);\n if ( ( (Project.Project)val.get_object()).fn != project.fn) {\n print(\"SKIP %s != %s\\n\", ((Project.Project)val.get_object()).name , project.name);\n return false;//continue\n }\n sel.select_iter(iter);\n this.project_selected(project);\n found = true;\n return true;\n \n \n });\n if (!found) {\n\t print(\"tried to select %s, could not find it\", project.name);\n }\n}\n", + "# bool is_loading" : false, + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "$ homogeneous" : false, + "@ void show_new_project" : "()", + "items" : [ + { + "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* pack" : "pack_end,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "cursor_changed" : " () => {\n if (_this.is_loading) {\n return;\n }\n \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n var s = this.el.get_selection();\n if (!s.get_selected(out mod, out iter)) {\n return;\n }\n \n GLib.Value gval;\n\n mod.get_value(iter, 1 , out gval);\n var project = (Project.Project)gval.get_object();\n \n _this.project_selected(project);\n \n} " + }, + "id" : "view", + "* init" : " var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.override_font(description); \n \n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n \n\n \n \n ", + "xtype" : "TreeView", + "* pack" : "add", + "$ enable_tree_lines" : true, + "$ headers_visible" : true, + "$ xns" : "Gtk", + "items" : [ + { + "id" : "model", + "* init" : "{\n this.el.set_sort_func(0, (mod,a,b) => {\n GLib.Value ga, gb;\n mod.get_value(a,0, out ga);\n mod.get_value(b,0, out gb);\n \n if ((string)ga == (string)gb) {\n return 0;\n }\n return (string)ga > (string)gb ? 1 : -1;\n }); \n\n\n}\n", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string), typeof(Object)", + "n_columns" : 2, + "$ xns" : "Gtk" + }, + { + "utf8 title" : "Projects", + "* init" : "\n this.el.add_attribute(_this.namecol.el , \"markup\", 0 );\n ", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "namecol", + "* pack" : "pack_start,true", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/WindowLeftProjects.vala b/src/Builder4/WindowLeftProjects.vala new file mode 100644 index 000000000..7d3e22c8b --- /dev/null +++ b/src/Builder4/WindowLeftProjects.vala @@ -0,0 +1,306 @@ +static Xcls_WindowLeftProjects _WindowLeftProjects; + +public class Xcls_WindowLeftProjects : Object +{ + public Gtk.Box el; + private Xcls_WindowLeftProjects _this; + + public static Xcls_WindowLeftProjects singleton() + { + if (_WindowLeftProjects == null) { + _WindowLeftProjects= new Xcls_WindowLeftProjects(); + } + return _WindowLeftProjects; + } + public Xcls_view view; + public Xcls_model model; + public Xcls_namecol namecol; + + // my vars (def) + public signal void project_selected (Project.Project project); + public bool is_loaded; + public bool is_loading; + public signal void show_new_project (); + + // ctor + public Xcls_WindowLeftProjects() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.is_loaded = false; + this.is_loading = false; + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_ScrolledWindow2( _this ); + child_0.ref(); + this.el.pack_end ( child_0.el , true,true,0 ); + + //listeners + this.el.show.connect( ( ) => { + this.load(); + }); + } + + // user defined functions + public void load () { + // clear list... + + if (_this.is_loaded) { + return; + } + _this.is_loading = true; + + _this.is_loaded = true; + + Project.Project.loadAll(); + var projects = Project.Project.allProjectsByName(); + + Gtk.TreeIter iter; + var m = this.model.el; + m.clear(); + + for (var i = 0; i < projects.size; i++) { + m.append(out iter); + m.set(iter, 0,projects.get(i).name ); + + var o = GLib.Value(typeof(Object)); + o.set_object((Object)projects.get(i)); + + m.set_value(iter, 1, o); + + } + m.set_sort_column_id(0, Gtk.SortType.ASCENDING); + _this.is_loading = false; + } + public Project.Project? getSelectedProject () { + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + var s = this.view.el.get_selection(); + if (!s.get_selected(out mod, out iter)) { + return null; + } + + GLib.Value gval; + + mod.get_value(iter, 1 , out gval); + var project = (Project.Project)gval.get_object(); + + return project; + } + public void selectProject (Project.Project project) { + + var sel = _this.view.el.get_selection(); + + sel.unselect_all(); + + var found = false; + _this.model.el.foreach((mod, path, iter) => { + GLib.Value val; + + mod.get_value(iter, 1, out val); + if ( ( (Project.Project)val.get_object()).fn != project.fn) { + print("SKIP %s != %s\n", ((Project.Project)val.get_object()).name , project.name); + return false;//continue + } + sel.select_iter(iter); + this.project_selected(project); + found = true; + return true; + + + }); + if (!found) { + print("tried to select %s, could not find it", project.name); + } + } + public class Xcls_ScrolledWindow2 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow2(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.TreeView el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_view(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.enable_tree_lines = true; + this.el.headers_visible = true; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn5( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.override_font(description); + + var selection = this.el.get_selection(); + selection.set_mode( Gtk.SelectionMode.SINGLE); + + //listeners + this.el.cursor_changed.connect( () => { + if (_this.is_loading) { + return; + } + + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + var s = this.el.get_selection(); + if (!s.get_selected(out mod, out iter)) { + return; + } + + GLib.Value gval; + + mod.get_value(iter, 1 , out gval); + var project = (Project.Project)gval.get_object(); + + _this.project_selected(project); + + }); + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 2, typeof(string), typeof(Object) ); + + // my vars (dec) + + // set gobject values + + // init method + + { + this.el.set_sort_func(0, (mod,a,b) => { + GLib.Value ga, gb; + mod.get_value(a,0, out ga); + mod.get_value(b,0, out gb); + + if ((string)ga == (string)gb) { + return 0; + } + return (string)ga > (string)gb ? 1 : -1; + }); + + + } + } + + // user defined functions + } + + public class Xcls_TreeViewColumn5 : Object + { + public Gtk.TreeViewColumn el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn5(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Projects"; + var child_0 = new Xcls_namecol( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + this.el.add_attribute(_this.namecol.el , "markup", 0 ); + } + + // user defined functions + } + public class Xcls_namecol : Object + { + public Gtk.CellRendererText el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_namecol(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + _this.namecol = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + +} diff --git a/src/Builder4/WindowLeftProps.bjs b/src/Builder4/WindowLeftProps.bjs new file mode 100644 index 000000000..cbe08fc6c --- /dev/null +++ b/src/Builder4/WindowLeftProps.bjs @@ -0,0 +1,367 @@ +{ + "name" : "WindowLeftProps", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/WindowLeftProps.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "# bool allow_edit" : false, + "| void updateKey" : "(string oldkey, string type, string key ) {\n\n \n\t\n\t_this.model.el.foreach((mod, path, iter) => {\n\t\t \n \n \t \n \n\t\t GLib.Value gvaltype, gval,kvalue;\n\t\t mod.get_value(iter, 1 , out gval); // one is key..\n\t\t\n\t mod.get_value(iter,0, out gvaltype);\n\t \n \t mod.get_value(iter,3, out kvalue);\n\t \n\t if (oldkey == ((string)gval) && type == ((string)gvaltype)) {\n\t \n\t\t \t //print(\"update iter type=%s, key=%s value=%s\\n\", type, key,(string) kvalue);\n\t \n \t \t this.updateIter(iter, type, key, (string)kvalue);\n \t \t return true;\n\t \t }\n\t \n\n\t\treturn false;\n\t});\n\t\n\tthis.changed();\n\n\n}\n", + "id" : "LeftProps", + "| void before_edit" : "()\n{\n\n print(\"before edit - stop editing\\n\");\n \n // these do not appear to trigger save...\n _this.keyrender.el.stop_editing(false);\n _this.keyrender.el.editable =false;\n\n _this.valrender.el.stop_editing(false);\n _this.valrender.el.editable =false; \n \n \n// technicall stop the popup editor..\n\n}\n", + "| string keySortFormat" : "(string key) {\n // listeners first - with 0\n // specials\n if (key[0] == '*') {\n return \"1 \" + key;\n }\n // functions\n \n var bits = key.split(\" \");\n \n if (key[0] == '|') {\n return \"2 \" + bits[bits.length -1];\n }\n // signals\n if (key[0] == '@') {\n return \"3 \" + bits[bits.length -1];\n }\n \n // props\n if (key[0] == '#') {\n return \"4 \" + bits[bits.length -1];\n }\n // the rest..\n return \"5 \" + bits[bits.length -1]; \n\n\n\n}", + "| void finish_editing" : "() {\n // \n this.before_edit();\n}", + "| bool startEditingValue" : "( Gtk.TreePath path) {\n\n // ONLY return true if editing is allowed - eg. combo..\n\n print(\"start editing?\\n\");\n if (!this.stop_editor()) {\n print(\"stop editor failed\\n\");\n return false;\n }\n \n Gtk.TreeIter iter;\n\n var mod = this.model.el;\n mod.get_iter (out iter, path);\n \n /*\n m.set(iter, \n 0, \"listener\",\n 1, miter.get_key(),\n 2, \"\" + miter.get_key() + \"\",\n 3, miter.get_value()\n ); \n \n */\n GLib.Value gval;\n mod.get_value(iter, 3 , out gval);\n var val = (string)gval;\n\n mod.get_value(iter, 1 , out gval);\n var key = (string)gval;\n \n \n string kname, kflag, ktype;\n this.node.normalize_key(key, out kname, out kflag, out ktype);\n \n \n mod.get_value(iter, 0 , out gval);\n var type = (string)gval; // listerner or prop..\n \n \n \n var use_textarea = false;\n\n //------------ things that require the text editor...\n \n if (type == \"listener\") {\n use_textarea = true;\n }\n if (key.length > 0 && key[0] == '|') { // user defined method\n use_textarea = true;\n }\n if (key.length > 0 && key[0] == '$') { // raw string\n use_textarea = true;\n }\n if (key.length > 0 && key == \"* init\") {\n use_textarea = true;\n }\n if (val.length > 40) { // long value...\n use_textarea = true;\n }\n \n \n \n if (use_textarea) {\n print(\"Call show editor\\n\");\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n this.view.el.get_selection().select_path(path);\n \n this.show_editor(file, node, type, key);\n \n return false;\n });\n \n \n return false;\n }\n \n var pal = Palete.factory(this.file.project.xtype);\n \n string[] opts;\n var has_opts = pal.typeOptions(this.node.fqn(), kname, ktype, out opts);\n \n \n \n // others... - fill in options for true/false?\n print(\"turn on editing %s \\n\" , mod.get_path(iter).to_string());\n \n print (ktype.up());\n if (has_opts) {\n print(\"start editing try/false)???\");\n this.valrender.el.has_entry = false;\n \n this.valrender.setOptions(opts);\n \n this.valrender.el.has_entry = false;\n this.valrender.el.editable = true;\n this.allow_edit = true;\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n this.view.el.set_cursor_on_cell(\n path,\n this.valcol.el,\n this.valrender.el,\n true\n );\n return false;\n });\n return true;\n }\n \n // see if type is a Enum.\n \n \n \n \n \n opts = { };\n this.valrender.setOptions(opts);\n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n \n // at this point - work out the type...\n // if its' a combo... then show the options..\n this.valrender.el.has_entry = true;\n \n this.valrender.el.editable = true; \n \n \n this.allow_edit = true;\n \n \n \n \n\n this.view.el.set_cursor_on_cell(\n path,\n this.valcol.el,\n this.valrender.el,\n true\n );\n return false;\n });\n return false;\n}\n", + "| void load" : "(JsRender.JsRender file, JsRender.Node? node) \n{\n print(\"load leftprops\\n\");\n this.before_edit();\n this.node = node;\n this.file = file;\n \n \n this.model.el.clear();\n \n //this.get('/RightEditor').el.hide();\n if (node ==null) {\n return ;\n }\n \n \n\n //var provider = this.get('/LeftTree').getPaleteProvider();\n Gtk.TreeIter iter;\n \n //typeof(string), // 0 key type\n //typeof(string), // 1 key\n //typeof(string), // 2 key (display)\n //typeof(string), // 3 value\n //typeof(string), // 4 value (display)\n //typeof(string), // 5 both (tooltip)\n \n \n \n \n // really need a way to sort the hashmap...\n var m = this.model.el;\n \n var miter = node.listeners.map_iterator();\n var i = 0;\n \n while(miter.next()) {\n i++;\n m.append(out iter,null);\n \n this.updateIter(iter, \"listener\", miter.get_key(), miter.get_value());\n \n \n }\n \n \n miter = node.props.map_iterator();\n \n \n while(miter.next()) {\n i++;\n m.append(out iter,null);\n this.updateIter(iter, \"prop\", miter.get_key(), miter.get_value());\n \n }\n print(\"clear selection\\n\");\n // clear selection?\n this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key..\n \n this.view.el.get_selection().unselect_all();\n \n var pane = _this.main_window.editpane.el;\n var try_size = (i * 25) + 60; // est. 20px per line + 40px header\n \n // max 80%...\n pane.set_position( \n ((try_size * 1.0f) / (pane.max_position * 1.0f)) > 0.8f ? \n (int) (pane.max_position * 0.2f) :\n pane.max_position-try_size);\n \n \n}\n", + "xtype" : "Box", + "| string keyFormat" : "(string val, string type) {\n \n // Glib.markup_escape_text(val);\n\n if (type == \"listener\") {\n return \"\" + \n GLib.Markup.escape_text(val) +\n \"\";\n }\n // property..\n if (val.length < 1) {\n return \"--empty--\";\n }\n \n //@ = signal\n //$ = property with \n //# - object properties\n //* = special\n // all of these... - display value is last element..\n var ar = val.strip().split(\" \");\n \n \n var dval = GLib.Markup.escape_text(ar[ar.length-1]);\n \n \n \n \n switch(val[0]) {\n case '@': // signal // just bold balck?\n if (dval[0] == '@') {\n dval = dval.substring(1);\n }\n \n return @\"@ $dval\"; \n case '#': // object properties?\n if (dval[0] == '#') {\n dval = dval.substring(1);\n }\n return @\"$dval\";\n case '*': // special\n if (dval[0] == '*') {\n dval = dval.substring(1);\n }\n return @\"$dval\"; \n case '$':\n if (dval[0] == '$') {\n dval = dval.substring(1);\n }\n return @\"$dval\";\n case '|': // user defined methods\n if (dval[0] == '|') {\n dval = dval.substring(1);\n }\n return @\"$dval\";\n \n \n \n default:\n return dval;\n }\n \n \n\n}", + "# JsRender.JsRender file" : "", + "@ bool stop_editor" : "()", + "@ void show_editor" : "(JsRender.JsRender file, JsRender.Node node, string type, string key)", + "@ void changed" : "()", + "| void deleteSelected" : " () {\n \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n var s = this.view.el.get_selection();\n s.get_selected(out mod, out iter);\n \n \n GLib.Value gval;\n mod.get_value(iter, 0 , out gval);\n var type = (string)gval;\n \n mod.get_value(iter, 1 , out gval);\n var key = (string)gval;\n \n switch(type) {\n case \"listener\":\n this.node.listeners.unset(key);\n break;\n \n case \"props\":\n this.node.props.unset(key);\n break;\n }\n this.load(this.file, this.node);\n \n _this.changed();\n}", + "$ xns" : "Gtk", + "| void startEditingKey" : "( Gtk.TreePath path) {\n \n if (!this.stop_editor()) {\n return;\n }\n \n // others... - fill in options for true/false?\n \n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n this.allow_edit = true;\n this.keyrender.el.editable = true;\n \n this.view.el.set_cursor_on_cell(\n path,\n this.keycol.el,\n this.keyrender.el,\n true\n );\n \n return false;\n });\n \n \n}\n", + "@ void show_add_props" : "(string type)", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "$ homogeneous" : "false ", + "# Xcls_MainWindow main_window" : "null", + "| void addProp" : " (string in_type, string key, string value, string value_type) {\n // info includes key, val, skel, etype..\n //console.dump(info);\n //type = info.type.toLowerCase();\n //var data = this.toJS();\n \n var type = in_type == \"signals\" ? \"listener\" : in_type;\n \n var fkey = (value_type.length > 0 ? value_type + \" \" : \"\") + key;\n \n if (type == \"listener\") {\n if (this.node.listeners.has_key(key)) {\n return;\n }\n this.node.listeners.set(key,value);\n } else {\n \n if (this.node.props.has_key(fkey)) {\n return;\n }\n this.node.props.set(fkey,value);\n }\n \n \n // add a row???\n this.load(this.file, this.node);\n \n \n \n /// need to find the row which I've just added..\n \n \n var s = this.view.el.get_selection();\n s.unselect_all();\n \n print(\"trying to find new iter\");\n \n this.model.el.foreach((model, path, iter) => {\n GLib.Value gval;\n \n this.model.el.get_value(iter, 0 , out gval);\n if ((string)gval != type) {\n print(\"not type: %s = %s\\n\", (string)gval , type);\n return false;\n }\n this.model.el.get_value(iter, 1 , out gval);\n if ((string)gval != fkey) {\n print(\"not key: %s = %s\\n\", (string)gval , fkey);\n return false;\n }\n // delay this?\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {\n \n this.startEditingValue(this.model.el.get_path(iter));\n return false;\n });\n //s.select_iter(iter);\n return true; \n });\n \n \n \n \n}\n", + "| void updateIter" : "(Gtk.TreeIter iter, string type, string key, string kvalue) {\n\n //print(\"update Iter %s, %s\\n\", key,kvalue);\n //typeof(string), // 0 key type\n //typeof(string), // 1 key\n //typeof(string), // 2 key (display)\n //typeof(string), // 3 value\n //typeof(string), // 4 value (display)\n //typeof(string), // 5 both (tooltip)\n //typeof(string), // 6 key (sort)\n \n var dl = kvalue.strip().split(\"\\n\");\n\n var dis_val = dl.length > 1 ? (dl[0].strip()+ \"...\") : dl[0];\n \n if (type == \"listener\") {\n \n \n \n this.model.el.set(iter, \n 0, type,\n 1, key,\n 2, this.keyFormat(key ,type),\n 3, kvalue,\n 4, dis_val,\n 5, \"\" + GLib.Markup.escape_text(key + \" \" +kvalue) + \"\",\n 6, \"0 \" + key\n ); \n return;\n }\n \n\n\n this.model.el.set(iter, \n 0, \"props\",\n 1, key,\n 2, this.keyFormat(key , \"prop\"),\n 3, kvalue,\n 4, dis_val,\n 5, \"\" + GLib.Markup.escape_text(key + \" \" + kvalue) + \"\",\n 6, this.keySortFormat(key)\n ); \n}", + "# JsRender.Node node" : "", + "items" : [ + { + "* pack" : "pack_start,false,true,0", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "listeners" : { + "button_press_event" : " (self, ev) => {\n _this.before_edit();\n \n \n var p = _this.AddPropertyPopup;\n p.el.set_screen(Gdk.Screen.get_default());\n p.el.show_all();\n p.el.popup(null, null, null, ev.button, ev.time);\n return true;\n}" + }, + "bool hexpand" : true, + "xtype" : "Button", + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "add", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "items" : [ + { + "$ Gtk.Stock stock" : "Gtk.Stock.ADD", + "* pack" : "add", + "xtype" : "Image", + "$ xns" : "Gtk", + "$ icon_size" : "Gtk.IconSize.MENU" + }, + { + "label" : "Other", + "xtype" : "Label", + "* pack" : "add", + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "AddPropertyPopup", + "xtype" : "Menu", + "* pack" : false, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : " () => {\n _this.addProp( \"prop\", \"id\", \"\", \"\");\n}" + }, + "label" : "id: _this.{ID} (Vala)", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "Using _this.{ID} will map to this element", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) => {\n\n _this.addProp( \"prop\", \"pack\",\"add\", \"*\");\n}" + }, + "label" : "pack: Pack method (Vala)", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) => {\n\n _this.addProp( \"prop\", \"ctor\",\"\", \"*\");\n}" + }, + "label" : "ctor: Alterative to default contructor (Vala)", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "eg. \n\nnew Clutter.Image.from_file(.....)", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) => {\n\n _this.addProp( \"prop\", \"init\", \"{\\n\\n}\\n\", \"*\" );\n}" + }, + "label" : "init: initialziation code (vala)", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "This code is called after the ctor", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " () => {\n _this.addProp( \"prop\", \"cms-id\", \"\", \"string\");\n}" + }, + "label" : "cms-id: (Roo JS/Pman library)", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})\n", + "$ xns" : "Gtk" + }, + { + "* pack" : "add", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " (self) => {\n\n _this.addProp( \"prop\", \"XXXX\", \"\",\"string\");\n\n}" + }, + "label" : "String", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "Add a user defined string property", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"XXX\", \"0\", \"int\");\n}" + }, + "label" : "Number", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "Add a user defined number property", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp( \"prop\", \"XXX\", \"true\", \"bool\");\n}" + }, + "label" : "Boolean", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "Add a user defined boolean property", + "$ xns" : "Gtk" + }, + { + "* pack" : "add", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"XXXX\", \"function() { }\", \"| function\");\n}" + }, + "label" : "Javascript Function", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "Add a user function boolean property", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp( \"prop\", \"XXXX\", \"() {\\n\\n}\\n\", \"| return_type\");\n}" + }, + "label" : "Vala Method", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "Add a user function boolean property", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp( \"prop\", \"XXXX\", \"()\", \"@ void\");\n}" + }, + "label" : "Vala Signal", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "Add a vala signal", + "$ xns" : "Gtk" + }, + { + "* pack" : "add", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"flexy:if\", \"value_or_condition\", \"string\");\n}" + }, + "label" : "Flexy - If", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "Add a flexy if (for HTML templates)", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"flexy:include\", \"name_of_file.html\", \"string\");\n}" + }, + "label" : "Flexy - Include", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "Add a flexy include (for HTML templates)", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"flexy:foreach\", \"array,key,value\", \"string\");\n}" + }, + "label" : "Flexy - Foreach", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "Add a flexy foreach (for HTML templates)", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "# bool editing" : false, + "id" : "EditProps", + "* init" : " {\n \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* pack" : "pack_end,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_press_event" : " ( ev) => {\n \n Gtk.TreeViewColumn col;\n int cell_x;\n int cell_y;\n Gtk.TreePath path;\n if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {\n print(\"nothing selected on click\");\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n this.el.get_selection().unselect_all();\n\n return false;\n });\n _this.before_edit();\n return false; //not on a element.\n }\n \n \n // double click on name..\n if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == \"Name\") { \n // show popup!. \n \n if (this.popover == null) {\n \t\t this.popover = new Xcls_PopoverProperty();\n \t\t this.popover.mainwindow = _this.main_window;\n \t\t}\n \t\t\n \n _this.before_edit();\n _this.stop_editor();\n\t\t \n _this.keyrender.el.stop_editing(false);\n _this.keyrender.el.editable =false;\n \n _this.valrender.el.stop_editing(false);\n _this.valrender.el.editable =false;\n Gtk.TreeIter iter;\n var mod = this.el.get_model();\n\t\t mod.get_iter (out iter, path);\n\t\t \n \n\t\tGLib.Value gvaltype, gval;\n\t\tmod.get_value(iter, 1 , out gval); // one is key..\n\t\t\n\t mod.get_value(iter,0, out gvaltype);\n\n this.popover.show(this.el, _this.node, (string)gvaltype, (string)gval);\n \n // _this.startEditingKey(path); \n \n return false;\n }\n \n \n \n \n // right click.\n if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) { \n // show popup!. \n //if (col.title == \"Value\") {\n // _this.before_edit();\n // return false;\n //}\n\n var p = _this.ContextMenu;\n\n p.el.set_screen(Gdk.Screen.get_default());\n p.el.show_all();\n p.el.popup(null, null, null, ev.button, ev.time);\n //Seed.print(\"click:\" + res.column.title);\n // select the \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n \n this.el.get_selection().select_path(path);\n return false;\n });\n _this.before_edit();\n return false;\n }\n \n \n if (col.title != \"Value\") {\n print(\"col title != Value\");\n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n this.el.get_selection().select_path(path);\n return false;\n });\n \n _this.before_edit();\n // XObject.error(\"column is not value?\");\n return false; // ignore.. - key click.. ??? should we do this??\n }\n \n \n // if the cell can be edited with a pulldown\n // then we should return true... - and let the start_editing handle it?\n \n \n \n \n \n \n // _this.before_edit(); <<< we really need to stop the other editor..\n _this.keyrender.el.stop_editing(false);\n _this.keyrender.el.editable =false;\n \n \n return _this.startEditingValue(path); // assumes selected row..\n \n \n\n \n \n}" + }, + "id" : "view", + "* init" : "{\n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n\n\n var description = new Pango.FontDescription();\n description.set_size(10000);\n this.el.override_font(description);\n}\n", + "tooltip_column" : 5, + "xtype" : "TreeView", + "$ enable_tree_lines" : true, + "$ headers_visible" : true, + "* pack" : "add", + "$ xns" : "Gtk", + "Xcls_PopoverProperty popover" : "null", + "items" : [ + { + "id" : "model", + "$ changed" : "function(str, doRefresh) {\n if (!this.activePath) {\n return;\n }\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));\n \n this.el.set_value(iter, 1, '' +str);\n this.el.set_value(iter, 3, '' + this.toShort(str));\n var type = this.getIterValue(iter, 4);\n\n this.el.set_value(iter, 5, type + ' : ' + str);\n // update the tree... \n\n this.get('/LeftTree.model').changed(this.toJS(), doRefresh); \n}\n", + "* pack" : "set_model", + "xtype" : "TreeStore", + "$ columns" : " typeof(string), // 0 key type\n typeof(string), // 1 key\n typeof(string), // 2 key (display)\n typeof(string), // 3 value\n typeof(string), // 4 value (display)\n typeof(string), // 5 both (tooltip) \n typeof(string) // 6 key (for sorting)\n", + "n_columns" : 7, + "$ xns" : "Gtk", + "$ toShort" : "function(str) {\n var a = typeof(str) == 'string' ? str.split(\"\\n\") : [];\n return a.length > 1 ? a[0] + '....' : '' + str;\n}\n" + }, + { + "id" : "keycol", + "* init" : " this.el.add_attribute(_this.keyrender.el , \"markup\", 2 );\n this.el.add_attribute(_this.keyrender.el , \"text\", 1 );\n ", + "title" : "Name", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "$ resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "editing_started" : "( editable, path) => {\n\n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n\n\n // this.get('/LeftPanel.model').activePath = path;\n _this.model.el.get_value(iter,1, out gval);\n var val = (string)gval;\n \n ((Gtk.Entry)editable).set_text(val); \n}", + "edited" : " (path, newtext) => {\n print(\"Keyrender - signal:edited\\n\");\n \n this.el.editable = false;\n \n \n\n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n _this.model.el.get_value(iter,1, out gval);\n var oldval = (string)gval;\n \n _this.model.el.get_value(iter,0, out gval);\n var ktype = (string)gval;\n \n _this.model.el.set_value(iter, 1, newtext);\n \n if (oldval == newtext) {\n return;\n }\n \n \n print(\"ktype: %s\\n\",ktype);\n switch(ktype) {\n case \"listener\":\n var ov = _this.node.listeners.get(oldval);\n _this.node.listeners.set(newtext, ov);\n _this.node.listeners.unset(oldval);\n \n _this.updateIter(iter, ktype, newtext, ov);\n \n break;\n case \"props\":\n var ov = _this.node.props.get(oldval);\n _this.node.props.set(newtext, ov);\n _this.node.props.unset(oldval);\n _this.updateIter(iter, ktype, newtext, ov);\n break;\n }\n _this.changed();\n \n}" + }, + "id" : "keyrender", + "* pack" : "pack_start,false", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "valcol", + "* init" : "{\n\t\n\t// typeof(string), // 0 key type\n // typeof(string), // 1 key\n // typeof(string), // 2 key (display)\n // typeof(string), // 3 value\n // typeof(string) // 4 value (display)\n\n\t\n\tthis.el.add_attribute(_this.valrender.el , \"text\", 4 );\n\t//this.el.add_attribute(_this.valrender.el , \"sensitive\", 4 );\n\t//this.el.add_attribute(this.items[0].el , 'editable', 3 );\n // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);\n\n //\tthis.get('/LeftPanel').editableColumn= this;\n}\n", + "* pack" : "append_column", + "title" : "Value", + "xtype" : "TreeViewColumn", + "$ resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "editing_started" : "( editable, path) => {\n //_this.editing = true;\n print(\"editing started called\\n\");\n if (!_this.allow_edit) {\n \n print(\"val - editing_Started\\n\");\n this.el.editable = false; // make sure it's not editor...\n \n \n return;\n }\n _this.allow_edit =false;\n \n \n if ( this.el.has_entry ) {\n \n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n\n \n // this.get('/LeftPanel.model').activePath = path;\n _this.model.el.get_value(iter,3, out gval);\n \n\n var val = (string)gval;\n var combo = (Gtk.ComboBox)editable;\n\n var entry = (Gtk.Entry) combo.get_child(); \n entry.set_text(val);\n }\n \n}", + "edited" : " (path, newtext) => {\n print(\"Valrender - signal:edited\\n\");\n \n this.el.editable = false;\n/* \n m.set(iter, \n 0, \"listener\",\n 1, miter.get_key(),\n 2, \"\" + miter.get_key() + \"\",\n 3, miter.get_value(),\n 4, display_value(short);\n ); \n\n */ \n\n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n _this.model.el.get_value(iter,0, out gval);\n var ktype = (string)gval;\n \n \n _this.model.el.get_value(iter,3, out gval);\n var oldval = (string)gval;\n \n _this.model.el.get_value(iter,1, out gval);\n var key = (string)gval;\n \n \n \n switch(ktype) {\n case \"listener\":\n _this.node.listeners.set(key, newtext);\n _this.updateIter(iter,ktype,key,newtext);\n break;\n case \"props\":\n _this.node.props.set(key,newtext);\n _this.updateIter(iter,ktype, key,newtext); \n break;\n }\n// _this.load(_this.file,_this.node);\n _this.changed();\n \n}" + }, + "id" : "valrender", + "xtype" : "CellRendererCombo", + "* pack" : "pack_start,true", + "$ editable" : false, + "$ has_entry" : true, + "$ xns" : "Gtk", + "| void setOptions" : "(string[] ar) {\n var m = _this.valrendermodel.el;\n m.clear();\n Gtk.TreeIter iret;\n for (var i =0; i < ar.length; i++) {\n m.append(out iret);\n m.set_value(iret, 0, ar[i]);\n }\n\n}", + "text_column" : 0, + "items" : [ + { + "id" : "valrendermodel", + "xtype" : "ListStore", + "* pack" : false, + "$ columns" : "typeof(string)", + "n_columns" : 1, + "$ xns" : "Gtk", + "* prop" : "model" + } + ] + } + ] + }, + { + "id" : "ContextMenu", + "* pack" : false, + "xtype" : "Menu", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : " ( ) =>{\n \n var s = _this.view.el.get_selection();\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n s.get_selected (out mod, out iter);\n \n if (_this.view.popover == null) {\n \t\t _this.view.popover = new Xcls_PopoverProperty();\n \t\t _this.view.popover.mainwindow = _this.main_window;\n \t\t}\n \t\t\n \n _this.before_edit();\n _this.stop_editor();\n\t \n _this.keyrender.el.stop_editing(false);\n _this.keyrender.el.editable =false;\n\n _this.valrender.el.stop_editing(false);\n _this.valrender.el.editable =false;\n \n \n\tGLib.Value gvaltype, gval;\n\tmod.get_value(iter, 1 , out gval); // one is key..\n\t\n mod.get_value(iter,0, out gvaltype);\n\n\t_this.view.popover.show(_this.view.el, _this.node, (string)gvaltype, (string)gval);\n \n \n \n // _this.startEditingKey(model.get_path(iter));\n}" + }, + "label" : "Edit (double click)", + "* pack" : "append", + "xtype" : "MenuItem", + "$ xns" : "Gtk" + }, + { + "* pack" : "append", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\t_this.deleteSelected();\n}" + }, + "label" : "Delete", + "* pack" : "append", + "xtype" : "MenuItem", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/WindowLeftProps.vala b/src/Builder4/WindowLeftProps.vala new file mode 100644 index 000000000..6e585e48f --- /dev/null +++ b/src/Builder4/WindowLeftProps.vala @@ -0,0 +1,1956 @@ +static Xcls_LeftProps _LeftProps; + +public class Xcls_LeftProps : Object +{ + public Gtk.Box el; + private Xcls_LeftProps _this; + + public static Xcls_LeftProps singleton() + { + if (_LeftProps == null) { + _LeftProps= new Xcls_LeftProps(); + } + return _LeftProps; + } + public Xcls_AddPropertyPopup AddPropertyPopup; + public Xcls_EditProps EditProps; + public Xcls_view view; + public Xcls_model model; + public Xcls_keycol keycol; + public Xcls_keyrender keyrender; + public Xcls_valcol valcol; + public Xcls_valrender valrender; + public Xcls_valrendermodel valrendermodel; + public Xcls_ContextMenu ContextMenu; + + // my vars (def) + public bool allow_edit; + public JsRender.JsRender file; + public signal bool stop_editor (); + public signal void show_editor (JsRender.JsRender file, JsRender.Node node, string type, string key); + public signal void changed (); + public signal void show_add_props (string type); + public Xcls_MainWindow main_window; + public JsRender.Node node; + + // ctor + public Xcls_LeftProps() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.allow_edit = false; + this.main_window = null; + + // set gobject values + this.el.homogeneous = false ; + var child_0 = new Xcls_Box2( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,0 ); + var child_1 = new Xcls_EditProps( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,0 ); + } + + // user defined functions + public void updateKey (string oldkey, string type, string key ) { + + + + _this.model.el.foreach((mod, path, iter) => { + + + + + GLib.Value gvaltype, gval,kvalue; + mod.get_value(iter, 1 , out gval); // one is key.. + + mod.get_value(iter,0, out gvaltype); + + mod.get_value(iter,3, out kvalue); + + if (oldkey == ((string)gval) && type == ((string)gvaltype)) { + + //print("update iter type=%s, key=%s value=%s\n", type, key,(string) kvalue); + + this.updateIter(iter, type, key, (string)kvalue); + return true; + } + + + return false; + }); + + this.changed(); + + + } + public void before_edit () + { + + print("before edit - stop editing\n"); + + // these do not appear to trigger save... + _this.keyrender.el.stop_editing(false); + _this.keyrender.el.editable =false; + + _this.valrender.el.stop_editing(false); + _this.valrender.el.editable =false; + + + // technicall stop the popup editor.. + + } + public string keySortFormat (string key) { + // listeners first - with 0 + // specials + if (key[0] == '*') { + return "1 " + key; + } + // functions + + var bits = key.split(" "); + + if (key[0] == '|') { + return "2 " + bits[bits.length -1]; + } + // signals + if (key[0] == '@') { + return "3 " + bits[bits.length -1]; + } + + // props + if (key[0] == '#') { + return "4 " + bits[bits.length -1]; + } + // the rest.. + return "5 " + bits[bits.length -1]; + + + + } + public void finish_editing () { + // + this.before_edit(); + } + public bool startEditingValue ( Gtk.TreePath path) { + + // ONLY return true if editing is allowed - eg. combo.. + + print("start editing?\n"); + if (!this.stop_editor()) { + print("stop editor failed\n"); + return false; + } + + Gtk.TreeIter iter; + + var mod = this.model.el; + mod.get_iter (out iter, path); + + /* + m.set(iter, + 0, "listener", + 1, miter.get_key(), + 2, "" + miter.get_key() + "", + 3, miter.get_value() + ); + + */ + GLib.Value gval; + mod.get_value(iter, 3 , out gval); + var val = (string)gval; + + mod.get_value(iter, 1 , out gval); + var key = (string)gval; + + + string kname, kflag, ktype; + this.node.normalize_key(key, out kname, out kflag, out ktype); + + + mod.get_value(iter, 0 , out gval); + var type = (string)gval; // listerner or prop.. + + + + var use_textarea = false; + + //------------ things that require the text editor... + + if (type == "listener") { + use_textarea = true; + } + if (key.length > 0 && key[0] == '|') { // user defined method + use_textarea = true; + } + if (key.length > 0 && key[0] == '$') { // raw string + use_textarea = true; + } + if (key.length > 0 && key == "* init") { + use_textarea = true; + } + if (val.length > 40) { // long value... + use_textarea = true; + } + + + + if (use_textarea) { + print("Call show editor\n"); + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + this.view.el.get_selection().select_path(path); + + this.show_editor(file, node, type, key); + + return false; + }); + + + return false; + } + + var pal = Palete.factory(this.file.project.xtype); + + string[] opts; + var has_opts = pal.typeOptions(this.node.fqn(), kname, ktype, out opts); + + + + // others... - fill in options for true/false? + print("turn on editing %s \n" , mod.get_path(iter).to_string()); + + print (ktype.up()); + if (has_opts) { + print("start editing try/false)???"); + this.valrender.el.has_entry = false; + + this.valrender.setOptions(opts); + + this.valrender.el.has_entry = false; + this.valrender.el.editable = true; + this.allow_edit = true; + GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { + this.view.el.set_cursor_on_cell( + path, + this.valcol.el, + this.valrender.el, + true + ); + return false; + }); + return true; + } + + // see if type is a Enum. + + + + + + opts = { }; + this.valrender.setOptions(opts); + + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + + // at this point - work out the type... + // if its' a combo... then show the options.. + this.valrender.el.has_entry = true; + + this.valrender.el.editable = true; + + + this.allow_edit = true; + + + + + + this.view.el.set_cursor_on_cell( + path, + this.valcol.el, + this.valrender.el, + true + ); + return false; + }); + return false; + } + public void load (JsRender.JsRender file, JsRender.Node? node) + { + print("load leftprops\n"); + this.before_edit(); + this.node = node; + this.file = file; + + + this.model.el.clear(); + + //this.get('/RightEditor').el.hide(); + if (node ==null) { + return ; + } + + + + //var provider = this.get('/LeftTree').getPaleteProvider(); + Gtk.TreeIter iter; + + //typeof(string), // 0 key type + //typeof(string), // 1 key + //typeof(string), // 2 key (display) + //typeof(string), // 3 value + //typeof(string), // 4 value (display) + //typeof(string), // 5 both (tooltip) + + + + + // really need a way to sort the hashmap... + var m = this.model.el; + + var miter = node.listeners.map_iterator(); + var i = 0; + + while(miter.next()) { + i++; + m.append(out iter,null); + + this.updateIter(iter, "listener", miter.get_key(), miter.get_value()); + + + } + + + miter = node.props.map_iterator(); + + + while(miter.next()) { + i++; + m.append(out iter,null); + this.updateIter(iter, "prop", miter.get_key(), miter.get_value()); + + } + print("clear selection\n"); + // clear selection? + this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key.. + + this.view.el.get_selection().unselect_all(); + + var pane = _this.main_window.editpane.el; + var try_size = (i * 25) + 60; // est. 20px per line + 40px header + + // max 80%... + pane.set_position( + ((try_size * 1.0f) / (pane.max_position * 1.0f)) > 0.8f ? + (int) (pane.max_position * 0.2f) : + pane.max_position-try_size); + + + } + public string keyFormat (string val, string type) { + + // Glib.markup_escape_text(val); + + if (type == "listener") { + return "" + + GLib.Markup.escape_text(val) + + ""; + } + // property.. + if (val.length < 1) { + return "--empty--"; + } + + //@ = signal + //$ = property with + //# - object properties + //* = special + // all of these... - display value is last element.. + var ar = val.strip().split(" "); + + + var dval = GLib.Markup.escape_text(ar[ar.length-1]); + + + + + switch(val[0]) { + case '@': // signal // just bold balck? + if (dval[0] == '@') { + dval = dval.substring(1); + } + + return @"@ $dval"; + case '#': // object properties? + if (dval[0] == '#') { + dval = dval.substring(1); + } + return @"$dval"; + case '*': // special + if (dval[0] == '*') { + dval = dval.substring(1); + } + return @"$dval"; + case '$': + if (dval[0] == '$') { + dval = dval.substring(1); + } + return @"$dval"; + case '|': // user defined methods + if (dval[0] == '|') { + dval = dval.substring(1); + } + return @"$dval"; + + + + default: + return dval; + } + + + + } + public void deleteSelected () { + + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + var s = this.view.el.get_selection(); + s.get_selected(out mod, out iter); + + + GLib.Value gval; + mod.get_value(iter, 0 , out gval); + var type = (string)gval; + + mod.get_value(iter, 1 , out gval); + var key = (string)gval; + + switch(type) { + case "listener": + this.node.listeners.unset(key); + break; + + case "props": + this.node.props.unset(key); + break; + } + this.load(this.file, this.node); + + _this.changed(); + } + public void startEditingKey ( Gtk.TreePath path) { + + if (!this.stop_editor()) { + return; + } + + // others... - fill in options for true/false? + + + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + this.allow_edit = true; + this.keyrender.el.editable = true; + + this.view.el.set_cursor_on_cell( + path, + this.keycol.el, + this.keyrender.el, + true + ); + + return false; + }); + + + } + public void addProp (string in_type, string key, string value, string value_type) { + // info includes key, val, skel, etype.. + //console.dump(info); + //type = info.type.toLowerCase(); + //var data = this.toJS(); + + var type = in_type == "signals" ? "listener" : in_type; + + var fkey = (value_type.length > 0 ? value_type + " " : "") + key; + + if (type == "listener") { + if (this.node.listeners.has_key(key)) { + return; + } + this.node.listeners.set(key,value); + } else { + + if (this.node.props.has_key(fkey)) { + return; + } + this.node.props.set(fkey,value); + } + + + // add a row??? + this.load(this.file, this.node); + + + + /// need to find the row which I've just added.. + + + var s = this.view.el.get_selection(); + s.unselect_all(); + + print("trying to find new iter"); + + this.model.el.foreach((model, path, iter) => { + GLib.Value gval; + + this.model.el.get_value(iter, 0 , out gval); + if ((string)gval != type) { + print("not type: %s = %s\n", (string)gval , type); + return false; + } + this.model.el.get_value(iter, 1 , out gval); + if ((string)gval != fkey) { + print("not key: %s = %s\n", (string)gval , fkey); + return false; + } + // delay this? + GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => { + + this.startEditingValue(this.model.el.get_path(iter)); + return false; + }); + //s.select_iter(iter); + return true; + }); + + + + + } + public void updateIter (Gtk.TreeIter iter, string type, string key, string kvalue) { + + //print("update Iter %s, %s\n", key,kvalue); + //typeof(string), // 0 key type + //typeof(string), // 1 key + //typeof(string), // 2 key (display) + //typeof(string), // 3 value + //typeof(string), // 4 value (display) + //typeof(string), // 5 both (tooltip) + //typeof(string), // 6 key (sort) + + var dl = kvalue.strip().split("\n"); + + var dis_val = dl.length > 1 ? (dl[0].strip()+ "...") : dl[0]; + + if (type == "listener") { + + + + this.model.el.set(iter, + 0, type, + 1, key, + 2, this.keyFormat(key ,type), + 3, kvalue, + 4, dis_val, + 5, "" + GLib.Markup.escape_text(key + " " +kvalue) + "", + 6, "0 " + key + ); + return; + } + + + + this.model.el.set(iter, + 0, "props", + 1, key, + 2, this.keyFormat(key , "prop"), + 3, kvalue, + 4, dis_val, + 5, "" + GLib.Markup.escape_text(key + " " + kvalue) + "", + 6, this.keySortFormat(key) + ); + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_Button3 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button3(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + var child_0 = new Xcls_Box4( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_AddPropertyPopup( _this ); + child_1.ref(); + + //listeners + this.el.button_press_event.connect( (self, ev) => { + _this.before_edit(); + + + var p = _this.AddPropertyPopup; + p.el.set_screen(Gdk.Screen.get_default()); + p.el.show_all(); + p.el.popup(null, null, null, ev.button, ev.time); + return true; + }); + } + + // user defined functions + } + public class Xcls_Box4 : Object + { + public Gtk.Box el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Box4(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Image5( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_Label6( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Image5 : Object + { + public Gtk.Image el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Image5(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.stock = Gtk.Stock.ADD; + this.el.icon_size = Gtk.IconSize.MENU; + } + + // user defined functions + } + + public class Xcls_Label6 : Object + { + public Gtk.Label el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Label6(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Other" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_AddPropertyPopup : Object + { + public Gtk.Menu el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_AddPropertyPopup(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.AddPropertyPopup = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem8( _this ); + child_0.ref(); + this.el.append ( child_0.el ); + var child_1 = new Xcls_MenuItem9( _this ); + child_1.ref(); + this.el.append ( child_1.el ); + var child_2 = new Xcls_MenuItem10( _this ); + child_2.ref(); + this.el.append ( child_2.el ); + var child_3 = new Xcls_MenuItem11( _this ); + child_3.ref(); + this.el.append ( child_3.el ); + var child_4 = new Xcls_MenuItem12( _this ); + child_4.ref(); + this.el.append ( child_4.el ); + var child_5 = new Xcls_SeparatorMenuItem13( _this ); + child_5.ref(); + this.el.add ( child_5.el ); + var child_6 = new Xcls_MenuItem14( _this ); + child_6.ref(); + this.el.append ( child_6.el ); + var child_7 = new Xcls_MenuItem15( _this ); + child_7.ref(); + this.el.append ( child_7.el ); + var child_8 = new Xcls_MenuItem16( _this ); + child_8.ref(); + this.el.append ( child_8.el ); + var child_9 = new Xcls_SeparatorMenuItem17( _this ); + child_9.ref(); + this.el.add ( child_9.el ); + var child_10 = new Xcls_MenuItem18( _this ); + child_10.ref(); + this.el.append ( child_10.el ); + var child_11 = new Xcls_MenuItem19( _this ); + child_11.ref(); + this.el.append ( child_11.el ); + var child_12 = new Xcls_MenuItem20( _this ); + child_12.ref(); + this.el.append ( child_12.el ); + var child_13 = new Xcls_SeparatorMenuItem21( _this ); + child_13.ref(); + this.el.add ( child_13.el ); + var child_14 = new Xcls_MenuItem22( _this ); + child_14.ref(); + this.el.append ( child_14.el ); + var child_15 = new Xcls_MenuItem23( _this ); + child_15.ref(); + this.el.append ( child_15.el ); + var child_16 = new Xcls_MenuItem24( _this ); + child_16.ref(); + this.el.append ( child_16.el ); + } + + // user defined functions + } + public class Xcls_MenuItem8 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem8(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Using _this.{ID} will map to this element"; + this.el.label = "id: _this.{ID} (Vala)"; + + //listeners + this.el.activate.connect( () => { + _this.addProp( "prop", "id", "", ""); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem9 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem9(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element"; + this.el.label = "pack: Pack method (Vala)"; + + //listeners + this.el.activate.connect( ( ) => { + + _this.addProp( "prop", "pack","add", "*"); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem10 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem10(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)"; + this.el.label = "ctor: Alterative to default contructor (Vala)"; + + //listeners + this.el.activate.connect( ( ) => { + + _this.addProp( "prop", "ctor","", "*"); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem11 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem11(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "This code is called after the ctor"; + this.el.label = "init: initialziation code (vala)"; + + //listeners + this.el.activate.connect( ( ) => { + + _this.addProp( "prop", "init", "{\n\n}\n", "*" ); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem12 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem12(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})\n"; + this.el.label = "cms-id: (Roo JS/Pman library)"; + + //listeners + this.el.activate.connect( () => { + _this.addProp( "prop", "cms-id", "", "string"); + }); + } + + // user defined functions + } + + public class Xcls_SeparatorMenuItem13 : Object + { + public Gtk.SeparatorMenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem13(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_MenuItem14 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem14(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user defined string property"; + this.el.label = "String"; + + //listeners + this.el.activate.connect( (self) => { + + _this.addProp( "prop", "XXXX", "","string"); + + }); + } + + // user defined functions + } + + public class Xcls_MenuItem15 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem15(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user defined number property"; + this.el.label = "Number"; + + //listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp("prop", "XXX", "0", "int"); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem16 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem16(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user defined boolean property"; + this.el.label = "Boolean"; + + //listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp( "prop", "XXX", "true", "bool"); + }); + } + + // user defined functions + } + + public class Xcls_SeparatorMenuItem17 : Object + { + public Gtk.SeparatorMenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem17(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_MenuItem18 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem18(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user function boolean property"; + this.el.label = "Javascript Function"; + + //listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp("prop", "XXXX", "function() { }", "| function"); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem19 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem19(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user function boolean property"; + this.el.label = "Vala Method"; + + //listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type"); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem20 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem20(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a vala signal"; + this.el.label = "Vala Signal"; + + //listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp( "prop", "XXXX", "()", "@ void"); + }); + } + + // user defined functions + } + + public class Xcls_SeparatorMenuItem21 : Object + { + public Gtk.SeparatorMenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem21(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_MenuItem22 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem22(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a flexy if (for HTML templates)"; + this.el.label = "Flexy - If"; + + //listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp("prop", "flexy:if", "value_or_condition", "string"); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem23 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem23(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a flexy include (for HTML templates)"; + this.el.label = "Flexy - Include"; + + //listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp("prop", "flexy:include", "name_of_file.html", "string"); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem24 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem24(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a flexy foreach (for HTML templates)"; + this.el.label = "Flexy - Foreach"; + + //listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp("prop", "flexy:foreach", "array,key,value", "string"); + }); + } + + // user defined functions + } + + + + + public class Xcls_EditProps : Object + { + public Gtk.ScrolledWindow el; + private Xcls_LeftProps _this; + + + // my vars (def) + public bool editing; + + // ctor + public Xcls_EditProps(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.EditProps = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + this.editing = false; + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + { + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.TreeView el; + private Xcls_LeftProps _this; + + + // my vars (def) + public Xcls_PopoverProperty popover; + + // ctor + public Xcls_view(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + this.popover = null; + + // set gobject values + this.el.tooltip_column = 5; + this.el.enable_tree_lines = true; + this.el.headers_visible = true; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_keycol( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + var child_2 = new Xcls_valcol( _this ); + child_2.ref(); + this.el.append_column ( child_2.el ); + var child_3 = new Xcls_ContextMenu( _this ); + child_3.ref(); + + // init method + + { + var selection = this.el.get_selection(); + selection.set_mode( Gtk.SelectionMode.SINGLE); + + + var description = new Pango.FontDescription(); + description.set_size(10000); + this.el.override_font(description); + } + + //listeners + this.el.button_press_event.connect( ( ev) => { + + Gtk.TreeViewColumn col; + int cell_x; + int cell_y; + Gtk.TreePath path; + if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) { + print("nothing selected on click"); + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + this.el.get_selection().unselect_all(); + + return false; + }); + _this.before_edit(); + return false; //not on a element. + } + + + // double click on name.. + if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == "Name") { + // show popup!. + + if (this.popover == null) { + this.popover = new Xcls_PopoverProperty(); + this.popover.mainwindow = _this.main_window; + } + + + _this.before_edit(); + _this.stop_editor(); + + _this.keyrender.el.stop_editing(false); + _this.keyrender.el.editable =false; + + _this.valrender.el.stop_editing(false); + _this.valrender.el.editable =false; + Gtk.TreeIter iter; + var mod = this.el.get_model(); + mod.get_iter (out iter, path); + + + GLib.Value gvaltype, gval; + mod.get_value(iter, 1 , out gval); // one is key.. + + mod.get_value(iter,0, out gvaltype); + + this.popover.show(this.el, _this.node, (string)gvaltype, (string)gval); + + // _this.startEditingKey(path); + + return false; + } + + + + + // right click. + if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) { + // show popup!. + //if (col.title == "Value") { + // _this.before_edit(); + // return false; + //} + + var p = _this.ContextMenu; + + p.el.set_screen(Gdk.Screen.get_default()); + p.el.show_all(); + p.el.popup(null, null, null, ev.button, ev.time); + //Seed.print("click:" + res.column.title); + // select the + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + + this.el.get_selection().select_path(path); + return false; + }); + _this.before_edit(); + return false; + } + + + if (col.title != "Value") { + print("col title != Value"); + + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + this.el.get_selection().select_path(path); + return false; + }); + + _this.before_edit(); + // XObject.error("column is not value?"); + return false; // ignore.. - key click.. ??? should we do this?? + } + + + // if the cell can be edited with a pulldown + // then we should return true... - and let the start_editing handle it? + + + + + + + // _this.before_edit(); <<< we really need to stop the other editor.. + _this.keyrender.el.stop_editing(false); + _this.keyrender.el.editable =false; + + + return _this.startEditingValue(path); // assumes selected row.. + + + + + + }); + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.TreeStore el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.TreeStore( 7, typeof(string), // 0 key type + typeof(string), // 1 key + typeof(string), // 2 key (display) + typeof(string), // 3 value + typeof(string), // 4 value (display) + typeof(string), // 5 both (tooltip) + typeof(string) // 6 key (for sorting) + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_keycol : Object + { + public Gtk.TreeViewColumn el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_keycol(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.keycol = this; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Name"; + this.el.resizable = true; + var child_0 = new Xcls_keyrender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + this.el.add_attribute(_this.keyrender.el , "markup", 2 ); + this.el.add_attribute(_this.keyrender.el , "text", 1 ); + } + + // user defined functions + } + public class Xcls_keyrender : Object + { + public Gtk.CellRendererText el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_keyrender(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.keyrender = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.editing_started.connect( ( editable, path) => { + + Gtk.TreeIter iter; + _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + + + + // this.get('/LeftPanel.model').activePath = path; + _this.model.el.get_value(iter,1, out gval); + var val = (string)gval; + + ((Gtk.Entry)editable).set_text(val); + }); + this.el.edited.connect( (path, newtext) => { + print("Keyrender - signal:edited\n"); + + this.el.editable = false; + + + + Gtk.TreeIter iter; + _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + + _this.model.el.get_value(iter,1, out gval); + var oldval = (string)gval; + + _this.model.el.get_value(iter,0, out gval); + var ktype = (string)gval; + + _this.model.el.set_value(iter, 1, newtext); + + if (oldval == newtext) { + return; + } + + + print("ktype: %s\n",ktype); + switch(ktype) { + case "listener": + var ov = _this.node.listeners.get(oldval); + _this.node.listeners.set(newtext, ov); + _this.node.listeners.unset(oldval); + + _this.updateIter(iter, ktype, newtext, ov); + + break; + case "props": + var ov = _this.node.props.get(oldval); + _this.node.props.set(newtext, ov); + _this.node.props.unset(oldval); + _this.updateIter(iter, ktype, newtext, ov); + break; + } + _this.changed(); + + }); + } + + // user defined functions + } + + + public class Xcls_valcol : Object + { + public Gtk.TreeViewColumn el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_valcol(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.valcol = this; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Value"; + this.el.resizable = true; + var child_0 = new Xcls_valrender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + { + + // typeof(string), // 0 key type + // typeof(string), // 1 key + // typeof(string), // 2 key (display) + // typeof(string), // 3 value + // typeof(string) // 4 value (display) + + + this.el.add_attribute(_this.valrender.el , "text", 4 ); + //this.el.add_attribute(_this.valrender.el , "sensitive", 4 ); + //this.el.add_attribute(this.items[0].el , 'editable', 3 ); + // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL); + + // this.get('/LeftPanel').editableColumn= this; + } + } + + // user defined functions + } + public class Xcls_valrender : Object + { + public Gtk.CellRendererCombo el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_valrender(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.valrender = this; + this.el = new Gtk.CellRendererCombo(); + + // my vars (dec) + + // set gobject values + this.el.editable = false; + this.el.text_column = 0; + this.el.has_entry = true; + var child_0 = new Xcls_valrendermodel( _this ); + child_0.ref(); + this.el.model = child_0.el; + + //listeners + this.el.editing_started.connect( ( editable, path) => { + //_this.editing = true; + print("editing started called\n"); + if (!_this.allow_edit) { + + print("val - editing_Started\n"); + this.el.editable = false; // make sure it's not editor... + + + return; + } + _this.allow_edit =false; + + + if ( this.el.has_entry ) { + + Gtk.TreeIter iter; + _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + + + + // this.get('/LeftPanel.model').activePath = path; + _this.model.el.get_value(iter,3, out gval); + + + var val = (string)gval; + var combo = (Gtk.ComboBox)editable; + + var entry = (Gtk.Entry) combo.get_child(); + entry.set_text(val); + } + + }); + this.el.edited.connect( (path, newtext) => { + print("Valrender - signal:edited\n"); + + this.el.editable = false; + /* + m.set(iter, + 0, "listener", + 1, miter.get_key(), + 2, "" + miter.get_key() + "", + 3, miter.get_value(), + 4, display_value(short); + ); + + */ + + Gtk.TreeIter iter; + _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + + _this.model.el.get_value(iter,0, out gval); + var ktype = (string)gval; + + + _this.model.el.get_value(iter,3, out gval); + var oldval = (string)gval; + + _this.model.el.get_value(iter,1, out gval); + var key = (string)gval; + + + + switch(ktype) { + case "listener": + _this.node.listeners.set(key, newtext); + _this.updateIter(iter,ktype,key,newtext); + break; + case "props": + _this.node.props.set(key,newtext); + _this.updateIter(iter,ktype, key,newtext); + break; + } + // _this.load(_this.file,_this.node); + _this.changed(); + + }); + } + + // user defined functions + public void setOptions (string[] ar) { + var m = _this.valrendermodel.el; + m.clear(); + Gtk.TreeIter iret; + for (var i =0; i < ar.length; i++) { + m.append(out iret); + m.set_value(iret, 0, ar[i]); + } + + } + } + public class Xcls_valrendermodel : Object + { + public Gtk.ListStore el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_valrendermodel(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.valrendermodel = this; + this.el = new Gtk.ListStore( 1, typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_ContextMenu : Object + { + public Gtk.Menu el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_ContextMenu(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.ContextMenu = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem34( _this ); + child_0.ref(); + this.el.append ( child_0.el ); + var child_1 = new Xcls_SeparatorMenuItem35( _this ); + child_1.ref(); + this.el.append ( child_1.el ); + var child_2 = new Xcls_MenuItem36( _this ); + child_2.ref(); + this.el.append ( child_2.el ); + } + + // user defined functions + } + public class Xcls_MenuItem34 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem34(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Edit (double click)"; + + //listeners + this.el.activate.connect( ( ) =>{ + + var s = _this.view.el.get_selection(); + Gtk.TreeIter iter; + Gtk.TreeModel mod; + s.get_selected (out mod, out iter); + + if (_this.view.popover == null) { + _this.view.popover = new Xcls_PopoverProperty(); + _this.view.popover.mainwindow = _this.main_window; + } + + + _this.before_edit(); + _this.stop_editor(); + + _this.keyrender.el.stop_editing(false); + _this.keyrender.el.editable =false; + + _this.valrender.el.stop_editing(false); + _this.valrender.el.editable =false; + + + GLib.Value gvaltype, gval; + mod.get_value(iter, 1 , out gval); // one is key.. + + mod.get_value(iter,0, out gvaltype); + + _this.view.popover.show(_this.view.el, _this.node, (string)gvaltype, (string)gval); + + + + // _this.startEditingKey(model.get_path(iter)); + }); + } + + // user defined functions + } + + public class Xcls_SeparatorMenuItem35 : Object + { + public Gtk.SeparatorMenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem35(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_MenuItem36 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem36(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Delete"; + + //listeners + this.el.activate.connect( ( ) =>{ + _this.deleteSelected(); + }); + } + + // user defined functions + } + + + + +} diff --git a/src/Builder4/WindowLeftTree.bjs b/src/Builder4/WindowLeftTree.bjs new file mode 100644 index 000000000..c17d8105b --- /dev/null +++ b/src/Builder4/WindowLeftTree.bjs @@ -0,0 +1,135 @@ +{ + "name" : "WindowLeftTree", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/WindowLeftTree.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "| JsRender.Node? getActiveElement" : " () { // return path to actie node.\n\n var path = this.getActivePath();\n if (path.length < 1) {\n return null;\n }\n return _this.model.pathToNode(path);\n \n}\n", + "id" : "WindowLeftTree", + "@ bool before_node_change" : "()", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "| JsRender.JsRender getActiveFile" : "() {\n return this.main_window.windowstate.file;\n}\n", + "* pack" : "add", + "xtype" : "ScrolledWindow", + "@ void changed" : "()", + "$ xns" : "Gtk", + "@ void node_selected" : "(JsRender.Node? node, string source)", + "# Xcls_MainWindow main_window" : "null", + "| string getActivePath" : " () {\n \n var view = this.view.el;\n if (view.get_selection().count_selected_rows() < 1) {\n return \"\";\n }\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n view.get_selection().get_selected(out mod, out iter);\n return mod.get_path(iter).to_string();\n}\n ", + "items" : [ + { + "listeners" : { + "button_press_event" : " ( ev) => {\n //console.log(\"button press?\");\n this.lastEventSource = \"tree\";\n if (! _this.before_node_change() ) {\n \n return true;\n }\n \n\n \n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {\n //print(\"click\" + ev.type);\n return false;\n }\n Gtk.TreePath res;\n if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n return true;\n }\n \n this.el.get_selection().select_path(res);\n \n //if (!this.get('/LeftTreeMenu').el) { \n // this.get('/LeftTreeMenu').init(); \n // }\n \n _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());\n _this.LeftTreeMenu.el.show_all();\n _this.LeftTreeMenu.el.popup(null, null, null, 3, ev.time);\n // print(\"click:\" + res.path.to_string());\n return true;\n}", + "drag_begin" : "( ctx) => {\n\t//print('SOURCE: drag-begin');\n \n \n //this.targetData = \"\";\n \n // find what is selected in our tree...\n \n var s = _this.view.el.get_selection();\n if (s.count_selected_rows() < 1) {\n return;\n }\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n\n \n\n // set some properties of the tree for use by the dropped element.\n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n var tp = mod.get_path(iter).to_string();\n var data = (JsRender.Node)(value.dup_object());\n var xname = data.fqn();\n print (\"XNAME IS \" + xname+ \"\\n\");\n this.dragData = tp;\n this.dropList = _this.main_window.windowstate.file.palete().getDropList(xname);\n \n print (\"DROP LIST IS \" + string.joinv(\", \", this.dropList) + \"\\n\");\n \n\n // make the drag icon a picture of the node that was selected\n \n \n // by default returns the path..\n var path = _this.model.el.get_path(iter);\n\n \n var pix = this.el.create_row_drag_icon ( path);\n \n Gtk.drag_set_icon_surface (ctx, pix) ;\n \n return;\n}", + "cursor_changed" : " ( ) => {\n\n\n if (this.blockChanges) { // probably not needed.. \n return ;\n }\n if (!_this.before_node_change( ) ) {\n\t this.blockChanges = true;\n\t this.el.get_selection().unselect_all();\n\t this.blockChanges = false;\n\t return;\n }\n if (_this.main_window.windowstate.file == null) {\n return;\n } \n \n //var render = this.get('/LeftTree').getRenderer(); \n print(\"LEFT TREE -> view -> selection changed called\\n\");\n \n \n // -- it appears that the selection is not updated.\n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n \n\n if (this.el.get_selection().count_selected_rows() < 1) {\n\n print(\"selected rows < 1\\n\");\n //??this.model.load( false);\n _this.node_selected(null, this.lastEventSource);\n \n return false ;\n }\n \n //console.log('changed');\n var s = this.el.get_selection();\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n \n \n // var val = \"\";\n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n _this.model.activePath = mod.get_path(iter).to_string();\n \n var node = (JsRender.Node)value.dup_object();\n _this.node_selected(node, this.lastEventSource);\n while (Gtk.events_pending()) {\n Gtk.main_iteration();\n }\n var cp = mod.get_path(iter);\n Gtk.TreePath sp, ep;\n this.el.get_visible_range(out sp, out ep);\n // if sp is before cp then retuns 1.\n // if cp is before ep then retuns 1.\n if (cp.compare(sp) >= 0 && ep.compare(cp) >=1) {\n return false;\n }\n \n \n \n this.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);\n \n return false;\n }); \n //_this.after_node_change(node);\n\n// _this.model.file.changed(node, \"tree\");\n \n //Seed.print( value.get_string());\n return ;\n \n}", + "drag_end" : " (drag_context) => {\n\t//Seed.print('LEFT-TREE: drag-end');\n this.dragData = \"\";\n this.dropList = null;\n// this.targetData = \"\";\n this.highlightDropPath(\"\",0);\n// return true;\n}", + "drag_motion" : " ( ctx, x, y, time) => {\n print(\"got drag motion\\n\");\n var src = Gtk.drag_get_source_widget(ctx);\n this.drag_x = x;\n this.drag_y = y; \n\n if (src != this.el) {\n \n \n \n // the point of this is to detect where an item could be dropped..\n print(\"requesting drag data\\n\");\n this.drag_in_motion = true;\n \n // request data that will be recieved by the recieve... \n Gtk.drag_get_data\n (\n this.el, // will receive 'drag-data-received' signal \n ctx, // represents the current state of the DnD \n Gdk.Atom.intern(\"STRING\",true), // the target type we want \n time // time stamp \n );\n return true;\n } \n\n\n print(\"action: %d\\n\", ctx.get_actions());\n //print(\"GETTING POS\");\n var targetData = \"\";\n\n Gtk.TreePath path;\n Gtk.TreeViewDropPosition pos;\n var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n\n // if there are not items in the tree.. the we have to set isOver to true for anything..\n var isEmpty = false;\n if (_this.model.el.iter_n_children(null) < 1) {\n print(\"got NO children?\\n\");\n isOver = true; //??? \n isEmpty = true;\n pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n }\n\n\n // ------------- a drag from self..\n\n\n //var action = Gdk.DragAction.COPY;\n // unless we are copying!!! ctl button..\n \n var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?\n Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;\n // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n\n\n if (_this.model.el.iter_n_children(null) < 1) {\n // no children.. -- asume it's ok..\n \n targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n \n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0); \n Gdk.drag_status(ctx, action ,time);\n return true;\n \n // continue through to allow drop...\n\n } \n \n \n\n \n \n //print(\"ISOVER? \" + isOver);\n if (!isOver) {\n \n Gdk.drag_status(ctx, 0 ,time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0); \n return false;\n\n }\n \n // drag node is parent of child..\n //console.log(\"SRC TREEPATH: \" + src.treepath);\n //console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n \n // nned to check a few here..\n //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n //Gtk.TreeViewDropPosition.AFTER\n //Gtk.TreeViewDropPosition.BEFORE\n \n // locally dragged items to not really use the \n var selection_text = this.dragData;\n \n \n \n if (selection_text == null || selection_text.length < 1) {\n //print(\"Error - drag selection text returned NULL\");\n Gdk.drag_status(ctx, 0 ,time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return false;\n }\n \n \n // see if we are dragging into ourself?\n var target_path = path.to_string(); \n print (\"Drag %s onto %s--%d\\n \", selection_text, target_path, pos);\n \n // pos : 3 = ontop - 0 = after, 1 = before\n //print(\"target_path=\"+target_path);\n\n // \n if (selection_text == target_path) {\n print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");\n \n Gdk.drag_status(ctx, 0 ,time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return false;\n// -- fixme -- this is not really correct..\n\n }\n \n // check that \n //print(\"DUMPING DATA\");\n //console.dump(data);\n // path, pos\n \n //print(data.path.to_string() +' => '+ data.pos);\n \n // dropList is a list of xtypes that this node could be dropped on.\n // it is set up when we start to drag..\n \n \n targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);\n \n print(\"targetDAta: \" + targetData +\"\\n\");\n \n if (targetData.length < 1) {\n //print(\"Can not find drop node path\");\n \n Gdk.drag_status(ctx, 0, time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return false;\n }\n \n var td_ar = targetData.split(\"|\");\n \n \n\n Gdk.drag_status(ctx, action ,time);\n this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));\n return true;\n \n \n}", + "drag_data_get" : "( drag_context, data, info, time) => {\n \n \n //print(\"drag-data-get\");\n var s = this.el.get_selection();\n if (s.count_selected_rows() < 1) {\n data.set_text(\"\",0); \n print(\"return empty string - no selection..\");\n return;\n }\n \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n s.get_selected(out mod, out iter);\n \n \n \n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n var ndata = (JsRender.Node)(value.dup_object());\n \n \n \n var tp = mod.get_path(iter).to_string();\n // by default returns the path..\n \n if ( info != Gdk.Atom.intern(\"STRING\",true) ) {\n tp = ndata.toJsonString();\n } \n \n //data.set_text(tp,tp.length); \n \n data.set (data.get_target (), 8, (uchar[]) tp.to_utf8 ());\n \n \n // print(\"return \" + tp);\n }", + "drag_data_received" : " (ctx, x, y, sel, info, time) => {\n \n // THIS CODE ONLY RELATES TO drag or drop of \"NEW\" elements or \"FROM another tree..\"\n \n \n // print(\"Tree: drag-data-received\\n\");\n var selection_text = (string)sel.get_data();\n //print(\"selection_text= %s\\n\",selection_text);\n\n var is_drag = this.drag_in_motion;\n \n \n\n print(\"Is Drag %s\\n\", is_drag ? \"Y\": \"N\");\n var targetData = \"\";\n \n Gtk.TreePath path;\n Gtk.TreeViewDropPosition pos;\n var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n \n // if there are not items in the tree.. the we have to set isOver to true for anything..\n var isEmpty = false;\n if (_this.model.el.iter_n_children(null) < 1) {\n print(\"got NO children?\\n\");\n isOver = true; //??? \n isEmpty = true;\n pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n }\n \n \n //console.log(\"LEFT-TREE: drag-motion\");\n var src = Gtk.drag_get_source_widget(ctx);\n \n // a drag from self - this should be handled by drop and motion.\n if (src == this.el) {\n print(\"Source == this element should not happen.. ? \\n\");\n return;\n }\n //print(\"drag_data_recieved from another element\");\n \n \n \n \n if (selection_text == null || selection_text.length < 1 || !isOver) {\n // nothing valid foudn to drop...\n print(\"empty sel text or not over\");\n if (is_drag) {\n Gdk.drag_status(ctx, 0, time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return;\n }\n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n // no drop action...\n return; \n \n }\n var dropNode = new JsRender.Node(); \n \n var dropNodeType = selection_text;\n var show_templates = true;\n // for drop\n if (dropNodeType[0] == '{') {\n var pa = new Json.Parser();\n try {\n pa.load_from_data(dropNodeType);\n } catch (Error e) {\n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n // no drop action...\n return; \n }\n \n dropNode.loadFromJson( pa.get_root().get_object(), 2);\n dropNodeType = dropNode.fqn();\n show_templates = false;\n \n \n } else {\n\n dropNode.setFqn(selection_text);\n }\n\n \n // dropList --- need to gather this ... \n print(\"get dropList for : %s\\n\",dropNodeType); \n var dropList = _this.main_window.windowstate.file.palete().getDropList(dropNodeType);\n \n print(\"dropList: %s\\n\", string.joinv(\" , \", dropList));\n \n // if drag action is link ... then we can drop it anywahere...\n if ((ctx.get_actions() & Gdk.DragAction.LINK) > 0) {\n // if path is null?? dragging into an empty tree?\n targetData = (path == null ? \"\" : path.to_string()) + \"|%d\".printf((int)pos);\n } else {\n \n \n targetData = _this.model.findDropNodeByPath( isEmpty ? \"\" : path.to_string(), dropList, pos);\n }\n \n \n \n print(\"targetDAta: \" + targetData +\"\\n\");\n \n if (targetData.length < 1) {\n \n // invalid drop path..\n if (this.drag_in_motion) {\n Gdk.drag_status(ctx, 0, time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return;\n }\n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n // no drop action...\n return;\n }\n // valid drop path..\n \n var td_ar = targetData.split(\"|\");\n \n \n if (this.drag_in_motion) { \n Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time);\n\n this.highlightDropPath( td_ar[0] , (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));\n return;\n }\n // continue on to allow drop..\n \n\n // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..\n \n\n _this.model.dropNode(targetData, dropNode, show_templates);\n print(\"ADD new node!!!\\n\");\n \n ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node);\n \n Gtk.drag_finish (ctx, false, false,time);\n \n \n \n \n \n}", + "drag_drop" : " ( ctx, x, y, time) => {\n //Seed.print(\"TARGET: drag-drop\");\n \n \n var src = Gtk.drag_get_source_widget(ctx);\n \n if (src != this.el) {\n \n \n \n this.drag_in_motion = false; \n // request data that will be recieved by the recieve... \n Gtk.drag_get_data\n (\n this.el, // will receive 'drag-data-received' signal \n ctx, // represents the current state of the DnD \n Gdk.Atom.intern(\"application/json\",true), // the target type we want \n time // time stamp \n );\n\n \n // No target offered by source => error\n \n\n return false;\n }\n \n // handle drop around self..\n \n \n \n //print(\"GETTING POS\");\n var targetData = \"\";\n \n Gtk.TreePath path;\n Gtk.TreeViewDropPosition pos;\n var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n \n // if there are not items in the tree.. the we have to set isOver to true for anything..\n var isEmpty = false;\n if (_this.model.el.iter_n_children(null) < 1) {\n print(\"got NO children?\\n\");\n isOver = true; //??? \n isEmpty = true;\n pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n }\n \n \n \n //var action = Gdk.DragAction.COPY;\n // unless we are copying!!! ctl button..\n \n var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?\n Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;\n // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n\n \n if (_this.model.el.iter_n_children(null) < 1) {\n // no children.. -- asume it's ok..\n \n targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n \n // continue through to allow drop...\n\n } else {\n \n \n \n \n \n //print(\"ISOVER? \" + isOver);\n if (!isOver) {\n \n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n return true; // not over apoint!?! - no action on drop or motion..\n }\n \n // drag node is parent of child..\n //console.log(\"SRC TREEPATH: \" + src.treepath);\n //console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n \n // nned to check a few here..\n //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n //Gtk.TreeViewDropPosition.AFTER\n //Gtk.TreeViewDropPosition.BEFORE\n \n // locally dragged items to not really use the \n var selection_text = this.dragData;\n \n \n \n if (selection_text == null || selection_text.length < 1) {\n //print(\"Error - drag selection text returned NULL\");\n \n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n return true; /// -- fixme -- this is not really correct..\n } \n \n // see if we are dragging into ourself?\n print (\"got selection text of \" + selection_text);\n \n var target_path = path.to_string();\n //print(\"target_path=\"+target_path);\n\n // \n if (selection_text == target_path) {\n print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");\n \n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n\n return true; /// -- fixme -- this is not really correct..\n\n }\n \n // check that \n //print(\"DUMPING DATA\");\n //console.dump(data);\n // path, pos\n \n //print(data.path.to_string() +' => '+ data.pos);\n \n // dropList is a list of xtypes that this node could be dropped on.\n // it is set up when we start to drag..\n \n \n targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);\n \n print(\"targetDAta: \" + targetData +\"\\n\");\n \n if (targetData.length < 1) {\n //print(\"Can not find drop node path\");\n \n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n return true;\n }\n \n \n \n // continue on to allow drop..\n }\n // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..\n\n\n var delete_selection_data = false;\n \n if (action == Gdk.DragAction.ASK) {\n /* Ask the user to move or copy, then set the ctx action. */\n }\n\n if (action == Gdk.DragAction.MOVE) {\n delete_selection_data = true;\n }\n \n // drag around.. - reorder..\n _this.model.moveNode(targetData, action);\n \n \n \n \n \n // we can send stuff to souce here...\n\n\n// do we always say failure, so we handle the reall drop?\n Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);\n\n return true;\n \n \n \n \n \n \n}" + }, + "# string dragData" : "", + "# int drag_x" : "", + "# string[] dropList" : "", + "id" : "view", + "gboolean headers_visible" : true, + "# int drag_y" : "", + "* init" : "{\n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.override_font(description);\n\n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n\n\n // is this really needed??\n /*\n this.selection.signal['changed'].connect(function() {\n\t _this.get('/LeftTree.view').listeners.cursor_changed.apply(\n\t _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']\n\t );\n });\n */\n Gtk.drag_source_set (\n\t this.el, /* widget will be drag-able */\n\t Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n\t BuilderApplication.targetList, /* lists of target to support */\n\t Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */\n );\n\n // ?? needed??\n //Gtk.drag_source_add_text_targets(this.el); \n\n Gtk.drag_dest_set\n (\n this.el, /* widget that will accept a drop */\n Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n BuilderApplication.targetList, /* lists of target to support */\n Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */\n );\n\n //Gtk.drag_dest_set_target_list(this.el, Builder.Application.targetList);\n //Gtk.drag_dest_add_text_targets(this.el);\n}\n", + "tooltip_column" : 1, + "bool expand" : true, + "* pack" : "add", + "xtype" : "TreeView", + "$ enable_tree_lines" : true, + "$ headers_visible" : false, + "| void highlightDropPath" : " ( string treepath, Gtk.TreeViewDropPosition pos) {\n\n // highlighting for drag/drop\n if (treepath.length > 0) {\n this.el.set_drag_dest_row( new Gtk.TreePath.from_string( treepath ), pos);\n } else {\n this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n \n}", + "$ string lastEventSource" : "\"\"", + "# bool drag_in_motion" : "", + "# bool blockChanges" : false, + "$ xns" : "Gtk", + "| void setCursor" : "(string treepath, string sourceEvent) {\n\tthis.lastEventSource = sourceEvent;\n\t//this.blockChanges = true; << block changes prevents loading of 'node data' and firing of node_selected..\n this.el.set_cursor(new Gtk.TreePath.from_string(treepath), null, false); \n // fire node_selected..\n //this.blockChanges = false;\n\tthis.lastEventSource = \"\";\n}\n", + "| void selectNode" : "(string treepath_str, string source) {\n\tthis.lastEventSource = source;\n //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));\n var tp = new Gtk.TreePath.from_string(treepath_str);\n \n this.el.set_cursor(tp, null, false); \n this.el.scroll_to_cell(tp, null, false, 0,0);\n}\n", + "items" : [ + { + "| string findDropNode" : " (string treepath_str, string[] targets) {\n\n // this is used by the dragdrop code in the roo version AFAIR..\n\n //var path = treepath_str.replace(/^builder-/, '');\n // treemap is depreciated... - should really check if model has any entries..\n\n if (this.el.iter_n_children(null) < 1) {\n //print(\"NO KEYS\");\n return \"|%d\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n //print(\"FIND treepath: \" + path);\n //console.dump(this.treemap);\n \n //if (!treepath_str.match(/^builder-/)) {\n // return []; // nothing!\n //}\n if (targets.length > 0 && targets[0] == \"*\") {\n return treepath_str;\n }\n return this.findDropNodeByPath(treepath_str,targets, -1);\n}\n", + "currentTree" : false, + "id" : "model", + "# DialogTemplateSelect template_select" : "null", + "* init" : "print(\"model initialized\");\n\n", + "| void loadFile" : "(JsRender.JsRender f) {\n //console.dump(f);\n this.el.clear();\n \n // needed???\n _this.main_window.windowstate.file = f;\n \n \n if (f.tree == null) {\n\t try {\n\t f.loadItems( );\n } catch (Error e) {\n \t\treturn;\n }\n }\n // if it's still null?\n if (f.tree == null) {\n return;\n }\n \n var o = new Gee.ArrayList();\n o.add(f.tree);\n this.load(o,null);\n \n _this.view.el.expand_all();\n\n if (f.tree.items.size < 1) {\n // single item..\n \n //this.get('/Window.leftvpaned').el.set_position(80);\n // select first...\n _this.view.el.set_cursor( \n new Gtk.TreePath.from_string(\"0\"), null, false);\n \n \n } else {\n //this.get('/Window.leftvpaned').el.set_position(200);\n }\n \n return;\n \n \n}\n", + "| void updateSelected" : "() {\n \n \n var s = _this.view.el.get_selection();\n \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n \n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n \n GLib.Value value;\n this.el.get_value(iter, 2, out value);\n var node = (JsRender.Node)(value.get_object());\n \n this.el.set(iter, 0, node.nodeTitle(),\n 1, node.nodeTip(), -1\n );\n}\n", + "* pack" : "set_model", + "xtype" : "TreeStore", + "| string findDropNodeByPath" : " (string treepath_str, string[] targets, int in_pref = -1) {\n\n var path = treepath_str; // dupe it..\n \n \n // pref : 3 = ontop - 0 = after, 1 = before\n int pref = in_pref < 0 ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : in_pref;\n \n var last = \"\";\n \n //console.dump(this.treemap);\n \n print(\"findDropNodeByPath : got path length %d / %s\\n\", path.length, path);\n \n if (path.length == 0) {\n // top drop. // just return empty..\n return \"|%d\".printf((int)pref) ;\n \n }\n \n \n while (path.length > 0) {\n \n if (path.length == treepath_str.length && pref != Gtk.TreeViewDropPosition.INTO_OR_AFTER) {\n if (path.last_index_of(\":\") < 0 ) {\n return \"\";\n }\n path = path.substring(0, path.last_index_of(\":\"));\n last = treepath_str;\n print(\"DROP before or after : using %s\\n\",path);\n continue;\n }\n \n //print(\"LOOKING FOR PATH: \" + path);\n var node_data = this.pathToNode(path);\n \n if (node_data == null) {\n print(\"node not found\");\n return \"\";\n }\n \n var xname = node_data.fqn();\n var match = \"\";\n var prop = \"\";\n \n for (var i =0; i < targets.length; i++) {\n var tg = targets[i];\n if ((tg == xname) ) {\n match = tg;\n break;\n }\n // if target is \"xxxx:name\"\n if (tg.contains(xname +\":\")) {\n match = tg;\n var ar = tg.split(\":\");\n prop = ar[1];\n break;\n }\n }\n \n if (match.length > 0) {\n if (last.length > 0) { // pref is after/before..\n // then it's after last\n //if (pref > 1) {\n // return \"\";\n //}\n return last + \"|%d\".printf((int)pref) + \"|\" + prop;\n\n \n }\n // we need to add prop - as :store -> needs to bee added when dropping onto.\n return path + \"|%d\".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER) + \"|\" + prop;\n }\n /*\n last = \"\" + path;\n var par = path.split(\":\");\n string [] ppar = {};\n for (var i = 0; i < par.length-1; i++) {\n ppar += par[i];\n }\n \n path = string.joinv(\":\", ppar);\n */\n break;\n\n }\n \n return \"\";\n \n}\n", + "| void moveNode" : "(string target_data, Gdk.DragAction action) \n{\n \n /// target_data = \"path|pos\");\n \n \n //print(\"MOVE NODE\");\n // console.dump(target_data);\n Gtk.TreeIter old_iter;\n Gtk.TreeModel mod;\n \n var s = _this.view.el.get_selection();\n s.get_selected(out mod , out old_iter);\n mod.get_path(old_iter);\n \n var node = this.pathToNode(mod.get_path(old_iter).to_string());\n //console.dump(node);\n if (node == null) {\n print(\"moveNode: ERROR - node is null?\");\n }\n \n \n\n // needs to drop first, otherwise the target_data \n // treepath will be invalid.\n\n \n if ((action & Gdk.DragAction.MOVE) > 0) {\n print(\"REMOVING OLD NODE : \" + target_data + \"\\n\");\n node.remove();\n this.dropNode(target_data, node, false);\n this.el.remove(ref old_iter);\n \n \n \n } else {\n print(\"DROPPING NODE // copy: \" + target_data + \"\\n\");\n node = node.deepClone();\n this.dropNode(target_data, node, false);\n }\n _this.changed();\n this.activePath= \"\";\n //this.updateNode(false,true);\n}\n", + "# string activePath" : "\"\"", + "$ columns" : "typeof(string),typeof(string),typeof(Object)", + "| void load" : "(Gee.ArrayList tr, Gtk.TreeIter? iter) \n{\n Gtk.TreeIter citer;\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.size; i++) {\n if (iter != null) {\n this.el.insert(out citer,iter,-1); // why not append?\n } else {\n this.el.append(out citer,null);\n }\n \n this.el.set(citer, 0, tr.get(i).nodeTitle(),\n 1, tr.get(i).nodeTip(), -1\n );\n var o = GLib.Value(typeof(Object));\n o.set_object((Object)tr.get(i));\n \n this.el.set_value(citer, 2, o);\n \n if (tr.get(i).items.size > 0) {\n this.load(tr.get(i).items, citer);\n }\n \n }\n\n \n}", + "| void deleteSelected" : "() {\n \n print(\"DELETE SELECTED?\");\n //_this.view.blockChanges = true;\n print(\"GET SELECTION?\");\n\n var s = _this.view.el.get_selection();\n \n print(\"GET SELECTED?\");\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n\n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n \n\n\n this.activePath= \"\"; \n print(\"GET vnode value?\");\n\n GLib.Value value;\n this.el.get_value(iter, 2, out value);\n var data = (JsRender.Node)(value.get_object());\n print(\"removing node from Render\\n\");\n if (data.parent == null) {\n _this.main_window.windowstate.file.tree = null;\n } else {\n data.remove();\n }\n print(\"removing node from Tree\\n\"); \n s.unselect_all();\n this.el.remove(ref iter);\n\n \n \n \n // \n \n \n\n\n this.activePath= \"\"; // again!?!? \n //this.changed(null,true);\n \n _this.changed();\n \n _this.view.blockChanges = false;\n}\n", + "n_columns" : 3, + "$ xns" : "Gtk", + "| JsRender.Node pathToNode" : "(string path) {\n \n \n Gtk.TreeIter iter;\n _this.model.el.get_iter_from_string(out iter, path);\n \n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n \n return (JsRender.Node)value.dup_object();\n\n}", + "| void dropNode" : "(string target_data_str, JsRender.Node node, bool show_templates) {\n// print(\"drop Node\");\n // console.dump(node);\n // console.dump(target_data);\n \n \n // 0 = before , 1=after 2/3 onto\n \n \n var target_data= target_data_str.split(\"|\");\n \n var parent_str = target_data[0].length > 0 ? target_data[0] : \"\";\n var pos = target_data.length > 1 ? int.parse(target_data[1]) : 2; // ontop..\n \n \n Gtk.TreePath tree_path = parent_str.length > 0 ? new Gtk.TreePath.from_string( parent_str ) : null;\n \n \n \n //print(\"add \" + tp + \"@\" + target_data[1] );\n \n JsRender.Node parentNode = null;\n \n Gtk.TreeIter iter_after;\n Gtk.TreeIter iter_par ;\n \n \n if (target_data.length == 3 && target_data[2].length > 0) {\n node.props.set(\"* prop\", target_data[2]);\n }\n\n Gtk.TreePath expand_parent = null;\n \n // we only need to show the template if it's come from else where?\n if (show_templates) {\n \n var ts = _this.main_window.windowstate.template_select;\n \n var new_node = ts.show(\n _this.main_window, // (Gtk.Window) _this.el.get_toplevel (),\n _this.main_window.windowstate.file.palete(),\n node,\n _this.main_window.windowstate.project);\n \n if (new_node == null) {\n return; // do not add?\n }\n node = new_node;\n } \n \n //print(\"pos is %d \\n\".printf(pos));\n \n Gtk.TreeIter n_iter; \n \n if ( parent_str.length < 1) {\n this.el.append(out n_iter, null); // drop at top level..\n node.parent = null;\n _this.main_window.windowstate.file.tree = node;\n \n \n } else if (pos < 2) {\n //print(target_data[1] > 0 ? 'insert_after' : 'insert_before');\n \n this.el.get_iter(out iter_after, tree_path ); \n this.el.iter_parent(out iter_par, iter_after);\n expand_parent = this.el.get_path(iter_par);\n \n GLib.Value value;\n this.el.get_value( iter_par, 2, out value);\n parentNode = (JsRender.Node)value.dup_object();\n \n \n this.el.get_value( iter_after, 2, out value);\n var relNode = (JsRender.Node)value.dup_object();\n \n if ( pos > 0 ) {\n \n this.el.insert_after(out n_iter, iter_par , iter_after);\n var ix = parentNode.items.index_of(relNode);\n parentNode.items.insert(ix+1, node);\n \n } else {\n this.el.insert_before(out n_iter, iter_par , iter_after);\n var ix = parentNode.items.index_of(relNode);\n parentNode.items.insert(ix, node);\n \n }\n node.parent = parentNode;\n \n \n \n } else {\n // print(\"appending to \" + parent_str);\n this.el.get_iter(out iter_par, tree_path);\n this.el.append(out n_iter, iter_par );\n expand_parent = this.el.get_path(iter_par);\n \n GLib.Value value;\n this.el.get_value( iter_par, 2, out value);\n parentNode = (JsRender.Node)value.dup_object();\n node.parent = parentNode;\n parentNode.items.add(node);\n }\n \n // reparent node in tree...\n \n \n // why only on no parent???\n \n //if (node.parent = null) {\n \n \n \n //}\n \n \n // work out what kind of packing to use.. -- should be in \n if (!node.has(\"pack\") && parent_str.length > 1) {\n \n _this.main_window.windowstate.file.palete().fillPack(node,parentNode);\n \n \n }\n \n // add the node...\n \n this.el.set(n_iter, 0, node.nodeTitle(), 1, node.nodeTip(), -1 );\n var o = GLib.Value(typeof(Object));\n o.set_object((Object)node);\n \n this.el.set_value(n_iter, 2, o);\n \n \n \n \n// load children - if it has any..\n \n if (node.items.size > 0) {\n this.load(node.items, n_iter);\n _this.view.el.expand_row(this.el.get_path(n_iter), true);\n } else if (expand_parent != null && !_this.view.el.is_row_expanded(expand_parent)) {\n _this.view.el.expand_row(expand_parent,true);\n }\n\n //if (tp != null && (node.items.length() > 0 || pos > 1)) {\n // _this.view.el.expand_row(this.el.get_path(iter_par), true);\n // }\n // wee need to get the empty proptypes from somewhere..\n \n //var olditer = this.activeIter;\n this.activePath = this.el.get_path(n_iter).to_string();\n\n\n \n \n _this.view.el.set_cursor(this.el.get_path(n_iter), null, false);\n _this.changed();\n \n \n \n}\n", + "$ listAllTypes" : "function() {\n var s = this.get('/LeftTree.view').selection;\n print (\"LIST ALL TYPES: \" + s.count_selected_rows() );\n \n if (s.count_selected_rows() > 0) {\n var iter = new Gtk.TreeIter(); \n s.get_selected(this.el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n \n \n var xname = this.get('/LeftTree.model').file.guessName(data);\n console.log('selected:' + xname);\n if (xname.length) {\n return [ xname ];\n }\n return []; // could not find it..\n }\n \n var ret = [ ];\n \n var _this = this;\n function addall(li)\n {\n li.forEach(function(el) {\n // this is specific to roo!!!?\n if (!el) { // skip empty?\n return;\n }\n var fullpath = _this.file.guessName(el);\n if (fullpath.length && ret.indexOf(fullpath) < 0) {\n ret.push(fullpath);\n }\n \n \n if (el.items && el.items.length) {\n addall(el.items);\n }\n \n });\n \n \n }\n \n addall([this.currentTree]);\n \n // only if we have nothing, should we add '*top'\n if (!ret.length) {\n ret = [ '*top' ];\n }\n //console.log('all types in tree');\n //console.dump(ret);\n \n return ret;\n \n}\n", + "| string treePathFromNode" : "(JsRender.Node node) {\n // iterate through the tree and find the node\n var ret = \"\";\n \n this.el.foreach((mod, pth, iter) => {\n // get the node..\n \n \n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n \n\n \n var n = (JsRender.Node)value;\n\n print(\"compare %s to %s\\n\", n.fqn(), node.fqn());\n if (node == n) {\n ret = pth.to_string();\n return true;\n }\n return false;\n });\n return ret;\n\n}\n" + }, + { + "utf8 title" : "test", + "* init" : " this.el.add_attribute(_this.renderer.el , \"markup\", 0 );\n ", + "xtype" : "TreeViewColumn", + "* pack" : "append_column", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "renderer", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + } + ] + } + ] + }, + { + "id" : "LeftTreeMenu", + "xtype" : "Menu", + "* pack" : false, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : " ( ) => {\n \n print(\"ACTIVATE?\");\n \n \n _this.model.deleteSelected();\n}" + }, + "label" : "Delete Element", + "xtype" : "MenuItem", + "* pack" : "add", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " () => {\n\n DialogSaveTemplate.singleton().show(\n (Gtk.Window) _this.el.get_toplevel (), \n _this.main_window.windowstate.file.palete(), \n _this.getActiveElement()\n );\n \n \n}" + }, + "label" : "Save as Template", + "xtype" : "MenuItem", + "* pack" : "add", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " () => {\n var node = _this.getActiveElement();\n var name = DialogSaveModule.singleton().show(\n (Gtk.Window) _this.el.get_toplevel (), \n _this.main_window.windowstate.project, \n node\n );\n if (name.length < 1) {\n return;\n \n }\n node.props.set(\"* xinclude\", name);\n node.items.clear();\n\n\n var s = _this.view.el.get_selection();\n \n print(\"GET SELECTED?\");\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n\n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n Gtk.TreeIter citer;\n var n_cn = mod.iter_n_children(iter) -1;\n for (var i = n_cn; i > -1; i--) {\n mod.iter_nth_child(out citer, iter, i);\n \n\n print(\"removing node from Tree\\n\"); \n \n _this.model.el.remove(ref citer);\n }\n _this.changed();\n _this.node_selected(node, \"tree\");\n \n \n}" + }, + "label" : "Save as Module", + "xtype" : "MenuItem", + "* pack" : "add", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/WindowLeftTree.vala b/src/Builder4/WindowLeftTree.vala new file mode 100644 index 000000000..983284b4f --- /dev/null +++ b/src/Builder4/WindowLeftTree.vala @@ -0,0 +1,1595 @@ +static Xcls_WindowLeftTree _WindowLeftTree; + +public class Xcls_WindowLeftTree : Object +{ + public Gtk.ScrolledWindow el; + private Xcls_WindowLeftTree _this; + + public static Xcls_WindowLeftTree singleton() + { + if (_WindowLeftTree == null) { + _WindowLeftTree= new Xcls_WindowLeftTree(); + } + return _WindowLeftTree; + } + public Xcls_view view; + public Xcls_model model; + public Xcls_renderer renderer; + public Xcls_LeftTreeMenu LeftTreeMenu; + + // my vars (def) + public signal bool before_node_change (); + public signal void changed (); + public signal void node_selected (JsRender.Node? node, string source); + public Xcls_MainWindow main_window; + + // ctor + public Xcls_WindowLeftTree() + { + _this = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + this.main_window = null; + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_LeftTreeMenu( _this ); + child_1.ref(); + + // init method + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + public JsRender.Node? getActiveElement () { // return path to actie node. + + var path = this.getActivePath(); + if (path.length < 1) { + return null; + } + return _this.model.pathToNode(path); + + } + public JsRender.JsRender getActiveFile () { + return this.main_window.windowstate.file; + } + public string getActivePath () { + + var view = this.view.el; + if (view.get_selection().count_selected_rows() < 1) { + return ""; + } + Gtk.TreeIter iter; + Gtk.TreeModel mod; + view.get_selection().get_selected(out mod, out iter); + return mod.get_path(iter).to_string(); + } + public class Xcls_view : Object + { + public Gtk.TreeView el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + public string dragData; + public int drag_x; + public string[] dropList; + public int drag_y; + public string lastEventSource; + public bool drag_in_motion; + public bool blockChanges; + + // ctor + public Xcls_view(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + this.lastEventSource = ""; + this.blockChanges = false; + + // set gobject values + this.el.expand = true; + this.el.tooltip_column = 1; + this.el.enable_tree_lines = true; + this.el.headers_visible = false; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn4( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + { + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.override_font(description); + + var selection = this.el.get_selection(); + selection.set_mode( Gtk.SelectionMode.SINGLE); + + + // is this really needed?? + /* + this.selection.signal['changed'].connect(function() { + _this.get('/LeftTree.view').listeners.cursor_changed.apply( + _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), ''] + ); + }); + */ + Gtk.drag_source_set ( + this.el, /* widget will be drag-able */ + Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */ + BuilderApplication.targetList, /* lists of target to support */ + Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */ + ); + + // ?? needed?? + //Gtk.drag_source_add_text_targets(this.el); + + Gtk.drag_dest_set + ( + this.el, /* widget that will accept a drop */ + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + BuilderApplication.targetList, /* lists of target to support */ + Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */ + ); + + //Gtk.drag_dest_set_target_list(this.el, Builder.Application.targetList); + //Gtk.drag_dest_add_text_targets(this.el); + } + + //listeners + this.el.button_press_event.connect( ( ev) => { + //console.log("button press?"); + this.lastEventSource = "tree"; + if (! _this.before_node_change() ) { + + return true; + } + + + + if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) { + //print("click" + ev.type); + return false; + } + Gtk.TreePath res; + if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) { + return true; + } + + this.el.get_selection().select_path(res); + + //if (!this.get('/LeftTreeMenu').el) { + // this.get('/LeftTreeMenu').init(); + // } + + _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default()); + _this.LeftTreeMenu.el.show_all(); + _this.LeftTreeMenu.el.popup(null, null, null, 3, ev.time); + // print("click:" + res.path.to_string()); + return true; + }); + this.el.drag_begin.connect( ( ctx) => { + //print('SOURCE: drag-begin'); + + + //this.targetData = ""; + + // find what is selected in our tree... + + var s = _this.view.el.get_selection(); + if (s.count_selected_rows() < 1) { + return; + } + Gtk.TreeIter iter; + Gtk.TreeModel mod; + s.get_selected(out mod, out iter); + + + + // set some properties of the tree for use by the dropped element. + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + var tp = mod.get_path(iter).to_string(); + var data = (JsRender.Node)(value.dup_object()); + var xname = data.fqn(); + print ("XNAME IS " + xname+ "\n"); + this.dragData = tp; + this.dropList = _this.main_window.windowstate.file.palete().getDropList(xname); + + print ("DROP LIST IS " + string.joinv(", ", this.dropList) + "\n"); + + + // make the drag icon a picture of the node that was selected + + + // by default returns the path.. + var path = _this.model.el.get_path(iter); + + + var pix = this.el.create_row_drag_icon ( path); + + Gtk.drag_set_icon_surface (ctx, pix) ; + + return; + }); + this.el.cursor_changed.connect( ( ) => { + + + if (this.blockChanges) { // probably not needed.. + return ; + } + if (!_this.before_node_change( ) ) { + this.blockChanges = true; + this.el.get_selection().unselect_all(); + this.blockChanges = false; + return; + } + if (_this.main_window.windowstate.file == null) { + return; + } + + //var render = this.get('/LeftTree').getRenderer(); + print("LEFT TREE -> view -> selection changed called\n"); + + + // -- it appears that the selection is not updated. + + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + + + if (this.el.get_selection().count_selected_rows() < 1) { + + print("selected rows < 1\n"); + //??this.model.load( false); + _this.node_selected(null, this.lastEventSource); + + return false ; + } + + //console.log('changed'); + var s = this.el.get_selection(); + Gtk.TreeIter iter; + Gtk.TreeModel mod; + s.get_selected(out mod, out iter); + + + // var val = ""; + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + _this.model.activePath = mod.get_path(iter).to_string(); + + var node = (JsRender.Node)value.dup_object(); + _this.node_selected(node, this.lastEventSource); + while (Gtk.events_pending()) { + Gtk.main_iteration(); + } + var cp = mod.get_path(iter); + Gtk.TreePath sp, ep; + this.el.get_visible_range(out sp, out ep); + // if sp is before cp then retuns 1. + // if cp is before ep then retuns 1. + if (cp.compare(sp) >= 0 && ep.compare(cp) >=1) { + return false; + } + + + + this.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f); + + return false; + }); + //_this.after_node_change(node); + + // _this.model.file.changed(node, "tree"); + + //Seed.print( value.get_string()); + return ; + + }); + this.el.drag_end.connect( (drag_context) => { + //Seed.print('LEFT-TREE: drag-end'); + this.dragData = ""; + this.dropList = null; + // this.targetData = ""; + this.highlightDropPath("",0); + // return true; + }); + this.el.drag_motion.connect( ( ctx, x, y, time) => { + print("got drag motion\n"); + var src = Gtk.drag_get_source_widget(ctx); + this.drag_x = x; + this.drag_y = y; + + if (src != this.el) { + + + + // the point of this is to detect where an item could be dropped.. + print("requesting drag data\n"); + this.drag_in_motion = true; + + // request data that will be recieved by the recieve... + Gtk.drag_get_data + ( + this.el, // will receive 'drag-data-received' signal + ctx, // represents the current state of the DnD + Gdk.Atom.intern("STRING",true), // the target type we want + time // time stamp + ); + return true; + } + + + print("action: %d\n", ctx.get_actions()); + //print("GETTING POS"); + var targetData = ""; + + Gtk.TreePath path; + Gtk.TreeViewDropPosition pos; + var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos); + + // if there are not items in the tree.. the we have to set isOver to true for anything.. + var isEmpty = false; + if (_this.model.el.iter_n_children(null) < 1) { + print("got NO children?\n"); + isOver = true; //??? + isEmpty = true; + pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER; + } + + + // ------------- a drag from self.. + + + //var action = Gdk.DragAction.COPY; + // unless we are copying!!! ctl button.. + + var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? + Gdk.DragAction.COPY : Gdk.DragAction.MOVE ; + // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ; + + + if (_this.model.el.iter_n_children(null) < 1) { + // no children.. -- asume it's ok.. + + targetData = "|%d|".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER); + + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + Gdk.drag_status(ctx, action ,time); + return true; + + // continue through to allow drop... + + } + + + + + + //print("ISOVER? " + isOver); + if (!isOver) { + + Gdk.drag_status(ctx, 0 ,time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return false; + + } + + // drag node is parent of child.. + //console.log("SRC TREEPATH: " + src.treepath); + //console.log("TARGET TREEPATH: " + data.path.to_string()); + + // nned to check a few here.. + //Gtk.TreeViewDropPosition.INTO_OR_AFTER + //Gtk.TreeViewDropPosition.INTO_OR_BEFORE + //Gtk.TreeViewDropPosition.AFTER + //Gtk.TreeViewDropPosition.BEFORE + + // locally dragged items to not really use the + var selection_text = this.dragData; + + + + if (selection_text == null || selection_text.length < 1) { + //print("Error - drag selection text returned NULL"); + Gdk.drag_status(ctx, 0 ,time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return false; + } + + + // see if we are dragging into ourself? + var target_path = path.to_string(); + print ("Drag %s onto %s--%d\n ", selection_text, target_path, pos); + + // pos : 3 = ontop - 0 = after, 1 = before + //print("target_path="+target_path); + + // + if (selection_text == target_path) { + print("self drag ?? == we should perhaps allow copy onto self..\n"); + + Gdk.drag_status(ctx, 0 ,time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return false; + // -- fixme -- this is not really correct.. + + } + + // check that + //print("DUMPING DATA"); + //console.dump(data); + // path, pos + + //print(data.path.to_string() +' => '+ data.pos); + + // dropList is a list of xtypes that this node could be dropped on. + // it is set up when we start to drag.. + + + targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos); + + print("targetDAta: " + targetData +"\n"); + + if (targetData.length < 1) { + //print("Can not find drop node path"); + + Gdk.drag_status(ctx, 0, time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return false; + } + + var td_ar = targetData.split("|"); + + + + Gdk.drag_status(ctx, action ,time); + this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1])); + return true; + + + }); + this.el.drag_data_get.connect( ( drag_context, data, info, time) => { + + + //print("drag-data-get"); + var s = this.el.get_selection(); + if (s.count_selected_rows() < 1) { + data.set_text("",0); + print("return empty string - no selection.."); + return; + } + + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + s.get_selected(out mod, out iter); + + + + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + var ndata = (JsRender.Node)(value.dup_object()); + + + + var tp = mod.get_path(iter).to_string(); + // by default returns the path.. + + if ( info != Gdk.Atom.intern("STRING",true) ) { + tp = ndata.toJsonString(); + } + + //data.set_text(tp,tp.length); + + data.set (data.get_target (), 8, (uchar[]) tp.to_utf8 ()); + + + // print("return " + tp); + }); + this.el.drag_data_received.connect( (ctx, x, y, sel, info, time) => { + + // THIS CODE ONLY RELATES TO drag or drop of "NEW" elements or "FROM another tree.." + + + // print("Tree: drag-data-received\n"); + var selection_text = (string)sel.get_data(); + //print("selection_text= %s\n",selection_text); + + var is_drag = this.drag_in_motion; + + + + print("Is Drag %s\n", is_drag ? "Y": "N"); + var targetData = ""; + + Gtk.TreePath path; + Gtk.TreeViewDropPosition pos; + var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos); + + // if there are not items in the tree.. the we have to set isOver to true for anything.. + var isEmpty = false; + if (_this.model.el.iter_n_children(null) < 1) { + print("got NO children?\n"); + isOver = true; //??? + isEmpty = true; + pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER; + } + + + //console.log("LEFT-TREE: drag-motion"); + var src = Gtk.drag_get_source_widget(ctx); + + // a drag from self - this should be handled by drop and motion. + if (src == this.el) { + print("Source == this element should not happen.. ? \n"); + return; + } + //print("drag_data_recieved from another element"); + + + + + if (selection_text == null || selection_text.length < 1 || !isOver) { + // nothing valid foudn to drop... + print("empty sel text or not over"); + if (is_drag) { + Gdk.drag_status(ctx, 0, time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return; + } + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + // no drop action... + return; + + } + var dropNode = new JsRender.Node(); + + var dropNodeType = selection_text; + var show_templates = true; + // for drop + if (dropNodeType[0] == '{') { + var pa = new Json.Parser(); + try { + pa.load_from_data(dropNodeType); + } catch (Error e) { + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + // no drop action... + return; + } + + dropNode.loadFromJson( pa.get_root().get_object(), 2); + dropNodeType = dropNode.fqn(); + show_templates = false; + + + } else { + + dropNode.setFqn(selection_text); + } + + + // dropList --- need to gather this ... + print("get dropList for : %s\n",dropNodeType); + var dropList = _this.main_window.windowstate.file.palete().getDropList(dropNodeType); + + print("dropList: %s\n", string.joinv(" , ", dropList)); + + // if drag action is link ... then we can drop it anywahere... + if ((ctx.get_actions() & Gdk.DragAction.LINK) > 0) { + // if path is null?? dragging into an empty tree? + targetData = (path == null ? "" : path.to_string()) + "|%d".printf((int)pos); + } else { + + + targetData = _this.model.findDropNodeByPath( isEmpty ? "" : path.to_string(), dropList, pos); + } + + + + print("targetDAta: " + targetData +"\n"); + + if (targetData.length < 1) { + + // invalid drop path.. + if (this.drag_in_motion) { + Gdk.drag_status(ctx, 0, time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return; + } + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + // no drop action... + return; + } + // valid drop path.. + + var td_ar = targetData.split("|"); + + + if (this.drag_in_motion) { + Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time); + + this.highlightDropPath( td_ar[0] , (Gtk.TreeViewDropPosition)int.parse(td_ar[1])); + return; + } + // continue on to allow drop.. + + + // at this point, drag is not in motion... -- as checked above... - so it's a real drop event.. + + + _this.model.dropNode(targetData, dropNode, show_templates); + print("ADD new node!!!\n"); + + ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node); + + Gtk.drag_finish (ctx, false, false,time); + + + + + + }); + this.el.drag_drop.connect( ( ctx, x, y, time) => { + //Seed.print("TARGET: drag-drop"); + + + var src = Gtk.drag_get_source_widget(ctx); + + if (src != this.el) { + + + + this.drag_in_motion = false; + // request data that will be recieved by the recieve... + Gtk.drag_get_data + ( + this.el, // will receive 'drag-data-received' signal + ctx, // represents the current state of the DnD + Gdk.Atom.intern("application/json",true), // the target type we want + time // time stamp + ); + + + // No target offered by source => error + + + return false; + } + + // handle drop around self.. + + + + //print("GETTING POS"); + var targetData = ""; + + Gtk.TreePath path; + Gtk.TreeViewDropPosition pos; + var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos); + + // if there are not items in the tree.. the we have to set isOver to true for anything.. + var isEmpty = false; + if (_this.model.el.iter_n_children(null) < 1) { + print("got NO children?\n"); + isOver = true; //??? + isEmpty = true; + pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER; + } + + + + //var action = Gdk.DragAction.COPY; + // unless we are copying!!! ctl button.. + + var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? + Gdk.DragAction.COPY : Gdk.DragAction.MOVE ; + // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ; + + + if (_this.model.el.iter_n_children(null) < 1) { + // no children.. -- asume it's ok.. + + targetData = "|%d|".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER); + + // continue through to allow drop... + + } else { + + + + + + //print("ISOVER? " + isOver); + if (!isOver) { + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + return true; // not over apoint!?! - no action on drop or motion.. + } + + // drag node is parent of child.. + //console.log("SRC TREEPATH: " + src.treepath); + //console.log("TARGET TREEPATH: " + data.path.to_string()); + + // nned to check a few here.. + //Gtk.TreeViewDropPosition.INTO_OR_AFTER + //Gtk.TreeViewDropPosition.INTO_OR_BEFORE + //Gtk.TreeViewDropPosition.AFTER + //Gtk.TreeViewDropPosition.BEFORE + + // locally dragged items to not really use the + var selection_text = this.dragData; + + + + if (selection_text == null || selection_text.length < 1) { + //print("Error - drag selection text returned NULL"); + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + return true; /// -- fixme -- this is not really correct.. + } + + // see if we are dragging into ourself? + print ("got selection text of " + selection_text); + + var target_path = path.to_string(); + //print("target_path="+target_path); + + // + if (selection_text == target_path) { + print("self drag ?? == we should perhaps allow copy onto self..\n"); + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + + return true; /// -- fixme -- this is not really correct.. + + } + + // check that + //print("DUMPING DATA"); + //console.dump(data); + // path, pos + + //print(data.path.to_string() +' => '+ data.pos); + + // dropList is a list of xtypes that this node could be dropped on. + // it is set up when we start to drag.. + + + targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos); + + print("targetDAta: " + targetData +"\n"); + + if (targetData.length < 1) { + //print("Can not find drop node path"); + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + return true; + } + + + + // continue on to allow drop.. + } + // at this point, drag is not in motion... -- as checked above... - so it's a real drop event.. + + + var delete_selection_data = false; + + if (action == Gdk.DragAction.ASK) { + /* Ask the user to move or copy, then set the ctx action. */ + } + + if (action == Gdk.DragAction.MOVE) { + delete_selection_data = true; + } + + // drag around.. - reorder.. + _this.model.moveNode(targetData, action); + + + + + + // we can send stuff to souce here... + + + // do we always say failure, so we handle the reall drop? + Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time); + + return true; + + + + + + + }); + } + + // user defined functions + public void highlightDropPath ( string treepath, Gtk.TreeViewDropPosition pos) { + + // highlighting for drag/drop + if (treepath.length > 0) { + this.el.set_drag_dest_row( new Gtk.TreePath.from_string( treepath ), pos); + } else { + this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER); + } + + } + public void setCursor (string treepath, string sourceEvent) { + this.lastEventSource = sourceEvent; + //this.blockChanges = true; << block changes prevents loading of 'node data' and firing of node_selected.. + this.el.set_cursor(new Gtk.TreePath.from_string(treepath), null, false); + // fire node_selected.. + //this.blockChanges = false; + this.lastEventSource = ""; + } + public void selectNode (string treepath_str, string source) { + this.lastEventSource = source; + //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str)); + var tp = new Gtk.TreePath.from_string(treepath_str); + + this.el.set_cursor(tp, null, false); + this.el.scroll_to_cell(tp, null, false, 0,0); + } + } + public class Xcls_model : Object + { + public Gtk.TreeStore el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + public DialogTemplateSelect template_select; + public string activePath; + + // ctor + public Xcls_model(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.TreeStore( 3, typeof(string),typeof(string),typeof(Object) ); + + // my vars (dec) + this.template_select = null; + this.activePath = ""; + + // set gobject values + + // init method + + print("model initialized"); + } + + // user defined functions + public string findDropNode (string treepath_str, string[] targets) { + + // this is used by the dragdrop code in the roo version AFAIR.. + + //var path = treepath_str.replace(/^builder-/, ''); + // treemap is depreciated... - should really check if model has any entries.. + + if (this.el.iter_n_children(null) < 1) { + //print("NO KEYS"); + return "|%d".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER); + } + //print("FIND treepath: " + path); + //console.dump(this.treemap); + + //if (!treepath_str.match(/^builder-/)) { + // return []; // nothing! + //} + if (targets.length > 0 && targets[0] == "*") { + return treepath_str; + } + return this.findDropNodeByPath(treepath_str,targets, -1); + } + public void loadFile (JsRender.JsRender f) { + //console.dump(f); + this.el.clear(); + + // needed??? + _this.main_window.windowstate.file = f; + + + if (f.tree == null) { + try { + f.loadItems( ); + } catch (Error e) { + return; + } + } + // if it's still null? + if (f.tree == null) { + return; + } + + var o = new Gee.ArrayList(); + o.add(f.tree); + this.load(o,null); + + _this.view.el.expand_all(); + + if (f.tree.items.size < 1) { + // single item.. + + //this.get('/Window.leftvpaned').el.set_position(80); + // select first... + _this.view.el.set_cursor( + new Gtk.TreePath.from_string("0"), null, false); + + + } else { + //this.get('/Window.leftvpaned').el.set_position(200); + } + + return; + + + } + public void updateSelected () { + + + var s = _this.view.el.get_selection(); + + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + + + if (!s.get_selected(out mod, out iter)) { + return; // nothing seleted.. + } + + GLib.Value value; + this.el.get_value(iter, 2, out value); + var node = (JsRender.Node)(value.get_object()); + + this.el.set(iter, 0, node.nodeTitle(), + 1, node.nodeTip(), -1 + ); + } + public string findDropNodeByPath (string treepath_str, string[] targets, int in_pref = -1) { + + var path = treepath_str; // dupe it.. + + + // pref : 3 = ontop - 0 = after, 1 = before + int pref = in_pref < 0 ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : in_pref; + + var last = ""; + + //console.dump(this.treemap); + + print("findDropNodeByPath : got path length %d / %s\n", path.length, path); + + if (path.length == 0) { + // top drop. // just return empty.. + return "|%d".printf((int)pref) ; + + } + + + while (path.length > 0) { + + if (path.length == treepath_str.length && pref != Gtk.TreeViewDropPosition.INTO_OR_AFTER) { + if (path.last_index_of(":") < 0 ) { + return ""; + } + path = path.substring(0, path.last_index_of(":")); + last = treepath_str; + print("DROP before or after : using %s\n",path); + continue; + } + + //print("LOOKING FOR PATH: " + path); + var node_data = this.pathToNode(path); + + if (node_data == null) { + print("node not found"); + return ""; + } + + var xname = node_data.fqn(); + var match = ""; + var prop = ""; + + for (var i =0; i < targets.length; i++) { + var tg = targets[i]; + if ((tg == xname) ) { + match = tg; + break; + } + // if target is "xxxx:name" + if (tg.contains(xname +":")) { + match = tg; + var ar = tg.split(":"); + prop = ar[1]; + break; + } + } + + if (match.length > 0) { + if (last.length > 0) { // pref is after/before.. + // then it's after last + //if (pref > 1) { + // return ""; + //} + return last + "|%d".printf((int)pref) + "|" + prop; + + + } + // we need to add prop - as :store -> needs to bee added when dropping onto. + return path + "|%d".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER) + "|" + prop; + } + /* + last = "" + path; + var par = path.split(":"); + string [] ppar = {}; + for (var i = 0; i < par.length-1; i++) { + ppar += par[i]; + } + + path = string.joinv(":", ppar); + */ + break; + + } + + return ""; + + } + public void moveNode (string target_data, Gdk.DragAction action) + { + + /// target_data = "path|pos"); + + + //print("MOVE NODE"); + // console.dump(target_data); + Gtk.TreeIter old_iter; + Gtk.TreeModel mod; + + var s = _this.view.el.get_selection(); + s.get_selected(out mod , out old_iter); + mod.get_path(old_iter); + + var node = this.pathToNode(mod.get_path(old_iter).to_string()); + //console.dump(node); + if (node == null) { + print("moveNode: ERROR - node is null?"); + } + + + + // needs to drop first, otherwise the target_data + // treepath will be invalid. + + + if ((action & Gdk.DragAction.MOVE) > 0) { + print("REMOVING OLD NODE : " + target_data + "\n"); + node.remove(); + this.dropNode(target_data, node, false); + this.el.remove(ref old_iter); + + + + } else { + print("DROPPING NODE // copy: " + target_data + "\n"); + node = node.deepClone(); + this.dropNode(target_data, node, false); + } + _this.changed(); + this.activePath= ""; + //this.updateNode(false,true); + } + public void load (Gee.ArrayList tr, Gtk.TreeIter? iter) + { + Gtk.TreeIter citer; + //this.insert(citer,iter,0); + for(var i =0 ; i < tr.size; i++) { + if (iter != null) { + this.el.insert(out citer,iter,-1); // why not append? + } else { + this.el.append(out citer,null); + } + + this.el.set(citer, 0, tr.get(i).nodeTitle(), + 1, tr.get(i).nodeTip(), -1 + ); + var o = GLib.Value(typeof(Object)); + o.set_object((Object)tr.get(i)); + + this.el.set_value(citer, 2, o); + + if (tr.get(i).items.size > 0) { + this.load(tr.get(i).items, citer); + } + + } + + + } + public void deleteSelected () { + + print("DELETE SELECTED?"); + //_this.view.blockChanges = true; + print("GET SELECTION?"); + + var s = _this.view.el.get_selection(); + + print("GET SELECTED?"); + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + + if (!s.get_selected(out mod, out iter)) { + return; // nothing seleted.. + } + + + + this.activePath= ""; + print("GET vnode value?"); + + GLib.Value value; + this.el.get_value(iter, 2, out value); + var data = (JsRender.Node)(value.get_object()); + print("removing node from Render\n"); + if (data.parent == null) { + _this.main_window.windowstate.file.tree = null; + } else { + data.remove(); + } + print("removing node from Tree\n"); + s.unselect_all(); + this.el.remove(ref iter); + + + + + // + + + + + this.activePath= ""; // again!?!? + //this.changed(null,true); + + _this.changed(); + + _this.view.blockChanges = false; + } + public JsRender.Node pathToNode (string path) { + + + Gtk.TreeIter iter; + _this.model.el.get_iter_from_string(out iter, path); + + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + + return (JsRender.Node)value.dup_object(); + + } + public void dropNode (string target_data_str, JsRender.Node node, bool show_templates) { + // print("drop Node"); + // console.dump(node); + // console.dump(target_data); + + + // 0 = before , 1=after 2/3 onto + + + var target_data= target_data_str.split("|"); + + var parent_str = target_data[0].length > 0 ? target_data[0] : ""; + var pos = target_data.length > 1 ? int.parse(target_data[1]) : 2; // ontop.. + + + Gtk.TreePath tree_path = parent_str.length > 0 ? new Gtk.TreePath.from_string( parent_str ) : null; + + + + //print("add " + tp + "@" + target_data[1] ); + + JsRender.Node parentNode = null; + + Gtk.TreeIter iter_after; + Gtk.TreeIter iter_par ; + + + if (target_data.length == 3 && target_data[2].length > 0) { + node.props.set("* prop", target_data[2]); + } + + Gtk.TreePath expand_parent = null; + + // we only need to show the template if it's come from else where? + if (show_templates) { + + var ts = _this.main_window.windowstate.template_select; + + var new_node = ts.show( + _this.main_window, // (Gtk.Window) _this.el.get_toplevel (), + _this.main_window.windowstate.file.palete(), + node, + _this.main_window.windowstate.project); + + if (new_node == null) { + return; // do not add? + } + node = new_node; + } + + //print("pos is %d \n".printf(pos)); + + Gtk.TreeIter n_iter; + + if ( parent_str.length < 1) { + this.el.append(out n_iter, null); // drop at top level.. + node.parent = null; + _this.main_window.windowstate.file.tree = node; + + + } else if (pos < 2) { + //print(target_data[1] > 0 ? 'insert_after' : 'insert_before'); + + this.el.get_iter(out iter_after, tree_path ); + this.el.iter_parent(out iter_par, iter_after); + expand_parent = this.el.get_path(iter_par); + + GLib.Value value; + this.el.get_value( iter_par, 2, out value); + parentNode = (JsRender.Node)value.dup_object(); + + + this.el.get_value( iter_after, 2, out value); + var relNode = (JsRender.Node)value.dup_object(); + + if ( pos > 0 ) { + + this.el.insert_after(out n_iter, iter_par , iter_after); + var ix = parentNode.items.index_of(relNode); + parentNode.items.insert(ix+1, node); + + } else { + this.el.insert_before(out n_iter, iter_par , iter_after); + var ix = parentNode.items.index_of(relNode); + parentNode.items.insert(ix, node); + + } + node.parent = parentNode; + + + + } else { + // print("appending to " + parent_str); + this.el.get_iter(out iter_par, tree_path); + this.el.append(out n_iter, iter_par ); + expand_parent = this.el.get_path(iter_par); + + GLib.Value value; + this.el.get_value( iter_par, 2, out value); + parentNode = (JsRender.Node)value.dup_object(); + node.parent = parentNode; + parentNode.items.add(node); + } + + // reparent node in tree... + + + // why only on no parent??? + + //if (node.parent = null) { + + + + //} + + + // work out what kind of packing to use.. -- should be in + if (!node.has("pack") && parent_str.length > 1) { + + _this.main_window.windowstate.file.palete().fillPack(node,parentNode); + + + } + + // add the node... + + this.el.set(n_iter, 0, node.nodeTitle(), 1, node.nodeTip(), -1 ); + var o = GLib.Value(typeof(Object)); + o.set_object((Object)node); + + this.el.set_value(n_iter, 2, o); + + + + + // load children - if it has any.. + + if (node.items.size > 0) { + this.load(node.items, n_iter); + _this.view.el.expand_row(this.el.get_path(n_iter), true); + } else if (expand_parent != null && !_this.view.el.is_row_expanded(expand_parent)) { + _this.view.el.expand_row(expand_parent,true); + } + + //if (tp != null && (node.items.length() > 0 || pos > 1)) { + // _this.view.el.expand_row(this.el.get_path(iter_par), true); + // } + // wee need to get the empty proptypes from somewhere.. + + //var olditer = this.activeIter; + this.activePath = this.el.get_path(n_iter).to_string(); + + + + + _this.view.el.set_cursor(this.el.get_path(n_iter), null, false); + _this.changed(); + + + + } + public string treePathFromNode (JsRender.Node node) { + // iterate through the tree and find the node + var ret = ""; + + this.el.foreach((mod, pth, iter) => { + // get the node.. + + + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + + + + var n = (JsRender.Node)value; + + print("compare %s to %s\n", n.fqn(), node.fqn()); + if (node == n) { + ret = pth.to_string(); + return true; + } + return false; + }); + return ret; + + } + } + + public class Xcls_TreeViewColumn4 : Object + { + public Gtk.TreeViewColumn el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn4(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "test"; + var child_0 = new Xcls_renderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + this.el.add_attribute(_this.renderer.el , "markup", 0 ); + } + + // user defined functions + } + public class Xcls_renderer : Object + { + public Gtk.CellRendererText el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_renderer(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.renderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_LeftTreeMenu : Object + { + public Gtk.Menu el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_LeftTreeMenu(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.LeftTreeMenu = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem7( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_MenuItem8( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_MenuItem9( _this ); + child_2.ref(); + this.el.add ( child_2.el ); + } + + // user defined functions + } + public class Xcls_MenuItem7 : Object + { + public Gtk.MenuItem el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem7(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Delete Element"; + + //listeners + this.el.activate.connect( ( ) => { + + print("ACTIVATE?"); + + + _this.model.deleteSelected(); + }); + } + + // user defined functions + } + + public class Xcls_MenuItem8 : Object + { + public Gtk.MenuItem el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem8(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save as Template"; + + //listeners + this.el.activate.connect( () => { + + DialogSaveTemplate.singleton().show( + (Gtk.Window) _this.el.get_toplevel (), + _this.main_window.windowstate.file.palete(), + _this.getActiveElement() + ); + + + }); + } + + // user defined functions + } + + public class Xcls_MenuItem9 : Object + { + public Gtk.MenuItem el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem9(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save as Module"; + + //listeners + this.el.activate.connect( () => { + var node = _this.getActiveElement(); + var name = DialogSaveModule.singleton().show( + (Gtk.Window) _this.el.get_toplevel (), + _this.main_window.windowstate.project, + node + ); + if (name.length < 1) { + return; + + } + node.props.set("* xinclude", name); + node.items.clear(); + + + var s = _this.view.el.get_selection(); + + print("GET SELECTED?"); + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + + if (!s.get_selected(out mod, out iter)) { + return; // nothing seleted.. + } + Gtk.TreeIter citer; + var n_cn = mod.iter_n_children(iter) -1; + for (var i = n_cn; i > -1; i--) { + mod.iter_nth_child(out citer, iter, i); + + + print("removing node from Tree\n"); + + _this.model.el.remove(ref citer); + } + _this.changed(); + _this.node_selected(node, "tree"); + + + }); + } + + // user defined functions + } + + +} diff --git a/src/Builder4/WindowRightPalete.bjs b/src/Builder4/WindowRightPalete.bjs new file mode 100644 index 000000000..ee0957d84 --- /dev/null +++ b/src/Builder4/WindowRightPalete.bjs @@ -0,0 +1,84 @@ +{ + "name" : "WindowRightPalete", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/WindowRightPalete.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "id" : "RightPalete", + "@ void after_node_change(JsRender.Node? node)" : "", + "* pack" : "add", + "xtype" : "Box", + "@ void before_node_change(JsRender.Node? node)" : "", + "| void load" : " (Palete.Palete pal, string cls ) {\n \n // this.get('model').expanded();\n \n var tr = pal.getChildList(cls);\n this.model.el.clear();\n\n\n Gtk.TreeIter citer;\n\n for(var i =0 ; i < tr.length; i++) {\n this.model.el.append(out citer); \n \n this.model.el.set_value(citer, 0, tr[i] ); // title \n \n }\n this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n} \n\n", + "@ void drag_end()" : "", + "$ xns" : "Gtk", + "| void clear" : "() {\n this.model.el.clear();\n} ", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "id" : "viewbox", + "* pack" : "pack_start,true,true,0", + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n this.el.set_size_request(-1,200);\n \n", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* pack" : "pack_start,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_press_event" : " ( event) => {\n\n //\tif (!this.get('/Editor').save()) {\n //\t // popup!! - click handled.. \n// \t return true;\n// }\n return false;\n}", + "drag_begin" : " ( ctx) => {\n // we could fill this in now...\n// Seed.print('SOURCE: drag-begin');\n \n \n \n Gtk.TreeIter iter;\n var s = this.el.get_selection();\n \n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n var path = mod.get_path(iter);\n \n /// pix is a surface..\n var pix = this.el.create_row_drag_icon ( path);\n \n \n Gtk.drag_set_icon_surface (ctx, pix);\n GLib.Value value;\n \n\n _this.model.el.get_value(iter, 0, out value);\n \n this.dragData = (string) value;\n \n \n return;\n}", + "drag_end" : "( drag_context) => {\n \t print(\"SOURCE: drag-end\\n\");\n\t\n\tthis.dragData = \"\";\n\t//this.dropList = null;\n\t_this.drag_end(); // call signal..\n\t//this.get('/LeftTree.view').highlight(false);\n\t \n}", + "drag_data_get" : "(drag_context, selection_data, info, time) => {\n \t//Seed.print('Palete: drag-data-get: ' + target_type);\n if (this.dragData.length < 1 ) {\n return; \n }\n \n print(\"setting drag data to %s\\n\", this.dragData);\n // selection_data.set_text(this.dragData ,this.dragData.length);\n selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());\n\n //this.el.dragData = \"TEST from source widget\";\n \n \n}" + }, + "# string dragData" : "", + "* init" : " {\n this.el.set_size_request(150,-1);\n // set_reorderable: [1]\n \n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.override_font(description);\n \n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n // this.selection.signal['changed'].connect(function() {\n // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);\n //});\n // see: http://live.gnome.org/GnomeLove/DragNDropTutorial\n \n Gtk.drag_source_set (\n this.el, /* widget will be drag-able */\n Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n BuilderApplication.targetList, /* lists of target to support */\n Gdk.DragAction.COPY /* what to do with data after dropped */\n );\n //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);\n \n // Gtk.drag_source_set_target_list(this.el, Application.targetList);\n // Gtk.drag_source_add_text_targets(this.el); \n \n}\n", + "xtype" : "TreeView", + "* pack" : "add", + "$ enable_tree_lines" : true, + "$ headers_visible" : true, + "$ xns" : "Gtk", + "items" : [ + { + "| string getValue" : " (Gtk.TreeIter iter, int col) {\n GLib.Value gval;\n this.el.get_value(iter, col , out gval);\n return (string)gval;\n \n \n}", + "id" : "model", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk" + }, + { + "utf8 title" : "Drag to add Object", + "* init" : " this.el.add_attribute(_this.txtrender.el , \"markup\", 0 );\n \n", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "txtrender", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/WindowRightPalete.vala b/src/Builder4/WindowRightPalete.vala new file mode 100644 index 000000000..046771ab1 --- /dev/null +++ b/src/Builder4/WindowRightPalete.vala @@ -0,0 +1,323 @@ +static Xcls_RightPalete _RightPalete; + +public class Xcls_RightPalete : Object +{ + public Gtk.Box el; + private Xcls_RightPalete _this; + + public static Xcls_RightPalete singleton() + { + if (_RightPalete == null) { + _RightPalete= new Xcls_RightPalete(); + } + return _RightPalete; + } + public Xcls_viewbox viewbox; + public Xcls_model model; + public Xcls_txtrender txtrender; + + // my vars (def) + public signal void after_node_change(JsRender.Node? node) ; + public signal void before_node_change(JsRender.Node? node) ; + public signal void drag_end() ; + + // ctor + public Xcls_RightPalete() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_viewbox( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + public void load (Palete.Palete pal, string cls ) { + + // this.get('model').expanded(); + + var tr = pal.getChildList(cls); + this.model.el.clear(); + + + Gtk.TreeIter citer; + + for(var i =0 ; i < tr.length; i++) { + this.model.el.append(out citer); + + this.model.el.set_value(citer, 0, tr[i] ); // title + + } + this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + public void clear () { + this.model.el.clear(); + } + public class Xcls_viewbox : Object + { + public Gtk.Box el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_viewbox(Xcls_RightPalete _owner ) + { + _this = _owner; + _this.viewbox = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_ScrolledWindow3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow3 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow3(Xcls_RightPalete _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_TreeView4( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + this.el.set_size_request(-1,200); + } + + // user defined functions + } + public class Xcls_TreeView4 : Object + { + public Gtk.TreeView el; + private Xcls_RightPalete _this; + + + // my vars (def) + public string dragData; + + // ctor + public Xcls_TreeView4(Xcls_RightPalete _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.enable_tree_lines = true; + this.el.headers_visible = true; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn6( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + { + this.el.set_size_request(150,-1); + // set_reorderable: [1] + + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.override_font(description); + + var selection = this.el.get_selection(); + selection.set_mode( Gtk.SelectionMode.SINGLE); + // this.selection.signal['changed'].connect(function() { + // _view.listeners['cursor-changed'].apply(_view, [ _view, '']); + //}); + // see: http://live.gnome.org/GnomeLove/DragNDropTutorial + + Gtk.drag_source_set ( + this.el, /* widget will be drag-able */ + Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */ + BuilderApplication.targetList, /* lists of target to support */ + Gdk.DragAction.COPY /* what to do with data after dropped */ + ); + //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList); + + // Gtk.drag_source_set_target_list(this.el, Application.targetList); + // Gtk.drag_source_add_text_targets(this.el); + + } + + //listeners + this.el.button_press_event.connect( ( event) => { + + // if (!this.get('/Editor').save()) { + // // popup!! - click handled.. + // return true; + // } + return false; + }); + this.el.drag_begin.connect( ( ctx) => { + // we could fill this in now... + // Seed.print('SOURCE: drag-begin'); + + + + Gtk.TreeIter iter; + var s = this.el.get_selection(); + + Gtk.TreeModel mod; + s.get_selected(out mod, out iter); + var path = mod.get_path(iter); + + /// pix is a surface.. + var pix = this.el.create_row_drag_icon ( path); + + + Gtk.drag_set_icon_surface (ctx, pix); + GLib.Value value; + + + _this.model.el.get_value(iter, 0, out value); + + this.dragData = (string) value; + + + return; + }); + this.el.drag_end.connect( ( drag_context) => { + print("SOURCE: drag-end\n"); + + this.dragData = ""; + //this.dropList = null; + _this.drag_end(); // call signal.. + //this.get('/LeftTree.view').highlight(false); + + }); + this.el.drag_data_get.connect( (drag_context, selection_data, info, time) => { + //Seed.print('Palete: drag-data-get: ' + target_type); + if (this.dragData.length < 1 ) { + return; + } + + print("setting drag data to %s\n", this.dragData); + // selection_data.set_text(this.dragData ,this.dragData.length); + selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ()); + + //this.el.dragData = "TEST from source widget"; + + + }); + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_RightPalete _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public string getValue (Gtk.TreeIter iter, int col) { + GLib.Value gval; + this.el.get_value(iter, col , out gval); + return (string)gval; + + + } + } + + public class Xcls_TreeViewColumn6 : Object + { + public Gtk.TreeViewColumn el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn6(Xcls_RightPalete _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Drag to add Object"; + var child_0 = new Xcls_txtrender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + this.el.add_attribute(_this.txtrender.el , "markup", 0 ); + } + + // user defined functions + } + public class Xcls_txtrender : Object + { + public Gtk.CellRendererText el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_txtrender(Xcls_RightPalete _owner ) + { + _this = _owner; + _this.txtrender = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + + +} diff --git a/src/Builder4/WindowRooView.bjs b/src/Builder4/WindowRooView.bjs new file mode 100644 index 000000000..ffd62616d --- /dev/null +++ b/src/Builder4/WindowRooView.bjs @@ -0,0 +1,206 @@ +{ + "name" : "WindowRooView", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/WindowRooView.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "builder", + "items" : [ + { + "| void scroll_to_line" : "(int line) {\n this.notebook.el.page = 1;// code preview...\n \n GLib.Timeout.add(500, () => {\n \n \n\t \n\t \n\t\t var buf = this.sourceview.el.get_buffer();\n\t \n\t\tvar sbuf = (Gtk.SourceBuffer) buf;\n\n\n\t\tGtk.TextIter iter; \n\t\tsbuf.get_iter_at_line(out iter, line);\n\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t\treturn false;\n\t}); \n\n \n}\n", + "id" : "WindowRooView", + "# Gtk.Widget lastObj" : "null", + "| void createThumb" : "() {\n \n \n if (this.file == null) {\n return;\n }\n\tif (this.notebook.el.page > 0 ) {\n return;\n }\n \n var filename = this.file.getIconFileName(false);\n \n var win = this.el.get_parent_window();\n var width = win.get_width();\n // var height = win.get_height();\n try { \n Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.paned.el.position);\n screenshot.save(filename,\"png\");\n } catch(Error e) {\n //noop\n }\n\n \n \n \n \n}\n", + "| void loadFile" : "\n(JsRender.JsRender file)\n{\n this.file = file;\n this.view.renderJS(true);\n this.notebook.el.page = 0;// gtk preview \n this.sourceview.loadFile(); \n \n}\n \n ", + "int width" : 0, + "bool hexpand" : true, + "| int search" : "(string txt) {\n\tthis.notebook.el.page = 1;\n \tvar s = new Gtk.SourceSearchSettings();\n\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();\n\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);\n\tthis.searchcontext.set_highlight(true);\n\ts.set_search_text(txt);\n\t\n\tGtk.TextIter beg, st,en;\n\t \n\tbuf.get_start_iter(out beg);\n\tthis.searchcontext.forward(beg, out st, out en);\n\tthis.last_search_end = 0;\n\treturn this.searchcontext.get_occurrences_count();\n\n \n}\n", + "int last_search_end" : 0, + "xtype" : "Box", + "Gtk.SourceSearchContext searchcontext" : "", + "# JsRender.JsRender file" : "null", + "int height" : 0, + "| void requestRedraw" : "() {\n this.view.renderJS(false);\n this.sourceview.loadFile(); \n}", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "# Xcls_MainWindow main_window" : "", + "| void forwardSearch" : "(bool change_focus) {\n\n\tif (this.searchcontext == null) {\n\t\treturn;\n\t}\n\tthis.notebook.el.page = 1;\n\tGtk.TextIter beg, st,en, stl;\n\t\n\tvar buf = this.sourceview.el.get_buffer();\n\tbuf.get_iter_at_offset(out beg, this.last_search_end);\n\tif (!this.searchcontext.forward(beg, out st, out en)) {\n\t\tthis.last_search_end = 0;\n\t} else { \n\t\tthis.last_search_end = en.get_offset();\n\t\tif (change_focus) {\n\t\t\tthis.sourceview.el.grab_focus();\n\t\t}\n\t\tbuf.place_cursor(st);\n\t\tvar ln = st.get_line();\n\t\tbuf.get_iter_at_line(out stl,ln);\n\t\t \n\t\tthis.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);\n\t}\n\n}\n", + "items" : [ + { + "id" : "notebook", + "xtype" : "Notebook", + "* pack" : "pack_start,true,true,0", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "label_preview", + "xtype" : "Label", + "* pack" : false, + "$ xns" : "Gtk", + "utf8 label" : "Preview" + }, + { + "id" : "label_code", + "* pack" : false, + "xtype" : "Label", + "$ xns" : "Gtk", + "utf8 label" : "Preview Generated Code" + }, + { + "id" : "paned", + "xtype" : "Paned", + "* pack" : "add", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "items" : [ + { + "id" : "viewbox", + "xtype" : "Box", + "* pack" : "pack1,true,true", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "$ homogeneous" : false, + "items" : [ + { + "$ vexpand" : false, + "* pack" : "pack_start,false,true,0", + "$ height_request" : 20, + "xtype" : "Box", + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "$ homogeneous" : true, + "items" : [ + { + "listeners" : { + "clicked" : "( ) => {\n _this.view.renderJS( true);\n}" + }, + "label" : "Redraw", + "* pack" : "pack_start,false,false,0", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "toggled" : " (state) => {\n this.el.set_label(this.el.active ? \"Auto Redraw On\" : \"Auto Redraw Off\");\n}" + }, + "label" : "Auto Redraw On", + "id" : "AutoRedraw", + "$ active" : true, + "* pack" : "pack_start,false,false,0", + "xtype" : "CheckButton", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "clicked" : " () => {\n _this.view.redraws = 99;\n _this.view.el.web_context.clear_cache(); \n //_this.view.renderJS(true);\n FakeServerCache.clear();\n _this.view.reInit();\n\n}" + }, + "label" : "Full Redraw", + "* pack" : "pack_start,false,false,0", + "xtype" : "Button", + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "viewcontainer", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "* pack" : "pack_end,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "script_dialog" : " (dialog) => {\n if (this.el == null) {\n return true;\n }\n \n var msg = dialog.get_message();\n if (msg.length < 4) {\n return false;\n }\n if (msg.substring(0,4) != \"IPC:\") {\n return false;\n }\n var ar = msg.split(\":\", 3);\n if (ar.length < 3) {\n return false;\n }\n switch(ar[1]) {\n case \"SAVEHTML\":\n _this.file.saveHTML(ar[2]);\n return true;\n default:\n return false;\n }\n \n}", + "show" : " ( ) => {\n this.initInspector();;\n}", + "drag_drop" : " ( ctx, x, y,time, ud) => {\n return false;\n /*\n\tprint(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n w, // will receive 'drag-data-received' signal \n ctx, /* represents the current state of the DnD \n this.get('/Window').atoms[\"STRING\"], /* the target type we want \n time /* time stamp \n );\n \n \n /* No target offered by source => error \n \n\n\treturn is_valid_drop_site;\n\t*/\n}", + "load_changed" : "(le) => {\n if (le != WebKit.LoadEvent.FINISHED) {\n return;\n }\n if (this.runjs.length < 1) {\n return;\n }\n // this.el.run_javascript(this.runjs, null);\n FakeServerCache.remove( this.runjs);\n this.runjs = \"\";\n}" + }, + "# string renderedData" : "\"\"", + "id" : "view", + "# bool refreshRequired" : false, + "* init" : " {\n // this may not work!?\n var settings = this.el.get_settings();\n settings.enable_developer_extras = true;\n \n \n var fs= new FakeServer(this.el);\n fs.ref();\n // this was an attempt to change the url perms.. did not work..\n // settings.enable_file_access_from_file_uris = true;\n // settings.enable_offline_web_application_cache - true;\n // settings.enable_universal_access_from_file_uris = true;\n \n \n \n \n \n\n // FIXME - base url of script..\n // we need it so some of the database features work.\n this.el.load_html( \"Render not ready\" , \n //fixme - should be a config option!\n // or should we catch stuff and fix it up..\n \"http://localhost/app.Builder/\"\n );\n \n \n //this.el.open('file:///' + __script_path__ + '/../builder.html');\n /*\n Gtk.drag_dest_set\n (\n this.el, //\n Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n null, // list of targets\n Gdk.DragAction.COPY // what to do with data after dropped \n );\n \n // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);\n Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n */\n GLib.Timeout.add_seconds(1, () =>{\n //print(\"run refresh?\");\n if (this.el == null) {\n return false;\n }\n this.runRefresh(); \n return true;\n });\n \n \n}\n", + "| void reInit" : "() {\n print(\"reInit?\");\n // if this happens destroy the webkit..\n // recreate it..\n this.el.stop_loading();\n \n if (_this.viewbox.el.get_parent() == null) {\n return;\n }\n \n \n _this.viewbox.el.remove(_this.viewcontainer.el);\n _this.paned.el.remove(_this.inspectorcontainer.el); \n \n // destory seems to cause problems.\n //this.el.destroy();\n //_this.viewcontainer.el.destroy();\n //_this.inspectorcontainer.el.destroy();\n var inv =new Xcls_inspectorcontainer(_this);\n inv.ref();\n _this.paned.el.pack2(inv.el,true,true);\n \n \n this.el = null; \n var nv =new Xcls_viewcontainer(_this);\n nv.ref();\n _this.viewbox.el.pack_end(nv.el,true,true,0);\n \n \n inv.el.show_all();\n nv.el.show_all();\n //while(Gtk.events_pending ()) Gtk.main_iteration ();\n //_this.view.renderJS(true); \n _this.view.refreshRequired = true;\n}\n", + "* pack" : "add", + "redraws" : 0, + "xtype" : "WebView", + "# WebKit.WebInspector inspector" : "", + "# string runjs" : "\"\"", + "# int redraws" : 0, + "| void runRefresh" : " () \n{\n // this is run every 2 seconds from the init..\n\n \n \n if (!this.refreshRequired) {\n // print(\"no refresh required\");\n return;\n }\n\n if (this.lastRedraw != null) {\n // do not redraw if last redraw was less that 5 seconds ago.\n if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {\n return;\n }\n }\n \n if (_this.file == null) {\n return;\n }\n \n \n this.refreshRequired = false;\n // print(\"HTML RENDERING\");\n \n \n //this.get('/BottomPane').el.show();\n //this.get('/BottomPane').el.set_current_page(2);// webkit inspector\n _this.file.webkit_page_id = this.el.get_page_id();\n \n var js = _this.file.toSourcePreview();\n\n if (js.length < 1) {\n print(\"no data\");\n return;\n }\n// var data = js[0];\n this.redraws++;\n \n var project = _this.file.project; \n\n //print (project.fn);\n // set it to non-empty.\n \n// runhtml = runhtml.length ? runhtml : ''; \n\n\n// this.runhtml = this.runhtml || '';\n \n \n // then we need to reload the browser using\n // load_html_string..\n\n // then trigger a redraw once it's loaded..\n this.pendingRedraw = true;\n\n var runhtml = \"\\n\" ;\n\n // fix to make sure they are the same..\n this.runhtml = project.runhtml;\n // need to modify paths\n\n string inhtml;\n var base_template = _this.file.project.base_template;\n \n if (base_template.length > 0 && !FileUtils.test(\n BuilderApplication.configDirectory() + \"/resources/\" + base_template, FileTest.EXISTS) \n ) {\n print(\"invalid base_template name - using default: %s\\n\", base_template);\n base_template = \"\";\n \n }\n try {\n GLib.FileUtils.get_contents(\n BuilderApplication.configDirectory() + \"/resources/\" + \n (base_template.length > 0 ? base_template : \"roo.builder.html\")\n , out inhtml);\n \n } catch (Error e) {\n inhtml = \"\";\n } \n this.renderedData = js;\n\n\n string js_src = js + \"\\n\" +\n\t\"Roo.onReady(function() {\\n\" +\n\t\"if (\" + _this.file.name +\".show) \" + _this.file.name +\".show({});\\n\" +\n\t\"Roo.XComponent.build();\\n\" +\n\t\"});\\n\";\n\t\n // print(\"render js: \" + js);\n //if (!this.ready) {\n // console.log('not loaded yet');\n //}\n this.lastRedraw = new DateTime.now_local();\n\n\n //this.runjs = js_src;\n var fc = FakeServerCache.factory_with_data(js_src);\n this.runjs = fc.fname;\n \n var html = inhtml.replace(\"\", runhtml + this.runhtml + \n \"\" + \n // \"\" + \n \n \"\");\n //print(\"LOAD HTML \" + html);\n \n var rootURL = _this.file.project.rootURL;\n \n \n \n this.el.load_html( html , \n //fixme - should be a config option!\n (rootURL.length > 0 ? rootURL : \"xhttp://localhost/app.Builder.js/\")\n );\n \n // force the inspector... \n // this.initInspector();\n \n // - no need for this, the builder javascript will call it when build is complete\n //GLib.Timeout.add_seconds(1, () => {\n // this.el.run_javascript(\"Builder.saveHTML()\",null);\n // return false;\n //});\n// print( \"before render\" + this.lastRedraw);\n// print( \"after render\" + (new Date()));\n \n}\n ", + "$ xns" : "WebKit", + "| void initInspector" : "() {\n \n /* if (this.inspector == this.el.get_inspector()) {\n this.inspector.show();\n this.inspector.open_window(); \n print(\"init inspecter called, and inspector is the same as existing\\n\");\n return;\n }\n print(\"new inspector?\\n\");\n*/\n this.inspector = this.el.get_inspector();\n this.inspector.ref();\n \n // got a new inspector...\n \n this.inspector.open_window.connect(() => {\n this.inspector = this.el.get_inspector();\n print(\"inspector attach\\n\");\n var wv = this.inspector.get_web_view();\n if (wv != null) {\n print(\"got inspector web view\\n\");\n \n var cn = _this.inspectorcontainer.el.get_child();\n if (cn != null) {\n _this.inspectorcontainer.el.remove(cn);\n }\n \n _this.inspectorcontainer.el.add(wv);\n wv.show();\n } else {\n //this.inspector.close();\n \n //this.inspector = null;\n \n \n }\n return true;\n \n });\n /*\n this.inspector.closed.connect(() => {\n print(\"inspector closed?!?\");\n // if this happens destroy the webkit..\n // recreate it..\n this.el.stop_loading();\n \n if (_this.viewbox.el.get_parent() == null) {\n return;\n }\n \n \n _this.viewbox.el.remove(_this.viewcontainer.el);\n _this.el.remove(_this.inspectorcontainer.el); \n \n // destory seems to cause problems.\n //this.el.destroy();\n //_this.viewcontainer.el.destroy();\n //_this.inspectorcontainer.el.destroy();\n\n this.el = null; \n var nv =new Xcls_viewcontainer(_this);\n nv.ref();\n _this.viewbox.el.pack_end(nv.el,true,true,0);\n \n var inv =new Xcls_inspectorcontainer(_this);\n inv.ref();\n _this.el.pack2(inv.el,true,true);\n \n inv.el.show_all();\n nv.el.show_all();\n //while(Gtk.events_pending ()) Gtk.main_iteration ();\n //_this.view.renderJS(true); \n _this.view.refreshRequired = true;\n \n }); \n */\n \n this.inspector.show();\n}\n", + "# GLib.DateTime lastRedraw" : "null", + "# string runhtml" : "\"\"", + "# bool pendingRedraw" : false, + "| void renderJS" : "(bool force) {\n\n // this is the public redraw call..\n // we refresh in a loop privately..\n var autodraw = _this.AutoRedraw.el.active;\n if (!autodraw && !force) {\n print(\"Skipping redraw - no force, and autodraw off\");\n return;\n }\n \n this.refreshRequired = true;\n}\n" + } + ] + } + ] + }, + { + "id" : "inspectorcontainer", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "xtype" : "ScrolledWindow", + "* pack" : "pack2,true,true", + "$ xns" : "Gtk" + } + ] + }, + { + "xtype" : "ScrolledWindow", + "* pack" : "append_page,_this.label_code.el", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_release_event" : "() => {\n\tthis.onCursorChanged();\n\n\treturn false;\n}", + "key_press_event" : "() => {\n\tthis.onCursorChanged();\n\treturn false; \n}" + }, + "gboolean show_line_marks" : true, + "| void onCursorChanged" : "(/*ParamSpec ps*/) {\n\t if (this.loading) {\n return;\n }\n // if (ps.name != \"cursor-position\") {\n // return;\n // }\n\n var buf = this.el.get_buffer();\n print(\"cursor changed : %d\\n\", buf.cursor_position);\n Gtk.TextIter cpos;\n buf.get_iter_at_offset(out cpos, buf.cursor_position);\n \n var ln = cpos.get_line();\n\t\tprint(\"cursor changed line : %d\\n\", ln);\n var node = _this.file.lineToNode(ln+1);\n \n if (node == null) {\n print(\"can not find node\\n\");\n return;\n }\n var prop = node.lineToProp(ln+1);\n print(\"prop : %s\", prop == null ? \"???\" : prop);\n \n \n \n \n // ---------- this selects the tree's node...\n \n var ltree = _this.main_window.windowstate.left_tree;\n var tp = ltree.model.treePathFromNode(node);\n print(\"got tree path %s\\n\", tp);\n if (tp != \"\") {\n\t this.allow_node_scroll = false; /// block node scrolling..\n\t \n\t \n\t //print(\"changing cursor on tree..\\n\");\n\t \n \n \n // let's try allowing editing on the methods.\n // a little klunky at present..\n this.prop_selected = \"\";\n if (prop != null) {\n \t\t//see if we can find it..\n \t\tvar kv = prop.split(\":\");\n \t\tif (kv[0] == \"p\") {\n \t\t\n\t \t\t//var k = prop.get_key(kv[1]);\n\t \t\t// fixme -- need to determine if it's an editable property...\n\t \t\tthis.prop_selected = prop;\n\t \t\t\n \t\t} else if (kv[0] == \"l\") {\n \t\t\t this.prop_selected = prop;\n \t\t\t\n \t\t}\n }\n ltree.view.setCursor(tp, \"editor\");\n // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); \n this.nodeSelected(node,false);\n \n // scrolling is disabled... as node selection calls scroll 10ms after it changes.\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n\t this.allow_node_scroll = true;\n\t return false;\n });\n }\n \n // highlight the node..\n}\n ", + "id" : "sourceview", + "| void clearGreySelection" : "() {\n // clear all the marks..\n var sbuf = (Gtk.SourceBuffer)this.el.buffer;\n \n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, \"grey\");\n \n \n}\n", + "* init" : "{\n \n var description = Pango.FontDescription.from_string(\"monospace\");\n description.set_size(8000);\n this.el.override_font(description);\n\n this.loading = true;\n //var buf = this.el.get_buffer();\n //buf.notify.connect(this.onCursorChanged);\n \n \n \n var attrs = new Gtk.SourceMarkAttributes();\n var pink = Gdk.RGBA();\n pink.parse ( \"pink\");\n attrs.set_background ( pink);\n attrs.set_icon_name ( \"process-stop\"); \n attrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"ERR\", attrs, 1);\n \n var wattrs = new Gtk.SourceMarkAttributes();\n var blue = Gdk.RGBA();\n blue.parse ( \"#ABF4EB\");\n wattrs.set_background ( blue);\n wattrs.set_icon_name ( \"process-stop\"); \n wattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"WARN\", wattrs, 1);\n \n \n \n var dattrs = new Gtk.SourceMarkAttributes();\n var purple = Gdk.RGBA();\n purple.parse ( \"#EEA9FF\");\n dattrs.set_background ( purple);\n dattrs.set_icon_name ( \"process-stop\"); \n dattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"DEPR\", dattrs, 1);\n \n \n var gattrs = new Gtk.SourceMarkAttributes();\n var grey = Gdk.RGBA();\n grey.parse ( \"#ccc\");\n gattrs.set_background ( grey);\n \n \n this.el.set_mark_attributes (\"grey\", gattrs, 1);\n \n \n \n \n \n \n}\n ", + "| void nodeSelected" : "(JsRender.Node? sel, bool scroll ) {\n \n \n\t\n // this is connected in widnowstate\n\n\n\t// not sure why.... \n while(Gtk.events_pending()) {\n Gtk.main_iteration();\n }\n \n this.node_selected = sel;\n \n this.updateGreySelection(scroll);\n \n \n \n}\n\n \n", + "bool loading" : true, + "| string toString" : "() {\n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_buffer().get_start_iter(out s);\n this.el.get_buffer().get_end_iter(out e);\n var ret = this.el.get_buffer().get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n", + "| void loadFile" : "( ) {\n this.loading = true;\n \n \n // get the cursor and scroll position....\n var buf = this.el.get_buffer();\n\tvar cpos = buf.cursor_position;\n \n print(\"BEFORE LOAD cursor = %d\\n\", cpos);\n \n var vadj_pos = this.el.get_vadjustment().get_value();\n \n \n \n buf.set_text(\"\",0);\n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n\n if (_this.file == null || _this.file.xtype != \"Roo\") {\n print(\"xtype != Roo\");\n this.loading = false;\n return;\n }\n \n // get the string from the rendered tree...\n \n var str = _this.file.toSource();\n \n// print(\"setting str %d\\n\", str.length);\n buf.set_text(str, str.length);\n var lm = Gtk.SourceLanguageManager.get_default();\n \n //?? is javascript going to work as js?\n \n ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));\n \n \n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, null); // remove all marks..\n \n GLib.Timeout.add(500, () => {\n\n print(\"RESORTING cursor to = %d\\n\", cpos);\n\t\tGtk.TextIter cpos_iter;\n\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);\n\t\tbuf.place_cursor(cpos_iter); \n\t\t\n\t\tthis.el.get_vadjustment().set_value(vadj_pos);;\n\t\t\n\n\t\tthis.onCursorChanged();\n\t\t\n\t\t\n\t\t_this.buffer.checkSyntax();\n\t\treturn false;\n\t});\n\t\t\n this.loading = false; \n _this.buffer.dirty = false;\n}\n", + "* pack" : "add", + "xtype" : "SourceView", + "bool allow_node_scroll" : true, + "$ string prop_selected" : "\"\"", + "| void updateGreySelection" : "(bool scroll) { \n\tvar sel = this.node_selected;\n\tprint(\"node selected\\n\");\n var buf = this.el.get_buffer();\n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n this.clearGreySelection();\n \n \n \n if (sel == null) {\n\t print(\"no selected node\\n\");\n // no highlighting..\n return;\n }\n \n print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);\n Gtk.TextIter iter; \n sbuf.get_iter_at_line(out iter, sel.line_start);\n \n \n Gtk.TextIter cur_iter;\n sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);\n \n var cursor_at_line = cur_iter.get_line();\n \n \n //var cur_line = cur_iter.get_line();\n //if (cur_line > sel.line_start && cur_line < sel.line_end) {\n \n //} else {\n if (scroll) {\n\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");\n \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t}\n \n var start_line = sel.line_start;\n var end_line = sel.line_end;\n \n \n this.el.editable = false;\n \n var colon_pos = 0;\n \n // now if we have selected a property...\n if (this.prop_selected.length> 0 ) {\n\n\t\tint nstart, nend;\n\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {\n\t\t\tstart_line = nstart;\n\t\t\tend_line = nend;\n\t\t\tthis.el.editable = true;\n\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);\n\t\t\t\n\t\t\t\t// see if we are 'right of ':'\n\t\t\t\t// get an iter for the start of the line.\n\t\t\tGtk.TextIter start_line_iter,end_line_iter;\n\t\t\tthis.el.buffer.get_iter_at_line(out start_line_iter, start_line -1);\n\t\t\tthis.el.buffer.get_iter_at_line(out end_line_iter, start_line -1);\n\t\t\t \n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif (end_line_iter.forward_to_line_end()) {\n\t\t\t\tvar first_line = this.el.buffer.get_text(start_line_iter, end_line_iter, false);\n\t\t\t\tprint(\"first line = %s\\n\", first_line);\n\t\t\t\tif (first_line.contains(\":\")) {\n\t\t\t\t\tcolon_pos = start_line_iter.get_offset() + first_line.index_of(\":\") + 1;\n\t\t\t\t}\n\t\t\t\tprint(\"colon_pos = %d\\n\", colon_pos);\n\t\t\t}\n\t\t\tprint(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);\n\t\t\tif (start_line - 1 == cursor_at_line) {\n\t\t\t\tprint(\"cursor is on current line.\\n\");\n\t\t\t\tvar before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);\n\t\t\t\tprint(\"before cursor string = %s\\n\", before_cursor_string);\n\t\t\t\tif (!before_cursor_string.contains(\":\")) {\n\t\t\t\t\tthis.el.editable = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t\n\t\t\n\t\t\n }\n \n\tprint(\"checking selection\\n\");\n \n \n // check selection - if it's out of 'bounds'\n if (this.el.editable && sbuf.get_has_selection()) {\n\t\tGtk.TextIter sel_start_iter, sel_end_iter;\n\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);\n\t\t\n\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||\n\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {\n\t\t\t// save?\n\t\t\tthis.el.editable = false;\n\t\t}\n\t\tif (colon_pos > 0 &&\n\t\t\t(sel_start_iter.get_offset() < colon_pos || sel_end_iter.get_offset() < colon_pos)\n\t\t\t\n\t\t) {\n\t\t\tthis.el.editable = false;\n\t\t}\n\t\t\n\t\t \n \n }\n \n \n \n \n for (var i = 0; i < buf.get_line_count();i++) {\n if (i < (start_line -1) || i > (end_line -1)) {\n \n sbuf.get_iter_at_line(out iter, i);\n sbuf.create_source_mark(null, \"grey\", iter);\n \n }\n \n }\n if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {\n\t Gtk.TextIter cpos_iter;\n\t\tbuf.get_iter_at_line(out cpos_iter, start_line);\n\t\t\n\t\tbuf.place_cursor(cpos_iter); \n\t}\n\n\n}", + "| void highlightErrorsJson" : " (string type, Json.Object obj) {\n // this is a hook for the vala code - it has no value in javascript \n // as we only have one error ususally....\n return ;\n \n \n\n\n}", + "JsRender.Node? node_selected" : "null", + "$ xns" : "Gtk", + "gboolean show_line_numbers" : true, + "gboolean editable" : false, + "items" : [ + { + "listeners" : { + "changed" : " () => {\n // check syntax??\n // ??needed..??\n // _this.save_button.el.sensitive = true;\n ///?? has changed occured during loading?\n if (_this.sourceview.loading) {\n\t\treturn;\n\t}\n\t\n print(\"- PREVIEW EDITOR CHANGED--\");\n\n this.dirty = true; \n if (!this.checkSyntax()) {\n\t\treturn;\n\t}\t\t\n \n // what are we editing??\n \n\n\n\n\n return ;\n}\n\n \n" + }, + "bool dirty" : false, + "int error_line" : "-1", + "id" : "buffer", + "| bool highlightErrors" : "( Gee.HashMap validate_res) {\n \n this.error_line = validate_res.size;\n\t\n if (this.error_line < 1) {\n return true;\n }\n var tlines = this.el.get_line_count ();\n Gtk.TextIter iter;\n var valiter = validate_res.map_iterator();\n while (valiter.next()) {\n \n// print(\"get inter\\n\");\n var eline = valiter.get_key();\n if (eline > tlines) {\n continue;\n }\n this.el.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);\n } \n return false;\n}", + "| string toString" : " () {\n \n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_start_iter(out s);\n this.el.get_end_iter(out e);\n var ret = this.el.get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n ", + "| bool checkSyntax" : " () {\n \n \n var str = this.toString();\n \n // needed???\n if (this.error_line > 0) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n this.el.get_bounds (out start, out end);\n\n this.el.remove_source_marks (start, end, null);\n }\n \n if (str.length < 1) {\n print(\"checkSyntax - empty string?\\n\");\n return false;\n }\n \n if (_this.file == null) {\n return false;\n }\n var p = Palete.factory(_this.file.xtype); // returns Roo | Gtk | PlainFile \n \n \n if (_this.file.language != \"js\") {\n\t\treturn false; // fake syntax error.\n\t}\n\t\n //Gee.HashMap ret_x;\n\n\treturn p.javascriptHasErrors(\n\t\t_this.main_window.windowstate,\n str, \n \"\", // _this.key, \n \"file\", //_this.ptype,\n _this.file, \n null\n ); \n \n}\n", + "* pack" : "set_buffer", + "xtype" : "SourceBuffer", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/Builder4/WindowRooView.vala b/src/Builder4/WindowRooView.vala new file mode 100644 index 000000000..ecddd4deb --- /dev/null +++ b/src/Builder4/WindowRooView.vala @@ -0,0 +1,1490 @@ +static Xcls_WindowRooView _WindowRooView; + +public class Xcls_WindowRooView : Object +{ + public Gtk.Box el; + private Xcls_WindowRooView _this; + + public static Xcls_WindowRooView singleton() + { + if (_WindowRooView == null) { + _WindowRooView= new Xcls_WindowRooView(); + } + return _WindowRooView; + } + public Xcls_notebook notebook; + public Xcls_label_preview label_preview; + public Xcls_label_code label_code; + public Xcls_paned paned; + public Xcls_viewbox viewbox; + public Xcls_AutoRedraw AutoRedraw; + public Xcls_viewcontainer viewcontainer; + public Xcls_view view; + public Xcls_inspectorcontainer inspectorcontainer; + public Xcls_sourceview sourceview; + public Xcls_buffer buffer; + + // my vars (def) + public Gtk.Widget lastObj; + public int width; + public int last_search_end; + public Gtk.SourceSearchContext searchcontext; + public JsRender.JsRender file; + public int height; + public Xcls_MainWindow main_window; + + // ctor + public Xcls_WindowRooView() + { + _this = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + this.lastObj = null; + this.width = 0; + this.last_search_end = 0; + this.file = null; + this.height = 0; + + // set gobject values + this.el.hexpand = true; + var child_0 = new Xcls_notebook( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + public void scroll_to_line (int line) { + this.notebook.el.page = 1;// code preview... + + GLib.Timeout.add(500, () => { + + + + + var buf = this.sourceview.el.get_buffer(); + + var sbuf = (Gtk.SourceBuffer) buf; + + + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, line); + this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + return false; + }); + + + } + public void createThumb () { + + + if (this.file == null) { + return; + } + if (this.notebook.el.page > 0 ) { + return; + } + + var filename = this.file.getIconFileName(false); + + var win = this.el.get_parent_window(); + var width = win.get_width(); + // var height = win.get_height(); + try { + Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.paned.el.position); + screenshot.save(filename,"png"); + } catch(Error e) { + //noop + } + + + + + + } + public void loadFile (JsRender.JsRender file) + { + this.file = file; + this.view.renderJS(true); + this.notebook.el.page = 0;// gtk preview + this.sourceview.loadFile(); + + } + public int search (string txt) { + this.notebook.el.page = 1; + var s = new Gtk.SourceSearchSettings(); + var buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer(); + this.searchcontext = new Gtk.SourceSearchContext(buf,s); + this.searchcontext.set_highlight(true); + s.set_search_text(txt); + + Gtk.TextIter beg, st,en; + + buf.get_start_iter(out beg); + this.searchcontext.forward(beg, out st, out en); + this.last_search_end = 0; + return this.searchcontext.get_occurrences_count(); + + + } + public void requestRedraw () { + this.view.renderJS(false); + this.sourceview.loadFile(); + } + public void forwardSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + this.notebook.el.page = 1; + Gtk.TextIter beg, st,en, stl; + + var buf = this.sourceview.el.get_buffer(); + buf.get_iter_at_offset(out beg, this.last_search_end); + if (!this.searchcontext.forward(beg, out st, out en)) { + this.last_search_end = 0; + } else { + this.last_search_end = en.get_offset(); + if (change_focus) { + this.sourceview.el.grab_focus(); + } + buf.place_cursor(st); + var ln = st.get_line(); + buf.get_iter_at_line(out stl,ln); + + this.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f); + } + + } + public class Xcls_notebook : Object + { + public Gtk.Notebook el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_notebook(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.notebook = this; + this.el = new Gtk.Notebook(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_label_preview( _this ); + child_0.ref(); + var child_1 = new Xcls_label_code( _this ); + child_1.ref(); + var child_2 = new Xcls_paned( _this ); + child_2.ref(); + this.el.add ( child_2.el ); + var child_3 = new Xcls_ScrolledWindow14( _this ); + child_3.ref(); + this.el.append_page ( child_3.el , _this.label_code.el ); + } + + // user defined functions + } + public class Xcls_label_preview : Object + { + public Gtk.Label el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_label_preview(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.label_preview = this; + this.el = new Gtk.Label( "Preview" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_label_code : Object + { + public Gtk.Label el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_label_code(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.label_code = this; + this.el = new Gtk.Label( "Preview Generated Code" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_paned : Object + { + public Gtk.Paned el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_paned(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.paned = this; + this.el = new Gtk.Paned( Gtk.Orientation.VERTICAL ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_viewbox( _this ); + child_0.ref(); + this.el.pack1 ( child_0.el , true,true ); + var child_1 = new Xcls_inspectorcontainer( _this ); + child_1.ref(); + this.el.pack2 ( child_1.el , true,true ); + } + + // user defined functions + } + public class Xcls_viewbox : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_viewbox(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.viewbox = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + var child_0 = new Xcls_Box7( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,0 ); + var child_1 = new Xcls_viewcontainer( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_Box7 : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Box7(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = true; + this.el.height_request = 20; + this.el.vexpand = false; + var child_0 = new Xcls_Button8( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_AutoRedraw( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_Button10( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , false,false,0 ); + } + + // user defined functions + } + public class Xcls_Button8 : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Button8(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Redraw"; + + //listeners + this.el.clicked.connect( ( ) => { + _this.view.renderJS( true); + }); + } + + // user defined functions + } + + public class Xcls_AutoRedraw : Object + { + public Gtk.CheckButton el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_AutoRedraw(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.AutoRedraw = this; + this.el = new Gtk.CheckButton(); + + // my vars (dec) + + // set gobject values + this.el.active = true; + this.el.label = "Auto Redraw On"; + + //listeners + this.el.toggled.connect( (state) => { + this.el.set_label(this.el.active ? "Auto Redraw On" : "Auto Redraw Off"); + }); + } + + // user defined functions + } + + public class Xcls_Button10 : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Button10(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Full Redraw"; + + //listeners + this.el.clicked.connect( () => { + _this.view.redraws = 99; + _this.view.el.web_context.clear_cache(); + //_this.view.renderJS(true); + FakeServerCache.clear(); + _this.view.reInit(); + + }); + } + + // user defined functions + } + + + public class Xcls_viewcontainer : Object + { + public Gtk.ScrolledWindow el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_viewcontainer(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.viewcontainer = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + } + public class Xcls_view : Object + { + public WebKit.WebView el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public string renderedData; + public bool refreshRequired; + public WebKit.WebInspector inspector; + public string runjs; + public int redraws; + public GLib.DateTime lastRedraw; + public string runhtml; + public bool pendingRedraw; + + // ctor + public Xcls_view(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.view = this; + this.el = new WebKit.WebView(); + + // my vars (dec) + this.renderedData = ""; + this.refreshRequired = false; + this.runjs = ""; + this.redraws = 0; + this.lastRedraw = null; + this.runhtml = ""; + this.pendingRedraw = false; + + // set gobject values + + // init method + + { + // this may not work!? + var settings = this.el.get_settings(); + settings.enable_developer_extras = true; + + + var fs= new FakeServer(this.el); + fs.ref(); + // this was an attempt to change the url perms.. did not work.. + // settings.enable_file_access_from_file_uris = true; + // settings.enable_offline_web_application_cache - true; + // settings.enable_universal_access_from_file_uris = true; + + + + + + + // FIXME - base url of script.. + // we need it so some of the database features work. + this.el.load_html( "Render not ready" , + //fixme - should be a config option! + // or should we catch stuff and fix it up.. + "http://localhost/app.Builder/" + ); + + + //this.el.open('file:///' + __script_path__ + '/../builder.html'); + /* + Gtk.drag_dest_set + ( + this.el, // + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + null, // list of targets + Gdk.DragAction.COPY // what to do with data after dropped + ); + + // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); + Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + */ + GLib.Timeout.add_seconds(1, () =>{ + //print("run refresh?"); + if (this.el == null) { + return false; + } + this.runRefresh(); + return true; + }); + + + } + + //listeners + this.el.script_dialog.connect( (dialog) => { + if (this.el == null) { + return true; + } + + var msg = dialog.get_message(); + if (msg.length < 4) { + return false; + } + if (msg.substring(0,4) != "IPC:") { + return false; + } + var ar = msg.split(":", 3); + if (ar.length < 3) { + return false; + } + switch(ar[1]) { + case "SAVEHTML": + _this.file.saveHTML(ar[2]); + return true; + default: + return false; + } + + }); + this.el.show.connect( ( ) => { + this.initInspector();; + }); + this.el.drag_drop.connect( ( ctx, x, y,time, ud) => { + return false; + /* + print("TARGET: drag-drop"); + var is_valid_drop_site = true; + + + Gtk.drag_get_data + ( + w, // will receive 'drag-data-received' signal + ctx, /* represents the current state of the DnD + this.get('/Window').atoms["STRING"], /* the target type we want + time /* time stamp + ); + + + /* No target offered by source => error + + + return is_valid_drop_site; + */ + }); + this.el.load_changed.connect( (le) => { + if (le != WebKit.LoadEvent.FINISHED) { + return; + } + if (this.runjs.length < 1) { + return; + } + // this.el.run_javascript(this.runjs, null); + FakeServerCache.remove( this.runjs); + this.runjs = ""; + }); + } + + // user defined functions + public void reInit () { + print("reInit?"); + // if this happens destroy the webkit.. + // recreate it.. + this.el.stop_loading(); + + if (_this.viewbox.el.get_parent() == null) { + return; + } + + + _this.viewbox.el.remove(_this.viewcontainer.el); + _this.paned.el.remove(_this.inspectorcontainer.el); + + // destory seems to cause problems. + //this.el.destroy(); + //_this.viewcontainer.el.destroy(); + //_this.inspectorcontainer.el.destroy(); + var inv =new Xcls_inspectorcontainer(_this); + inv.ref(); + _this.paned.el.pack2(inv.el,true,true); + + + this.el = null; + var nv =new Xcls_viewcontainer(_this); + nv.ref(); + _this.viewbox.el.pack_end(nv.el,true,true,0); + + + inv.el.show_all(); + nv.el.show_all(); + //while(Gtk.events_pending ()) Gtk.main_iteration (); + //_this.view.renderJS(true); + _this.view.refreshRequired = true; + } + public void runRefresh () + { + // this is run every 2 seconds from the init.. + + + + if (!this.refreshRequired) { + // print("no refresh required"); + return; + } + + if (this.lastRedraw != null) { + // do not redraw if last redraw was less that 5 seconds ago. + if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) { + return; + } + } + + if (_this.file == null) { + return; + } + + + this.refreshRequired = false; + // print("HTML RENDERING"); + + + //this.get('/BottomPane').el.show(); + //this.get('/BottomPane').el.set_current_page(2);// webkit inspector + _this.file.webkit_page_id = this.el.get_page_id(); + + var js = _this.file.toSourcePreview(); + + if (js.length < 1) { + print("no data"); + return; + } + // var data = js[0]; + this.redraws++; + + var project = _this.file.project; + + //print (project.fn); + // set it to non-empty. + + // runhtml = runhtml.length ? runhtml : ''; + + + // this.runhtml = this.runhtml || ''; + + + // then we need to reload the browser using + // load_html_string.. + + // then trigger a redraw once it's loaded.. + this.pendingRedraw = true; + + var runhtml = "\n" ; + + // fix to make sure they are the same.. + this.runhtml = project.runhtml; + // need to modify paths + + string inhtml; + var base_template = _this.file.project.base_template; + + if (base_template.length > 0 && !FileUtils.test( + BuilderApplication.configDirectory() + "/resources/" + base_template, FileTest.EXISTS) + ) { + print("invalid base_template name - using default: %s\n", base_template); + base_template = ""; + + } + try { + GLib.FileUtils.get_contents( + BuilderApplication.configDirectory() + "/resources/" + + (base_template.length > 0 ? base_template : "roo.builder.html") + , out inhtml); + + } catch (Error e) { + inhtml = ""; + } + this.renderedData = js; + + + string js_src = js + "\n" + + "Roo.onReady(function() {\n" + + "if (" + _this.file.name +".show) " + _this.file.name +".show({});\n" + + "Roo.XComponent.build();\n" + + "});\n"; + + // print("render js: " + js); + //if (!this.ready) { + // console.log('not loaded yet'); + //} + this.lastRedraw = new DateTime.now_local(); + + + //this.runjs = js_src; + var fc = FakeServerCache.factory_with_data(js_src); + this.runjs = fc.fname; + + var html = inhtml.replace("", runhtml + this.runhtml + + "" + + // "" + + + ""); + //print("LOAD HTML " + html); + + var rootURL = _this.file.project.rootURL; + + + + this.el.load_html( html , + //fixme - should be a config option! + (rootURL.length > 0 ? rootURL : "xhttp://localhost/app.Builder.js/") + ); + + // force the inspector... + // this.initInspector(); + + // - no need for this, the builder javascript will call it when build is complete + //GLib.Timeout.add_seconds(1, () => { + // this.el.run_javascript("Builder.saveHTML()",null); + // return false; + //}); + // print( "before render" + this.lastRedraw); + // print( "after render" + (new Date())); + + } + public void initInspector () { + + /* if (this.inspector == this.el.get_inspector()) { + this.inspector.show(); + this.inspector.open_window(); + print("init inspecter called, and inspector is the same as existing\n"); + return; + } + print("new inspector?\n"); + */ + this.inspector = this.el.get_inspector(); + this.inspector.ref(); + + // got a new inspector... + + this.inspector.open_window.connect(() => { + this.inspector = this.el.get_inspector(); + print("inspector attach\n"); + var wv = this.inspector.get_web_view(); + if (wv != null) { + print("got inspector web view\n"); + + var cn = _this.inspectorcontainer.el.get_child(); + if (cn != null) { + _this.inspectorcontainer.el.remove(cn); + } + + _this.inspectorcontainer.el.add(wv); + wv.show(); + } else { + //this.inspector.close(); + + //this.inspector = null; + + + } + return true; + + }); + /* + this.inspector.closed.connect(() => { + print("inspector closed?!?"); + // if this happens destroy the webkit.. + // recreate it.. + this.el.stop_loading(); + + if (_this.viewbox.el.get_parent() == null) { + return; + } + + + _this.viewbox.el.remove(_this.viewcontainer.el); + _this.el.remove(_this.inspectorcontainer.el); + + // destory seems to cause problems. + //this.el.destroy(); + //_this.viewcontainer.el.destroy(); + //_this.inspectorcontainer.el.destroy(); + + this.el = null; + var nv =new Xcls_viewcontainer(_this); + nv.ref(); + _this.viewbox.el.pack_end(nv.el,true,true,0); + + var inv =new Xcls_inspectorcontainer(_this); + inv.ref(); + _this.el.pack2(inv.el,true,true); + + inv.el.show_all(); + nv.el.show_all(); + //while(Gtk.events_pending ()) Gtk.main_iteration (); + //_this.view.renderJS(true); + _this.view.refreshRequired = true; + + }); + */ + + this.inspector.show(); + } + public void renderJS (bool force) { + + // this is the public redraw call.. + // we refresh in a loop privately.. + var autodraw = _this.AutoRedraw.el.active; + if (!autodraw && !force) { + print("Skipping redraw - no force, and autodraw off"); + return; + } + + this.refreshRequired = true; + } + } + + + + public class Xcls_inspectorcontainer : Object + { + public Gtk.ScrolledWindow el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_inspectorcontainer(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.inspectorcontainer = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + } + + + public class Xcls_ScrolledWindow14 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow14(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_sourceview( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_sourceview : Object + { + public Gtk.SourceView el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public bool loading; + public bool allow_node_scroll; + public string prop_selected; + public JsRender.Node? node_selected; + + // ctor + public Xcls_sourceview(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.sourceview = this; + this.el = new Gtk.SourceView(); + + // my vars (dec) + this.loading = true; + this.allow_node_scroll = true; + this.prop_selected = ""; + this.node_selected = null; + + // set gobject values + this.el.editable = false; + this.el.show_line_marks = true; + this.el.show_line_numbers = true; + var child_0 = new Xcls_buffer( _this ); + child_0.ref(); + this.el.set_buffer ( child_0.el ); + + // init method + + { + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(8000); + this.el.override_font(description); + + this.loading = true; + //var buf = this.el.get_buffer(); + //buf.notify.connect(this.onCursorChanged); + + + + var attrs = new Gtk.SourceMarkAttributes(); + var pink = Gdk.RGBA(); + pink.parse ( "pink"); + attrs.set_background ( pink); + attrs.set_icon_name ( "process-stop"); + attrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("ERR", attrs, 1); + + var wattrs = new Gtk.SourceMarkAttributes(); + var blue = Gdk.RGBA(); + blue.parse ( "#ABF4EB"); + wattrs.set_background ( blue); + wattrs.set_icon_name ( "process-stop"); + wattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("WARN", wattrs, 1); + + + + var dattrs = new Gtk.SourceMarkAttributes(); + var purple = Gdk.RGBA(); + purple.parse ( "#EEA9FF"); + dattrs.set_background ( purple); + dattrs.set_icon_name ( "process-stop"); + dattrs.query_tooltip_text.connect(( mark) => { + //print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("DEPR", dattrs, 1); + + + var gattrs = new Gtk.SourceMarkAttributes(); + var grey = Gdk.RGBA(); + grey.parse ( "#ccc"); + gattrs.set_background ( grey); + + + this.el.set_mark_attributes ("grey", gattrs, 1); + + + + + + + } + + //listeners + this.el.button_release_event.connect( () => { + this.onCursorChanged(); + + return false; + }); + this.el.key_press_event.connect( () => { + this.onCursorChanged(); + return false; + }); + } + + // user defined functions + public void onCursorChanged (/*ParamSpec ps*/) { + if (this.loading) { + return; + } + // if (ps.name != "cursor-position") { + // return; + // } + + var buf = this.el.get_buffer(); + print("cursor changed : %d\n", buf.cursor_position); + Gtk.TextIter cpos; + buf.get_iter_at_offset(out cpos, buf.cursor_position); + + var ln = cpos.get_line(); + print("cursor changed line : %d\n", ln); + var node = _this.file.lineToNode(ln+1); + + if (node == null) { + print("can not find node\n"); + return; + } + var prop = node.lineToProp(ln+1); + print("prop : %s", prop == null ? "???" : prop); + + + + + // ---------- this selects the tree's node... + + var ltree = _this.main_window.windowstate.left_tree; + var tp = ltree.model.treePathFromNode(node); + print("got tree path %s\n", tp); + if (tp != "") { + this.allow_node_scroll = false; /// block node scrolling.. + + + //print("changing cursor on tree..\n"); + + + + // let's try allowing editing on the methods. + // a little klunky at present.. + this.prop_selected = ""; + if (prop != null) { + //see if we can find it.. + var kv = prop.split(":"); + if (kv[0] == "p") { + + //var k = prop.get_key(kv[1]); + // fixme -- need to determine if it's an editable property... + this.prop_selected = prop; + + } else if (kv[0] == "l") { + this.prop_selected = prop; + + } + } + ltree.view.setCursor(tp, "editor"); + // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); + this.nodeSelected(node,false); + + // scrolling is disabled... as node selection calls scroll 10ms after it changes. + GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { + this.allow_node_scroll = true; + return false; + }); + } + + // highlight the node.. + } + public void clearGreySelection () { + // clear all the marks.. + var sbuf = (Gtk.SourceBuffer)this.el.buffer; + + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, "grey"); + + + } + public void nodeSelected (JsRender.Node? sel, bool scroll ) { + + + + // this is connected in widnowstate + + + // not sure why.... + while(Gtk.events_pending()) { + Gtk.main_iteration(); + } + + this.node_selected = sel; + + this.updateGreySelection(scroll); + + + + } + public string toString () { + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_buffer().get_start_iter(out s); + this.el.get_buffer().get_end_iter(out e); + var ret = this.el.get_buffer().get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + public void loadFile ( ) { + this.loading = true; + + + // get the cursor and scroll position.... + var buf = this.el.get_buffer(); + var cpos = buf.cursor_position; + + print("BEFORE LOAD cursor = %d\n", cpos); + + var vadj_pos = this.el.get_vadjustment().get_value(); + + + + buf.set_text("",0); + var sbuf = (Gtk.SourceBuffer) buf; + + + + if (_this.file == null || _this.file.xtype != "Roo") { + print("xtype != Roo"); + this.loading = false; + return; + } + + // get the string from the rendered tree... + + var str = _this.file.toSource(); + + // print("setting str %d\n", str.length); + buf.set_text(str, str.length); + var lm = Gtk.SourceLanguageManager.get_default(); + + //?? is javascript going to work as js? + + ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language)); + + + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, null); // remove all marks.. + + GLib.Timeout.add(500, () => { + + print("RESORTING cursor to = %d\n", cpos); + Gtk.TextIter cpos_iter; + buf.get_iter_at_offset(out cpos_iter, cpos); + buf.place_cursor(cpos_iter); + + this.el.get_vadjustment().set_value(vadj_pos);; + + + this.onCursorChanged(); + + + _this.buffer.checkSyntax(); + return false; + }); + + this.loading = false; + _this.buffer.dirty = false; + } + public void updateGreySelection (bool scroll) { + var sel = this.node_selected; + print("node selected\n"); + var buf = this.el.get_buffer(); + var sbuf = (Gtk.SourceBuffer) buf; + + + this.clearGreySelection(); + + + + if (sel == null) { + print("no selected node\n"); + // no highlighting.. + return; + } + + print("highlight region %d to %d\n", sel.line_start,sel.line_end); + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, sel.line_start); + + + Gtk.TextIter cur_iter; + sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position); + + var cursor_at_line = cur_iter.get_line(); + + + //var cur_line = cur_iter.get_line(); + //if (cur_line > sel.line_start && cur_line < sel.line_end) { + + //} else { + if (scroll) { + print("scrolling to node -- should occur on node picking.\n"); + this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + } + + var start_line = sel.line_start; + var end_line = sel.line_end; + + + this.el.editable = false; + + var colon_pos = 0; + + // now if we have selected a property... + if (this.prop_selected.length> 0 ) { + + int nstart, nend; + if (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) { + start_line = nstart; + end_line = nend; + this.el.editable = true; + print("start line = %d, end line = %d\n", start_line, end_line); + + // see if we are 'right of ':' + // get an iter for the start of the line. + Gtk.TextIter start_line_iter,end_line_iter; + this.el.buffer.get_iter_at_line(out start_line_iter, start_line -1); + this.el.buffer.get_iter_at_line(out end_line_iter, start_line -1); + + + + + if (end_line_iter.forward_to_line_end()) { + var first_line = this.el.buffer.get_text(start_line_iter, end_line_iter, false); + print("first line = %s\n", first_line); + if (first_line.contains(":")) { + colon_pos = start_line_iter.get_offset() + first_line.index_of(":") + 1; + } + print("colon_pos = %d\n", colon_pos); + } + print("is cursor at line? %d ?= %d\n", start_line -1 , cursor_at_line); + if (start_line - 1 == cursor_at_line) { + print("cursor is on current line.\n"); + var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false); + print("before cursor string = %s\n", before_cursor_string); + if (!before_cursor_string.contains(":")) { + this.el.editable = false; + } + + } + + + } + print("propSelected = %s range %d -> %d\n", this.prop_selected, start_line, end_line); + + + } + + print("checking selection\n"); + + + // check selection - if it's out of 'bounds' + if (this.el.editable && sbuf.get_has_selection()) { + Gtk.TextIter sel_start_iter, sel_end_iter; + sbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter); + + if (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line || + sel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line ) { + // save? + this.el.editable = false; + } + if (colon_pos > 0 && + (sel_start_iter.get_offset() < colon_pos || sel_end_iter.get_offset() < colon_pos) + + ) { + this.el.editable = false; + } + + + + } + + + + + for (var i = 0; i < buf.get_line_count();i++) { + if (i < (start_line -1) || i > (end_line -1)) { + + sbuf.get_iter_at_line(out iter, i); + sbuf.create_source_mark(null, "grey", iter); + + } + + } + if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) { + Gtk.TextIter cpos_iter; + buf.get_iter_at_line(out cpos_iter, start_line); + + buf.place_cursor(cpos_iter); + } + + + } + public void highlightErrorsJson (string type, Json.Object obj) { + // this is a hook for the vala code - it has no value in javascript + // as we only have one error ususally.... + return ; + + + + + } + } + public class Xcls_buffer : Object + { + public Gtk.SourceBuffer el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public bool dirty; + public int error_line; + + // ctor + public Xcls_buffer(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.buffer = this; + this.el = new Gtk.SourceBuffer( null ); + + // my vars (dec) + this.dirty = false; + this.error_line = -1; + + // set gobject values + + //listeners + this.el.changed.connect( () => { + // check syntax?? + // ??needed..?? + // _this.save_button.el.sensitive = true; + ///?? has changed occured during loading? + if (_this.sourceview.loading) { + return; + } + + print("- PREVIEW EDITOR CHANGED--"); + + this.dirty = true; + if (!this.checkSyntax()) { + return; + } + + // what are we editing?? + + + + + + return ; + }); + } + + // user defined functions + public bool highlightErrors ( Gee.HashMap validate_res) { + + this.error_line = validate_res.size; + + if (this.error_line < 1) { + return true; + } + var tlines = this.el.get_line_count (); + Gtk.TextIter iter; + var valiter = validate_res.map_iterator(); + while (valiter.next()) { + + // print("get inter\n"); + var eline = valiter.get_key(); + if (eline > tlines) { + continue; + } + this.el.get_iter_at_line( out iter, eline); + //print("mark line\n"); + this.el.create_source_mark(valiter.get_value(), "ERR", iter); + } + return false; + } + public string toString () { + + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_start_iter(out s); + this.el.get_end_iter(out e); + var ret = this.el.get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + public bool checkSyntax () { + + + var str = this.toString(); + + // needed??? + if (this.error_line > 0) { + Gtk.TextIter start; + Gtk.TextIter end; + this.el.get_bounds (out start, out end); + + this.el.remove_source_marks (start, end, null); + } + + if (str.length < 1) { + print("checkSyntax - empty string?\n"); + return false; + } + + if (_this.file == null) { + return false; + } + var p = Palete.factory(_this.file.xtype); // returns Roo | Gtk | PlainFile + + + if (_this.file.language != "js") { + return false; // fake syntax error. + } + + //Gee.HashMap ret_x; + + return p.javascriptHasErrors( + _this.main_window.windowstate, + str, + "", // _this.key, + "file", //_this.ptype, + _this.file, + null + ); + + } + } + + + + +} diff --git a/src/Builder4/WindowState.vala b/src/Builder4/WindowState.vala new file mode 100644 index 000000000..b9b7ee6d0 --- /dev/null +++ b/src/Builder4/WindowState.vala @@ -0,0 +1,1217 @@ +/** + * as state management is a bit too complicated inside the builder + * it's better to seperate this into this class + * + * This class has references to all the Class instances that make up the window.. + * + */ +public class WindowState : Object +{ + public Xcls_MainWindow win; + + public enum State { + NONE, + PREVIEW, + OBJECT, + PROP, + LISTENER, + CODE, // code editor. + CODEONLY, + FILES, + PROJECT, // project settings.. + FILEPROJECT, // project when in file mode + PROJECTCODEONLY // when editing code... + } + + public State state = State.NONE; + + public bool children_loaded = false; + + + public Project.Project project; + public JsRender.JsRender file; + + + public Xcls_WindowLeftTree left_tree; + public Xcls_WindowAddProp add_props; + public Xcls_LeftProps left_props; + public Xcls_ProjectSettings projectsettings; + public ValaProjectSettings vala_projectsettings; + public Xcls_RightPalete rightpalete; + public Editor code_editor; + public Xcls_WindowRooView window_rooview; + public Xcls_GtkView window_gladeview; + + public Xcls_ClutterFiles clutterfiles; + + public Xcls_WindowLeftProjects left_projects; // can not see where this is initialized.. + + public DialogTemplateSelect template_select; + + public Xcls_PopoverFileDetails file_details; + + + public Xcls_ValaCompileResults compile_results; + + // dialogs?? + public Xcls_DialogPluginWebkit webkit_plugin; + + + public Palete.ValaSource valasource; // the spawner that runs the vala compiler. + public Json.Object last_compile_result; + + // ctor + public WindowState(Xcls_MainWindow win) + { + this.win = win; + // initialize + + // left elements.. + this.leftTreeInit(); + this.propsListInit(); + + // on clutter space... + this.projectEditInit(); + this.codeEditInit(); + this.projectListInit(); + this.fileViewInit(); + + // adding stuff + this.objectAddInit(); + this.propsAddInit(); + + + // previews... + this.gtkViewInit(); + this.webkitViewInit(); + + // dialogs + + this.fileDetailsInit(); + + this.webkit_plugin = new Xcls_DialogPluginWebkit(); + this.template_select = new DialogTemplateSelect(); + this.children_loaded = true; + + + this.valasource = new Palete.ValaSource(); + this.valasource.compiled.connect(this.showCompileResult); + + this.compile_results = new Xcls_ValaCompileResults(); + this.compile_results.window = this.win; + this.valasource.compile_output.connect(this.compile_results.addLine); + + this.win.statusbar_compilestatus_label.el.hide(); + this.win.statusbar_run.el.hide(); + this.win.search_results.el.hide(); + } + + + // left tree + + public void leftTreeInit() + { + + this.left_tree = new Xcls_WindowLeftTree(); + this.left_tree.ref(); + this.left_tree.main_window = this.win; + + this.win.tree.el.pack_start(this.left_tree.el,true, true,0); + this.left_tree.el.show_all(); + + this.left_tree.before_node_change.connect(() => { + // if the node change is caused by the editor (code preview) + if (this.left_tree.view.lastEventSource == "editor") { + return true; + } + return this.leftTreeBeforeChange(); + + }); + + this.left_tree.node_selected.connect((sel, source) => { + if (source == "editor") { + return; + } + if (this.file.xtype == "Roo") { + this.window_rooview.sourceview.nodeSelected(sel,true); // foce scroll. + } else { + this.window_gladeview.sourceview.nodeSelected(sel); + } + }); + + this.left_tree.node_selected.connect((sel, source) => { + this.leftTreeNodeSelected(sel, source); + }); + + this.left_tree.changed.connect(() => { + print("LEFT TREE: Changed fired\n"); + this.file.save(); + if (this.left_tree.getActiveFile().xtype == "Roo" ) { + this.window_rooview.requestRedraw(); + } else { + this.window_gladeview.loadFile(this.left_tree.getActiveFile()); + } + + }); + + } + + public bool leftTreeBeforeChange() + { + if (this.state != State.CODE) { + this.left_props.finish_editing(); + return true; + } + if (!this.code_editor.saveContents()) { + return false; + } + return false; + } + + public void leftTreeNodeSelected(JsRender.Node? sel, string source) + { + + print("node_selected called %s\n", (sel == null) ? "NULL" : "a value"); + + if (sel == null) { + this.left_props.el.hide(); + } + this.left_props.el.show(); + this.left_props.load(this.left_tree.getActiveFile(), sel); + switch (this.state) { + + case State.OBJECT: + + if (sel == null) { + this.rightpalete.clear(); + break; + } + this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn()); + break; + + + case State.PROP: + if (sel == null) { + this.add_props.clear(); + break; + } + this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn()); + break; + + case State.LISTENER: + + if (sel == null) { + this.add_props.clear(); + break; + } + this.add_props.show(this.left_tree.getActiveFile().palete(), "signals", sel.fqn()); + break; + + case State.CODE: + this.switchState(State.PREVIEW); + + break; + + + } + + + } + + + + + public void propsListInit() + { + + this.left_props =new Xcls_LeftProps(); + this.left_props.ref(); + this.left_props.main_window = this.win; + this.win.props.el.pack_start(this.left_props.el,true, true,0); + this.left_props.el.show_all(); + + this.left_props.show_editor.connect( (file, node, type, key) => { + this.switchState(State.CODE); + this.code_editor.show( + file, + node, + type, + key + ); + + + }); + + + this.left_props.stop_editor.connect( () => { + if (this.state != State.CODE) { + return true; + } + + var ret = this.code_editor.saveContents(); + if (!ret) { + return false; + } + this.switchState(State.PREVIEW); + return ret; + }); + + this.left_props.changed.connect(() => { + if (this.left_tree.getActiveFile().xtype == "Roo" ) { + this.window_rooview.requestRedraw(); + } else { + this.window_gladeview.loadFile(this.left_tree.getActiveFile()); + } + this.left_tree.model.updateSelected(); + this.file.save(); + if (this.file.xtype=="Gtk") { + this.valasource.checkFileSpawn(this.file); + } + }); + + + + } + + //------------- projects edit + + public void projectEditInit() + { + this.projectsettings =new Xcls_ProjectSettings(); + this.projectsettings.ref(); /// really? + + this.vala_projectsettings =new ValaProjectSettings(); + this.vala_projectsettings.ref(); + this.vala_projectsettings.window = this.win; + + ((Gtk.Container)(this.win.projecteditview.el.get_widget())).add(this.projectsettings.el); + //this.projectsettings.el.show_all(); + + var stage = this.win.projecteditview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + + this.projectsettings.buttonPressed.connect((btn) => { + if (this.left_tree.getActiveFile().xtype == "Roo" ) { + if (btn == "save") { + this.window_rooview.view.renderJS(true); + } + if (btn == "apply") { + this.window_rooview.view.renderJS(true); + return; + } + } else { + // do nothing for gtk.. + } + if (btn == "save" || btn == "apply") { + this.win.project.save(); + + } + this.switchState (State.PREVIEW); + + }); + + } + // ----------- object adding + public void objectAddInit() + { + + this.rightpalete = new Xcls_RightPalete(); + this.rightpalete.ref(); /// really? + ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el); + //this.projectsettings.el.show_all(); + + var stage = this.win.objectview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + + } + + // ----------- properties adding list... + // listener uses the properties + public void propsAddInit() + { + // Add properties + this.add_props = new Xcls_WindowAddProp(); + this.add_props.ref(); /// really? + ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el); + //this.projectsettings.el.show_all(); + + var stage = this.win.addpropsview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + + + this.add_props.select.connect( (key,type,skel, etype) => { + this.left_props.addProp(etype, key, skel, type); + }); + + } + public void propsAddShow() + { + + } + public void propsAddHide() + { + + } + + + + + // ----------- Add / Edit listener + // listener uses the properties + //public void listenerInit() { } + public void listenerShow() + { + + } + public void listenerHide() + { + + } + + // -------------- codeEditor + + public void codeEditInit() + { + this.code_editor = new Editor(); + //this.code_editor.ref(); /// really? + ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el); + + this.code_editor.window = this.win; + //this.projectsettings.el.show_all(); + + var stage = this.win.codeeditview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + // editor.save... + + this.code_editor.save.connect( () => { + this.file.save(); + this.left_tree.model.updateSelected(); + if (this.left_tree.getActiveFile().xtype == "Roo" ) { + this.window_rooview.requestRedraw(); + } else { + this.window_gladeview.loadFile(this.left_tree.getActiveFile()); + } + // we do not need to call spawn... - as it's already called by the editor? + + }); + + } + + // ----------- list of projects on left + public void projectListInit() + { + + this.left_projects = new Xcls_WindowLeftProjects(); + this.left_projects.ref(); + this.win.leftpane.el.pack_start(this.left_projects.el,true, true,0); + this.left_projects.el.show_all(); + this.left_projects.project_selected.connect((proj) => { + this.buttonsShowHide(); + proj.scanDirs(); + this.clutterfiles.loadProject(proj); + + }); + + } + // ----------- file view + + public void fileViewInit() + { + var stage = this.win.rooview.el.get_stage(); // seems odd... + this.clutterfiles = new Xcls_ClutterFiles(); + this.clutterfiles.ref(); + stage.add_child(this.clutterfiles.el); + this.clutterfiles.el.show(); + + + this.clutterfiles.open.connect((file) => { + this.fileViewOpen(file); + }); + this.clutterfiles.el.transitions_completed.connect(() => { + if (this.state == State.FILES) { + this.win.rooview.el.hide(); + } else { + this.clutterfiles.el.hide(); + } + + + }); + + } + + public void fileDetailsInit() + { + this.file_details = new Xcls_PopoverFileDetails(); + this.file_details.mainwindow = this.win; + // force it modal to the main window.. + + this.file_details.success.connect((project,file) => + { + this.fileViewOpen(file); + }); + + } + + public void fileViewOpen(JsRender.JsRender file, int line = -1) + { + this.win.project = file.project; + this.project = file.project; + this.file = file; + + + if (file.xtype == "PlainFile") { + this.switchState (State.CODEONLY); + file.loadItems(); + this.code_editor.show(file, null, "", ""); + if (line> -1) { + this.code_editor.scroll_to_line(line); + } + } else { + + this.switchState (State.PREVIEW); + // this triggers loadItems.. + this.left_tree.model.loadFile(file); + if (file.project.xtype == "Gtk" && line> -1 ) { + this.window_gladeview.scroll_to_line(line); + } + + } + + + var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget())); + var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget())); + + if (file.project.xtype == "Roo" ) { + ctr.foreach( (w) => { ctr.remove(w); }); + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr.add(this.window_rooview.el); + ctr_p.add(this.projectsettings.el); + if (file.xtype != "PlainFile") { + this.window_rooview.loadFile(file); + this.window_rooview.el.show_all(); + } + this.projectsettings.el.show_all(); + + + } else { + ctr.foreach( (w) => { ctr.remove(w); }); + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr.add(this.window_gladeview.el); + ctr_p.add(this.vala_projectsettings.el); + if (file.xtype != "PlainFile") { + this.window_gladeview.loadFile(file); + this.window_gladeview.el.show_all(); + } + this.vala_projectsettings.el.show_all(); + } + print("OPEN : " + file.name); + if (file.xtype != "PlainFile") { + this.win.editpane.el.set_position(this.win.editpane.el.max_position); + } + this.win.setTitle(file.project.name + " : " + file.name); + + + } + + // our project properties is different for Roo and Gtk + // it would be better to change the above code to use this, + public void attachProjectSettings() { + + var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget())); + + if (this.win.project.xtype == "Roo" ) { + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr_p.add(this.projectsettings.el); + this.projectsettings.el.show_all(); + + } else { + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr_p.add(this.vala_projectsettings.el); + this.vala_projectsettings.el.show_all(); + } + } + /* + public void fileViewOpenPlain(string fname) + { + + this.switchState (State.CODEONLY); + this.code_editor.showPlainFile(fname); + } + */ + + // --------- webkit view + public void webkitViewInit() + { + this.window_rooview =new Xcls_WindowRooView(); + this.window_rooview.main_window = this.win; + this.window_rooview.ref(); + ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el); + this.window_rooview.el.show_all(); + + var stage = this.win.rooview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + } + + // ------ Gtk - view + + public void gtkViewInit() + { + this.window_gladeview =new Xcls_GtkView(); + this.window_gladeview.ref(); + this.window_gladeview.main_window = this.win; + } + + public void easingSaveAll() + { + this.win.addpropsview.el.save_easing_state(); + this.win.codeeditview.el.save_easing_state(); + this.win.objectview.el.save_easing_state(); + this.win.projecteditview.el.save_easing_state(); + this.win.rooview.el.save_easing_state(); + this.clutterfiles.el.save_easing_state(); + + } + public void easingRestoreAll() + { + this.win.addpropsview.el.restore_easing_state(); + this.win.codeeditview.el.restore_easing_state(); + this.win.objectview.el.restore_easing_state(); + this.win.projecteditview.el.restore_easing_state(); + this.win.rooview.el.restore_easing_state(); + this.clutterfiles.el.restore_easing_state(); + + } + public void switchState(State new_state) + { + + // if the new state and the old state are the same.. + + if (new_state == this.state) { + return; + } + + // stop werid stuff happening + + if (this.state == State.FILES + && new_state == State.FILEPROJECT + && this.left_projects.getSelectedProject() == null) { + return; + } + // save the easing state of everything.. + this.easingSaveAll(); + + switch (this.state) { + + case State.PREVIEW: + if (this.left_tree.getActiveFile() != null) { + if (this.left_tree.getActiveFile().xtype == "Roo" ) { + this.window_rooview.createThumb(); + } else { + this.window_gladeview.createThumb(); + } + } + // normally we are going from preview to another state. + // and different windows hide the preview in differnt ways.. + + break; + + + case State.LISTENER: + case State.PROP: + + this.win.addpropsview.el.set_scale(0.0f,0.0f); + break; + + case State.CODE: + this.code_editor.saveContents(); + + this.win.codeeditview.el.set_scale(0.0f,0.0f); + break; + + case State.CODEONLY: + // going from codeonly.. + + // enable re-calc of canvas.. + + //this.code_editor.saveContents(); << not yet... + if (new_state != State.PROJECTCODEONLY) { + this.win.rooview.el.show(); + this.win.leftpane.el.show(); + this.win.codeeditview.el.set_scale(0.0f,0.0f); + } else { + this.win.codeeditview.el.set_pivot_point(0.0f,1.0f); // bottom left + this.win.codeeditview.el.set_scale(0.5f,0.5f); + } + while (Gtk.events_pending()) { + Gtk.main_iteration(); + } + + // hides it completely... + + break; + + case State.OBJECT: + + this.win.objectview.el.set_scale(0.0f,0.0f); + break; + + case State.FILEPROJECT: + case State.PROJECT: + case State.PROJECTCODEONLY: + if (this.win.project.xtype == "Gtk") { + this.vala_projectsettings.save(); + } + if (this.state == State.FILEPROJECT) { + this.clutterfiles.el.set_scale(1.0f,1.0f); + + } + this.win.projecteditview.el.set_scale(0.0f,0.0f); + break; + + case State.FILES: // goes to preview or codeonly... + // hide files... + + + if (new_state == State.FILEPROJECT) { + + this.clutterfiles.el.set_easing_duration(1000); + this.clutterfiles.el.set_pivot_point(0.5f,1.0f); + this.clutterfiles.el.set_scale(0.5f,0.5f); + break; + } + + if (new_state == State.CODEONLY) { + this.win.rooview.el.hide(); + } else { + this.win.rooview.el.show(); + } + + this.win.rooview.el.set_easing_duration(1000); + this.win.rooview.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f); + this.win.rooview.el.set_scale(1.0f,1.0f); + this.win.rooview.el.set_pivot_point(0.5f,0.5f); + this.win.rooview.el.set_opacity(0xff); + + this.clutterfiles.el.set_easing_duration(1000); + this.clutterfiles.el.set_pivot_point(0.5f,0.5f); + this.clutterfiles.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, -180.0f); + this.clutterfiles.el.set_opacity(0); + + + //this.clutterfiles.el.hide(); + + + break; + + + } + + var oldstate =this.state; + this.state = new_state; + + + + this.buttonsShowHide(); + + + switch (this.state) { + + case State.PREVIEW: // this is the default state when working... + this.win.editpane.el.show(); // holder for tree and properties.. + + + this.left_projects.el.hide(); + if (oldstate != State.FILES) { + // it's handled above.. + print ("changing state to preview from NOT files.."); + + + this.win.rooview.el.set_scale(1.0f,1.0f); + } + + break; + + + case State.LISTENER: + // same as prop? + case State.PROP: + var ae = this.left_tree.getActiveElement(); + if (ae == null) { + this.state = oldstate; + this.buttonsShowHide(); + this.resizeCanvasElements(); + this.easingRestoreAll(); + return; + } + this.add_props.el.show_all(); + this.add_props.show( + Palete.factory(this.win.project.xtype), + this.state == State.LISTENER ? "signals" : "props", + ae.fqn() + ); + + + + + // -- FIXME? this needs to be State aware? + + this.win.rooview.el.set_pivot_point(1.0f,0.5f); + + this.win.addpropsview.el.set_scale(1.0f,1.0f); + break; + + case State.OBJECT: + var n = this.left_tree.getActiveElement(); + + if (this.file == null) { + this.state =oldstate; + this.buttonsShowHide(); + this.resizeCanvasElements(); + this.easingRestoreAll(); + return; + } + + if (n == null && this.file.tree != null) { + this.state = oldstate; + this.buttonsShowHide(); + this.resizeCanvasElements(); + this.easingRestoreAll(); + return; + } + + this.rightpalete.el.show_all(); + this.rightpalete.load(this.left_tree.getActiveFile().palete(), n == null ? "*top" : n.fqn()); + + + + this.win.rooview.el.set_pivot_point(1.0f,0.5f); + this.win.objectview.el.set_scale(1.0f,1.0f); + + break; + + + case State.CODE: + this.win.codeeditview.el.show(); + this.code_editor.el.show_all(); + // caller needs to call editor - show.... + this.win.codeeditview.el.set_scale(1.0f,1.0f); + this.win.rooview.el.set_pivot_point(1.0f,0.5f); + + break; + + case State.CODEONLY: + // going to codeonly.. + this.win.codeeditview.el.show(); + // recalc canvas... + //while (Gtk.events_pending()) { + // Gtk.main_iteration(); + //} + + this.win.leftpane.el.hide(); + this.win.codeeditview.el.show(); + //while (Gtk.events_pending()) { + // Gtk.main_iteration(); + //} + + + this.code_editor.el.show_all(); + + this.win.codeeditview.el.set_scale(1.0f,1.0f); + this.win.rooview.el.set_pivot_point(1.0f,0.5f); + break; + + case State.PROJECTCODEONLY: + // going to project edit (when in code only) + + + + if (this.win.project.xtype == "Roo") { + this.projectsettings.el.show_all(); + this.projectsettings.show(this.win.project); + } else { + this.vala_projectsettings.el.show_all(); + this.vala_projectsettings.show((Project.Gtk)this.win.project); + } + + this.win.projecteditview.el.set_scale(1.0f,1.0f); + + break; + + + case State.PROJECT: + this.win.rooview.el.set_pivot_point(1.0f,1.0f); // bottom right.. + + if (this.win.project.xtype == "Roo") { + this.projectsettings.el.show_all(); + this.projectsettings.show(this.win.project); + } else { + this.vala_projectsettings.el.show_all(); + this.vala_projectsettings.show((Project.Gtk)this.win.project); + } + + this.win.projecteditview.el.set_scale(1.0f,1.0f); + + break; + + case State.FILEPROJECT: + var pr = this.left_projects.getSelectedProject(); + + this.win.project = pr; + + this.attachProjectSettings(); + print("FIlE PROJECT - show %s\n", pr.xtype); + + if (pr.xtype == "Roo") { + this.projectsettings.el.show_all(); + this.projectsettings.show(this.win.project); + } else { + this.vala_projectsettings.el.show_all(); + this.vala_projectsettings.show((Project.Gtk)this.win.project); + } + + this.win.projecteditview.el.set_scale(1.0f,1.0f); + + break; + + case State.FILES: // can only get here from PREVIEW (or code-only) state.. in theory.. + + + this.win.editpane.el.hide(); // holder for tree and properties.. + + this.left_projects.el.show(); + + // rotate the preview to hidden... + this.win.rooview.el.set_easing_duration(1000); + this.win.rooview.el.set_pivot_point(0.5f,0.5f); + this.win.rooview.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 180.0f); + this.win.rooview.el.set_opacity(0); + + + + + if (this.win.project != null) { + this.left_projects.selectProject(this.win.project); + } + + + this.clutterfiles.el.show(); + + this.clutterfiles.el.set_easing_duration(1000); + this.clutterfiles.el.set_pivot_point(0.5f,0.5f); + this.clutterfiles.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f); + this.clutterfiles.el.set_opacity(0xff); + + + + break; + + + } + this.resizeCanvasElements(); + this.easingRestoreAll(); + + // run the animation.. - then load files... + GLib.Timeout.add(500, () =>{ + this.resizeCanvasElements(); + return false; + }); + + } + + public int redraw_count = 0; + public void resizeCanvas() // called by window resize .. delays redraw + { + var rc = this.redraw_count; + this.redraw_count = 2; + if (rc == 0) { + GLib.Timeout.add(100, () =>{ + return this.resizeCanvasQueue(); + }); + } + } + public bool resizeCanvasQueue() + { + //print("WindowState.resizeCanvasQueue %d\n", this.redraw_count); + + if (this.redraw_count < 1) { + return false; // should not really happen... + } + + + this.redraw_count--; + + if (this.redraw_count > 0) { + return true; // do it again in 1 second... + } + // got down to 0 or -1.... + this.redraw_count = 0; + this.resizeCanvasElements(); + return false; + + } + public void resizeCanvasElements() + { + Gtk.Allocation alloc; + this.win.clutterembed.el.get_allocation(out alloc); + + // print("WindowState.resizeCanvasElements\n"); + if (!this.children_loaded || this.win.clutterembed == null) { + print("WindowState.resizeCanvasElements = ingnore not loaded or no clutterfiles\n"); + return; + } + + var avail = alloc.width < 50.0f ? 0 : alloc.width - 50.0f; + var palsize = avail < 300.0f ? avail : 300.0f; + + + // -------- code edit min 600 + + var codesize = avail < 800.0f ? avail : 800.0f; + + + //print("set code size %f\n", codesize); + + + + switch ( this.state) { + case State.PREVIEW: + + this.win.rooview.el.set_size(alloc.width-50, alloc.height); + break; + + case State.FILES: + this.clutterfiles.set_size(alloc.width-50, alloc.height); + break; + + case State.PROJECT: + + this.win.projecteditview.el.set_size(alloc.width-50, alloc.height / 2.0f); + + // this.win.rooview.el.save_easing_state(); + //this.win.rooview.el.set_size(alloc.width / 2.0f, alloc.height / 2.0f); + + this.win.rooview.el.set_scale(0.5f, 0.5f); + //this.win.rooview.el.restore_easing_state(); + break; + + case State.CODE: + this.win.codeeditview.el.set_size(codesize, alloc.height); + var scale = avail > 0.0f ? (avail - codesize -10 ) / avail : 0.0f; + //this.win.rooview.el.save_easing_state(); + + this.win.rooview.el.set_scale(scale,scale); + // this.win.rooview.el.restore_easing_state(); + break; + + case State.CODEONLY: + this.win.codeeditview.el.set_size(codesize, alloc.height); + var scale = avail > 0.0f ? (avail - codesize -10 ) / avail : 0.0f; + //this.win.rooview.el.save_easing_state(); + this.win.rooview.el.hide(); + this.win.rooview.el.set_scale(scale,scale); + // this.win.rooview.el.restore_easing_state(); + break; + case State.PROP: + case State.LISTENER: + this.win.addpropsview.el.set_size(palsize, alloc.height); + var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f; + this.win.rooview.el.set_scale(scale,scale); + break; + + case State.OBJECT: + this.win.objectview.el.set_size(palsize, alloc.height); + var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f; + //this.win.rooview.el.save_easing_state(); + this.win.rooview.el.set_scale(scale,scale); + // this.win.rooview.el.restore_easing_state(); + break; + } + } + + // -- buttons show hide..... + + public void buttonsShowHide() + { + // basically hide everything, then show the relivant.. + + // top bar btns + this.win.openbtn.el.hide(); + this.win.openbackbtn.el.hide(); + + this.win.backbutton.el.hide(); + + + this.win.editfilebutton.el.hide(); + this.win.projecteditbutton.el.hide(); + + + this.win.objectshowbutton.el.hide(); // add objects + this.win.addpropbutton.el.hide(); + this.win.addlistenerbutton.el.hide(); + + + + this.win.addprojectbutton.el.hide(); + this.win.addfilebutton.el.hide(); + this.win.delprojectbutton.el.hide(); + + this.win.search_entry.el.hide(); + this.win.search_results.el.hide(); + switch (this.state) { + + case State.PREVIEW: // this is the default state when working... + + + this.win.editfilebutton.el.show(); + this.win.projecteditbutton.el.show(); + + + + this.win.objectshowbutton.el.show(); // add objects + this.win.addpropbutton.el.show(); + this.win.addlistenerbutton.el.show(); + this.win.search_entry.el.show(); + + this.win.openbtn.el.show(); + + break; + + case State.CODEONLY: + this.win.openbtn.el.show(); + this.win.projecteditbutton.el.show(); + this.win.search_entry.el.show(); + break; + + case State.CODE: + this.win.search_entry.el.show(); + this.win.backbutton.el.show(); + this.win.objectshowbutton.el.show(); // add objects ?? can you do this from here? + this.win.addpropbutton.el.show(); + this.win.addlistenerbutton.el.show(); + break; + // continue thru.. + case State.PROP: + case State.LISTENER: + case State.OBJECT: + + this.win.backbutton.el.show(); + this.win.objectshowbutton.el.show(); // add objects + this.win.addpropbutton.el.show(); + this.win.addlistenerbutton.el.show(); + break; + + case State.PROJECT: + case State.FILEPROJECT: + case State.PROJECTCODEONLY: + // anything else? + this.win.backbutton.el.show(); + + break; + + + case State.FILES: + if (this.left_projects.getSelectedProject() != null ) { + if (this.left_tree.getActiveFile() != null) { + + this.win.openbackbtn.el.show(); + } + this.win.addfilebutton.el.show(); + this.win.search_entry.el.show(); + this.win.projecteditbutton.el.show(); + } + + + this.win.addprojectbutton.el.show(); + this.win.delprojectbutton.el.show(); + + + + + break; + } + + + + } + + + public void showCompileResult(Json.Object obj) + { + // vala has finished compiling... + print("vala compiled"); + var generator = new Json.Generator (); + var n = new Json.Node(Json.NodeType.OBJECT); + n.init_object(obj); + generator.set_root (n); + print("result :%s", generator.to_data (null)); + + + var buf = this.code_editor.buffer; + buf.check_running = false; + var has_errors = false; + + if (obj.has_member("ERR-TOTAL")) { + if (obj.get_int_member("ERR-TOTAL")> 0) { + has_errors = true; + } + this.win.statusbar_errors.setNotices( obj.get_object_member("ERR") , (int) obj.get_int_member("ERR-TOTAL")); + } else { + this.win.statusbar_errors.setNotices( new Json.Object() , 0); + } + + if (obj.has_member("WARN-TOTAL")) { + + this.win.statusbar_warnings.setNotices(obj.get_object_member("WARN"), (int) obj.get_int_member("WARN-TOTAL")); + } else { + this.win.statusbar_warnings.setNotices( new Json.Object() , 0); + + } + if (obj.has_member("DEPR-TOTAL")) { + + this.win.statusbar_depricated.setNotices( obj.get_object_member("DEPR"), (int) obj.get_int_member("DEPR-TOTAL")); + + } else { + this.win.statusbar_depricated.setNotices( new Json.Object(),0); + } + if (this.state == State.CODE || this.state == State.PROJECTCODEONLY) { + buf.highlightErrorsJson("ERR", obj); + buf.highlightErrorsJson("WARN", obj); + buf.highlightErrorsJson("DEPR", obj); + } + + this.win.statusbar_compilestatus_label.el.hide(); + this.win.statusbar_run.el.hide(); + if (!has_errors) { + this.win.statusbar_compilestatus_label.el.show(); + this.win.statusbar_run.el.show(); + } + if (this.file.xtype == "Gtk") { + // not sure how this is working ok? - as highlighting is happening on the vala files at present.. + var gbuf = this.window_gladeview.sourceview; + gbuf.highlightErrorsJson("ERR", obj); + gbuf.highlightErrorsJson("WARN", obj); + gbuf.highlightErrorsJson("DEPR", obj); + + if (!has_errors) { + this.win.statusbar_run.el.show(); + } + + } + + if (this.file.xtype == "Gtk") { + // not sure how this is working ok? - as highlighting is happening on the vala files at present.. + var gbuf = this.window_rooview.sourceview; + gbuf.highlightErrorsJson("ERR", obj); + gbuf.highlightErrorsJson("WARN", obj); + gbuf.highlightErrorsJson("DEPR", obj); + + } + + this.last_compile_result = obj; + + + } + +} + + diff --git a/src/Builder4/config1.builder b/src/Builder4/config1.builder new file mode 100644 index 000000000..42106916f --- /dev/null +++ b/src/Builder4/config1.builder @@ -0,0 +1,115 @@ +[ + { + "name" : "builder", + "compile_flags" : "", + "execute_args" : "", + "target_bin" : "/tmp/builder", + "sources" : [ + "../Builder4/About.vala", + "../Builder4/ClutterFiles.vala", + "../Builder4/DialogConfirm.vala", + "../Builder4/DialogPluginWebkit.vala", + "../Builder4/DialogSaveModule.vala", + "../Builder4/DialogSaveTemplate.vala", + "../Builder4/DialogTemplateSelect.vala", + "../Builder4/Editor.vala", + "../Builder4/EditProject.vala", + "../Builder4/FakeServer.vala", + "../Builder4/GtkView.vala", + "../Builder4/MainWindow.vala", + "../Builder4/ProjectSettings.vala", + "../Builder4/RooProjectProperties.vala", + "../Builder4/StandardErrorDialog.vala", + "../Builder4/ValaProjectSettings.vala", + "../Builder4/WindowAddProp.vala", + "../Builder4/WindowLeftProjects.vala", + "../Builder4/WindowLeftProps.vala", + "../Builder4/WindowLeftTree.vala", + "../Builder4/WindowRightPalete.vala", + "../Builder4/WindowRooView.vala", + "../Builder4/WindowState.vala", + "../Builder4", + "../JsRender/Gtk.vala", + "../JsRender/JsRender.vala", + "../JsRender/Lang.vala", + "../JsRender/NodeToGlade.vala", + "../JsRender/NodeToGtk.vala", + "../JsRender/NodeToJs.vala", + "../JsRender/NodeToVala.vala", + "../JsRender/Node.vala", + "../JsRender/RooDatabase.vala", + "../JsRender/Roo.vala", + "../JsRender", + "../Palete/Gir.vala", + "../Palete/Gtk.vala", + "../Palete/Javascript.vala", + "../Palete/Palete.vala", + "../Palete/RooDatabase.vala", + "../Palete/Roo.vala", + "../Palete/ValaSource.vala", + "../Palete", + "../Project/Gtk.vala", + "../Project/Project.vala", + "../Project/Roo.vala", + "../Project", + "../../src/Application.vala", + "../../src/Main.vala", + "../../src/Resources.vala", + "../../src", + "../c/jscore_object_call_as_function.c", + "../Palete/GirObject.vala", + "../Palete/VapiParser.vala", + "../Builder4/PopoverFileDetails.vala", + "../../src/Spawn.vala", + "../Builder4/ValaCompileErrors.vala", + "../Palete/ValaSourceCompiler.vala", + "../JsRender/PlainFile.vala", + "../Builder4/ValaCompileResults.vala", + "../Palete/CompletionProvider.vala", + "../Builder4/PopoverProperty.vala" + ], + "packages" : [ + ] + }, + { + "name" : "_default_", + "compile_flags" : "--thread -X -lm --target-glib=2.32 -g --pkg roojspacker-1.0", + "execute_args" : "", + "target_bin" : "", + "sources" : [ + "../../../app.Builder.js", + "../Builder4", + "../../src", + "../JsRender", + "../Palete", + "../Project", + "../vapi", + "../c", + "../..//tests", + "../..//pixmaps" + ], + "packages" : [ + "gdk-3.0", + "gtk+-3.0", + "gtksourceview-3.0", + "libgda-5.0", + "clutter-gtk-1.0", + "glib-2.0", + "gobject-introspection-1.0", + "gobject-2.0", + "javascriptcore", + "json-glib-1.0", + "libxml-2.0", + "libsoup-2.4", + "libvala-0.26", + "webkit2gtk-4.0", + "gee-1.0", + "posix", + "libvala-0.24", + "libvala-0.30", + "librsvg-2.0", + "libvala-0.32", + "roojspacker-1.0" + ] + } +] \ No newline at end of file diff --git a/src/JsRender/Gtk.vala b/src/JsRender/Gtk.vala new file mode 100644 index 000000000..75bb80465 --- /dev/null +++ b/src/JsRender/Gtk.vala @@ -0,0 +1,263 @@ +/** + * + * this is the code represents a File when using the Gtk view.. + * + * It ues NodeToGtk + * + * + */ + +namespace JsRender { + + + + int gid = 1; + + + public class Gtk : JsRender + { + + + public Gtk(Project.Project project, string path) { + + base( project, path); + this.xtype = "Gtk"; + this.language = "vala"; + + + //this.items = false; + //if (cfg.json) { + // var jstr = JSON.parse(cfg.json); + // this.items = [ jstr ]; + // //console.log(cfg.items.length); + // delete cfg.json; // not needed! + // } + + + + // super?!?! + this.id = "file-gtk-%d".printf(gid++); + //console.dump(this); + // various loader methods.. + + // Class = list of arguments ... and which property to use as a value. + + + + + } + + + /* + setNSID : function(id) + { + + this.items[0]['*class'] = id; + + + }, + getType: function() { + return 'Gtk'; + }, + */ + + public override void removeFiles() { + var js = GLib.Path.get_dirname(this.path) +"/" + name + ".js"; + if (FileUtils.test(js, FileTest.EXISTS)) { + GLib.FileUtils.remove(js); + } + var vala = GLib.Path.get_dirname(this.path) +"/" + name + ".vala"; + if (FileUtils.test(vala, FileTest.EXISTS)) { + GLib.FileUtils.remove(vala); + } + } + + public override void loadItems() throws GLib.Error // : function(cb, sync) == original was async. + { + + print("load Items!\n"); + if (this.tree != null) { + this.loaded = true; + + return; + } + /* + print("load: %s\n" , this.path); + if (!GLib.FileUtils.test(this.path, GLib.FileTest.EXISTS)) { + // new file?!? + this.tree = null; + this.loaded = true; + return; + } + */ + + var pa = new Json.Parser(); + pa.load_from_file(this.path); + var node = pa.get_root(); + + if (node.get_node_type () != Json.NodeType.OBJECT) { + throw new Error.INVALID_FORMAT ("Unexpected element type %s", node.type_name ()); + } + var obj = node.get_object (); + + this.name = obj.get_string_member("name"); + this.parent = obj.get_string_member("parent"); + this.title = obj.get_string_member("title"); + + if (obj.has_member("build_module")) { // should check type really.. + this.build_module = obj.get_string_member("build_module"); + } + + // load items[0] ??? into tree... + var bjs_version_str = this.jsonHasOrEmpty(obj, "bjs-version"); + bjs_version_str = bjs_version_str == "" ? "1" : bjs_version_str; + + if (obj.has_member("items") + && + obj.get_member("items").get_node_type() == Json.NodeType.ARRAY + && + obj.get_array_member("items").get_length() > 0 + ) { + var ar = obj.get_array_member("items"); + var tree_base = ar.get_object_element(0); + this.tree = new Node(); + this.tree.loadFromJson(tree_base, int.parse(bjs_version_str)); + + } + NodeToVala.mungeFile(this); // force line numbering.. + this.loaded = true; + + } + + + + public override string toSourcePreview() + { + return ""; + } + public override void setSource(string str) {} + + public override string toSourceCode() // no seed support currently. + { + return NodeToVala.mungeFile(this); + } + + // this is only used by dumping code... + public override string toSource() // no seed support currently. + { + + + /* + if (this.tree == null) { + return ""; + } + + // var data = JSON.parse(JSON.stringify(this.items[0])); + // we should base this on the objects in the tree really.. + string[] inc = { "Gtk", "Gdk", "Pango", "GLib", "Gio", "GObject", + "GtkSource", "WebKit", "Vte" }; //, "GtkClutter" , "Gdl"]; + var src = ""; + + for (var i=0; i< inc.length; i++) { + var e = inc[i]; + src += e+" = imports.gi." + e +";\n"; + } + + src += "console = imports.console;\n"; // path?!!? + src += "XObject = imports.XObject.XObject;\n"; // path?!!? + + + src += this.name + "=new XObject("+ this.mungeToString(" ") + ");\n"; + src += this.name + ".init();\n"; + // register it in the cache + src += "XObject.cache['/" + this.name + "'] = " + this.name + ";\n"; + return src; + */ + return ""; + + + } + + public override void save() { + this.saveBJS(); + // this.saveJS(); - disabled at present.. project settings will probably enable this later.. + + this.saveVala(); + } + // ignore these calls. + public override void saveHTML ( string html ) {} + + + /** + * saveJS + * + * save as a javascript file. - not used currently + * why is this not save...??? + * + + + void saveJS() + { + + var fn = GLib.Path.get_dirname(this.path) + "/" + this.name + ".js"; + print("WRITE :%s\n " , fn); + this.writeFile(fn, this.toSource()); + + } + */ + void saveVala() + { + if (this.tree == null) { + return; + } + var fn = GLib.Path.get_dirname(this.path) + "/" + this.name + ".vala"; + print("WRITE :%s\n " , fn); + this.writeFile(fn, NodeToVala.mungeFile(this)); + + + } + /* + valaCompileCmd : function() + { + + var fn = '/tmp/' + this.name + '.vala'; + print("WRITE : " + fn); + File.write(fn, this.toVala(true)); + + + + return ["valac", + "--pkg", "gio-2.0", + "--pkg" , "posix" , + "--pkg" , "gtk+-3.0", + "--pkg", "libnotify", + "--pkg", "gtksourceview-3.0", + "--pkg", "libwnck-3.0", + fn , "-o", "/tmp/" + this.name]; + + + + + }, + */ + + + string getHelpUrl(string cls) + { + return "http://devel.akbkhome.com/seed/" + cls + ".html"; + } + public override void findTransStrings(Node? node ) + { + // not yet.. + } + + + + + + + } +} + + + diff --git a/src/JsRender/JsRender.vala b/src/JsRender/JsRender.vala new file mode 100644 index 000000000..db19fe2c8 --- /dev/null +++ b/src/JsRender/JsRender.vala @@ -0,0 +1,361 @@ +//