Created
May 13, 2014 06:28
-
-
Save codebrainz/f8000c1f0d07e8c0c336 to your computer and use it in GitHub Desktop.
Minimal GObject boilerplate (~ 8 lines of additional code)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "foobar.h" | |
G_DEFINE_TYPE (FooBar, foo_bar, G_TYPE_OBJECT) | |
static void foo_bar_class_init (FooBarClass *klass) {} | |
static void foo_bar_init (FooBar *self) {} | |
// Test program, doesn't count :) | |
int main() | |
{ | |
g_type_init(); | |
GObject *theObj = g_object_new(foo_bar_get_type(), NULL); | |
g_object_ref(theObj); | |
g_object_unref(theObj); | |
g_object_unref(theObj); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef FOOBAR_H_ | |
#define FOOBAR_H_ 1 | |
#include <glib-object.h> | |
typedef struct FooBar_ { | |
GObject parent; | |
} | |
FooBar; | |
typedef struct FooBarClass_ { | |
GObjectClass parent_class; | |
} | |
FooBarClass; | |
GType foo_bar_get_type(void); | |
#endif /* FOOBAR_H_ */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment