gedit r6787 - in trunk: . plugins/snippets/data



Author: jessevdk
Date: Thu Jan  1 19:47:23 2009
New Revision: 6787
URL: http://svn.gnome.org/viewvc/gedit?rev=6787&view=rev

Log:
	* plugins/snippets/data/chdr.xml:
	* plugins/snippets/data/c++.xml:
	* plugins/snippets/data/cpp.xml:
	* plugins/snippets/data/c.xml:
	* plugins/snippets/data/Makefile.am:
	
	Added chdr language with C/C++ header specific snippets. Removed header
	specific snippets from c and c++ languages. Fixed language id in
	C++ language file since apparently it has changed.


Added:
   trunk/plugins/snippets/data/chdr.xml
   trunk/plugins/snippets/data/cpp.xml   (contents, props changed)
      - copied, changed from r6779, /trunk/plugins/snippets/data/c++.xml
Removed:
   trunk/plugins/snippets/data/c++.xml
Modified:
   trunk/ChangeLog
   trunk/plugins/snippets/data/Makefile.am
   trunk/plugins/snippets/data/c.xml

Modified: trunk/plugins/snippets/data/Makefile.am
==============================================================================
--- trunk/plugins/snippets/data/Makefile.am	(original)
+++ trunk/plugins/snippets/data/Makefile.am	Thu Jan  1 19:47:23 2009
@@ -4,7 +4,8 @@
 snippets_DATA = \
 	css.xml \
 	c.xml \
-	c++.xml \
+	cpp.xml \
+	chdr.xml \
 	docbook.xml \
 	global.xml \
 	haskell.xml \

Modified: trunk/plugins/snippets/data/c.xml
==============================================================================
--- trunk/plugins/snippets/data/c.xml	(original)
+++ trunk/plugins/snippets/data/c.xml	Thu Jan  1 19:47:23 2009
@@ -87,17 +87,6 @@
     <tag>while</tag>
     <description>while loop</description>
   </snippet>
