SF.net SVN: geany-plugins:[364] trunk/geany-mini-script

prublot at users.sourceforge.net prublot at xxxxx
Sun Jan 4 21:09:22 UTC 2009


Revision: 364
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=364&view=rev
Author:   prublot
Date:     2009-01-04 21:09:11 +0000 (Sun, 04 Jan 2009)

Log Message:
-----------
Creation

Added Paths:
-----------
    trunk/geany-mini-script/COPYING
    trunk/geany-mini-script/ChangeLog
    trunk/geany-mini-script/INSTALL
    trunk/geany-mini-script/Makefile.am
    trunk/geany-mini-script/README
    trunk/geany-mini-script/TODO
    trunk/geany-mini-script/configure.in
    trunk/geany-mini-script/doc/
    trunk/geany-mini-script/doc/Doxyfile_gms
    trunk/geany-mini-script/doc/gms_help.pdf
    trunk/geany-mini-script/src/
    trunk/geany-mini-script/src/Makefile.am
    trunk/geany-mini-script/src/gms.c
    trunk/geany-mini-script/src/gms.h
    trunk/geany-mini-script/src/gms_debug.h
    trunk/geany-mini-script/src/gms_gui.c
    trunk/geany-mini-script/src/gms_gui.h
    trunk/geany-mini-script/test/
    trunk/geany-mini-script/test/awk.gms
    trunk/geany-mini-script/test/perl.gms
    trunk/geany-mini-script/test/python.gms
    trunk/geany-mini-script/test/sed.gms
    trunk/geany-mini-script/test/sed2.gms
    trunk/geany-mini-script/test/shell.gms
    trunk/geany-mini-script/test/testfile.txt
    trunk/geany-mini-script/test/testfile2.txt

Added: trunk/geany-mini-script/COPYING
===================================================================
--- trunk/geany-mini-script/COPYING	                        (rev 0)
+++ trunk/geany-mini-script/COPYING	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+	51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  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
+this service 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 make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  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.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the 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 a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE 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.
+
+		     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
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision 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, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This 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 Library General
+Public License instead of this License.

Added: trunk/geany-mini-script/ChangeLog
===================================================================
--- trunk/geany-mini-script/ChangeLog	                        (rev 0)
+++ trunk/geany-mini-script/ChangeLog	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,7 @@
+2009-01-03 V0.2
+			* using autotools
+			* adding a help document ( ./doc/gms_help.pdf ) 
+			* add a break if a error is happened  in the session mode
+			* svn
+			
+2009-01-02 V0.1 initial version 

Added: trunk/geany-mini-script/INSTALL
===================================================================
--- trunk/geany-mini-script/INSTALL	                        (rev 0)
+++ trunk/geany-mini-script/INSTALL	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,18 @@
+These installation instructions are written for a GNU/Linux system.
+
+( for a detailled procedure, see the following document : ./doc/gms_help.pdf )
+
+At the time of this writing, building the plugin requires a recent geany (0.15)
+installed.
+
+ % autoreconf -i
+ % configure
+ % make clean
+ % make
+ % sudo make install
+
+There is no "make uninstall" target, so if you want to remove the plugin,
+just delete the "gms.la" anf "gms.so" from geany plugins directory 
+(usually: /usr/lib/geany or /usr/lib/local/geany).
+
+

Added: trunk/geany-mini-script/Makefile.am
===================================================================
--- trunk/geany-mini-script/Makefile.am	                        (rev 0)
+++ trunk/geany-mini-script/Makefile.am	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,4 @@
+## Makefile.am -- Process this file with automake to produce Makefile.in
+SUBDIRS = src 
+
+

Added: trunk/geany-mini-script/README
===================================================================
--- trunk/geany-mini-script/README	                        (rev 0)
+++ trunk/geany-mini-script/README	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,100 @@
+.. |(version)| replace:: 0.1
+
+====
+gms
+====
+
+.. contents::
+
+About
+=====
+
+gms is a Geany Mini-Script filter plugin
+
+In order to use it you need Geany 0.15.
+
+Features
+========
+This plugin is a tools to apply a script filter on ::
+   o the text selection,
+   o the current document,
+   o all documents of the current session.
+
+The filter type can be ::
+   o Unix shell script,
+   o perl script,
+   o python script,
+   o sed commands,
+   o awk script.
+
+The output can be ::
+   o the selection of the current document,
+   o all the current document,
+   o or a new document.
+
+Requirements
+============
+
+For compiling gms you need Geany,GTK2 includes, and GTK2 library.
+
+Furthermore you need, of course, a C compiler and the Make tool; The
+GNU versions of these tools are recommended.
+
+Usage
+=====
+
+After compiling and/or installing gms, start Geany and go to menu
+Tools->Plugin Manager and set checkbox at gms plugin.
+
+You can configure the following options::
+    o Shell path,
+    o Perl path,
+    o Python path,
+    o sed path,
+    o Awk path,
+    o user script .
+
+After configuring, go to menu Tools->Plugin Manager and click to "Mini-script".
+Geany opens a gms dialog box::
+    o With the combobox, you select the script type,
+    o In the text view, you write the filter script.
+    o In the input area, you select the filter input::
+           * current selection
+           * current document
+           * all the session documents
+    o In the output area, you select the filter output::
+           * current document
+           * new document
+    o and you click on the apply button.
+
+License
+=======
+
+gms is distributed under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version. A copy of this license
+can be found in the file COPYING included with the source code of this
+program.
+
+Ideas, questions, patches and bug reports
+=========================================
+
+If you add something, or fix a bug, please send a patch (in 'diff -u'
+format) to the author listed below.
+
+Coding
+======
+
+Use static functions where possible.
+Try to use GLib types and functions - e.g. g_free instead of free and
+try to use only GLib 2.6 and GTK 2.6 functions. At least for the moment,
+we want to keep the minimum requirement for GTK at 2.6.
+
+Download
+========
+
+The current version is |(version)|, download it here http://
+
+--
+2008-2009 by Pascal BURLOT
+prublot(at)users(dot)sourceforge(dot)net

Added: trunk/geany-mini-script/TODO
===================================================================
--- trunk/geany-mini-script/TODO	                        (rev 0)
+++ trunk/geany-mini-script/TODO	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,3 @@
+* highlighting the script ( shell,perl,sed,awk)
+* internationalization
+

Added: trunk/geany-mini-script/configure.in
===================================================================
--- trunk/geany-mini-script/configure.in	                        (rev 0)
+++ trunk/geany-mini-script/configure.in	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,61 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT([gms], [0.2], [burlot.p ascal at wanadoo.fr])
+dnl AC_CONFIG_SRCDIR([src/gms.c  srcgms_gui.c])
+
+AM_INIT_AUTOMAKE([1.9 foreign])
+
+AM_CONFIG_HEADER(config.h)
+
+AC_PROG_CC
+
+AC_DISABLE_STATIC
+AM_PROG_LIBTOOL
+LIBTOOL="$LIBTOOL --silent"
+
+AC_PROG_INSTALL
+#AC_PROG_INTLTOOL
+AC_PROG_MAKE_SET
+
+# checking for Geany
+PKG_CHECK_MODULES(GEANY, [geany >= 0.15])
+AC_SUBST(GTK_CFLAGS)
+AC_SUBST(GTK_LIBS)
+
+GEANY_VERSION=`$PKG_CONFIG --modversion geany`
+GTK_VERSION=`$PKG_CONFIG --modversion gtk+-2.0`
+
+# i18n
+#GETTEXT_PACKAGE=gms
+#AC_SUBST(GETTEXT_PACKAGE)
+#AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
+
+#ALL_LINGUAS="`sed -e '/^#/d' $srcdir/po/LINGUAS`" # take all languages found in file po/LINGUAS
+
+#AM_GLIB_GNU_GETTEXT
+# workaround for intltool bug (http://bugzilla.gnome.org/show_bug.cgi?id=490845)
+#if test "x$MSGFMT" = "xno"; then
+#	AC_MSG_ERROR([msgfmt not found. Please install the gettext package.])
+#fi
+
+# intltool hack to define install_sh on Debian/Ubuntu systems
+if test "x$install_sh" = "x"; then
+	install_sh="`pwd`/install-sh"
+	AC_SUBST(install_sh)
+fi
+
+# get the plugin installed at the correct location for Geany
+# TODO find a way to NOT override --libdir command line option if given
+libdir="`$PKG_CONFIG --variable=libdir geany`/geany"
+
+
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
+
+echo "----------------------------------------"
+echo "Install Geany Mini-Script in       : ${libdir}"
+echo "Using Geany version                : ${GEANY_VERSION}"
+echo "Using GTK version                  : ${GTK_VERSION}"
+echo ""
+echo "Configuration is done OK."
+echo ""

Added: trunk/geany-mini-script/doc/Doxyfile_gms
===================================================================
--- trunk/geany-mini-script/doc/Doxyfile_gms	                        (rev 0)
+++ trunk/geany-mini-script/doc/Doxyfile_gms	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,297 @@
+# Doxyfile 1.5.5
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+DOXYFILE_ENCODING      = UTF-8
+PROJECT_NAME           = gms
+PROJECT_NUMBER         = 0.1
+OUTPUT_DIRECTORY       = ./doc-doxygen/
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = YES
+STRIP_FROM_PATH        = ./
+STRIP_FROM_INC_PATH    = 
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = NO
+QT_AUTOBRIEF           = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = NO
+INHERIT_DOCS           = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE               = 4
+ALIASES                = 
+OPTIMIZE_OUTPUT_FOR_C  = YES
+OPTIMIZE_OUTPUT_JAVA   = NO
+OPTIMIZE_FOR_FORTRAN   = NO
+OPTIMIZE_OUTPUT_VHDL   = NO
+BUILTIN_STL_SUPPORT    = NO
+CPP_CLI_SUPPORT        = NO
+SIP_SUPPORT            = NO
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING            = YES
+TYPEDEF_HIDES_STRUCT   = NO
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = NO
+EXTRACT_PRIVATE        = NO
+EXTRACT_STATIC         = YES
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = NO
+EXTRACT_ANON_NSPACES   = NO
+HIDE_UNDOC_MEMBERS     = YES
+HIDE_UNDOC_CLASSES     = YES
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = NO
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_GROUP_NAMES       = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+GENERATE_BUGLIST       = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       = 
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = NO
+FILE_VERSION_FILTER    = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = ../src
+INPUT_ENCODING         = UTF-8
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.d \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.idl \
+                         *.odl \
+                         *.cs \
+                         *.php \
+                         *.php3 \
+                         *.inc \
+                         *.m \
+                         *.mm \
+                         *.dox \
+                         *.py \
+                         *.f90 \
+                         *.f \
+                         *.vhd \
+                         *.vhdl \
+                         *.C \
+                         *.CC \
+                         *.C++ \
+                         *.II \
+                         *.I++ \
+                         *.H \
+                         *.HH \
+                         *.H++ \
+                         *.CS \
+                         *.PHP \
+                         *.PHP3 \
+                         *.M \
+                         *.MM \
+                         *.PY \
+                         *.F90 \
+                         *.F \
+                         *.VHD \
+                         *.VHDL
+RECURSIVE              = NO
+EXCLUDE                = 
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       = 
+EXCLUDE_SYMBOLS        = 
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       = *
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = 
+INPUT_FILTER           = 
+FILTER_PATTERNS        = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = YES
+INLINE_SOURCES         = YES
+STRIP_CODE_COMMENTS    = YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION    = NO
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS              = NO
+VERBATIM_HEADERS       = NO
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            = 
+HTML_FOOTER            = 
+HTML_STYLESHEET        = 
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = NO
+GENERATE_DOCSET        = NO
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+HTML_DYNAMIC_SECTIONS  = NO
+CHM_FILE               = 
+HHC_LOCATION           = 
+GENERATE_CHI           = NO
+BINARY_TOC             = NO
+TOC_EXPAND             = NO
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NO
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         = 
+LATEX_HEADER           = 
+PDF_HYPERLINKS         = YES
+USE_PDFLATEX           = YES
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    = 
+RTF_EXTENSIONS_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             = 
+XML_DTD                = 
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX = 
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = YES
+EXPAND_ONLY_PREDEF     = YES
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = 
+INCLUDE_FILE_PATTERNS  = 
+PREDEFINED             = 
+EXPAND_AS_DEFINED      = 
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = 
+GENERATE_TAGFILE       = 
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = NO
+MSCGEN_PATH            = 
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = YES
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = NO
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = YES
+CALLER_GRAPH           = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = 
+DOTFILE_DIRS           = 
+DOT_GRAPH_MAX_NODES    = 50
+MAX_DOT_GRAPH_DEPTH    = 1000
+DOT_TRANSPARENT        = YES
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+SEARCHENGINE           = NO

Added: trunk/geany-mini-script/doc/gms_help.pdf
===================================================================
(Binary files differ)


Property changes on: trunk/geany-mini-script/doc/gms_help.pdf
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/geany-mini-script/src/Makefile.am
===================================================================
--- trunk/geany-mini-script/src/Makefile.am	                        (rev 0)
+++ trunk/geany-mini-script/src/Makefile.am	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,7 @@
+## Makefile.am -- Process this file with automake to produce Makefile.in
+lib_LTLIBRARIES = gms.la
+gms_la_SOURCES  = gms.c  gms_gui.c
+gms_la_LDFLAGS  = -module -avoid-version
+gms_la_LIBADD   = @GEANY_LIBS@
+
+AM_CPPFLAGS     = @GEANY_CFLAGS@ -DLOCALEDIR=\""$(localedir)"\"

