[gnome-builder] snippets: add ginterface snippet for c and chdr languages.



commit 5b157579188daf11b23a2aaa0a57798dbbc017bb
Author: Christian Hergert <christian hergert me>
Date:   Wed Dec 3 11:18:02 2014 -0800

    snippets: add ginterface snippet for c and chdr languages.
    
    This will create the scaffolding for a new GObject interface based on
    the file name. Name files like "foo-bar.c".

 src/resources/snippets/c.snippets    |    9 +++++++++
 src/resources/snippets/chdr.snippets |   26 ++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/resources/snippets/c.snippets b/src/resources/snippets/c.snippets
index 43d5d0c..ec1fb67 100644
--- a/src/resources/snippets/c.snippets
+++ b/src/resources/snippets/c.snippets
@@ -183,3 +183,12 @@ snippet unref
        g_object_unref (${1});$0
 snippet clear
        g_clear_object (&${1});$0
+snippet ginterface
+       #include "${1:$filename|stripsuffix}.h"
+
+       G_DEFINE_INTERFACE (${2:$1|camelize}, ${3:$1|functify}, ${4:G_TYPE_OBJECT})
+
+       static void
+       $3_default_init ($2Interface *iface)
+       {
+       }
diff --git a/src/resources/snippets/chdr.snippets b/src/resources/snippets/chdr.snippets
index 3b3663b..e5ec0b7 100644
--- a/src/resources/snippets/chdr.snippets
+++ b/src/resources/snippets/chdr.snippets
@@ -50,3 +50,29 @@ snippet guard
        G_END_DECLS
 
        #endif /* $1_H */
+snippet ginterface
+       #ifndef ${$1|functify|upper}_H
+       #define ${$1|functify|upper}_H
+
+       #include <glib-object.h>
+
+       G_BEGIN_DECLS
+
+       #define ${$1|functify|namespace|upper}_TYPE_${$1|class|functify|upper}               
(${$1|functify}_get_type ())
+       #define ${$1|functify|namespace|upper}_${$1|class|functify|upper}(obj)               
(G_TYPE_CHECK_INSTANCE_CAST ((obj), ${$1|functify|namespace|upper}_TYPE_${$1|class|functify|upper}, $1))
+       #define ${$1|functify|namespace|upper}_IS_${$1|class|functify|upper}(obj)            
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ${$1|functify|namespace|upper}_TYPE_${$1|class|functify|upper}))
+       #define ${$1|functify|namespace|upper}_${$1|class|functify|upper}_GET_INTERFACE(obj) 
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), ${$1|functify|namespace|upper}_TYPE_${$1|class|functify|upper}, 
$1Interface))
+
+       typedef struct _$1      $1;
+       typedef struct _$1Interface $1Interface;
+
+       struct _${1:$filename|stripsuffix|functify|camelize}Interface
+       {
+               GTypeInterface parent;
+       };
+
+       GType foo_bar_get_type (void) G_GNUC_CONST;
+
+       G_END_DECLS
+
+       #endif /* ${$1|functify|upper}_H */


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