summaryrefslogtreecommitdiffstats
path: root/src/boilerplate.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/boilerplate.h')
-rw-r--r--src/boilerplate.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/boilerplate.h b/src/boilerplate.h
new file mode 100644
index 0000000..413c48d
--- /dev/null
+++ b/src/boilerplate.h
@@ -0,0 +1,45 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv 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 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv 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
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+typedef gpointer gobject;
+
+/**
+ A case in a switch statement in a set_properties implementation.
+ @prop: Property enumeration ID.
+ @type: Name of the value type, e.g. uint for guint.
+ @field: Field to set to the new value.
+*/
+#define SET_CASE(prop, type, field) \
+ case PROP_##prop: { \
+ const g##type tmp = g_value_get_##type(value); \
+ if (field != tmp) { \
+ field = tmp; \
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(object)); \
+ } \
+ break; \
+ }
+
+/**
+ A case in a switch statement in a get_properties implementation.
+ @prop: Property enumeration ID.
+ @type: Name of the value type, e.g. uint for guint.
+ @field: Field to set to the new value.
+*/
+#define GET_CASE(prop, type, field) \
+ case PROP_##prop: \
+ g_value_set_##type(value, field); \
+ break;