From 528c1e5ff51e213936e800fc5a9a25da99c0bdf2 Mon Sep 17 00:00:00 2001 From: Perberos Date: Mon, 7 Nov 2011 16:46:58 -0300 Subject: initial --- plugins/taglist/HTML.tags.xml.in | 2672 +++++++++++++++++++++++ plugins/taglist/Latex.tags.xml.in | 344 +++ plugins/taglist/Makefile.am | 60 + plugins/taglist/XSLT.tags.xml.in | 337 +++ plugins/taglist/XUL.tags.xml.in | 536 +++++ plugins/taglist/gedit-taglist-plugin-panel.c | 776 +++++++ plugins/taglist/gedit-taglist-plugin-panel.h | 89 + plugins/taglist/gedit-taglist-plugin-parser.c | 655 ++++++ plugins/taglist/gedit-taglist-plugin-parser.h | 68 + plugins/taglist/gedit-taglist-plugin.c | 160 ++ plugins/taglist/gedit-taglist-plugin.h | 85 + plugins/taglist/taglist.gedit-plugin.desktop.in | 8 + 12 files changed, 5790 insertions(+) create mode 100755 plugins/taglist/HTML.tags.xml.in create mode 100755 plugins/taglist/Latex.tags.xml.in create mode 100755 plugins/taglist/Makefile.am create mode 100755 plugins/taglist/XSLT.tags.xml.in create mode 100755 plugins/taglist/XUL.tags.xml.in create mode 100755 plugins/taglist/gedit-taglist-plugin-panel.c create mode 100755 plugins/taglist/gedit-taglist-plugin-panel.h create mode 100755 plugins/taglist/gedit-taglist-plugin-parser.c create mode 100755 plugins/taglist/gedit-taglist-plugin-parser.h create mode 100755 plugins/taglist/gedit-taglist-plugin.c create mode 100755 plugins/taglist/gedit-taglist-plugin.h create mode 100755 plugins/taglist/taglist.gedit-plugin.desktop.in (limited to 'plugins/taglist') diff --git a/plugins/taglist/HTML.tags.xml.in b/plugins/taglist/HTML.tags.xml.in new file mode 100755 index 00000000..116cc247 --- /dev/null +++ b/plugins/taglist/HTML.tags.xml.in @@ -0,0 +1,2672 @@ + + + + + + <abbr title=" + "></abbr> + + + + abbr=" + " + + + + accesskey=" + " + + + + <acronym title=" + "></acronym> + + + + align=" + " + + + + char=" + " + + + + alt=" + " + + + + <a href=" + "></a> + + + + <a id=" + "></a> + + + + + code=" + " + + + + content=" + " + + + + <address> + </address> + + + + axis=" + " + + + + + bgcolor=" + " + + + + + background=" + " + + + + + <basefont> + + + + codebase=" + " + + + + <b> + </b> + + + + + border=" + " + + + + rowspan=" + " + + + + + <center> + </center> + + + + charset=" + " + + + + checked="checked" + + + + <cite> + </cite> + + + + cite=" + " + + + + classid=" + " + + + + class=" + " + + + + clear=" + " + + + + codetype=" + " + + + + + alink=" + " + + + + colspan=" + " + + + + cols=" + " + + + + <!-- + --> + + + + <code> + </code> + + + + + type=" + " + + + + coords=" + " + + + + datetime="YYYYMMDD" + + + + + declare="declare" + + + + + defer="defer" + + + + <dd> + </dd> + + + + <dl> + </dl> + + + + <dt> + </dt> + + + + <del> + </del> + + + + dir=" + " + + + + + <dir> + </dir> + + + + disabled="disabled" + + + + <div> + </div> + + + + <div style=> + </div> + + + + <base href=" + " /> + + + + <body> + </body> + + + + <head> + </head> + + + + id=" + " + + + + <title> + </title> + + + + <!DOCTYPE> + + + + <em> + </em> + + + + enctype=" + " + + + + + face=" + " + + + + for=" + " + + + + <br /> + + + + action=" + " + + + + <fieldset> + </fieldset> + + + + <label> + </label> + + + + <input type=" + " /> + + + + <input /> + + + + <form method=" + "></form> + + + + method=" + " + + + + <form> + </form> + + + + rel=" + " + + + + frame=" + " + + + + <frame src=" + "></frame> + + + + target=" + " + + + + <frame> + </frame> + + + + frameborder=" + " + + + + <frameset cols=" + "></frameset> + + + + <frameset rows=" + "></frameset> + + + + <frameset> + </frameset> + + + + framespacing=" + " + + + + <object> + </object> + + + + <meta content=" + "></meta> + + + + <span> + </span> + + + + headers=" + " + + + + <h1> + </h1> + + + + <h2> + </h2> + + + + <h3> + </h3> + + + + <h4> + </h4> + + + + <h5> + </h5> + + + + <h6> + </h6> + + + + height=" + + + + <hr /> + + + + + hspace=" + " + + + + href=" + " + + + + <html> + </html> + + + + http-equiv=" + " + + + + <bdo> + </bdo> + + + + <area alt=" + "></area> + + + + <map name=" + "></map> + + + + <map id=" + "></map> + + + + <img id=" + " src="" alt="" /> + + + + <iframe> + </iframe> + + + + <ins> + </ins> + + + + <dfn> + </dfn> + + + + <i> + </i> + + + + + <applet height=" + " width=""></applet> + + + + label=" + " + + + + hreflang=" + " + + + + lang=" + " + + + + <big> + </big> + + + + + link=" + " + + + + <li> + </li> + + + + accept=" + " + + + + accept-charset=" + " + + + + <font> + </font> + + + + longdesc=" + " + + + + <blockquote> + </blockquote> + + + + + marginheight=" + " + + + + + marginwidth=" + " + + + + maxlength=" + " + + + + media=" + " + + + + + <link rel=" + " type="" href="" /> + + + + + <menu> + </menu> + + + + <textarea cols=" + " rows=""></textarea> + + + + multiple="multiple" + + + + name=" + " + + + + <param name=" + "></param> + + + + <noframes> + </noframes> + + + + noresize="noresize" + + + + <noscript> + </noscript> + + + + + noshade="noshade" + + + + nohref=" + " + + + + + nowrap="nowrap" + + + + + object=" + " + + + + data=" + " + + + + charoff=" + " + + + + onblur=" + " + + + + onchange=" + " + + + + onclick=" + " + + + + ondbclick=" + " + + + + onfocus=" + " + + + + onkeydown=" + " + + + + onkeypress=" + " + + + + onkeyup=" + " + + + + onload=" + " + + + + onmousedown=" + " + + + + onmousemove=" + " + + + + onmouseout=" + " + + + + onmouseover=" + " + + + + onmouseup=" + " + + + + onreset=" + " + + + + onselect=" + " + + + + onsubmit=" + " + + + + onunload=" + " + + + + <optgroup label=" + "></optgroup> + + + + <select> + </select> + + + + <ol> + </ol> + + + + <p class=" + "></p> + + + + <p style=" + "></p> + + + + <p> + </p> + + + + <pre> + </pre> + + + + profile=" + " + + + + <button> + </button> + + + + readonly="readonly" + + + + + compact="compact_rendering" + + + + rev=" + " + + + + rows=" + " + + + + rules=" + " + + + + <samp> + </samp> + + + + scope=" + " + + + + + language=" + " + + + + <script type=" + "></script> + + + + scrolling=" + " + + + + <option> + </option> + + + + selected="selected" + + + + ismap=" + " + + + + shape=" + " + + + + <q> + </q> + + + + + size=" + " + + + + <small> + </small> + + + + src=" + " + + + + archive=" + " + + + + cellspacing=" + " + + + + cellpadding=" + " + + + + span=" + " + + + + standby=" + " + + + + + start=" + " + + + + + <s> + </s> + + + + + <strike> + </strike> + + + + <strong> + </strong> + + + + <style type="text/css"> + </style> + + + + style=" + " + + + + <sub> + </sub> + + + + <sup> + </sup> + + + + <tbody> + </tbody> + + + + <caption> + </caption> + + + + <colgroup> + </colgroup> + + + + <col> + </col> + + + + <td> + </td> + + + + <tfoot> + </tfoot> + + + + <th> + </th> + + + + <thead> + </thead> + + + + <tr> + </tr> + + + + summary=" + " + + + + <table> + </table> + + + + <a target="_blank"> + </a> + + + + <a target="_parent"> + </a> + + + + <a target="_self"> + </a> + + + + <a target="_top"> + </a> + + + + <tt> + </tt> + + + + + color=" + " + + + + + text=" + " + + + + <kbd> + </kbd> + + + + title=" + " + + + + <u> + </u> + + + + <ul> + </ul> + + + + usemap=" + " + + + + valuetype=" + " + + + + value=" + " + + + + <var> + </var> + + + + valign=" + " + + + + + vspace=" + " + + + + + vlink=" + " + + + + width=" + " + + + + + + + + <abbr> + </abbr> + + + + abbr= + + + + <above> + + + + accesskey= + + + + <acronym> + </acronym> + + + + align= + + + + char= + + + + alt= + + + + <a href=> + </a> + + + + <a> + </a> + + + + code= + + + + <array> + + + + content= + + + + <address> + </address> + + + + axis= + + + + bgcolor= + + + + background= + + + + <basefont> + + + + codebase= + + + + <b> + </b> + + + + bordercolor= + + + + border= + + + + rowspan= + + + + <center> + </center> + + + + charset= + + + + checked + + + + <cite> + </cite> + + + + cite= + + + + classid= + + + + class= + + + + clear= + + + + codetype= + + + + alink= + + + + colspan= + + + + cols= + + + + <!-- + --> + + + + <comment> + </comment> + + + + <code> + </code> + + + + scheme= + + + + type= + + + + coords= + + + + datetime= + + + + declare + + + + + defer + + + + <dd> + </dd> + + + + <dl> + </dl> + + + + <dt> + </dt> + + + + <del> + </del> + + + + direction= + + + + dir= + + + + <dir> + </dir> + + + + disabled + + + + <div> + </div> + + + + <div style=> + </div> + + + + <base> + + + + <body> + </body> + + + + <head> + </head> + + + + id= + + + + <title> + </title> + + + + <!DOCTYPE> + + + + version= + + + + <embed> + </embed> + + + + <em> + </em> + + + + enctype= + + + + <fig> + </fig> + + + + face= + + + + for= + + + + <br /> + + + + action= + + + + <fieldset> + </fieldset> + + + + <label> + </label> + + + + <input type=> + + + + <input> + + + + <form method=> + + + + method= + + + + <form> + </form> + + + + rel= + + + + frame= + + + + <frame src=> + + + + target= + + + + <frame> + + + + frameborder= + + + + <frameset cols=> + </frameset> + + + + <frameset rows=> + </frameset> + + + + <frameset> + </frameset> + + + + framespacing= + + + + <object> + + + + <meta> + + + + <span> + </span> + + + + headers= + + + + <h1> + </h1> + + + + <h2> + </h2> + + + + <h3> + </h3> + + + + <h4> + </h4> + + + + <h5> + </h5> + + + + <h6> + </h6> + + + + <h> + </h> + + + + height= + + + + <hr /> + + + + hspace= + + + + href= + + + + <html> + </html> + + + + http-equiv= + + + + <BDO> + </BDO> + + + + <area> + + + + <map name=> + </map> + + + + <map> + </map> + + + + <img src=> + + + + <img> + + + + <iframe> + </iframe> + + + + <ilayer> + </ilayer> + + + + <ins> + </ins> + + + + <dfn> + </dfn> + + + + <i> + </i> + + + + <applet> + </applet> + + + + label= + + + + hreflang= + + + + lang= + + + + <big> + </big> + + + + <layer> + + + + link= + + + + <li> + </li> + + + + accept= + + + + accept-charset= + + + + <listing> + </listing> + + + + <font> + </font> + + + + longdesc= + + + + <blockquote> + </blockquote> + + + + mailto= + + + + marginheight= + + + + marginwidth= + + + + <marquee> + </marquee> + + + + maxlength= + + + + media= + + + + <link rel="> + + + + <menu> + </menu> + + + + <multicol> + </multicol> + + + + <textarea> + </textarea> + + + + multiple + + + + name= + + + + <param> + + + + <nextid> + + + + <noembed> + + + + <noframes> + </noframes> + + + + <nolayer> + </nolayer> + + + + <nobr> + </nobr> + + + + noresize + + + + <noscript> + </noscript> + + + + noshade + + + + nohref + + + + nowrap + + + + <note> + </note> + + + + object= + + + + data= + + + + charoff= + + + + onblur= + + + + onchange= + + + + onclick= + + + + ondbclick= + + + + onfocus= + + + + onkeydown= + + + + onkeypress= + + + + onkeyup= + + + + onload= + + + + onmousedown= + + + + onmousemove= + + + + onmouseout= + + + + onmouseover= + + + + onmouseup= + + + + onreset= + + + + onselect= + + + + onsubmit= + + + + onunload= + + + + <optgroup> + </optgroup> + + + + <select> + </select> + + + + <ol> + </ol> + + + + <p class=> + </p> + + + + <p style=> + </p> + + + + <p> + </p> + + + + <xmp> + </xmp> + + + + <pre> + </pre> + + + + profile= + + + + prompt= + + + + <button> + </button> + + + + <quote> + + + + <range> + + + + readonly + + + + compact + + + + rev= + + + + <root> + + + + rows= + + + + rules= + + + + <samp> + </samp> + + + + scope= + + + + language= + + + + <script> + </script> + + + + scrolling= + + + + <option> + + + + selected + + + + ismap + + + + shape= + + + + <q> + </q> + + + + <isindex> + + + + size= + + + + <small> + </small> + + + + <wbr> + + + + <sound> + + + + src= + + + + archive= + + + + <spacer> + + + + cellspacing= + + + + cellpadding= + + + + span= + + + + <sqrt> + + + + standby= + + + + start + + + + <s> + </s> + + + + <strike> + </strike> + + + + <strong> + </strong> + + + + <style> + </style> + + + + style= + + + + <sub> + </sub> + + + + <sup> + </sup> + + + + tabindex= + + + + <tbody> + </tbody> + + + + <caption> + </caption> + + + + <colgroup> + </colgroup> + + + + <col> + </col> + + + + <td> + </td> + + + + <tfoot> + </tfoot> + + + + <th> + </th> + + + + <thead> + </thead> + + + + <tr> + </tr> + + + + summary= + + + + <table> + </table> + + + + <a target="_blank"> + </a> + + + + <a target="_parent"> + </a> + + + + <a target="_self"> + </a> + + + + <a target="_top"> + </a> + + + + <tt> + </tt> + + + + color= + + + + text= + + + + <kbd> + </kbd> + + + + <text> + + + + title= + + + + topmargin + + + + <u> + </u> + + + + <ul> + </ul> + + + + url= + + + + usemap= + + + + valuetype= + + + + value= + + + + <var> + </var> + + + + valign= + + + + vspace= + + + + vlink= + + + + width= + + + + + + + + &nbsp; + + + + &shy; + + + + &quot; + + + + &amp; + + + + &iexcl; + + + + &brvbar; + + + + &uml; + + + + &macr; + + + + &acute; + + + + &cedil; + + + + &lt; + + + + &gt; + + + + &plusmn; + + + + &laquo; + + + + &raquo; + + + + &times; + + + + &divide; + + + + &cent; + + + + &pound; + + + + &euro; + + + + &curren; + + + + &yen; + + + + &sect; + + + + &copy; + + + + &not; + + + + &reg; + + + + &trade; + + + + &deg; + + + + &micro; + + + + &para; + + + + &middot; + + + + &frac14; + + + + &frac12; + + + + &frac34; + + + + &sup1; + + + + &sup2; + + + + &sup3; + + + + &aacute; + + + + &Aacute; + + + + &acirc; + + + + &Acirc; + + + + &agrave; + + + + &Agrave; + + + + &aring; + + + + &Aring; + + + + &atilde; + + + + &Atilde; + + + + &auml; + + + + &Auml; + + + + &ordf; + + + + &aelig; + + + + &AElig; + + + + &ccedil; + + + + &Ccedil; + + + + &ETH; + + + + &eth; + + + + &eacute; + + + + &Eacute; + + + + &ecirc; + + + + &Ecirc; + + + + &egrave; + + + + &Egrave; + + + + &euml; + + + + &Euml; + + + + &iacute; + + + + &Iacute; + + + + &icirc; + + + + &Icirc; + + + + &igrave; + + + + &Igrave; + + + + &iuml; + + + + &Iuml; + + + + &ntilde; + + + + &Ntilde; + + + + &oacute; + + + + &Oacute; + + + + &ocirc; + + + + &Ocirc; + + + + &ograve; + + + + &Ograve; + + + + &ordm; + + + + &oslash; + + + + &Oslash; + + + + &otilde; + + + + &Otilde; + + + + &ouml; + + + + &Ouml; + + + + &szlig; + + + + &thorn; + + + + &THORN; + + + + &uacute; + + + + &Uacute; + + + + &ucirc; + + + + &Ucirc; + + + + &ugrave; + + + + &Ugrave; + + + + &uuml; + + + + &Uuml; + + + + &yacute; + + + + &Yacute; + + + + &yuml; + + + + diff --git a/plugins/taglist/Latex.tags.xml.in b/plugins/taglist/Latex.tags.xml.in new file mode 100755 index 00000000..5ac71c0d --- /dev/null +++ b/plugins/taglist/Latex.tags.xml.in @@ -0,0 +1,344 @@ + + + + + \cite{ + } + + + + \bibitem{ + }{} + + + + \shortcite{ + } + + + + \begin{thebibliography}{99} + \end{thebibliography} + + + + \left( + \right) + + + + \left[ + \right] + + + + \left\{ + \right\} + + + + \left\langle + \right\rangle + + + + \input{ + } + + + + \cos{ + } + + + + e^{ + } + + + + \exp{ + } + + + + \log{ + } + + + + \log_{10}{ + } + + + + \sin{ + } + + + + \alpha + + + + \beta + + + + \varepsilon + + + + \gamma + + + + \lambda + + + + \rho + + + + \tau + + + + \chapter{ + } + + + + \chapter*{ + } + + + + \section{ + } + + + + \section*{ + } + + + + \subsection{ + } + + + + \subsection*{ + } + + + + \subsubsection{ + } + + + + \subsubsection*{ + } + + + + \paragraph{ + } + + + + \appendix + + + + \begin{description} + \end{description} + + + + \begin{enumerate} + \end{enumerate} + + + + \begin{itemize} + \end{itemize} + + + + \item[ + ] + + + + \item + + + + $$ + $$ + + + + $ + $ + + + + \frac{ + }{} + + + + \int\limits_{ + }^{} + + + + \int_{ + }^{} + + + + \sum\limits_{ + }^{} + + + + \sum_{ + }^{} + + + + \label{ + } + + + + {\protect\ref{ + }} + + + + \ll + + + + \le + + + + \ge + + + + \gg + + + + \mathrm{and} + + + + \mathrm{const} + + + + \frac{\partial{ + }^2}{\partial t^2} + + + + \dagger + + + + \frac{{\mathrm{d}} + }{{\mathrm{d}}t} + + + + \frac{\partial + }{\partial t} + + + + \equiv + + + + -- + + + + --- + + + + \infty + + + + \quad\mathrm{,} + + + + \quad\mathrm{.} + + + + \quad + + + + \qquad + + + + \simeq + + + + \star + + + + \textbf{ + } + + + + \texttt{ + } + + + + \textit{ + } + + + + \textsl{ + } + + + + \emph{ + } + + + + \mbox{ + } + + + + \footnote{ + } + + + + diff --git a/plugins/taglist/Makefile.am b/plugins/taglist/Makefile.am new file mode 100755 index 00000000..b04f4584 --- /dev/null +++ b/plugins/taglist/Makefile.am @@ -0,0 +1,60 @@ +# Tag list plugin +plugindir = $(GEDIT_PLUGINS_LIBS_DIR) + +taglistdir = $(GEDIT_PLUGINS_DATA_DIR)/taglist + +taglist_in_files = \ + HTML.tags.xml.in \ + Latex.tags.xml.in \ + XSLT.tags.xml.in \ + XUL.tags.xml.in + +taglist_DATA = $(taglist_in_files:.tags.xml.in=.tags.gz) + +INCLUDES = \ + -I$(top_srcdir) \ + $(GEDIT_CFLAGS) \ + $(WARN_CFLAGS) \ + $(DISABLE_DEPRECATED_CFLAGS) + +plugin_LTLIBRARIES = libtaglist.la + +libtaglist_la_SOURCES = \ + gedit-taglist-plugin-parser.c \ + gedit-taglist-plugin-parser.h \ + gedit-taglist-plugin-panel.c \ + gedit-taglist-plugin-panel.h \ + gedit-taglist-plugin.c \ + gedit-taglist-plugin.h + +libtaglist_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS) +libtaglist_la_LIBADD = $(GEDIT_LIBS) + +plugin_in_files = taglist.gedit-plugin.desktop.in + +%.gedit-plugin: %.gedit-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) + $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache + +GZIP_ENV = -9 + +%.tags.gz: %.tags.xml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) + LC_ALL=C $(INTLTOOL_MERGE) $(top_srcdir)/po $< $(@:.gz=) -x -u -c $(top_builddir)/po/.intltool-merge-cache + GZIP=$(GZIP_ENV) gzip -f $(@:.gz=) + +plugin_DATA = $(plugin_in_files:.gedit-plugin.desktop.in=.gedit-plugin) + +EXTRA_DIST = \ + $(taglist_in_files) $(taglist_DATA) \ + $(plugin_in_files) $(plugin_DATA) + +CLEANFILES = \ + $(taglist_DATA) \ + $(plugin_DATA) +DISTCLEANFILES = \ + $(taglist_DATA) \ + $(plugin_DATA) + + + + +-include $(top_srcdir)/git.mk diff --git a/plugins/taglist/XSLT.tags.xml.in b/plugins/taglist/XSLT.tags.xml.in new file mode 100755 index 00000000..f9591a25 --- /dev/null +++ b/plugins/taglist/XSLT.tags.xml.in @@ -0,0 +1,337 @@ + + + + + + <xsl:apply-imports> + </xsl:apply-imports> + + + <xsl:apply-templates select=" + "/> + + + <xsl:attribute name=" + "></xsl:attribute> + + + <xsl:attribute-set name=" + "></xsl:attribute-set> + + + <xsl:call-template name=" + "/> + + + <xsl:choose> + </xsl:choose> + + + <xsl:comment> + </xsl:comment> + + + <xsl:copy/> + + + <xsl:copy-of select=" + "/> + + + <xsl:decimal-format/> + + + <xsl:element name=" + "></xsl:element> + + + <xsl:fallback> + </xsl:fallback> + + + <xsl:for-each select=" + "> </xsl:for-each> + + + <xsl:if test=" + "> </xsl:if> + + + <xsl:import href=" + "/> + + + <xsl:include href=" + "/> + + + <xsl:key name=" + " match="" use=""/> + + + <xsl:message> + </xsl:message> + + + <xsl:namespace-alias stylesheet-prefix=" + " result-prefix=""/> + + + <xsl:number/> + + + <xsl:otherwise> + </xsl:otherwise> + + + <xsl:output encoding="utf-8" method=" + "/> + + + <xsl:param name=" + "></xsl:param> + + + <xsl:preserve-space elements=" + "></xsl:preserve-space> + + + <xsl:processing-instruction name=" + "></xsl:processing-instruction> + + + <xsl:sort/> + + + <xsl:strip-space elements=" + "></xsl:strip-space> + + + <xsl:stylesheet version=" + "/> </xsl:stylesheet> + + + <xsl:template match=" + "> </xsl:template> + + + <xsl:text/> + + + <xsl:value-of select=" + "/> + + + <xsl:variable select=" + "/> + + + <xsl:when test=" + > </xsl:when> + + + <xsl:with-param name=" + "></xsl:with-param> + + + + + + boolean( + ) + + + ceiling( + ) + + + comment() + + + concat( + ,,) + + + contains( + ,) + + + count( + ) + + + current() + + + document( + ,) + + + element-available( + ) + + + false() + + + floor( + ) + + + format-number( + ,,) + + + function-available( + ) + + + generate-id( + ) + + + id( + ) + + + key( + ,) + + + lang( + ) + + + last() + + + local-name( + ) + + + name( + ) + + + namespace-uri( + ) + + + node() + + + normalize-space( + ) + + + not( + ) + + + number( + ) + + + position() + + + processing-instruction( + ) + + + round( + ) + + + starts-with( + ,) + + + string( + ) + + + string-length( + ) + + + substring( + ,,) + + + substring-after( + ,) + + + substring-before( + ,) + + + sum( + ) + + + system-property( + ) + + + text() + + + translate( + ,,) + + + true() + + + unparsed-entity-uri( + ) + + + + + + ancestor:: + + + ancestor-or-self:: + + + @ + + + child:: + + + descendant:: + + + // + + + following:: + + + following-sibling:: + + + namespace:: + + + .. + + + preceding:: + + + preceding-sibling:: + + + . + + + diff --git a/plugins/taglist/XUL.tags.xml.in b/plugins/taglist/XUL.tags.xml.in new file mode 100755 index 00000000..fc4c26a7 --- /dev/null +++ b/plugins/taglist/XUL.tags.xml.in @@ -0,0 +1,536 @@ + + + + + + <action> + </action> + + + + <arrowscrollbox orient="vertical" flex="1"> + </arrowscrollbox> + + + + <bbox> + </bbox> + + + + <binding id=""> + </binding> + + + + <bindings xmlns="http://www.mozilla.org/xbl"> + </bindings> + + + + <box orient=""> + </box> + + + + <broadcaster id="" label=""/> + + + + <broadcasterset> + </broadcasterset> + + + + <button id="" label="" oncommand=""/> + + + + <browser src="" type="content" flex="1"/> + + + + <checkbox id="" checked="false" label=""/> + + + + <caption label=""/> + + + + <colorpicker> + </colorpicker> + + + + <column flex="1"/> + + + + <columns> + </columns> + + + + <commandset id="" commandupdater="true" events="focus" oncommandupdate=""/> + </commandset> + + + + <command id="" oncommand=""/> + + + + <conditions> + </conditions> + + + + <content uri=""/> + + + + <deck selectedIndex="1"> + </deck> + + + + <description> + </description> + + + + <dialog id="" title="" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + buttons="accept,cancel" + ondialogaccept="" + ondialogcancel=""> + </dialog> + + + + <dialogheader title="" description=""/> + + + + <editor src=""/> + + + + <grid> + </grid> + + + + <grippy> + </grippy> + + + + <groupbox flex="1"><caption label=""> + </groupbox> + + + + <hbox flex="1"> + </hbox> + + + + <iframe id="" src="" flex="1"/> + + + + <image id="" src=""/> + + + + <key id="" modifiers="control alt" key="" onkeypress=""/> + + + + <keyset> + </keyset> + + + + <label value="" control=""/> + + + + <listbox rows=""> + </listbox> + + + + <listcell label=""/> + + + + <listcol> + </listcol> + + + + <listcols> + </listcols> + + + + <listhead> + </listhead> + + + + <listheader label="" flex="1"/> + + + + <listitem id="" value="" label=""/> + + + + <member container="" child=""/> + + + + <menu accesskey=""> + </menu> + + + + <menubar> + </menubar> + + + + <menuitem value="" label="" accesskey="" acceltext="" oncommand=""/> + + + + <menulist label=""> + </menulist> + + + + <menupopup id=""> + </menupopup> + + + + <menuseparator/> + + + + <observes element="" attribute="" onbroadcast=""/> + + + + <overlay id="" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + </overlay> + + + + <page> + </page> + + + + <popup id="" position="after_start"> + </popup> + + + + <popupset> + </popupset> + + + + <preference> + </preference> + + + + <preferences> + </preferences> + + + + <prefpane> + </prefpane> + + + + <prefwindow> + </prefwindow> + + + + <progressmeter id="" mode="determined" value="50%"/> + + + + <radio id="" value="" name="" label=""/> + + + + <radiogroup> + </radiogroup> + + + + <resizer> + </resizer> + + + + <richlistbox> + </richlistbox> + + + + <richlistitem> + </richlistitem> + + + + <row flex="1"> + </row> + + + + <rows> + </rows> + + + + <rule> + </rule> + + + + <script src="" language="Javascript"> + </script> + + + + <scrollbar id="" orient="vertical" curpos="20" maxpos="100" increment="1" pageincrement="10"/> + + + + <scrollbox> + </scrollbox> + + + + <scrollcorner> + </scrollcorner> + + + + <separator> + </separator> + + + + <spacer flex="1"/> + + + + <splitter state="open" collapse="before" resizebefore="closest" resizeafter="grow"><grippy/> + </splitter> + + + + <stack> + </stack> + + + + <statusbar> + </statusbar> + + + + <statusbarpanel id="" label=""> + </statusbarpanel> + + + + <stringbundle id="" src=""/> + + + + <stringbundleset> + </stringbundleset> + + + + <tab id="" label=""/> + + + + <tabbrowser> + </tabbrowser> + + + + <tabbox id=""> + </tabbox> + + + + <tabpanel id=""> + </tabpanel> + + + + <tabpanels> + </tabpanels> + + + + <tabs> + </tabs> + + + + <template> + </template> + + + + <textnode> + </textnode> + + + + <textbox id="" value="" multiline="false"/> + + + + <titlebar> + </titlebar> + + + + <toolbar id=""> + </toolbar> + + + + <toolbarbutton id="" label=""/> + + + + <toolbargrippy> + </toolbargrippy> + + + + <toolbaritem> + </toolbaritem> + + + + <toolbarpalette> + </toolbarpalette> + + + + <toolbarseparator> + </toolbarseparator> + + + + <toolbarset> + </toolbarset> + + + + <toolbarspacer> + </toolbarspacer> + + + + <toolbarspring> + </toolbarspring> + + + + <toolbox> + </toolbox> + + + + <tooltip id="" orient="vertical"> + </tooltip> + + + + <tree id="" flex="1"> + </tree> + + + + <treecell label=""/> + + + + <treechildren> + </treechildren> + + + + <treecol label="" flex="1" primary="true"/> + + + + <treecols> + </treecols> + + + + <treeitem container="true" open="true"> + </treeitem> + + + + <treerow> + </treerow> + + + + <treeseparator> + </treeseparator> + + + + <triple> + </triple> + + + + <vbox flex="1"> + </vbox> + + + + <window id="" title="" orient="horizontal" pageid="" next="" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + </window> + + + + <wizard id="" title="" wizardnext="" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + </wizard> + + + + <wizardpage description="" onwizardfinish="" pageadvanced=""> + </wizardpage> + + + + diff --git a/plugins/taglist/gedit-taglist-plugin-panel.c b/plugins/taglist/gedit-taglist-plugin-panel.c new file mode 100755 index 00000000..d66acc08 --- /dev/null +++ b/plugins/taglist/gedit-taglist-plugin-panel.c @@ -0,0 +1,776 @@ +/* + * gedit-taglist-plugin-panel.c + * This file is part of gedit + * + * Copyright (C) 2005 - Paolo Maggi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the gedit Team, 2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "gedit-taglist-plugin-panel.h" +#include "gedit-taglist-plugin-parser.h" + +#include +#include +#include + +#include +#include + +#define GEDIT_TAGLIST_PLUGIN_PANEL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \ + GEDIT_TYPE_TAGLIST_PLUGIN_PANEL, \ + GeditTaglistPluginPanelPrivate)) + +enum +{ + COLUMN_TAG_NAME, + COLUMN_TAG_INDEX_IN_GROUP, + NUM_COLUMNS +}; + +struct _GeditTaglistPluginPanelPrivate +{ + GeditWindow *window; + + GtkWidget *tag_groups_combo; + GtkWidget *tags_list; + GtkWidget *preview; + + TagGroup *selected_tag_group; + + gchar *data_dir; +}; + +GEDIT_PLUGIN_DEFINE_TYPE (GeditTaglistPluginPanel, gedit_taglist_plugin_panel, GTK_TYPE_VBOX) + +enum +{ + PROP_0, + PROP_WINDOW, +}; + +static void +set_window (GeditTaglistPluginPanel *panel, + GeditWindow *window) +{ + g_return_if_fail (panel->priv->window == NULL); + g_return_if_fail (GEDIT_IS_WINDOW (window)); + + panel->priv->window = window; + + /* TODO */ +} + +static void +gedit_taglist_plugin_panel_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GeditTaglistPluginPanel *panel = GEDIT_TAGLIST_PLUGIN_PANEL (object); + + switch (prop_id) + { + case PROP_WINDOW: + set_window (panel, g_value_get_object (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gedit_taglist_plugin_panel_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GeditTaglistPluginPanel *panel = GEDIT_TAGLIST_PLUGIN_PANEL (object); + + switch (prop_id) + { + case PROP_WINDOW: + g_value_set_object (value, + GEDIT_TAGLIST_PLUGIN_PANEL_GET_PRIVATE (panel)->window); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gedit_taglist_plugin_panel_finalize (GObject *object) +{ + GeditTaglistPluginPanel *panel = GEDIT_TAGLIST_PLUGIN_PANEL (object); + + g_free (panel->priv->data_dir); + + G_OBJECT_CLASS (gedit_taglist_plugin_panel_parent_class)->finalize (object); +} + +static void +gedit_taglist_plugin_panel_class_init (GeditTaglistPluginPanelClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = gedit_taglist_plugin_panel_finalize; + object_class->get_property = gedit_taglist_plugin_panel_get_property; + object_class->set_property = gedit_taglist_plugin_panel_set_property; + + g_object_class_install_property (object_class, + PROP_WINDOW, + g_param_spec_object ("window", + "Window", + "The GeditWindow this GeditTaglistPluginPanel is associated with", + GEDIT_TYPE_WINDOW, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + + g_type_class_add_private (object_class, sizeof(GeditTaglistPluginPanelPrivate)); +} + +static void +insert_tag (GeditTaglistPluginPanel *panel, + Tag *tag, + gboolean grab_focus) +{ + GeditView *view; + GtkTextBuffer *buffer; + GtkTextIter start, end; + GtkTextIter cursor; + gboolean sel = FALSE; + + gedit_debug (DEBUG_PLUGINS); + + view = gedit_window_get_active_view (panel->priv->window); + g_return_if_fail (view != NULL); + + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); + + gtk_text_buffer_begin_user_action (buffer); + + /* always insert the begin tag at the beginning of the selection + * and the end tag at the end, if there is no selection they will + * be automatically inserted at the cursor position. + */ + + if (tag->begin != NULL) + { + sel = gtk_text_buffer_get_selection_bounds (buffer, + &start, + &end); + + gtk_text_buffer_insert (buffer, + &start, + (gchar *)tag->begin, + -1); + + /* get iterators again since they have been invalidated and move + * the cursor after the selection */ + gtk_text_buffer_get_selection_bounds (buffer, + &start, + &cursor); + } + + if (tag->end != NULL) + { + sel = gtk_text_buffer_get_selection_bounds (buffer, + &start, + &end); + + gtk_text_buffer_insert (buffer, + &end, + (gchar *)tag->end, + -1); + + /* if there is no selection and we have a paired tag, move the + * cursor between the pair, otherwise move it at the end */ + if (!sel) + { + gint offset; + + offset = gtk_text_iter_get_offset (&end) - + g_utf8_strlen ((gchar *)tag->end, -1); + + gtk_text_buffer_get_iter_at_offset (buffer, + &end, + offset); + } + + cursor = end; + } + + gtk_text_buffer_place_cursor (buffer, &cursor); + + gtk_text_buffer_end_user_action (buffer); + + if (grab_focus) + gtk_widget_grab_focus (GTK_WIDGET (view)); +} + +static void +tag_list_row_activated_cb (GtkTreeView *tag_list, + GtkTreePath *path, + GtkTreeViewColumn *column, + GeditTaglistPluginPanel *panel) +{ + GtkTreeIter iter; + GtkTreeModel *model; + gint index; + + gedit_debug (DEBUG_PLUGINS); + + model = gtk_tree_view_get_model (tag_list); + + gtk_tree_model_get_iter (model, &iter, path); + g_return_if_fail (&iter != NULL); + + gtk_tree_model_get (model, &iter, COLUMN_TAG_INDEX_IN_GROUP, &index, -1); + + gedit_debug_message (DEBUG_PLUGINS, "Index: %d", index); + + insert_tag (panel, + (Tag*)g_list_nth_data (panel->priv->selected_tag_group->tags, index), + TRUE); +} + +static gboolean +tag_list_key_press_event_cb (GtkTreeView *tag_list, + GdkEventKey *event, + GeditTaglistPluginPanel *panel) +{ + gboolean grab_focus; + + grab_focus = (event->state & GDK_CONTROL_MASK) != 0; + + if (event->keyval == GDK_Return) + { + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + gint index; + + gedit_debug_message (DEBUG_PLUGINS, "RETURN Pressed"); + + model = gtk_tree_view_get_model (tag_list); + + selection = gtk_tree_view_get_selection (tag_list); + + if (gtk_tree_selection_get_selected (selection, NULL, &iter)) + { + gtk_tree_model_get (model, &iter, COLUMN_TAG_INDEX_IN_GROUP, &index, -1); + + gedit_debug_message (DEBUG_PLUGINS, "Index: %d", index); + + insert_tag (panel, + (Tag*)g_list_nth_data (panel->priv->selected_tag_group->tags, index), + grab_focus); + } + + return TRUE; + } + + return FALSE; +} + +static GtkTreeModel* +create_model (GeditTaglistPluginPanel *panel) +{ + gint i = 0; + GtkListStore *store; + GtkTreeIter iter; + GList *list; + + gedit_debug (DEBUG_PLUGINS); + + /* create list store */ + store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_INT); + + /* add data to the list store */ + list = panel->priv->selected_tag_group->tags; + + while (list != NULL) + { + const gchar* tag_name; + + tag_name = (gchar *)((Tag*)list->data)->name; + + gedit_debug_message (DEBUG_PLUGINS, "%d : %s", i, tag_name); + + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COLUMN_TAG_NAME, tag_name, + COLUMN_TAG_INDEX_IN_GROUP, i, + -1); + ++i; + + list = g_list_next (list); + } + + gedit_debug_message (DEBUG_PLUGINS, "Rows: %d ", + gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL)); + + return GTK_TREE_MODEL (store); +} + +static void +populate_tags_list (GeditTaglistPluginPanel *panel) +{ + GtkTreeModel* model; + + gedit_debug (DEBUG_PLUGINS); + + g_return_if_fail (taglist != NULL); + + model = create_model (panel); + gtk_tree_view_set_model (GTK_TREE_VIEW (panel->priv->tags_list), + model); + g_object_unref (model); +} + +static TagGroup * +find_tag_group (const gchar *name) +{ + GList *l; + + gedit_debug (DEBUG_PLUGINS); + + g_return_val_if_fail (taglist != NULL, NULL); + + for (l = taglist->tag_groups; l != NULL; l = g_list_next (l)) + { + if (strcmp (name, (gchar *)((TagGroup*)l->data)->name) == 0) + return (TagGroup*)l->data; + } + + return NULL; +} + +static void +populate_tag_groups_combo (GeditTaglistPluginPanel *panel) +{ + GList *l; + GtkComboBox *combo; + + gedit_debug (DEBUG_PLUGINS); + + combo = GTK_COMBO_BOX (panel->priv->tag_groups_combo); + + if (taglist == NULL) + return; + + for (l = taglist->tag_groups; l != NULL; l = g_list_next (l)) + { + gtk_combo_box_append_text (combo, + (gchar *)((TagGroup*)l->data)->name); + } + + gtk_combo_box_set_active (combo, 0); + + return; +} + +static void +selected_group_changed (GtkComboBox *combo, + GeditTaglistPluginPanel *panel) +{ + gchar* group_name; + + gedit_debug (DEBUG_PLUGINS); + + group_name = gtk_combo_box_get_active_text (combo); + + if ((group_name == NULL) || (strlen (group_name) <= 0)) + { + g_free (group_name); + return; + } + + if ((panel->priv->selected_tag_group == NULL) || + (strcmp (group_name, (gchar *)panel->priv->selected_tag_group->name) != 0)) + { + panel->priv->selected_tag_group = find_tag_group (group_name); + g_return_if_fail (panel->priv->selected_tag_group != NULL); + + gedit_debug_message (DEBUG_PLUGINS, + "New selected group: %s", + panel->priv->selected_tag_group->name); + + populate_tags_list (panel); + } + + /* Clean up preview */ + gtk_label_set_text (GTK_LABEL (panel->priv->preview), + ""); + + g_free (group_name); +} + +static gchar * +create_preview_string (Tag *tag) +{ + GString *str; + + str = g_string_new (""); + + if (tag->begin != NULL) + { + gchar *markup; + + markup = g_markup_escape_text ((gchar *)tag->begin, -1); + g_string_append (str, markup); + g_free (markup); + } + + if (tag->end != NULL) + { + gchar *markup; + + markup = g_markup_escape_text ((gchar *)tag->end, -1); + g_string_append (str, markup); + g_free (markup); + } + + g_string_append (str, ""); + + return g_string_free (str, FALSE); +} + +static void +update_preview (GeditTaglistPluginPanel *panel, + Tag *tag) +{ + gchar *str; + + str = create_preview_string (tag); + + gtk_label_set_markup (GTK_LABEL (panel->priv->preview), + str); + + g_free (str); +} + +static void +tag_list_cursor_changed_cb (GtkTreeView *tag_list, + gpointer data) +{ + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + gint index; + + GeditTaglistPluginPanel *panel = (GeditTaglistPluginPanel *)data; + + model = gtk_tree_view_get_model (tag_list); + + selection = gtk_tree_view_get_selection (tag_list); + + if (gtk_tree_selection_get_selected (selection, NULL, &iter)) + { + gtk_tree_model_get (model, &iter, COLUMN_TAG_INDEX_IN_GROUP, &index, -1); + + gedit_debug_message (DEBUG_PLUGINS, "Index: %d", index); + + update_preview (panel, + (Tag*)g_list_nth_data (panel->priv->selected_tag_group->tags, index)); + } +} + +static gboolean +tags_list_query_tooltip_cb (GtkWidget *widget, + gint x, + gint y, + gboolean keyboard_tip, + GtkTooltip *tooltip, + GeditTaglistPluginPanel *panel) +{ + GtkTreeIter iter; + GtkTreeModel *model; + GtkTreePath *path = NULL; + gint index; + Tag *tag; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + + if (keyboard_tip) + { + gtk_tree_view_get_cursor (GTK_TREE_VIEW (widget), + &path, + NULL); + + if (path == NULL) + { + return FALSE; + } + } + else + { + gint bin_x, bin_y; + + gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget), + x, y, + &bin_x, &bin_y); + + if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), + bin_x, bin_y, + &path, + NULL, NULL, NULL)) + { + return FALSE; + } + } + + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, + COLUMN_TAG_INDEX_IN_GROUP, &index, + -1); + + tag = g_list_nth_data (panel->priv->selected_tag_group->tags, index); + if (tag != NULL) + { + gchar *tip; + + tip = create_preview_string (tag); + gtk_tooltip_set_markup (tooltip, tip); + g_free (tip); + gtk_tree_path_free (path); + + return TRUE; + } + + gtk_tree_path_free (path); + + return FALSE; +} + +static gboolean +expose_event_cb (GtkWidget *panel, + GdkEventExpose *event, + gpointer user_data) +{ + GeditTaglistPluginPanel *ppanel = GEDIT_TAGLIST_PLUGIN_PANEL (panel); + + gedit_debug (DEBUG_PLUGINS); + + /* If needed load taglists from files at the first expose */ + if (taglist == NULL) + create_taglist (ppanel->priv->data_dir); + + /* And populate combo box */ + populate_tag_groups_combo (GEDIT_TAGLIST_PLUGIN_PANEL (panel)); + + /* We need to manage only the first expose event -> disconnect */ + g_signal_handlers_disconnect_by_func (panel, expose_event_cb, NULL); + + return FALSE; +} + +static void +set_combo_tooltip (GtkWidget *widget, + gpointer data) +{ + if (GTK_IS_BUTTON (widget)) + { + gtk_widget_set_tooltip_text (widget, + _("Select the group of tags you want to use")); + } +} + +static void +realize_tag_groups_combo (GtkWidget *combo, + gpointer data) +{ + gtk_container_forall (GTK_CONTAINER (combo), + set_combo_tooltip, + NULL); +} + +static void +add_preview_widget (GeditTaglistPluginPanel *panel) +{ + GtkWidget *expander; + GtkWidget *frame; + + expander = gtk_expander_new_with_mnemonic (_("_Preview")); + + panel->priv->preview = gtk_label_new (NULL); + gtk_widget_set_size_request (panel->priv->preview, -1, 80); + + gtk_label_set_line_wrap (GTK_LABEL (panel->priv->preview), TRUE); + gtk_label_set_use_markup (GTK_LABEL (panel->priv->preview), TRUE); + gtk_misc_set_alignment (GTK_MISC (panel->priv->preview), 0, 0); + gtk_misc_set_padding (GTK_MISC (panel->priv->preview), 6, 6); + gtk_label_set_selectable (GTK_LABEL (panel->priv->preview), TRUE); + gtk_label_set_selectable (GTK_LABEL (panel->priv->preview), TRUE); + gtk_label_set_ellipsize (GTK_LABEL (panel->priv->preview), + PANGO_ELLIPSIZE_END); + + frame = gtk_frame_new (0); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); + + gtk_container_add (GTK_CONTAINER (frame), + panel->priv->preview); + + gtk_container_add (GTK_CONTAINER (expander), + frame); + + gtk_box_pack_start (GTK_BOX (panel), expander, FALSE, FALSE, 0); + + gtk_widget_show_all (expander); +} + +static void +gedit_taglist_plugin_panel_init (GeditTaglistPluginPanel *panel) +{ + GtkWidget *sw; + GtkTreeViewColumn *column; + GtkCellRenderer *cell; + GList *focus_chain = NULL; + + gedit_debug (DEBUG_PLUGINS); + + panel->priv = GEDIT_TAGLIST_PLUGIN_PANEL_GET_PRIVATE (panel); + panel->priv->data_dir = NULL; + + /* Build the window content */ + panel->priv->tag_groups_combo = gtk_combo_box_new_text (); + gtk_box_pack_start (GTK_BOX (panel), + panel->priv->tag_groups_combo, + FALSE, + TRUE, + 0); + + g_signal_connect (panel->priv->tag_groups_combo, + "realize", + G_CALLBACK (realize_tag_groups_combo), + panel); + + sw = gtk_scrolled_window_new (NULL, NULL); + + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), + GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (panel), sw, TRUE, TRUE, 0); + + /* Create tree view */ + panel->priv->tags_list = gtk_tree_view_new (); + + gedit_utils_set_atk_name_description (panel->priv->tag_groups_combo, + _("Available Tag Lists"), + NULL); + gedit_utils_set_atk_name_description (panel->priv->tags_list, + _("Tags"), + NULL); + gedit_utils_set_atk_relation (panel->priv->tag_groups_combo, + panel->priv->tags_list, + ATK_RELATION_CONTROLLER_FOR); + gedit_utils_set_atk_relation (panel->priv->tags_list, + panel->priv->tag_groups_combo, + ATK_RELATION_CONTROLLED_BY); + + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (panel->priv->tags_list), FALSE); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (panel->priv->tags_list), FALSE); + + g_object_set (panel->priv->tags_list, "has-tooltip", TRUE, NULL); + + /* Add the tags column */ + cell = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Tags"), + cell, + "text", + COLUMN_TAG_NAME, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (panel->priv->tags_list), + column); + + gtk_tree_view_set_search_column (GTK_TREE_VIEW (panel->priv->tags_list), + COLUMN_TAG_NAME); + + gtk_container_add (GTK_CONTAINER (sw), panel->priv->tags_list); + + focus_chain = g_list_prepend (focus_chain, panel->priv->tags_list); + focus_chain = g_list_prepend (focus_chain, panel->priv->tag_groups_combo); + + gtk_container_set_focus_chain (GTK_CONTAINER (panel), + focus_chain); + g_list_free (focus_chain); + + add_preview_widget (panel); + + gtk_widget_show_all (GTK_WIDGET (sw)); + gtk_widget_show (GTK_WIDGET (panel->priv->tag_groups_combo)); + + g_signal_connect_after (panel->priv->tags_list, + "row_activated", + G_CALLBACK (tag_list_row_activated_cb), + panel); + g_signal_connect (panel->priv->tags_list, + "key_press_event", + G_CALLBACK (tag_list_key_press_event_cb), + panel); + g_signal_connect (panel->priv->tags_list, + "query-tooltip", + G_CALLBACK (tags_list_query_tooltip_cb), + panel); + g_signal_connect (panel->priv->tags_list, + "cursor_changed", + G_CALLBACK (tag_list_cursor_changed_cb), + panel); + g_signal_connect (panel->priv->tag_groups_combo, + "changed", + G_CALLBACK (selected_group_changed), + panel); + g_signal_connect (panel, + "expose-event", + G_CALLBACK (expose_event_cb), + NULL); +} + +GtkWidget * +gedit_taglist_plugin_panel_new (GeditWindow *window, + const gchar *data_dir) +{ + GeditTaglistPluginPanel *panel; + + g_return_val_if_fail (GEDIT_IS_WINDOW (window), NULL); + + panel = g_object_new (GEDIT_TYPE_TAGLIST_PLUGIN_PANEL, + "window", window, + NULL); + + panel->priv->data_dir = g_strdup (data_dir); + + return GTK_WIDGET (panel); +} diff --git a/plugins/taglist/gedit-taglist-plugin-panel.h b/plugins/taglist/gedit-taglist-plugin-panel.h new file mode 100755 index 00000000..3f8e82d0 --- /dev/null +++ b/plugins/taglist/gedit-taglist-plugin-panel.h @@ -0,0 +1,89 @@ +/* + * gedit-taglist-plugin-panel.h + * This file is part of gedit + * + * Copyright (C) 2005 - Paolo Maggi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the gedit Team, 2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id$ + */ + +#ifndef __GEDIT_TAGLIST_PLUGIN_PANEL_H__ +#define __GEDIT_TAGLIST_PLUGIN_PANEL_H__ + +#include + +#include + +G_BEGIN_DECLS + +/* + * Type checking and casting macros + */ +#define GEDIT_TYPE_TAGLIST_PLUGIN_PANEL (gedit_taglist_plugin_panel_get_type()) +#define GEDIT_TAGLIST_PLUGIN_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL, GeditTaglistPluginPanel)) +#define GEDIT_TAGLIST_PLUGIN_PANEL_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL, GeditTaglistPluginPanel const)) +#define GEDIT_TAGLIST_PLUGIN_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL, GeditTaglistPluginPanelClass)) +#define GEDIT_IS_TAGLIST_PLUGIN_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL)) +#define GEDIT_IS_TAGLIST_PLUGIN_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL)) +#define GEDIT_TAGLIST_PLUGIN_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL, GeditTaglistPluginPanelClass)) + +/* Private structure type */ +typedef struct _GeditTaglistPluginPanelPrivate GeditTaglistPluginPanelPrivate; + +/* + * Main object structure + */ +typedef struct _GeditTaglistPluginPanel GeditTaglistPluginPanel; + +struct _GeditTaglistPluginPanel +{ + GtkVBox vbox; + + /*< private > */ + GeditTaglistPluginPanelPrivate *priv; +}; + +/* + * Class definition + */ +typedef struct _GeditTaglistPluginPanelClass GeditTaglistPluginPanelClass; + +struct _GeditTaglistPluginPanelClass +{ + GtkVBoxClass parent_class; +}; + +/* + * Public methods + */ +GType gedit_taglist_plugin_panel_register_type (GTypeModule *module); + +GType gedit_taglist_plugin_panel_get_type (void) G_GNUC_CONST; + +GtkWidget *gedit_taglist_plugin_panel_new (GeditWindow *window, + const gchar *data_dir); + +G_END_DECLS + +#endif /* __GEDIT_TAGLIST_PLUGIN_PANEL_H__ */ diff --git a/plugins/taglist/gedit-taglist-plugin-parser.c b/plugins/taglist/gedit-taglist-plugin-parser.c new file mode 100755 index 00000000..e09c0e25 --- /dev/null +++ b/plugins/taglist/gedit-taglist-plugin-parser.c @@ -0,0 +1,655 @@ +/* + * gedit-taglist-plugin-parser.c + * This file is part of gedit + * + * Copyright (C) 2002-2005 - Paolo Maggi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the gedit Team, 2002-2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id$ + */ + +/* FIXME: we should rewrite the parser to avoid using DOM */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include + +#include "gedit-taglist-plugin-parser.h" + +/* we screwed up so we still look here for compatibility */ +#define USER_GEDIT_TAGLIST_PLUGIN_LOCATION_LEGACY ".gedit-2/plugins/taglist/" +#define USER_GEDIT_TAGLIST_PLUGIN_LOCATION "gedit/taglist/" + +TagList *taglist = NULL; +static gint taglist_ref_count = 0; + +static gboolean parse_tag (Tag *tag, xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur); +static gboolean parse_tag_group (TagGroup *tg, const gchar *fn, + xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, + gboolean sort); +static TagGroup* get_tag_group (const gchar* filename, xmlDocPtr doc, + xmlNsPtr ns, xmlNodePtr cur); +static TagList* lookup_best_lang (TagList *taglist, const gchar *filename, + xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur); +static TagList *parse_taglist_file (const gchar* filename); +static TagList *parse_taglist_dir (const gchar *dir); + +static void free_tag (Tag *tag); +static void free_tag_group (TagGroup *tag_group); + +static gboolean +parse_tag (Tag *tag, xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) +{ + /* + gedit_debug_message (DEBUG_PLUGINS, " Tag name: %s", tag->name); + */ + /* We don't care what the top level element name is */ + cur = cur->xmlChildrenNode; + + while (cur != NULL) + { + if ((!xmlStrcmp (cur->name, (const xmlChar *)"Begin")) && + (cur->ns == ns)) + { + tag->begin = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1); + /* + gedit_debug_message (DEBUG_PLUGINS, " - Begin: %s", tag->begin); + */ + } + + if ((!xmlStrcmp (cur->name, (const xmlChar *)"End")) && + (cur->ns == ns)) + { + tag->end = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1); + /* + gedit_debug_message (DEBUG_PLUGINS, " - End: %s", tag->end); + */ + } + + cur = cur->next; + } + + if ((tag->begin == NULL) && (tag->end == NULL)) + return FALSE; + + return TRUE; +} + +static gint +tags_cmp (gconstpointer a, gconstpointer b) +{ + gchar *tag_a = (gchar*)((Tag *)a)->name; + gchar *tag_b = (gchar*)((Tag *)b)->name; + + return g_utf8_collate (tag_a, tag_b); +} + +static gboolean +parse_tag_group (TagGroup *tg, const gchar* fn, xmlDocPtr doc, + xmlNsPtr ns, xmlNodePtr cur, gboolean sort) +{ + gedit_debug_message (DEBUG_PLUGINS, "Parse TagGroup: %s", tg->name); + + /* We don't care what the top level element name is */ + cur = cur->xmlChildrenNode; + + while (cur != NULL) + { + if ((xmlStrcmp (cur->name, (const xmlChar *) "Tag")) || (cur->ns != ns)) + { + g_warning ("The tag list file '%s' is of the wrong type, " + "was '%s', 'Tag' expected.", fn, cur->name); + + return FALSE; + } + else + { + Tag *tag; + + tag = g_new0 (Tag, 1); + + /* Get Tag name */ + tag->name = xmlGetProp (cur, (const xmlChar *) "name"); + + if (tag->name == NULL) + { + /* Error: No name */ + g_warning ("The tag list file '%s' is of the wrong type, " + "Tag without name.", fn); + + g_free (tag); + + return FALSE; + } + else + { + /* Parse Tag */ + if (parse_tag (tag, doc, ns, cur)) + { + /* Prepend Tag to TagGroup */ + tg->tags = g_list_prepend (tg->tags, tag); + } + else + { + /* Error parsing Tag */ + g_warning ("The tag list file '%s' is of the wrong type, " + "error parsing Tag '%s' in TagGroup '%s'.", + fn, tag->name, tg->name); + + free_tag (tag); + + return FALSE; + } + } + } + + cur = cur->next; + } + + if (sort) + tg->tags = g_list_sort (tg->tags, tags_cmp); + else + tg->tags = g_list_reverse (tg->tags); + + return TRUE; +} + +static TagGroup* +get_tag_group (const gchar* filename, xmlDocPtr doc, + xmlNsPtr ns, xmlNodePtr cur) +{ + TagGroup *tag_group; + xmlChar *sort_str; + gboolean sort = FALSE; + + tag_group = g_new0 (TagGroup, 1); + + /* Get TagGroup name */ + tag_group->name = xmlGetProp (cur, (const xmlChar *) "name"); + + sort_str = xmlGetProp (cur, (const xmlChar *) "sort"); + + if ((sort_str != NULL) && + ((xmlStrcasecmp (sort_str, (const xmlChar *) "yes") == 0) || + (xmlStrcasecmp (sort_str, (const xmlChar *) "true") == 0) || + (xmlStrcasecmp (sort_str, (const xmlChar *) "1") == 0))) + { + sort = TRUE; + } + + xmlFree(sort_str); + + if (tag_group->name == NULL) + { + /* Error: No name */ + g_warning ("The tag list file '%s' is of the wrong type, " + "TagGroup without name.", filename); + + g_free (tag_group); + } + else + { + /* Name found */ + gboolean exists = FALSE; + GList *t = taglist->tag_groups; + + /* Check if the tag group already exists */ + while (t && !exists) + { + gchar *tgn = (gchar*)((TagGroup*)(t->data))->name; + + if (strcmp (tgn, (gchar*)tag_group->name) == 0) + { + gedit_debug_message (DEBUG_PLUGINS, + "Tag group '%s' already exists.", tgn); + + exists = TRUE; + + free_tag_group (tag_group); + } + + t = g_list_next (t); + } + + if (!exists) + { + /* Parse tag group */ + if (parse_tag_group (tag_group, filename, doc, ns, cur, sort)) + { + return tag_group; + } + else + { + /* Error parsing TagGroup */ + g_warning ("The tag list file '%s' is of the wrong type, " + "error parsing TagGroup '%s'.", + filename, tag_group->name); + + free_tag_group (tag_group); + } + } + } + return NULL; +} + +static gint +groups_cmp (gconstpointer a, gconstpointer b) +{ + gchar *g_a = (gchar *)((TagGroup *)a)->name; + gchar *g_b = (gchar *)((TagGroup *)b)->name; + + return g_utf8_collate (g_a, g_b); +} + +/* + * tags file is localized by intltool-merge below. + * + * + * + * + * + * + * + * ..... + * + * + * ..... + * Therefore need to pick up the best lang on the current locale. + */ +static TagList* +lookup_best_lang (TagList *taglist, const gchar *filename, + xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) +{ + + TagGroup *best_tag_group = NULL; + TagGroup *tag_group; + gint best_lanking = -1; + + /* + * Walk the tree. + * + * First level we expect a list TagGroup + */ + cur = cur->xmlChildrenNode; + + while (cur != NULL) + { + if ((xmlStrcmp (cur->name, (const xmlChar *) "TagGroup")) || (cur->ns != ns)) + { + g_warning ("The tag list file '%s' is of the wrong type, " + "was '%s', 'TagGroup' expected.", filename, cur->name); + xmlFreeDoc (doc); + + return taglist; + } + else + { + const char * const *langs_pointer; + gchar *lang; + gint cur_lanking; + gint i; + + langs_pointer = g_get_language_names (); + + lang = (gchar*) xmlGetProp (cur, (const xmlChar*) "lang"); + cur_lanking = 1; + + /* + * When found a new TagGroup, prepend the best + * tag_group to taglist. In the current intltool-merge, + * the first section is the default lang NULL. + */ + if (lang == NULL) { + if (best_tag_group != NULL) { + taglist->tag_groups = + g_list_prepend (taglist->tag_groups, best_tag_group); + } + + best_tag_group = NULL; + best_lanking = -1; + } + + /* + * If already find the best TagGroup on the current + * locale, ignore the logic. + */ + if (best_lanking != -1 && best_lanking <= cur_lanking) { + cur = cur->next; + continue; + } + + /* try to find the best lang */ + for (i = 0; langs_pointer[i] != NULL; i++) + { + const gchar *best_lang = langs_pointer[i]; + + /* + * if launch on C, POSIX locale or does + * not find the best lang on the current locale, + * this is called. + * g_get_language_names returns lang + * lists with C locale. + */ + if (lang == NULL && + (!g_ascii_strcasecmp (best_lang, "C") || + !g_ascii_strcasecmp (best_lang, "POSIX"))) + { + tag_group = get_tag_group (filename, doc, ns, cur); + if (tag_group != NULL) + { + if (best_tag_group !=NULL) + free_tag_group (best_tag_group); + best_lanking = cur_lanking; + best_tag_group = tag_group; + } + } + + /* if it is possible the best lang is not C */ + else if (lang == NULL) + { + cur_lanking++; + continue; + } + + /* if the best lang is found */ + else if (!g_ascii_strcasecmp (best_lang, lang)) + { + tag_group = get_tag_group (filename, doc, ns, cur); + if (tag_group != NULL) + { + if (best_tag_group !=NULL) + free_tag_group (best_tag_group); + best_lanking = cur_lanking; + best_tag_group = tag_group; + } + } + + cur_lanking++; + } + + if (lang) g_free (lang); + } /* End of else */ + + cur = cur->next; + } /* End of while (cur != NULL) */ + + /* Prepend TagGroup to TagList */ + if (best_tag_group != NULL) { + taglist->tag_groups = + g_list_prepend (taglist->tag_groups, best_tag_group); + } + + taglist->tag_groups = g_list_sort (taglist->tag_groups, groups_cmp); + + return taglist; +} + +static TagList * +parse_taglist_file (const gchar* filename) +{ + xmlDocPtr doc; + + xmlNsPtr ns; + xmlNodePtr cur; + + gedit_debug_message (DEBUG_PLUGINS, "Parse file: %s", filename); + + xmlKeepBlanksDefault (0); + + /* + * build an XML tree from a the file; + */ + doc = xmlParseFile (filename); + if (doc == NULL) + { + g_warning ("The tag list file '%s' is empty.", filename); + + return taglist; + } + + /* + * Check the document is of the right kind + */ + + cur = xmlDocGetRootElement (doc); + + if (cur == NULL) + { + g_warning ("The tag list file '%s' is empty.", filename); + xmlFreeDoc(doc); + return taglist; + } + + ns = xmlSearchNsByHref (doc, cur, + (const xmlChar *) "http://gedit.sourceforge.net/some-location"); + + if (ns == NULL) + { + g_warning ("The tag list file '%s' is of the wrong type, " + "gedit namespace not found.", filename); + xmlFreeDoc (doc); + + return taglist; + } + + if (xmlStrcmp(cur->name, (const xmlChar *) "TagList")) + { + g_warning ("The tag list file '%s' is of the wrong type, " + "root node != TagList.", filename); + xmlFreeDoc (doc); + + return taglist; + } + + /* + * If needed, allocate taglist + */ + + if (taglist == NULL) + taglist = g_new0 (TagList, 1); + + taglist = lookup_best_lang (taglist, filename, doc, ns, cur); + + xmlFreeDoc (doc); + + gedit_debug_message (DEBUG_PLUGINS, "END"); + + return taglist; +} + +static void +free_tag (Tag *tag) +{ + /* + gedit_debug_message (DEBUG_PLUGINS, "Tag: %s", tag->name); + */ + g_return_if_fail (tag != NULL); + + free (tag->name); + + if (tag->begin != NULL) + free (tag->begin); + + if (tag->end != NULL) + free (tag->end); + + g_free (tag); +} + +static void +free_tag_group (TagGroup *tag_group) +{ + GList *l; + + gedit_debug_message (DEBUG_PLUGINS, "Tag group: %s", tag_group->name); + + g_return_if_fail (tag_group != NULL); + + free (tag_group->name); + + for (l = tag_group->tags; l != NULL; l = g_list_next (l)) + { + free_tag ((Tag *) l->data); + } + + g_list_free (tag_group->tags); + g_free (tag_group); + + gedit_debug_message (DEBUG_PLUGINS, "END"); +} + +void +free_taglist (void) +{ + GList *l; + + gedit_debug_message (DEBUG_PLUGINS, "ref_count: %d", taglist_ref_count); + + if (taglist == NULL) + return; + + g_return_if_fail (taglist_ref_count > 0); + + --taglist_ref_count; + if (taglist_ref_count > 0) + return; + + for (l = taglist->tag_groups; l != NULL; l = g_list_next (l)) + { + free_tag_group ((TagGroup *) l->data); + } + + g_list_free (taglist->tag_groups); + g_free (taglist); + taglist = NULL; + + gedit_debug_message (DEBUG_PLUGINS, "Really freed"); +} + +static TagList * +parse_taglist_dir (const gchar *dir) +{ + GError *error = NULL; + GDir *d; + const gchar *dirent; + + gedit_debug_message (DEBUG_PLUGINS, "DIR: %s", dir); + + d = g_dir_open (dir, 0, &error); + if (!d) + { + gedit_debug_message (DEBUG_PLUGINS, "%s", error->message); + g_error_free (error); + return taglist; + } + + while ((dirent = g_dir_read_name (d))) + { + if (g_str_has_suffix (dirent, ".tags") || + g_str_has_suffix (dirent, ".tags.gz")) + { + gchar *tags_file = g_build_filename (dir, dirent, NULL); + parse_taglist_file (tags_file); + g_free (tags_file); + } + } + + g_dir_close (d); + + return taglist; +} + +TagList* create_taglist (const gchar *data_dir) +{ + gchar *pdir; + + gedit_debug_message (DEBUG_PLUGINS, "ref_count: %d", taglist_ref_count); + + if (taglist_ref_count > 0) + { + ++taglist_ref_count; + + return taglist; + } + +#ifndef G_OS_WIN32 + const gchar *home; + const gchar *envvar; + + /* load user's taglists */ + + /* legacy dir */ + home = g_get_home_dir (); + if (home != NULL) + { + pdir = g_build_filename (home, + USER_GEDIT_TAGLIST_PLUGIN_LOCATION_LEGACY, + NULL); + parse_taglist_dir (pdir); + g_free (pdir); + } + + /* Support old libmate env var */ + envvar = g_getenv ("MATE22_USER_DIR"); + if (envvar != NULL) + { + pdir = g_build_filename (envvar, + USER_GEDIT_TAGLIST_PLUGIN_LOCATION, + NULL); + parse_taglist_dir (pdir); + g_free (pdir); + } + else if (home != NULL) + { + pdir = g_build_filename (home, + ".mate2", + USER_GEDIT_TAGLIST_PLUGIN_LOCATION, + NULL); + parse_taglist_dir (pdir); + g_free (pdir); + } + +#else + pdir = g_build_filename (g_get_user_config_dir (), + "gedit", + "taglist", + NULL); + parse_taglist_dir (pdir); + g_free (pdir); +#endif + + /* load system's taglists */ + parse_taglist_dir (data_dir); + + ++taglist_ref_count; + g_return_val_if_fail (taglist_ref_count == 1, taglist); + + return taglist; +} diff --git a/plugins/taglist/gedit-taglist-plugin-parser.h b/plugins/taglist/gedit-taglist-plugin-parser.h new file mode 100755 index 00000000..d008836e --- /dev/null +++ b/plugins/taglist/gedit-taglist-plugin-parser.h @@ -0,0 +1,68 @@ +/* + * gedit-taglist-plugin-parser.h + * This file is part of gedit + * + * Copyright (C) 2002-2005 - Paolo Maggi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the gedit Team, 2002-2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id$ + */ + +#ifndef __GEDIT_TAGLIST_PLUGIN_PARSER_H__ +#define __GEDIT_TAGLIST_PLUGIN_PARSER_H__ + +#include +#include + +typedef struct _TagList TagList; +typedef struct _TagGroup TagGroup; +typedef struct _Tag Tag; + +struct _TagList +{ + GList *tag_groups; +}; + +struct _TagGroup +{ + xmlChar *name; + + GList *tags; +}; + +struct _Tag +{ + xmlChar *name; + xmlChar *begin; + xmlChar *end; +}; + +/* Note that the taglist is ref counted */ +extern TagList *taglist; + +TagList* create_taglist (const gchar *data_dir); + +void free_taglist (void); + +#endif /* __GEDIT_TAGLIST_PLUGIN_PARSER_H__ */ + diff --git a/plugins/taglist/gedit-taglist-plugin.c b/plugins/taglist/gedit-taglist-plugin.c new file mode 100755 index 00000000..081fefcb --- /dev/null +++ b/plugins/taglist/gedit-taglist-plugin.c @@ -0,0 +1,160 @@ +/* + * gedit-taglist-plugin.h + * + * Copyright (C) 2002-2005 - Paolo Maggi + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +/* + * Modified by the gedit Team, 2002-2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gedit-taglist-plugin.h" +#include "gedit-taglist-plugin-panel.h" +#include "gedit-taglist-plugin-parser.h" + +#include +#include + +#include +#include + +#define WINDOW_DATA_KEY "GeditTaglistPluginWindowData" + +#define GEDIT_TAGLIST_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPluginPrivate)) + +struct _GeditTaglistPluginPrivate +{ + gpointer dummy; +}; + +GEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE (GeditTaglistPlugin, gedit_taglist_plugin, + gedit_taglist_plugin_panel_register_type (module); +) + +static void +gedit_taglist_plugin_init (GeditTaglistPlugin *plugin) +{ + plugin->priv = GEDIT_TAGLIST_PLUGIN_GET_PRIVATE (plugin); + + gedit_debug_message (DEBUG_PLUGINS, "GeditTaglistPlugin initializing"); +} + +static void +gedit_taglist_plugin_finalize (GObject *object) +{ +/* + GeditTaglistPlugin *plugin = GEDIT_TAGLIST_PLUGIN (object); +*/ + gedit_debug_message (DEBUG_PLUGINS, "GeditTaglistPlugin finalizing"); + + free_taglist (); + + G_OBJECT_CLASS (gedit_taglist_plugin_parent_class)->finalize (object); +} + +static void +impl_activate (GeditPlugin *plugin, + GeditWindow *window) +{ + GeditPanel *side_panel; + GtkWidget *taglist_panel; + gchar *data_dir; + + gedit_debug (DEBUG_PLUGINS); + + g_return_if_fail (g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY) == NULL); + + side_panel = gedit_window_get_side_panel (window); + + data_dir = gedit_plugin_get_data_dir (plugin); + taglist_panel = gedit_taglist_plugin_panel_new (window, data_dir); + g_free (data_dir); + + gedit_panel_add_item_with_stock_icon (side_panel, + taglist_panel, + _("Tags"), + GTK_STOCK_ADD); + + g_object_set_data (G_OBJECT (window), + WINDOW_DATA_KEY, + taglist_panel); +} + +static void +impl_deactivate (GeditPlugin *plugin, + GeditWindow *window) +{ + GeditPanel *side_panel; + gpointer data; + + gedit_debug (DEBUG_PLUGINS); + + data = g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY); + g_return_if_fail (data != NULL); + + side_panel = gedit_window_get_side_panel (window); + + gedit_panel_remove_item (side_panel, + GTK_WIDGET (data)); + + g_object_set_data (G_OBJECT (window), + WINDOW_DATA_KEY, + NULL); +} + +static void +impl_update_ui (GeditPlugin *plugin, + GeditWindow *window) +{ + gpointer data; + GeditView *view; + + gedit_debug (DEBUG_PLUGINS); + + data = g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY); + g_return_if_fail (data != NULL); + + view = gedit_window_get_active_view (window); + + gtk_widget_set_sensitive (GTK_WIDGET (data), + (view != NULL) && + gtk_text_view_get_editable (GTK_TEXT_VIEW (view))); +} + +static void +gedit_taglist_plugin_class_init (GeditTaglistPluginClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GeditPluginClass *plugin_class = GEDIT_PLUGIN_CLASS (klass); + + object_class->finalize = gedit_taglist_plugin_finalize; + + plugin_class->activate = impl_activate; + plugin_class->deactivate = impl_deactivate; + plugin_class->update_ui = impl_update_ui; + + g_type_class_add_private (object_class, sizeof (GeditTaglistPluginPrivate)); +} diff --git a/plugins/taglist/gedit-taglist-plugin.h b/plugins/taglist/gedit-taglist-plugin.h new file mode 100755 index 00000000..d0444e76 --- /dev/null +++ b/plugins/taglist/gedit-taglist-plugin.h @@ -0,0 +1,85 @@ +/* + * gedit-taglist-plugin.h + * + * Copyright (C) 2002-2005 - Paolo Maggi + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +/* + * Modified by the gedit Team, 2002-2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id$ + */ + +#ifndef __GEDIT_TAGLIST_PLUGIN_H__ +#define __GEDIT_TAGLIST_PLUGIN_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +/* + * Type checking and casting macros + */ +#define GEDIT_TYPE_TAGLIST_PLUGIN (gedit_taglist_plugin_get_type ()) +#define GEDIT_TAGLIST_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPlugin)) +#define GEDIT_TAGLIST_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPluginClass)) +#define GEDIT_IS_TAGLIST_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GEDIT_TYPE_TAGLIST_PLUGIN)) +#define GEDIT_IS_TAGLIST_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GEDIT_TYPE_TAGLIST_PLUGIN)) +#define GEDIT_TAGLIST_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPluginClass)) + +/* Private structure type */ +typedef struct _GeditTaglistPluginPrivate GeditTaglistPluginPrivate; + +/* + * Main object structure + */ +typedef struct _GeditTaglistPlugin GeditTaglistPlugin; + +struct _GeditTaglistPlugin +{ + GeditPlugin parent_instance; + + /*< private >*/ + GeditTaglistPluginPrivate *priv; +}; + +/* + * Class definition + */ +typedef struct _GeditTaglistPluginClass GeditTaglistPluginClass; + +struct _GeditTaglistPluginClass +{ + GeditPluginClass parent_class; +}; + +/* + * Public methods + */ +GType gedit_taglist_plugin_get_type (void) G_GNUC_CONST; + +/* All the plugins must implement this function */ +G_MODULE_EXPORT GType register_gedit_plugin (GTypeModule *module); + +G_END_DECLS + +#endif /* __GEDIT_TAGLIST_PLUGIN_H__ */ diff --git a/plugins/taglist/taglist.gedit-plugin.desktop.in b/plugins/taglist/taglist.gedit-plugin.desktop.in new file mode 100755 index 00000000..09d0f2d0 --- /dev/null +++ b/plugins/taglist/taglist.gedit-plugin.desktop.in @@ -0,0 +1,8 @@ +[Gedit Plugin] +Module=taglist +IAge=2 +_Name=Tag list +_Description=Provides a method to easily insert commonly used tags/strings into a document without having to type them. +Authors=Paolo Maggi +Copyright=Copyright © 2002-2005 Paolo Maggi +Website=http://www.gedit.org -- cgit v1.2.1