Added: trunk/geany-mini-script/src/gms.c
===================================================================
--- trunk/geany-mini-script/src/gms.c	                        (rev 0)
+++ trunk/geany-mini-script/src/gms.c	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,293 @@
+/*
+ * gms.c: miniscript plugin for geany editor
+ *            Geany, a fast and lightweight IDE
+ *
+ * Copyright 2008 Pascal BURLOT <prublot(at)users(dot)sourceforge(dot)net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ */
+
+/**
+ * gms is a tools to apply a script filter on a text selection, or on
+ * the whole document, or all opened document.
+ *
+ * note: the script filter could be : Unix shell, perl , python , sed ,awk ...
+ *
+ * Note: This is not installed by default, but (on *nix) you can build it
+ * as follows:
+ * make clean ; make
+ *
+ * Then :
+ * make install_local
+ *
+ * Or copy or symlink the gms.so file to ~/.geany/plugins
+ * - it will be loaded at next startup.
+ */
+
+/* headers */
+#include    <stdlib.h>
+#include    <glib.h>
+#include    <glib/gstdio.h>
+
+/* geany headers */
+#include    "geany.h"
+#include    "support.h"
+#include    "plugindata.h"
+#include    "editor.h"
+#include    "document.h"
+#include    "prefs.h"
+#include    "utils.h"
+#include    "ui_utils.h"
+#include    "pluginmacros.h"
+
+/* user header */
+#include    "gms.h"
+#include    "gms_gui.h"
+#include    "gms_debug.h"
+
+GeanyPlugin     *geany_plugin;
+GeanyData       *geany_data;
+GeanyFunctions  *geany_functions;
+
+/* Check that the running Geany supports the plugin API used below, and check
+ * for binary compatibility. */
+PLUGIN_VERSION_CHECK(100)
+
+/* All plugins must set name, description, version and author. */
+PLUGIN_SET_INFO(_("geany mini-script"), _("GMS (Geany Mini-Script filter plugin)"),
+                    VERSION , _("Pascal BURLOT, a Geany fan"))
+
+static GtkWidget     *gms_item   = NULL ;
+static gms_handle_t gms_hnd     = NULL ;
+static gchar        *gms_command = NULL ;
+
+
+/**
+ * \brief the function creates from the current selection to the input file
+ */
+static void create_selection_2_input_file( ScintillaObject *sci )
+{
+    gchar  *contents = NULL;
+    gint    size_buf = p_sci->get_selected_text_length(sci);
+
+    contents = GMS_G_MALLOC( gchar, size_buf + 1  ) ;
+    GMS_PNULL(contents) ;
+
+    p_sci->get_selected_text( sci ,contents  );
+
+    g_file_set_contents(gms_get_in_filename(gms_hnd), contents, -1 , NULL );
+    GMS_G_FREE(contents);
+}
+
+/**
+ * \brief the function reads the result file
+ */
+static gchar *read_result_file( gchar *filename )
+{
+    gchar *utf8     = NULL;
+    gchar *contents = NULL;
+    GError *error   = NULL ;
+    if (g_file_get_contents(filename, &contents, NULL, &error ))
+    {
+        if ( contents )
+        {
+            utf8 = g_locale_to_utf8 (contents, -1, NULL, NULL, NULL);
+            GMS_G_FREE(contents);
+        }
+    }
+    return utf8 ;
+}
+/**
+ * \brief the function select entirely the document
+ */
+static void select_entirely_doc( ScintillaObject *sci  )
+{
+    gint            size_buf = p_sci->get_length(sci);
+
+    p_sci->set_selection_start( sci , 0 ) ;
+    p_sci->set_selection_end( sci , size_buf ) ;
+}
+
+/**
+ * \brief the function updates the current document
+ */
+static void update_doc( ScintillaObject *sci, gchar * contents )
+{
+    if (contents==NULL) return ;
+    p_sci->replace_sel( sci, contents  );
+}
+/**
+ * \brief the function deletes the tempory files
+ */
+static void delete_tmp_files()
+{
+    if( g_file_test( gms_get_in_filename(gms_hnd),G_FILE_TEST_EXISTS) == TRUE )
+        g_unlink( gms_get_in_filename(gms_hnd) ) ;
+    if( g_file_test( gms_get_out_filename(gms_hnd),G_FILE_TEST_EXISTS) == TRUE )
+        g_unlink( gms_get_out_filename(gms_hnd) ) ;
+    if( g_file_test( gms_get_filter_filename(gms_hnd),G_FILE_TEST_EXISTS) == TRUE )
+        g_unlink( gms_get_filter_filename(gms_hnd) ) ;
+}
+
+/**
+ * \brief the function updates the current document
+ */
+static gint run_filter( ScintillaObject *sci )
+{
+    int r , ret = 0 ;
+    gchar *result = NULL ;
+
+    gms_command = gms_get_str_command(gms_hnd);
+    r = system( gms_command ) ;
+    if ( r != 0 )
+    {
+        GtkWidget *dlg ;
+        result = read_result_file( gms_get_error_filename(gms_hnd) ) ;
+
+        dlg = gtk_message_dialog_new( GTK_WINDOW(geany->main_widgets->window),
+                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                        GTK_MESSAGE_ERROR,
+                        GTK_BUTTONS_CLOSE,
+                        result);
+
+        gtk_dialog_run(GTK_DIALOG(dlg));
+        gtk_widget_destroy(GTK_WIDGET(dlg)) ;
+		ret = -1 ;
+    }
+    else
+    {
+        result = read_result_file( gms_get_out_filename(gms_hnd) ) ;
+
+        if ( gms_get_output_mode( gms_hnd) == OUT_CURRENT_DOC )
+        {
+            if ( gms_get_input_mode( gms_hnd) != IN_SELECTION )
+                select_entirely_doc(  sci  ) ;
+
+            update_doc( sci, result ) ;
+        }
+        else
+        {
+            p_document->new_file( NULL, NULL, result ) ;
+        }
+    }
+    GMS_G_FREE( result ) ;
+	
+	return ret ;
+}
+
+/**
+ * \brief Callback when the menu item is clicked.
+ */
+static void item_activate(GtkMenuItem *menuitem, gpointer gdata)
+{
+    GeanyDocument   *doc = p_document->get_current();
+    ScintillaObject *sci = doc->editor->sci ;
+    if ( gms_hnd  == NULL )
+        return ;
+
+    if ( gms_dlg( gms_hnd ) == 0 )
+        return ;
+
+    gms_create_filter_file( gms_hnd ) ;
+
+    switch ( gms_get_input_mode(gms_hnd) )
+    {
+        case IN_CURRENT_DOC :
+            select_entirely_doc(  sci  ) ;
+            create_selection_2_input_file(sci) ;
+            run_filter( sci ) ;
+            delete_tmp_files() ;
+            break;
+        case IN_SELECTION :
+            create_selection_2_input_file(sci) ;
+            run_filter( sci ) ;
+            delete_tmp_files() ;
+            break;
+        case IN_DOCS_SESSION :
+            {
+                guint nb_doc = 0  , i=0;
+
+				/* find the opened document in the geany session */
+                while ( (doc = p_document->get_from_page(nb_doc))!=NULL ) nb_doc++;
+
+                /* For each document */
+                for( i=0; i<nb_doc;i++)
+                {
+                    doc = p_document->get_from_page(i) ;
+                    sci = doc->editor->sci ;
+                    select_entirely_doc(  sci  ) ;
+                    create_selection_2_input_file(sci) ;
+                    if ( run_filter( sci ) )
+						break ; // if error then stop the loop
+                }
+            }
+            delete_tmp_files() ;
+            break;
+        default:
+            delete_tmp_files() ;
+            return ;
+    }
+
+}
+
+/**
+ * \brief Called by Geany to initialize the plugin.
+ * \note data is the same as geany_data.
+ */
+void plugin_init(GeanyData *data)
+{
+    gms_hnd = gms_new(geany->main_widgets->window,
+                    data->interface_prefs->editor_font ,
+                    data->editor_prefs->indentation->width
+                    ) ;
+
+    /* Add an item to the Tools menu */
+    gms_item = gtk_menu_item_new_with_mnemonic(_("_Mini-Script"));
+    gtk_widget_show(gms_item);
+    gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), gms_item);
+    g_signal_connect(gms_item, "activate", G_CALLBACK(item_activate), NULL);
+
+    /* make the menu item sensitive only when documents are open */
+    p_ui->add_document_sensitive(gms_item);
+
+}
+
+
+/* Called by Geany to show the plugin's configure dialog. This function is always called after
+ * plugin_init() was called.
+ * You can omit this function if the plugin doesn't need to be configured.
+ * Note: parent is the parent window which can be used as the transient window for the created
+ *  dialog. */
+#if 1
+GtkWidget *plugin_configure(GtkDialog *dialog)
+{
+    g_signal_connect(dialog, "response", G_CALLBACK(on_gms_configure_response), gms_hnd );
+    return gms_configure_gui( gms_hnd ) ;
+}
+#endif
+
+/**
+ * \brief Called by Geany before unloading the plugin.
+ */
+void plugin_cleanup(void)
+{
+    if ( gms_hnd != NULL )
+       gms_delete( &gms_hnd ) ;
+
+    /* remove the menu item added in plugin_init() */
+    gtk_widget_destroy(gms_item);
+}

Added: trunk/geany-mini-script/src/gms.h
===================================================================
--- trunk/geany-mini-script/src/gms.h	                        (rev 0)
+++ trunk/geany-mini-script/src/gms.h	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,33 @@
+/*
+ * gms.h: miniscript plugin for geany editor
+ *            Geany, a fast and lightweight IDE
+ *
+ * Copyright 2008 Pascal BURLOT <prublot(at)users(dot)sourceforge(dot)net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GMS_H
+#define GMS_H
+
+
+extern GeanyPlugin      *geany_plugin;
+extern GeanyData        *geany_data;
+extern GeanyFunctions   *geany_functions;
+
+
+#endif /* GMS_H */