-  <snippet id="once">
-    <text><![CDATA[#ifndef __${1:NAME}_H__
-#define __$1_H__
-
-$0
-
-#endif /* __$1_H__ */
-]]></text>
-    <tag>once</tag>
-    <description>Header-Include Guard</description>
-  </snippet>
   <snippet id="if">
     <text><![CDATA[if (${1:condition})
 {
@@ -164,4 +153,57 @@
     <tag>td</tag>
     <description>typedef</description>
   </snippet>
+  <snippet id="gobject">>
+    <text><![CDATA[#include "$1.h"
+$<
+global camel_str,low_str, type_str, is_str, up_str
+components = $1.split('-')
+low_str = '_'.join(components).lower()
+up_str = '_'.join(components).upper()
+type_str = '_'.join([components[0], 'TYPE'] + components[1:]).upper()
+is_str = '_'.join([components[0], 'IS'] + components[1:]).upper()
+camel_str = ''
+
+for t in components:
+  camel_str += t.capitalize()
+>
+
+#define $<[1]: return up_str >_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), $<[1]: return type_str >, $<[1]: return camel_str >Private))
+
+struct _$<[1]: return camel_str >Private
+{
+};
+
+G_DEFINE_TYPE ($<[1]: return camel_str >, $<[1]: return low_str >, ${2:G_TYPE_OBJECT})
+
+static void
+$<[1]: return low_str>_finalize (GObject *object)
+{
+	G_OBJECT_CLASS ($<[1]: return low_str >_parent_class)->finalize (object);
+}
+
+static void
+$<[1]: return low_str >_class_init ($<[1]: return camel_str >Class *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	
+	object_class->finalize = $<[1]: return low_str >_finalize;
+
+	g_type_class_add_private (object_class, sizeof($<[1]: return camel_str >Private));
+}
+
+static void
+$<[1]: return low_str >_init ($<[1]: return camel_str> *self)
+{
+	self->priv = $<[1]: return up_str >_GET_PRIVATE (self);
+}
+
+$<[1]: return camel_str >*
+$<[1]: return low_str >_new ()
+{
+	return g_object_new ($<[1]: return type_str >, NULL);
+}]]></text>
+    <tag>gobject</tag>
+    <description>GObject template</description>
+  </snippet>
 </snippets>

Added: trunk/plugins/snippets/data/chdr.xml
==============================================================================
--- (empty file)
+++ trunk/plugins/snippets/data/chdr.xml	Thu Jan  1 19:47:23 2009
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<snippets language="chdr">
+  <snippet id="once">
+    <text><![CDATA[#ifndef __${1:NAME}_H__
+#define __$1_H__
+
+$0
+
+#endif /* __$1_H__ */
+]]></text>
+    <description>Header Include-Guard</description>
+    <tag>once</tag>
+  </snippet>
+  <snippet id="inc">
+    <text><![CDATA[#include "${1:file}"
+$0]]></text>
+    <description>#include ".."</description>
+    <tag>inc</tag>
+  </snippet>
+  <snippet id="Inc">
+    <text><![CDATA[#include <${1:file}>
+$0]]></text>
+    <description>#include &lt;..&gt;</description>
+    <tag>Inc</tag>
+  </snippet>
+  <snippet id="namespace">
+    <text><![CDATA[namespace ${1:ns}
+{
+	$0
+};
+]]></text>
+    <description>namespace ..</description>
+    <tag>namespace</tag>
+  </snippet>
+  <snippet id="gpl">
+    <text><![CDATA[/*
+ * ${1:[$GEDIT_BASENAME,<filename>]}
+ * This file is part of ${2:<program name>}
+ *
+ * Copyright (C) $<3: import datetime; return str(datetime.date.today().year)> - $<4:
+import pwd, os
+try:
+  return pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0]
+except KeyError:
+  return '<author\>' >
+ *
+ * ${2} 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.
+ *
+ * ${2} 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 ${2}; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+ 
+ $0]]></text>
+    <tag>gpl</tag>
+    <description>GPL License</description>
+  </snippet>
+  <snippet id="lgpl">
+    <text><![CDATA[/*
+ * ${1:[$GEDIT_BASENAME,<filename>]}
+ * This file is part of ${2:<library name>} 
+ *
+ * Copyright (C) $<3: import datetime; return str(datetime.date.today().year)> - $<4:
+import pwd, os
+try:
+  return pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0]
+except KeyError:
+  return '<author\>' >
+ *
+ * ${2} is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * ${2} is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+ 
+ $0]]></text>
+    <tag>lgpl</tag>
+    <description>LGPL License</description>
+  </snippet>
+  <snippet id="td">
+    <text><![CDATA[typedef ${1:newtype} ${2:type};
+$0]]></text>
+    <tag>td</tag>
+    <description>typedef</description>
+  </snippet>
+  <snippet id="class">
+    <text><![CDATA[class ${1:name}
+{
+	public:
+		${1:name} (${2:arguments});
+		virtual ~${1:name} ();
+
+	private:
+		${0:/* data */}
+};]]></text>
+    <description>class ..</description>
+    <tag>class</tag>
+  </snippet>
+  <snippet id="struct">
+    <text><![CDATA[struct ${1:name}
+{
+	${0:/* data */}
+};]]></text>
+    <tag>struct</tag>
+    <description>struct</description>
+  </snippet>
+  <snippet id="template">
+    <text><![CDATA[template <typename ${1:_InputIter}>]]></text>
+    <description>template &lt;typename ..&gt;</description>
+    <tag>template</tag>
+  </snippet>
+  <snippet id="gobject">
+    <text><![CDATA[#ifndef __${1:NAME}_H__
+#define __$1_H__
+
+#include <${2:glib-object.h}>
+
+G_BEGIN_DECLS
+
+$<
+global camel_str
+components = $1.split('_')
+type_str = '_'.join([components[0], 'TYPE'] + components[1:])
+is_str = '_'.join([components[0], 'IS'] + components[1:])
+camel_str = ''
+
+for t in components:
+  camel_str += t.capitalize()
+
+items = [ \
+['#define ' + type_str, '(' + $1.lower() + '_get_type ())'], \
+['#define ' + $1 + '(obj)', '(G_TYPE_CHECK_INSTANCE_CAST ((obj), ' + type_str + ', ' + camel_str + '))'], \
+['#define ' + $1 + '_CONST(obj)', '(G_TYPE_CHECK_INSTANCE_CAST ((obj), ' + type_str + ', ' + camel_str + ' const))'], \
+['#define ' + $1 + '_CLASS(klass)', '(G_TYPE_CHECK_CLASS_CAST ((klass), ' + type_str + ', ' + camel_str + 'Class))'], \
+['#define ' + is_str + '(obj)', '(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ' + type_str + '))'], \
+['#define ' + is_str + '_CLASS(klass)', '(G_TYPE_CHECK_CLASS_TYPE ((klass), ' + type_str + '))'], \
+['#define ' + $1 + '_GET_CLASS(obj)', '(G_TYPE_INSTANCE_GET_CLASS ((obj), ' + type_str + ', ' + camel_str + 'Class))']
+]
+
+return align(items) >
+
+$<[1]:
+items = [ \
+['typedef struct _' + camel_str, camel_str + ';'], \
+['typedef struct _' + camel_str + 'Class', camel_str + 'Class;'], \
+['typedef struct _' + camel_str + 'Private', camel_str + 'Private;'] \
+]
+
+return align(items) >
+
+struct _$<[1]: return camel_str > {
+	${7:GObject} parent;
+	
+	$<[1]: return camel_str >Private *priv;
+};
+
+struct _$<[1]: return camel_str >Class {
+	$7Class parent_class;
+};
+
+GType $< return $1.lower() + '_get_type' > (void) G_GNUC_CONST;
+$<[1]: return camel_str > *$< return $1.lower()>_new (void);
+
+$0
+G_END_DECLS
+
+#endif /* __$1_H__ */]]></text>
+    <tag>gobject</tag>
+    <description>GObject template</description>
+  </snippet>
+</snippets>

Copied: trunk/plugins/snippets/data/cpp.xml (from r6779, /trunk/plugins/snippets/data/c++.xml)
==============================================================================
--- /trunk/plugins/snippets/data/c++.xml	(original)
+++ trunk/plugins/snippets/data/cpp.xml	Thu Jan  1 19:47:23 2009
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<snippets language="C 43@@43@">
+<snippets language="cpp">
   <snippet id="main">
     <text><![CDATA[int main (int argc, char const* argv[])
 {
@@ -22,19 +22,6 @@
     <description>$1.begin</description>
     <tag>beginend</tag>
   </snippet>
-  <snippet id="class">
-    <text><![CDATA[class ${1:name}
-{
-	public:
-		${1:name} (${2:arguments});
-		virtual ~${1:name} ();
-
-	private:
-		${0:/* data */}
-};]]></text>
-    <description>class ..</description>
-    <tag>class</tag>
-  </snippet>
   <snippet id="do">
     <text><![CDATA[do
 {
@@ -57,17 +44,6 @@
     <description>if ..</description>
     <tag>if</tag>
   </snippet>
-  <snippet id="once">
-    <text><![CDATA[#ifndef __${1:NAME}_H__
-#define __$1_H__
-
-$0
-
-#endif /* __$1_H__ */
-]]></text>
-    <description>Header Include-Guard</description>
-    <tag>once</tag>
-  </snippet>
   <snippet id="inc">
     <text><![CDATA[#include "${1:file}"
 $0]]></text>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]