[gedit] snippets: add gboxed templates



commit c8ba935c0f7e38ff844e69197f197a76b3c39742
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat Aug 13 09:52:42 2011 +0200

    snippets: add gboxed templates

 plugins/snippets/data/c.xml    |   34 ++++++++++++++++++++++++++++++
 plugins/snippets/data/chdr.xml |   44 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 0 deletions(-)
---
diff --git a/plugins/snippets/data/c.xml b/plugins/snippets/data/c.xml
index d08f9bf..fd2180d 100644
--- a/plugins/snippets/data/c.xml
+++ b/plugins/snippets/data/c.xml
@@ -280,4 +280,38 @@ $<[1]: return low_str>_get_type ()
     <tag>ginterface</tag>
     <description>GObject interface</description>
   </snippet>
+    <snippet>
+    <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()
+camel_str = ''
+
+for t in components:
+  camel_str += t.capitalize()
+>
+
+struct _$<[1]: return camel_str >
+{
+};
+
+G_DEFINE_BOXED_TYPE ($<[1]: return camel_str >, $<[1]: return low_str >, $<[1]: return low_str >_${2:copy}, $<[1]: return low_str >_${3:free})
+
+$<[1]: return camel_str > *
+$<[1]: return low_str >_${2:copy} ($<[1]: return camel_str > *${4:boxed_name})
+{
+	
+}
+
+void
+$<[1]: return low_str >_${3:free} ($<[1]: return camel_str > *${4:boxed_name})
+{
+	
+}]]></text>
+    <tag>gboxed</tag>
+    <description>GBoxed template</description>
+  </snippet>
 </snippets>
diff --git a/plugins/snippets/data/chdr.xml b/plugins/snippets/data/chdr.xml
index c6145d5..63a8492 100644
--- a/plugins/snippets/data/chdr.xml
+++ b/plugins/snippets/data/chdr.xml
@@ -238,4 +238,48 @@ G_END_DECLS
     <tag>ginterface</tag>
     <description>GObject interface</description>
   </snippet>
+    <snippet>
+    <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)', '((' + camel_str + ' *)obj)'], \
+['#define ' + $1 + '_CONST(obj)', '((' + camel_str + ' const *)obj)'], \
+]
+
+return align(items) >
+
+$<[1]:
+items = [ \
+['typedef struct _' + camel_str, camel_str + ';'], \
+]
+
+return align(items) >
+
+GType $< return $1.lower() + '_get_type' > (void) G_GNUC_CONST;
+$<[1]: return camel_str > *$< return $1.lower()>_${3:copy} ($<[1]: return camel_str > *${4:boxed_name});
+void $< return $1.lower()>_${5:free} ($<[1]: return camel_str > *${4:boxed_name});
+
+$0
+G_END_DECLS
+
+#endif /* __$1_H__ */]]></text>
+    <tag>gboxed</tag>
+    <description>GBoxed template</description>
+  </snippet>
 </snippets>



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