Added: trunk/geany-mini-script/src/gms_debug.h
===================================================================
--- trunk/geany-mini-script/src/gms_debug.h	                        (rev 0)
+++ trunk/geany-mini-script/src/gms_debug.h	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,137 @@
+/*
+ * gms_debug.h: miniscript plugin for geany editor
+ *            Geany, a fast and lightweight IDE
+ *
+ * Copyright 2008 Pascal BURLOT <prublot(at)users(dot)sourceforge(dot)net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ */
+
+/*******************************************************************************
+ * \file  gms_debug.h
+ * \brief macros used for debugging
+ */
+
+#ifndef GMS_DEBUG_H
+#define GMS_DEBUG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//! \brief Macro to glib allocation (glib)
+#define GMS_G_MALLOC(t,n)       ((t *) g_malloc(sizeof(t)*n))
+//! \brief Macro to glib allocation (glib) with zero filling
+#define GMS_G_MALLOC0(t,n)      ((t *) g_malloc0(sizeof(t)*n))
+
+//! \brief Macro to free (glib)
+#define GMS_G_FREE(p)   if ( p != NULL ) { g_free(p) ; p=NULL ; }
+
+//! \brief Macro pour la liberation des PangoFontDescription
+#define GMS_FREE_FONTDESC(p) if ( p != NULL ) { pango_font_description_free (p) ;p=NULL ; }
+
+//! \brief Macro for freeing a GtkWidget structure
+#define GMS_FREE_WIDGET(p)   if ( p != NULL ) { gtk_widget_destroy(GTK_WIDGET(p)) ;p=NULL ; }
+
+
+#ifdef GMS_DEBUG
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#define GMS_CALL(f) \
+                                                                    \
+  if (((int)(f)) == -1)                                             \
+  {                                                                 \
+    int err = errno;                                                \
+    char *strerr = strerror(err);                                   \
+                                                                    \
+    fprintf(stderr,                                                 \
+            "GMS_CALL(%s): Error at line %u, file %s: %s (errno=%d)\n", \
+            #f, __LINE__, __FILE__,                                 \
+            strerr == NULL ? "Bad error number" : strerr,           \
+            err);                                                   \
+    abort();                                                        \
+  }
+
+#define GMS_PNULL(pp) \
+                                                                    \
+  if ( (pp) == NULL)                                                \
+  {                                                                 \
+    fprintf(stderr,                                                 \
+            "GMS_PNULL(%s): null pointer => %s at line %u, file %s: \n",\
+            #pp, __FUNCTION__, __LINE__, __FILE__ );                \
+    abort();                                                        \
+  }
+
+#define GMS_FOPEN(pp,...)                                            \
+  pp=fopen(__VA_ARGS__) ;                                           \
+  if ( (pp) == NULL)                                                \
+  {                                                                 \
+    int err = errno;                                                \
+    char *strerr = strerror(err);                                   \
+                                                                    \
+    fprintf(stderr,                                                 \
+            "%s=fopen%s: \n\tError at line %u, file %s: %s (errno=%d)\n",\
+            #pp, #__VA_ARGS__, __LINE__, __FILE__ ,                         \
+            strerr == NULL ? "Bad error number" : strerr,           \
+            err);                                                   \
+    abort();                                                        \
+  }
+
+#define GMS_ASSERT(cc)                                    \
+                                                         \
+  if (!(cc))                                             \
+  {                                                      \
+    fprintf(stderr,                                      \
+            "GMS_ASSERT(%s): %s at line %u, file %s\n",   \
+            #cc,  __FUNCTION__, __LINE__, __FILE__);     \
+    abort();                                             \
+  }
+
+#define GMS_WARNING(cc)                                   \
+                                                         \
+  if ((cc))                                              \
+  {                                                      \
+    fprintf(stderr,                                      \
+            "GMS_WARNING(%s): %s at line %u, file %s\n",  \
+            #cc, __FUNCTION__, __LINE__, __FILE__);      \
+  }
+
+#define GMS_FINFO(fd,...) fprintf(fd, "INFO:"__VA_ARGS__)
+#define GMS_INFO(...)     printf("INFO:"__VA_ARGS__)
+
+#else
+
+#define GMS_CALL(f)  (f)
+#define GMS_ASSERT(cc)
+#define GMS_WARNING(cc)
+#define GMS_PNULL(pp)
+#define GMS_FOPEN(pp,...)   pp=fopen(__VA_ARGS__)
+#define GMS_FINFO(fd,...)
+#define GMS_INFO(...)
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GMS_DEBUG_H */


Property changes on: trunk/geany-mini-script/src/gms_debug.h
___________________________________________________________________
Added: svn:executable
   + 

Added: trunk/geany-mini-script/src/gms_gui.c
===================================================================
--- trunk/geany-mini-script/src/gms_gui.c	                        (rev 0)
+++ trunk/geany-mini-script/src/gms_gui.c	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,749 @@
+/*
+ * gms_gui.c: miniscript plugin for geany editor
+ *            Geany, a fast and lightweight IDE
+ *
+ * Copyright 2008 Pascal BURLOT <prublot(at)users(dot)sourceforge(dot)net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ */
+
+/**
+ * \file  gms_gui.c
+ * \brief it is the graphical user interface of the geany miniscript plugin
+ */
+
+#include    <glib.h>
+#include    <glib/gstdio.h>
+#include    <glib/gprintf.h>
+
+#include    <stdlib.h>
+#include    <string.h>
+#include    <sys/stat.h>
+#include    <sys/types.h>
+#include    <unistd.h>
+
+#include    <pango/pango.h>
+
+/* geany headers */
+#include    "geany.h"
+#include    "support.h"
+#include    "plugindata.h"
+#include    "editor.h"
+#include    "document.h"
+#include    "prefs.h"
+#include    "utils.h"
+#include    "ui_utils.h"
+#include    "pluginmacros.h"
+
+/* user header */
+#include    "gms_debug.h"
+#include    "gms.h"
+#include    "gms_gui.h"
+
+/*
+ * *****************************************************************************
+ *  Local Macro and new local type definition
+ */
+//! \brief Number of script type
+#define GMS_NB_TYPE_SCRIPT  6
+//! \brief Number of char of the line buffer
+#define GMS_MAX_LINE        127
+
+//! \brief macro uset to cast a gms_handle_t  to a gms_private_t pointer
+#define GMS_PRIVATE(p) ((gms_private_t *) p)
+
+//! \brief definition of gui data structure
+typedef struct {
+    GtkWidget *dlg            ; //!< Dialog widget
+    GtkWidget   *cb_st        ; //!< Script type combobox
+    GtkWidget   *t_script     ; //!< script text
+    GtkWidget   *rb_select    ; //!< radio button : filtering the selection
+    GtkWidget   *rb_doc       ; //!< radio button : filtering the current document
+    GtkWidget   *rb_session   ; //!< radio button : filtering all documents of the current session
+    GtkWidget   *rb_cdoc      ; //!< radio button : the filter output is in the current document
+    GtkWidget   *rb_ndoc      ; //!< radio button : the filter output is in the current document
+
+    GtkWidget *e_script[GMS_NB_TYPE_SCRIPT] ; //!< entry for script configuration
+
+    PangoFontDescription *fontdesc;
+} gms_gui_t  ;
+
+//! \brief definition of mini-script data structure
+typedef struct {
+    int id ;                                     //!< ID of the instance
+    GString    *cmd ;                            //!< Command string of filtering
+    GtkWidget  *mw ;                             //!< MainWindow of Geany
+    gms_gui_t  w  ;                             //!< Widgets of minis-script gui
+    GString    *input_name ;                     //!< filename of the filter input
+    GString    *filter_name ;                    //!< filter filename
+    GString    *output_name ;                    //!< filename of the filter output
+    GString    *error_name ;                     //!< errors filename
+    GString    *script_cmd[GMS_NB_TYPE_SCRIPT]; //!< array of script command names
+} gms_private_t  ;
+/*
+ * *****************************************************************************
+ *  Global variables
+ */
+
+/*
+ * *****************************************************************************
+ *  Local variables
+ */
+static unsigned char inst_cnt = 0  ; //!< counter of instance
+static gchar bufline[GMS_MAX_LINE+1]; //!< buffer used to read the configuration file
+
+static const gchar geany_d[]         = ".geany"    ; //!< geany directory
+static const gchar pref_filename[]   = "gms.rc"    ; //!< preferences filename
+static const gchar prefix_filename[] = "/tmp/gms"  ; //!< prefix filename
+static const gchar in_ext[]          = ".in"       ; //!< filename extension for the input file
+static const gchar out_ext[]         = ".out"      ; //!< filename extension for the output file
+static const gchar filter_ext[]      = ".filter"   ; //!< filename extension for the filter file
+static const gchar error_ext[]       = ".error"    ; //!< filename extension for the error file
+
+///< \brief It's the default script command
+static const gchar *default_script_cmd[GMS_NB_TYPE_SCRIPT] = {
+    "${SHELL} ", "perl ", "python ", "sed -f ", "awk -f ", "cat - "  };
+
+///< \brief It's the label for the script command combobox
+const gchar *label_script_cmd[GMS_NB_TYPE_SCRIPT] = {
+    "Shell", "Perl", "Python", "Sed", "Awk", "User" };
+
+///< \brief It's the information string for the information dialog box
+static const gchar str_info[] = "<b>GMS : Geany Mini-Script filter Plugin</b>\n\
+This plugin is a tools to apply a script filter on :\n\
+   o the text selection,\n\
+   o the current document,\n\
+   o all documents of the current session.\n\
+\n\
+The filter type can be : \n\
+   o Unix shell script, \n\
+   o perl script, \n\
+   o python script, \n\
+   o sed commands,\n\
+   o awk script.\n\
+\n\
+<b>AUTHOR</b>\n\
+   Written by Pascal BURLOT (December,2008)\n\
+\n\
+<b>LICENSE:</b>\n\
+This program is free software; you can redistribute\n\
+it and/or modify it under the terms of the GNU \n\
+General Public License as published by the Free\n\
+Software Foundation; either version 2 of the License,\n\
+or (at your option) any later version.";
+
+/*
+ * *****************************************************************************
+ *  Local functions
+ */
+
+/**
+ * \brief the function loads the preferences file
+ */
+static void load_prefs_file(
+    gms_private_t *this  ///< pointer of mini-script data structure
+    )
+{
+    GString *gms_pref = g_string_new("") ;
+
+    g_string_printf(gms_pref , "%s/%s/%s", getenv("HOME"),geany_d,pref_filename );
+
+    if ( g_file_test( gms_pref->str, G_FILE_TEST_EXISTS ) == TRUE )
+    {
+        FILE *fd = g_fopen( gms_pref->str, "r" ) ;
+        if ( fd != NULL )
+        {
+            int  ii ;
+            for ( ii = 0 ; ii <GMS_NB_TYPE_SCRIPT ;ii++ )
+            {
+                fgets(bufline,GMS_MAX_LINE,fd);
+                fgets(bufline,GMS_MAX_LINE,fd);
+                bufline[strlen(bufline)-1] = 0 ;
+                g_string_assign(this->script_cmd[ii] , bufline ) ;
+            }
+            fclose(fd) ;
+        }
+     }
+    g_string_free( gms_pref , TRUE) ;
+}
+
+/**
+ * \brief the function saves the preferences file
+ */
+static void save_prefs_file(
+        gms_private_t *this ///< pointer of mini-script data structure
+    )
+{
+    GString *gms_pref = g_string_new(getenv("HOME"));
+    g_string_append_c( gms_pref, '/' );
+    g_string_append( gms_pref, geany_d );
+
+    if ( g_file_test( gms_pref->str, G_FILE_TEST_EXISTS ) != TRUE )
+        g_mkdir( gms_pref->str, 0755 ) ;
+
+    if ( g_file_test( gms_pref->str, G_FILE_TEST_IS_DIR ) == TRUE )
+    {
+        FILE *fd ;
+        g_string_append_c( gms_pref, '/' );
+        g_string_append( gms_pref, pref_filename );
+
+        fd = g_fopen( gms_pref->str, "w" ) ;
+        if ( fd != NULL )
+        {
+            int  ii ;
+            for ( ii = 0 ; ii <GMS_NB_TYPE_SCRIPT ;ii++ )
+                fprintf(fd,"# %s\n%s\n",label_script_cmd[ii],this->script_cmd[ii]->str);
+
+            fclose(fd) ;
+        }
+    }
+    g_string_free( gms_pref , TRUE) ;
+}
+
+/**
+ * \brief Callback associated to a button "new"
+ */
+static void gms_cb_new(
+    GtkWidget *w  ,
+    gpointer data
+    )
+{
+    gms_private_t *this = GMS_PRIVATE(data) ;
+    GtkTextIter start;
+    GtkTextIter end;
+    GtkTextBuffer* text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW( this->w.t_script ) );
+    gtk_text_buffer_get_start_iter(text_buffer,&start);
+    gtk_text_buffer_get_end_iter(text_buffer,&end);
+    gtk_text_buffer_delete( text_buffer ,&start , &end) ;
+}
+
+/**
+ * \brief Callback associated to a button "load"
+ */
+static void gms_cb_load(
+    GtkWidget *w  ,
+    gpointer  data
+    )
+{
+    gms_private_t *this = GMS_PRIVATE(data) ;
+    GtkWidget    *p_dialog = gtk_file_chooser_dialog_new ("Load Mini-Script File",
+                                    GTK_WINDOW(this->mw) ,
+                                    GTK_FILE_CHOOSER_ACTION_OPEN,
+                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                    GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+                                    NULL);
+    if ( p_dialog == NULL )
+        return ;
+
+    if (gtk_dialog_run (GTK_DIALOG (p_dialog)) == GTK_RESPONSE_ACCEPT)
+    {
+        gms_private_t *this = GMS_PRIVATE(data) ;
+        gchar         *filename = NULL;
+
+        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (p_dialog));
+
+        if(filename != NULL)
+        {
+            gchar *contents = NULL;
+            GError *error = NULL ;
+
+            if (g_file_get_contents(filename, &contents, NULL, &error ))
+            {
+                gchar         *utf8 = NULL;
+                GtkTextIter   start;
+                GtkTextIter   end;
+                GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW( this->w.t_script ) );
+
+                /* destroy the old text of buffer */
+                gtk_text_buffer_get_start_iter(text_buffer,&start);
+                gtk_text_buffer_get_end_iter(text_buffer,&end);
+                gtk_text_buffer_delete( text_buffer ,&start , &end) ;
+
+                /* Copy file contents in GtkTextView */
+                gtk_text_buffer_get_start_iter(text_buffer,&start);
+                utf8 = g_locale_to_utf8 (contents, -1, NULL, NULL, NULL);
+                GMS_G_FREE(contents);
+                gtk_text_buffer_insert (text_buffer, &start, utf8, -1);
+                GMS_G_FREE(utf8);
+            }
+            GMS_G_FREE(filename);
+        }
+    }
+    gtk_widget_destroy (p_dialog);
+}
+
+
+/**
+ * \brief Callback associated to a button "load"
+ */
+static void gms_cb_save(
+    GtkWidget *w  ,
+    gpointer  data
+    )
+{
+    gms_private_t *this = GMS_PRIVATE(data) ;
+    GtkWidget    *p_dialog = gtk_file_chooser_dialog_new ("Save Mini-Script File",
+                                    GTK_WINDOW(this->mw) ,
+                                    GTK_FILE_CHOOSER_ACTION_SAVE,
+                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                    GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+                                    NULL);
+    if ( p_dialog == NULL )
+        return ;
+
+    if (gtk_dialog_run (GTK_DIALOG (p_dialog)) == GTK_RESPONSE_ACCEPT)
+    {
+        gms_private_t *this = GMS_PRIVATE(data) ;
+        gchar         *filename = NULL;
+
+        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (p_dialog));
+
+        if(filename != NULL)
+        {
+            gchar        *contents = NULL;
+            GtkTextIter   start;
+            GtkTextIter   end;
+            GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW( this->w.t_script ) );
+            gtk_text_buffer_get_start_iter(text_buffer,&start);
+            gtk_text_buffer_get_end_iter(text_buffer,&end);
+            contents=gtk_text_buffer_get_text(text_buffer,&start,&end,FALSE);
+            g_file_set_contents(filename, contents, -1 , NULL );
+            GMS_G_FREE(contents);
+            GMS_G_FREE(filename);
+       }
+    }
+    gtk_widget_destroy (p_dialog);
+}
+/**
+ * \brief Callback associated to a button "load"
+ */
+static void gms_cb_info(
+    GtkWidget *w  ,
+    gpointer  data
+    )
+{
+    gms_private_t *this = GMS_PRIVATE(data) ;
+
+    GtkWidget *dlg = gtk_message_dialog_new_with_markup( GTK_WINDOW(this->mw),
+                                GTK_DIALOG_DESTROY_WITH_PARENT,
+                                GTK_MESSAGE_INFO,
+                                GTK_BUTTONS_CLOSE,
+                                str_info);
+    gtk_dialog_run(GTK_DIALOG(dlg));
+    GMS_FREE_WIDGET(dlg);
+}
+
+/*
+ * *****************************************************************************
+ *  Global functions
+ */
+
+/**
+ * \brief the function initializes the mini-script gui structure.
+ */
+gms_handle_t gms_new(
+    GtkWidget *mw, ///< Geany Main windows
+    gchar *font  , ///< Geany editor font
+    gint tabs      ///< Geany editor tabstop
+    )
+{
+    gms_private_t *this = GMS_G_MALLOC0(gms_private_t,1);
+
+    if ( this != NULL )
+    {
+        GtkBox     *vb_dlg        ; //!< vbox of dialog box
+        GtkWidget  *hb_st         ; //!< Hbox for script type
+        GtkWidget  *b_open        ; //!< button for loading a existing script
+        GtkWidget  *b_save        ; //!< button for saving the current script
+        GtkWidget  *b_new         ; //!< button for erasing the script text box
+        GtkWidget  *b_info        ; //!< button for info box
+        GtkWidget  *sb_script     ; //!< Scroll box for script text
+        GtkWidget  *hb_rb         ; //!< Hbox for radio buttons
+        GtkWidget  *f_rbi         ; //!< frame for radio buttons : input filter
+        GtkWidget  *hb_rbi        ; //!< Hbox for radio buttons
+        GtkWidget  *f_rbo         ; //!< frame for radio buttons : input filter
+        GtkWidget  *hb_rbo        ; //!< Hbox for radio buttons
+
+        PangoTabArray* tabsarray  ;
+
+        GdkScreen  *ecran  = gdk_screen_get_default();
+        gint        width  = gdk_screen_get_width(ecran) ;
+        gint        height = gdk_screen_get_height(ecran) ;
+        gint        i , size_pid ;
+
+        this->mw = mw ;
+        this->cmd = g_string_new(""); ;
+
+        this->w.dlg = gtk_dialog_new_with_buttons(
+                        _("Mini-Script Filter"),
+                        GTK_WINDOW( mw ),
+                        GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL,
+                        GTK_STOCK_APPLY,GTK_RESPONSE_APPLY,
+                        GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,
+                        NULL
+                         ) ;
+        vb_dlg   = GTK_BOX (GTK_DIALOG(this->w.dlg)->vbox)  ;
+
+        if ( width > 800 )
+            width = 800 ;
+
+        if ( height > 600 )
+            height = 600 ;
+
+        gtk_window_set_default_size( GTK_WINDOW(this->w.dlg) , width/2 , height/2 ) ;
+
+    // Hbox : type de script
+        hb_st = gtk_hbox_new (FALSE, 0);
+        gtk_container_set_border_width (GTK_CONTAINER (hb_st), 0);
+        gtk_box_pack_start( vb_dlg , hb_st, FALSE, FALSE, 0);
+
+        b_new   = gtk_button_new_from_stock( GTK_STOCK_CLEAR  ) ;
+        gtk_box_pack_start( GTK_BOX (hb_st), b_new, FALSE, FALSE, 0);
+        g_signal_connect (G_OBJECT (b_new), "clicked",G_CALLBACK (gms_cb_new), (gpointer) this );
+
+        b_open  = gtk_button_new_from_stock( GTK_STOCK_OPEN ) ;
+        gtk_box_pack_start( GTK_BOX (hb_st), b_open, FALSE, FALSE, 0);
+        g_signal_connect (G_OBJECT (b_open), "clicked",G_CALLBACK (gms_cb_load), (gpointer) this );
+
+        b_save  = gtk_button_new_from_stock( GTK_STOCK_SAVE_AS ) ;
+        gtk_box_pack_start( GTK_BOX (hb_st),b_save, FALSE, FALSE, 0);
+        g_signal_connect (G_OBJECT (b_save), "clicked",G_CALLBACK (gms_cb_save), (gpointer) this );
+
+        b_info  = gtk_button_new_from_stock( GTK_STOCK_INFO) ;
+        gtk_box_pack_end( GTK_BOX (hb_st), b_info, FALSE, FALSE, 0);
+        g_signal_connect (G_OBJECT (b_info), "clicked",G_CALLBACK (gms_cb_info), (gpointer) this );
+
+        this->w.cb_st = gtk_combo_box_new_text() ;
+        for ( i=0;i<GMS_NB_TYPE_SCRIPT ; i++ )
+           gtk_combo_box_append_text( GTK_COMBO_BOX(this->w.cb_st), label_script_cmd[i] ) ;
+        gtk_combo_box_set_active(GTK_COMBO_BOX(this->w.cb_st), 0 );
+        gtk_box_pack_start(GTK_BOX(hb_st), this->w.cb_st, FALSE, FALSE, 0);
+        GTK_WIDGET_SET_FLAGS (this->w.cb_st, GTK_CAN_DEFAULT);
+
+    // Scroll Box : script
+        sb_script =  gtk_scrolled_window_new (NULL,NULL);
+        gtk_container_set_border_width (GTK_CONTAINER (sb_script), 0);
+        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sb_script),
+                                        GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+        gtk_box_pack_start(vb_dlg, sb_script, TRUE, TRUE, 0);
+
+        this->w.t_script =  gtk_text_view_new();
+        this->w.fontdesc = pango_font_description_from_string(font);
+        gtk_widget_modify_font( this->w.t_script, this->w.fontdesc );
+        gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW (sb_script), this->w.t_script);
+        { // find the width of the space character
+            gint largeur,hauteur ;
+            PangoLayout *layout = gtk_widget_create_pango_layout (this->w.t_script, " ");
+            pango_layout_set_font_description (layout, this->w.fontdesc);
+            pango_layout_get_pixel_size(layout, &largeur, &hauteur);
+            tabs = tabs*largeur ;
+            g_object_unref (layout);
+        }
+        tabsarray = pango_tab_array_new_with_positions ( 1,  TRUE  , PANGO_TAB_LEFT, tabs ) ;
+        gtk_text_view_set_tabs(GTK_TEXT_VIEW(this->w.t_script),tabsarray);
+
+    // Hbox : Radio bouttons for choosing the input/output:
+        hb_rb = gtk_hbox_new (FALSE, 0);
+        gtk_container_set_border_width (GTK_CONTAINER (hb_rb), 0);
+        gtk_box_pack_start( vb_dlg, hb_rb, FALSE, FALSE, 0);
+
+    // Hbox : Radio bouttons for choosing the input:
+    //                   selection/current document/all documents of the current session
+        f_rbi = gtk_frame_new (_("filter input") );
+        gtk_box_pack_start( GTK_BOX (hb_rb), f_rbi, FALSE, FALSE, 0);
+
+        hb_rbi = gtk_hbox_new (FALSE, 0);
+        gtk_container_set_border_width (GTK_CONTAINER (hb_rbi), 0);
+        gtk_container_add (GTK_CONTAINER (f_rbi), hb_rbi );
+
+        this->w.rb_select  = gtk_radio_button_new_with_label( NULL, _("selection") ) ;
+        this->w.rb_doc     = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON( this->w.rb_select) ,_("document") ) ;
+        this->w.rb_session = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON( this->w.rb_select) ,_("session") ) ;
+        gtk_box_pack_start(GTK_BOX(hb_rbi), this->w.rb_select, TRUE, TRUE, 0);
+        gtk_box_pack_start(GTK_BOX(hb_rbi), this->w.rb_doc, TRUE, TRUE, 0);
+        gtk_box_pack_start(GTK_BOX(hb_rbi), this->w.rb_session, TRUE, TRUE, 0);
+        gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(this->w.rb_doc) ,TRUE) ;
+
+
+    // Hbox : Radio bouttons for choosing the output:
+    //                   current document/ or new document
+        f_rbo = gtk_frame_new (_("filter output") );
+        gtk_box_pack_start( GTK_BOX(hb_rb), f_rbo, FALSE, FALSE, 0);
+
+        hb_rbo = gtk_hbox_new (FALSE, 0);
+        gtk_container_set_border_width (GTK_CONTAINER(hb_rbo), 0);
+        gtk_container_add (GTK_CONTAINER(f_rbo), hb_rbo );
+
+        this->w.rb_cdoc    = gtk_radio_button_new_with_label( NULL, _("Current Doc.") ) ;
+        this->w.rb_ndoc    = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON( this->w.rb_cdoc) ,_("New Doc.") ) ;
+        gtk_box_pack_start(GTK_BOX(hb_rbo), this->w.rb_cdoc, TRUE, TRUE, 0);
+        gtk_box_pack_start(GTK_BOX(hb_rbo), this->w.rb_ndoc, TRUE, TRUE, 0);
+        gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(this->w.rb_ndoc) ,TRUE) ;
+
+        gtk_widget_show_all(GTK_WIDGET(vb_dlg));
+        this->id  = ++inst_cnt ;
+
+        this->input_name = g_string_new(prefix_filename) ;
+        this->filter_name= g_string_new(prefix_filename) ;
+        this->output_name= g_string_new(prefix_filename) ;
+        this->error_name = g_string_new(prefix_filename) ;
+
+		size_pid = (gint)(2*sizeof(pid_t)) ;
+        g_string_append_printf( this->input_name,"%02x_%0*x%s",
+                    this->id,size_pid, getpid(), in_ext ) ;
+
+        g_string_append_printf(this->filter_name,"%02x_%0*x%s",
+                    this->id,size_pid, getpid(), filter_ext ) ;
+
+        g_string_append_printf(this->output_name,"%02x_%0*x%s",
+                    this->id,size_pid, getpid(), out_ext ) ;
+
+        g_string_append_printf(this->error_name,"%02x_%0*x%s",
+                    this->id,size_pid, getpid(), error_ext ) ;
+
+        for ( i=0;i<GMS_NB_TYPE_SCRIPT ; i++ )
+        {
+            this->script_cmd[i]=g_string_new(default_script_cmd[i] ) ;
+            this->w.e_script[i]=NULL;
+        }
+        load_prefs_file(this) ;
+
+    }
+
+    return GMS_HANDLE(this) ;
+}
+/**
+ * \brief the function destroys the mini-script gui structure.
+ */
+
+void gms_delete(
+    gms_handle_t *hnd  ///< handle of mini-script data structure
+    )
+{
+    if ( hnd != NULL )
+    {
+        gms_private_t *this = GMS_PRIVATE( *hnd ) ;
+        gint i ;
+        gboolean flag = TRUE ;
+
+        GMS_FREE_FONTDESC(this->w.fontdesc );
+        GMS_FREE_WIDGET(this->w.dlg);
+
+        g_string_free( this->input_name  ,flag) ;
+        g_string_free( this->output_name ,flag) ;
+        g_string_free( this->filter_name ,flag) ;
+        g_string_free( this->cmd         ,flag) ;
+
+        for ( i=0;i<GMS_NB_TYPE_SCRIPT ; i++ )
+            g_string_free(this->script_cmd[i] ,flag) ;
+
+
+        GMS_G_FREE( this )  ;
+    }
+}
+
+/**
+ * \brief the function runs the mini-script dialog.
+ */
+int gms_dlg(
+    gms_handle_t hnd ///< handle of mini-script data structure
+    )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+    gint ret = 0 ;
+
+    if ( this == NULL )
+        return 0 ;
+
+    gtk_widget_show(this->w.dlg);
+    ret = gtk_dialog_run(GTK_DIALOG(this->w.dlg));
+    gtk_widget_hide(this->w.dlg);
+
+    if ( ret == GTK_RESPONSE_APPLY )
+        return 1 ;
+    else
+        return 0 ;
+}
+
+/**
+ * \brief the function get the input mode.
+ */
+gms_input_t  gms_get_input_mode(
+    gms_handle_t hnd ///< handle of mini-script data structure
+    )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+    gms_input_t mode  = IN_CURRENT_DOC ;
+
+    if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(this->w.rb_select) ) == TRUE )
+        mode  = IN_SELECTION ;
+    else  if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(this->w.rb_session) ) == TRUE )
+        mode  = IN_DOCS_SESSION ;
+
+    return mode ;
+}
+
+/**
+ * \brief the function get the output mode.
+ */
+gms_output_t  gms_get_output_mode(
+    gms_handle_t hnd ///< handle of mini-script data structure
+    )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+    gms_output_t mode  = OUT_CURRENT_DOC ;
+
+    if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(this->w.rb_ndoc) ) == TRUE )
+        mode  = OUT_NEW_DOC ;
+
+    return mode ;
+}
+
+/**
+ * \brief the function get the input filename for filter input.
+ */
+gchar *gms_get_in_filename(
+    gms_handle_t hnd ///< handle of mini-script data structure
+    )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+    return this->input_name->str ;
+}
+
+/**
+ * \brief the function get the output filename for filter result.
+ */
+gchar *gms_get_out_filename(
+    gms_handle_t hnd ///< handle of mini-script data structure
+    )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+    return this->output_name->str ;
+}
+
+/**
+ * \brief the function get the output filename for filter script.
+ */
+gchar *gms_get_filter_filename( gms_handle_t hnd )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+    return this->filter_name->str ;
+}
+
+/**
+ * \brief the function get the error filename for filter script.
+ */
+gchar *gms_get_error_filename(
+    gms_handle_t hnd ///< handle of mini-script data structure
+    )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+    return this->error_name->str ;
+}
+
+/**
+ * \brief the function creates the filter file.
+ */
+void  gms_create_filter_file(
+    gms_handle_t hnd ///< handle of mini-script data structure
+    )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+    gchar           *contents = NULL;
+    GtkTextIter      start;
+    GtkTextIter      end;
+    GtkTextBuffer   *text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW( this->w.t_script ) );
+
+    gtk_text_buffer_get_start_iter(text_buffer,&start);
+    gtk_text_buffer_get_end_iter(text_buffer,&end);
+    contents=gtk_text_buffer_get_text(text_buffer,&start,&end,FALSE);
+    g_file_set_contents(this->filter_name->str, contents, -1 , NULL );
+    GMS_G_FREE(contents);
+}
+
+/**
+ * \brief the function creates the command string.
+ */
+gchar *gms_get_str_command(
+    gms_handle_t hnd ///< handle of mini-script data structure
+    )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+    gint ii_script = gtk_combo_box_get_active(GTK_COMBO_BOX(this->w.cb_st) ) ;
+
+    g_string_printf( this->cmd,"cat %s | %s %s > %s 2> %s",
+                                this->input_name->str,
+                                    this->script_cmd[ii_script]->str,
+                                        this->filter_name->str,
+                                            this->output_name->str,
+                                                this->error_name->str );
+    return this->cmd->str  ;
+}
+
+/**
+ * \brief the function creates the configuration gui.
+ */
+
+GtkWidget   *gms_configure_gui(
+    gms_handle_t hnd ///< handle of mini-script data structure
+    )
+{
+    gms_private_t *this = GMS_PRIVATE( hnd ) ;
+
+    volatile gint ii ;
+    GtkWidget *vb_pref        ; //!< vbox for mini-script configuration
+    GtkWidget  *f_script      ; //!< frame for configuration script
+    GtkWidget  *t_script      ; //!< table for configuration script
+    GtkWidget  *w ;
+
+    vb_pref= gtk_vbox_new(FALSE, 6);
+    f_script = gtk_frame_new (_("script configuration") );
+    gtk_box_pack_start( GTK_BOX (vb_pref), f_script, FALSE, FALSE, 0);
+
+    t_script = gtk_table_new( GMS_NB_TYPE_SCRIPT ,3,FALSE) ;
+    gtk_container_add (GTK_CONTAINER (f_script), t_script );
+
+    for ( ii = 0 ; ii <GMS_NB_TYPE_SCRIPT ;ii++ )
+    {
+        w = gtk_label_new(label_script_cmd[ii]);
+        gtk_table_attach_defaults(GTK_TABLE(t_script),w, 0,1,ii,ii+1 );
+
+        this->w.e_script[ii] = gtk_entry_new();
+        gtk_entry_set_text(GTK_ENTRY(this->w.e_script[ii]), this->script_cmd[ii]->str);
+        gtk_table_attach_defaults(GTK_TABLE(t_script),this->w.e_script[ii], 1,2,ii,ii+1 );
+    }
+
+    gtk_widget_show_all(vb_pref);
+    return vb_pref ;
+}
+
+/**
+ * \brief Callback associated to a button "new"
+ */
+void on_gms_configure_response(GtkDialog *dialog, gint response, gpointer user_data   )
+{
+    if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
+    {
+        int  ii ;
+        gms_private_t *this = GMS_PRIVATE(user_data) ;
+
+        for ( ii = 0 ; ii <GMS_NB_TYPE_SCRIPT ;ii++ )
+            if (this->w.e_script[ii]!=NULL )
+                g_string_assign( this->script_cmd[ii] , gtk_entry_get_text(GTK_ENTRY(this->w.e_script[ii])));
+        save_prefs_file(this);
+    }
+}

