[Rawstudio-commit] r2207 - trunk/contrib

Anders Kvist anders at kvistmail.dk
Sat Feb 21 22:57:23 CET 2009


Author: akv
Date: 2009-02-21 22:57:23 +0100 (Sat, 21 Feb 2009)
New Revision: 2207

Added:
   trunk/contrib/filter-Makefile-template.am
   trunk/contrib/filter-template.c
   trunk/contrib/new_filter.sh
Log:
Added script for creating a new filter.

Added: trunk/contrib/filter-Makefile-template.am
===================================================================
--- trunk/contrib/filter-Makefile-template.am	                        (rev 0)
+++ trunk/contrib/filter-Makefile-template.am	2009-02-21 21:57:23 UTC (rev 2207)
@@ -0,0 +1,21 @@
+plugindir = $(libdir)/rawstudio/plugins
+
+AM_CFLAGS =\
+	-Wall\
+	-O4
+
+AM_CXXFLAGS = $(AM_CFLAGS)
+
+INCLUDES = \
+	-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
+	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+	@PACKAGE_CFLAGS@ \
+	-I../../librawstudio/
+
+lib_LTLIBRARIES = template.la
+
+libdir = $(datadir)/rawstudio/plugins/
+
+template_la_LIBADD = @PACKAGE_LIBS@
+template_la_LDFLAGS = -module -avoid-version
+template_la_SOURCES = template.c

Added: trunk/contrib/filter-template.c
===================================================================
--- trunk/contrib/filter-template.c	                        (rev 0)
+++ trunk/contrib/filter-template.c	2009-02-21 21:57:23 UTC (rev 2207)
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2006-2009 Anders Brander <anders at brander.dk> and 
+ * Anders Kvist <akv at lnxbx.dk>
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+/* Plugin tmpl version 4 */
+
+#include <rawstudio.h>
+
+#define RS_TYPE_TEMPLATE (rs_template_type)
+#define RS_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_TEMPLATE, RSTemplate))
+#define RS_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_TEMPLATE, RSTemplateClass))
+#define RS_IS_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_TEMPLATE))
+
+typedef struct _RSTemplate RSTemplate;
+typedef struct _RSTemplateClass RSTemplateClass;
+
+struct _RSTemplate {
+	RSFilter parent;
+
+	gchar *changeme;
+};
+
+struct _RSTemplateClass {
+	RSFilterClass parent_class;
+};
+
+RS_DEFINE_FILTER(rs_template, RSTemplate)
+
+enum {
+	PROP_0,
+	PROP_CHANGEME
+};
+
+static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
+static RS_IMAGE16 *get_image(RSFilter *filter);
+static gint get_width(RSFilter *filter);
+static gint get_height(RSFilter *filter);
+
+static RSFilterClass *rs_template_parent_class = NULL;
+
+G_MODULE_EXPORT void
+rs_plugin_load(RSPlugin *plugin)
+{
+	rs_template_get_type(G_TYPE_MODULE(plugin));
+}
+
+static void
+rs_template_class_init(RSTemplateClass *klass)
+{
+	RSFilterClass *filter_class = RS_FILTER_CLASS (klass);
+	GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+	rs_template_parent_class = g_type_class_peek_parent (klass);
+
+	object_class->get_property = get_property;
+	object_class->set_property = set_property;
+
+	g_object_class_install_property(object_class,
+		PROP_CHANGEME, g_param_spec_string (
+			"changeme",
+			"Changeme nick",
+			"Changeme blurb",
+			NULL,
+			G_PARAM_READWRITE)
+	);
+
+	filter_class->name = "Template filter";
+	filter_class->get_image = get_image;
+	filter_class->get_width = get_width;
+	filter_class->get_height = get_height;
+}
+
+static void
+rs_template_init(RSTemplate *template)
+{
+	template->changeme = NULL;
+}
+
+static void
+get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+	RSTemplate *template = RS_TEMPLATE(object);
+
+	switch (property_id)
+	{
+		case PROP_CHANGEME:
+			g_value_get_string (value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+	}
+}
+
+static void
+set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+	RSTemplate *template = RS_TEMPLATE(object);
+
+	switch (property_id)
+	{
+		case PROP_CHANGEME:
+			g_free(template->changeme);
+			template->changeme = g_value_dup_string(value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+	}
+}
+
+static RS_IMAGE16 *
+get_image(RSFilter *filter)
+{
+	RSTemplate *template = RS_TEMPLATE(filter);
+	RS_IMAGE16 *input;
+	RS_IMAGE16 *output = NULL;
+
+	input = rs_filter_get_image(filter->previous);
+
+	/* Process */
+
+	g_object_unref(input);
+	return output;
+}
+
+static gint
+get_width(RSFilter *filter)
+{
+	RSTemplate *template = RS_TEMPLATE(filter);
+
+	return -1;
+}
+
+static gint
+get_height(RSFilter *filter)
+{
+	RSTemplate *template = RS_TEMPLATE(filter);
+
+	return -1;
+}
+

Added: trunk/contrib/new_filter.sh
===================================================================
--- trunk/contrib/new_filter.sh	                        (rev 0)
+++ trunk/contrib/new_filter.sh	2009-02-21 21:57:23 UTC (rev 2207)
@@ -0,0 +1,39 @@
+#!/bin/bash 
+# bash is needed for timeout in 'read'
+
+MAKEFILETEMPLATE=filter-Makefile-template.am
+FILTERTEMPLATE=filter-template.c
+
+FILTERPATH=../plugins
+
+NAME=${1}
+Name=${2}
+name=${3}
+
+
+if [ -z ${3} ]; then
+    echo ${0} NAME Name name # FIXME: This should be done with only one name
+    exit 1
+fi
+
+if [ ! -e ${MAKEFILETEMPLATE} -o ! -e ${FILTERTEMPLATE} ]; then
+    echo "This script needs to be run from the contrib/ directory..."
+    exit 2
+fi
+
+if [ -d ${FILTERPATH}/${name} ]; then
+    echo -n "Target ${FILTERPATH}/${name} exists, remove? [N/y] "
+    read -t 10 TEMP
+    TEMP=$(echo ${TEMP}|tr [:upper:] [:lower:])
+    if [ "${TEMP}" = "y" ]; then
+	rm -rf ${FILTERPATH}/${name}
+    else
+	exit 3
+    fi
+fi
+
+mkdir ${FILTERPATH}/${name}
+sed "s/TEMPLATE/${NAME}/g;s/Template/${Name}/g;s/template/${name}/g" ${FILTERTEMPLATE} > ${FILTERPATH}/${name}/${name}.c
+sed "s/TEMPLATE/${NAME}/g;s/Template/${Name}/g;s/template/${name}/g" ${MAKEFILETEMPLATE} > ${FILTERPATH}/${name}/Makefile.am
+
+echo "${FILTERPATH}/${name}/${name}.c has been created, please edit configure.in and plugins/Makefile.am to enable filter"


Property changes on: trunk/contrib/new_filter.sh
___________________________________________________________________
Name: svn:executable
   + *




More information about the Rawstudio-commit mailing list