Added: trunk/geany-mini-script/src/gms_gui.h
===================================================================
--- trunk/geany-mini-script/src/gms_gui.h	                        (rev 0)
+++ trunk/geany-mini-script/src/gms_gui.h	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,56 @@
+/*
+ * gms_gui.h: miniscript plugin for geany editor
+ *            Geany, a fast and lightweight IDE
+ *
+ * Copyright 2008 Pascal BURLOT <prublot(at)users(dot)sourceforge(dot)net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ */
+#ifndef GMS_GUI_H
+#define GMS_GUI_H
+
+#define GMS_HANDLE(p) ((gms_handle_t *) p)
+typedef void* gms_handle_t ;
+
+typedef enum {
+    IN_SELECTION    =0,
+    IN_CURRENT_DOC  =1,
+    IN_DOCS_SESSION =3
+} gms_input_t ;
+
+typedef enum {
+    OUT_CURRENT_DOC    =0,
+    OUT_NEW_DOC        =1
+} gms_output_t ;
+
+gms_handle_t gms_new(  GtkWidget *mw, gchar *font, gint tabs);
+void        gms_delete( gms_handle_t *hnd );
+int         gms_dlg( gms_handle_t hnd ) ;
+gchar       *gms_get_in_filename( gms_handle_t hnd ) ;
+gchar       *gms_get_out_filename( gms_handle_t hnd ) ;
+gchar       *gms_get_filter_filename( gms_handle_t hnd ) ;
+gchar       *gms_get_error_filename( gms_handle_t hnd ) ;
+void        gms_create_filter_file( gms_handle_t hnd ) ;
+gchar       *gms_get_str_command( gms_handle_t hnd ) ;
+gms_input_t  gms_get_input_mode( gms_handle_t hnd );
+gms_output_t gms_get_output_mode( gms_handle_t hnd );
+
+GtkWidget   *gms_configure_gui( gms_handle_t hnd );
+void        on_gms_configure_response( GtkDialog *dialog, gint response, gpointer user_data) ;
+
+#endif /* GMS_GUI_H */
+

Added: trunk/geany-mini-script/test/awk.gms
===================================================================
--- trunk/geany-mini-script/test/awk.gms	                        (rev 0)
+++ trunk/geany-mini-script/test/awk.gms	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,7 @@
+{
+ tmp = $1
+ $1  = $2 
+ $2  = $3
+ $3  = tmp
+ print NR,$0
+}
\ No newline at end of file

Added: trunk/geany-mini-script/test/perl.gms
===================================================================
--- trunk/geany-mini-script/test/perl.gms	                        (rev 0)
+++ trunk/geany-mini-script/test/perl.gms	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,8 @@
+print "BEGIN\n";
+while ( <STDIN>)
+{
+	chomp ;
+	$i++;
+	print "[$i] (($_))\n" ;
+}
+print "END\n";

Added: trunk/geany-mini-script/test/python.gms
===================================================================
--- trunk/geany-mini-script/test/python.gms	                        (rev 0)
+++ trunk/geany-mini-script/test/python.gms	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,9 @@
+import sys
+
+i = 0
+while 1 :
+ t = sys.stdin.readline()
+ if t =='':
+    break
+ print i ,' ', t
+ i = i + 1

Added: trunk/geany-mini-script/test/sed.gms
===================================================================
--- trunk/geany-mini-script/test/sed.gms	                        (rev 0)
+++ trunk/geany-mini-script/test/sed.gms	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,3 @@
+s/marins/MARINS/g
+s/capitaines/CAPITAINES/g
+/Nul/,/sort/d
\ No newline at end of file

Added: trunk/geany-mini-script/test/sed2.gms
===================================================================
--- trunk/geany-mini-script/test/sed2.gms	                        (rev 0)
+++ trunk/geany-mini-script/test/sed2.gms	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1 @@
+s/\(Victor\).*\(Hugo\)/*** \2 *** \1 ***/g
\ No newline at end of file

Added: trunk/geany-mini-script/test/shell.gms
===================================================================
--- trunk/geany-mini-script/test/shell.gms	                        (rev 0)
+++ trunk/geany-mini-script/test/shell.gms	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1 @@
+grep "[cC]ombien" - | tr '[a-z]' '[A-Z]'
\ No newline at end of file

Added: trunk/geany-mini-script/test/testfile.txt
===================================================================
--- trunk/geany-mini-script/test/testfile.txt	                        (rev 0)
+++ trunk/geany-mini-script/test/testfile.txt	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,59 @@
+Oceano nox (Victor Hugo)
+
+Oh ! combien de marins, combien de capitaines
+Qui sont partis joyeux pour des courses lointaines,
+Dans ce morne horizon se sont évanouis !
+Combien ont disparu, dure et triste fortune !
+Dans une mer sans fond, par une nuit sans lune,
+Sous l'aveugle océan à jamais enfouis !
+
+Combien de patrons morts avec leurs équipages !
+L'ouragan de leur vie a pris toutes les pages
+Et d'un souffle il a tout dispersé sur les flots !
+Nul ne saura leur fin dans l'abîme plongée.
+Chaque vague en passant d'un butin s'est chargée ;
+L'une a saisi l'esquif, l'autre les matelots !
+
+Nul ne sait votre sort, pauvres têtes perdues !
+Vous roulez à travers les sombres étendues,
+Heurtant de vos fronts morts des écueils inconnus.
+Oh ! que de vieux parents, qui n'avaient plus qu'un rêve,
+Sont morts en attendant tous les jours sur la grève
+Ceux qui ne sont pas revenus !
+
+On s'entretient de vous parfois dans les veillées.
+Maint joyeux cercle, assis sur des ancres rouillées,
+Mêle encor quelque temps vos noms d'ombre couverts
+Aux rires, aux refrains, aux récits d'aventures,
+Aux baisers qu'on dérobe à vos belles futures,
+Tandis que vous dormez dans les goémons verts !
+
+On demande : - Où sont-ils ? sont-ils rois dans quelque île ?
+Nous ont-ils délaissés pour un bord plus fertile ? -
+Puis votre souvenir même est enseveli.
+Le corps se perd dans l'eau, le nom dans la mémoire.
+Le temps, qui sur toute ombre en verse une plus noire,
+Sur le sombre océan jette le sombre oubli.
+
+Bientôt des yeux de tous votre ombre est disparue.
+L'un n'a-t-il pas sa barque et l'autre sa charrue ?
+Seules, durant ces nuits où l'orage est vainqueur,
+Vos veuves aux fronts blancs, lasses de vous attendre,
+Parlent encor de vous en remuant la cendre
+De leur foyer et de leur coeur !
+
+Et quand la tombe enfin a fermé leur paupière,
+Rien ne sait plus vos noms, pas même une humble pierre
+Dans l'étroit cimetière où l'écho nous répond,
+Pas même un saule vert qui s'effeuille à l'automne,
+Pas même la chanson naïve et monotone
+Que chante un mendiant à l'angle d'un vieux pont !
+
+Où sont-ils, les marins sombrés dans les nuits noires ?
+O flots, que vous savez de lugubres histoires !
+Flots profonds redoutés des mères à genoux !
+Vous vous les racontez en montant les marées,
+Et c'est ce qui vous fait ces voix désespérées
+Que vous avez le soir quand vous venez vers nous!
+
+Victor Hugo, in Les Rayons et les Ombres, XLII, 1840

Added: trunk/geany-mini-script/test/testfile2.txt
===================================================================
--- trunk/geany-mini-script/test/testfile2.txt	                        (rev 0)
+++ trunk/geany-mini-script/test/testfile2.txt	2009-01-04 21:09:11 UTC (rev 364)
@@ -0,0 +1,19 @@
+Demain, dès l'aube... (Victor Hugo)
+
+Demain, dès l'aube, à l'heure où blanchit la campagne,
+Je partirai. Vois-tu, je sais que tu m'attends.
+J'irai par la forêt, j'irai par la montagne.
+Je ne puis demeurer loin de toi plus longtemps.
+
+Je marcherai les yeux fixés sur mes pensées,
+Sans rien voir au dehors, sans entendre aucun bruit,
+Seul, inconnu, le dos courbé, les mains croisées,
+Triste, et le jour pour moi sera comme la nuit.
+
+Je ne regarderai ni l'or du soir qui tombe,
+Ni les voiles au loin descendant vers Harfleur,
+Et quand j'arriverai, je mettrai sur ta tombe
+Un bouquet de houx vert et de bruyère en fleur.
+
+ Victor Hugo (1802-1885)
+(Recueil : Les contemplations) 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list