[nautilus-actions] Define NAExportFormat new class
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Define NAExportFormat new class
- Date: Fri, 19 Feb 2010 02:27:31 +0000 (UTC)
commit 934558809559afe7716f585b586c4d8aeaf19b16
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Feb 17 10:29:36 2010 +0100
Define NAExportFormat new class
ChangeLog | 5 +
src/core/na-export-format.c | 307 +++++++++++++++++++++++++++++++++++++++++++
src/core/na-export-format.h | 79 +++++++++++
3 files changed, 391 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4219375..1cf15c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-02-17 Pierre Wieser <pwieser trychlos org>
+ Define NAExportFormat new class.
+
+ * src/core/na-export-format.c:
+ * src/core/na-export-format.h: New files.
+
Rename src/nact/nact-assistant-export-ask.{c,h} to
src/nact/nact-export-ask.{c,h}
diff --git a/src/core/na-export-format.c b/src/core/na-export-format.c
new file mode 100644
index 0000000..f818e7d
--- /dev/null
+++ b/src/core/na-export-format.c
@@ -0,0 +1,307 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "na-export-format.h"
+
+/* private class data
+ */
+struct NAExportFormatClassPrivate {
+ void *empty; /* so that gcc -pedantic is happy */
+};
+
+/* private instance data
+ */
+struct NAExportFormatPrivate {
+ gboolean dispose_has_run;
+ GQuark id;
+ NAExporterStr *str;
+ NAIExporter *exporter;
+};
+
+static GObjectClass *st_parent_class = NULL;
+
+static GType register_type( void );
+static void class_init( NAExportFormatClass *klass );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_dispose( GObject *object );
+static void instance_finalize( GObject *object );
+
+GType
+na_export_format_get_type( void )
+{
+ static GType object_type = 0;
+
+ if( !object_type ){
+ object_type = register_type();
+ }
+
+ return( object_type );
+}
+
+static GType
+register_type( void )
+{
+ static const gchar *thisfn = "na_export_format_register_type";
+ GType type;
+
+ static GTypeInfo info = {
+ sizeof( NAExportFormatClass ),
+ ( GBaseInitFunc ) NULL,
+ ( GBaseFinalizeFunc ) NULL,
+ ( GClassInitFunc ) class_init,
+ NULL,
+ NULL,
+ sizeof( NAExportFormat ),
+ 0,
+ ( GInstanceInitFunc ) instance_init
+ };
+
+ g_debug( "%s", thisfn );
+
+ type = g_type_register_static( G_TYPE_OBJECT, "NAExportFormat", &info, 0 );
+
+ return( type );
+}
+
+static void
+class_init( NAExportFormatClass *klass )
+{
+ static const gchar *thisfn = "na_export_format_class_init";
+ GObjectClass *object_class;
+
+ g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+ st_parent_class = g_type_class_peek_parent( klass );
+
+ object_class = G_OBJECT_CLASS( klass );
+ object_class->dispose = instance_dispose;
+ object_class->finalize = instance_finalize;
+
+ klass->private = g_new0( NAExportFormatClassPrivate, 1 );
+}
+
+static void
+instance_init( GTypeInstance *instance, gpointer klass )
+{
+ static const gchar *thisfn = "na_export_format_instance_init";
+ NAExportFormat *self;
+
+ g_debug( "%s: instance=%p (%s), klass=%p",
+ thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
+ g_return_if_fail( NA_IS_EXPORT_FORMAT( instance ));
+ self = NA_EXPORT_FORMAT( instance );
+
+ self->private = g_new0( NAExportFormatPrivate, 1 );
+
+ self->private->dispose_has_run = FALSE;
+}
+
+static void
+instance_dispose( GObject *object )
+{
+ static const gchar *thisfn = "na_export_format_instance_dispose";
+ NAExportFormat *self;
+
+ g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+ g_return_if_fail( NA_IS_EXPORT_FORMAT( object ));
+ self = NA_EXPORT_FORMAT( object );
+
+ if( !self->private->dispose_has_run ){
+
+ self->private->dispose_has_run = TRUE;
+
+ /* chain up to the parent class */
+ if( G_OBJECT_CLASS( st_parent_class )->dispose ){
+ G_OBJECT_CLASS( st_parent_class )->dispose( object );
+ }
+ }
+}
+
+static void
+instance_finalize( GObject *object )
+{
+ static const gchar *thisfn = "na_export_format_instance_finalize";
+ NAExportFormat *self;
+
+ g_debug( "%s: object=%p", thisfn, ( void * ) object );
+ g_return_if_fail( NA_IS_EXPORT_FORMAT( object ));
+ self = NA_EXPORT_FORMAT( object );
+
+ g_free( self->private );
+
+ /* chain call to parent class */
+ if( G_OBJECT_CLASS( st_parent_class )->finalize ){
+ G_OBJECT_CLASS( st_parent_class )->finalize( object );
+ }
+}
+
+/**
+ * na_export_format_new:
+ * @str: a #NAExporterStr which describes an export format.
+ * @exporter: the #NAIExporter which provides this export format.
+ *
+ * Returns: a newly allocated #NAExportFormat object.
+ */
+NAExportFormat *
+na_export_format_new( const NAExporterStr *str, const NAIExporter *exporter )
+{
+ NAExportFormat *format;
+
+ format = g_object_new( NA_EXPORT_FORMAT_TYPE, NULL );
+
+ format->private->id = g_quark_from_string( str->format );
+ format->private->str = ( NAExporterStr * ) str;
+ format->private->exporter = ( NAIExporter * ) exporter;
+
+ return( format );
+}
+
+/**
+ * na_export_format_get_quark:
+ * @format: this #NAExportFormat object.
+ *
+ * Returns: the #GQuark associated with this format.
+ */
+GQuark
+na_export_format_get_quark( const NAExportFormat *format )
+{
+ GQuark id;
+
+ g_return_val_if_fail( NA_IS_EXPORT_FORMAT( format ), 0 );
+
+ id = 0;
+
+ if( !format->private->dispose_has_run ){
+
+ id = format->private->id;
+ }
+
+ return( id );
+}
+
+/**
+ * na_export_format_get_id:
+ * @format: this #NAExportFormat object.
+ *
+ * Returns: the ASCII id of the format, as a newly allocated string which
+ * should be g_free() by the caller.
+ */
+gchar *
+na_export_format_get_id( const NAExportFormat *format )
+{
+ gchar *id;
+
+ g_return_val_if_fail( NA_IS_EXPORT_FORMAT( format ), NULL );
+
+ id = NULL;
+
+ if( !format->private->dispose_has_run ){
+
+ id = g_strdup( format->private->str->format );
+ }
+
+ return( id );
+}
+
+/**
+ * na_export_format_get_ask_label:
+ * @format: this #NAExportFormat object.
+ *
+ * Returns: the UTF-8 localizable label of the format, as a newly
+ * allocated string which should be g_free() by the caller.
+ */
+gchar *
+na_export_format_get_ask_label( const NAExportFormat *format )
+{
+ gchar *label;
+
+ g_return_val_if_fail( NA_IS_EXPORT_FORMAT( format ), NULL );
+
+ label = NULL;
+
+ if( !format->private->dispose_has_run ){
+
+ label = g_strdup( format->private->str->dlg_label );
+ }
+
+ return( label );
+}
+
+/**
+ * na_export_format_get_label:
+ * @format: this #NAExportFormat object.
+ *
+ * Returns: the UTF-8 localizable label of the format, as a newly
+ * allocated string which should be g_free() by the caller.
+ */
+gchar *
+na_export_format_get_label( const NAExportFormat *format )
+{
+ gchar *label;
+
+ g_return_val_if_fail( NA_IS_EXPORT_FORMAT( format ), NULL );
+
+ label = NULL;
+
+ if( !format->private->dispose_has_run ){
+
+ label = g_strdup( format->private->str->wnd_label );
+ }
+
+ return( label );
+}
+
+/**
+ * na_export_format_get_description:
+ * @format: this #NAExportFormat object.
+ *
+ * Returns: the UTF-8 localizable description of the format, as a newly
+ * allocated string which should be g_free() by the caller.
+ */
+gchar *
+na_export_format_get_description( const NAExportFormat *format )
+{
+ gchar *description;
+
+ g_return_val_if_fail( NA_IS_EXPORT_FORMAT( format ), NULL );
+
+ description = NULL;
+
+ if( !format->private->dispose_has_run ){
+
+ description = g_strdup( format->private->str->description );
+ }
+
+ return( description );
+}
diff --git a/src/core/na-export-format.h b/src/core/na-export-format.h
new file mode 100644
index 0000000..cfd6347
--- /dev/null
+++ b/src/core/na-export-format.h
@@ -0,0 +1,79 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __CORE_NA_EXPORT_FORMAT_H__
+#define __CORE_NA_EXPORT_FORMAT_H__
+
+/**
+ * SECTION: na_export_format
+ * @short_description: #NAExportFormat class definition.
+ * @include: core/na-export-format.h
+ */
+
+#include <api/na-iexporter.h>
+
+G_BEGIN_DECLS
+
+#define NA_EXPORT_FORMAT_TYPE ( na_export_format_get_type())
+#define NA_EXPORT_FORMAT( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_EXPORT_FORMAT_TYPE, NAExportFormat ))
+#define NA_EXPORT_FORMAT_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NA_EXPORT_FORMAT_TYPE, NAExportFormatClass ))
+#define NA_IS_EXPORT_FORMAT( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_EXPORT_FORMAT_TYPE ))
+#define NA_IS_EXPORT_FORMAT_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_EXPORT_FORMAT_TYPE ))
+#define NA_EXPORT_FORMAT_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_EXPORT_FORMAT_TYPE, NAExportFormatClass ))
+
+typedef struct NAExportFormatPrivate NAExportFormatPrivate;
+
+typedef struct {
+ GObject parent;
+ NAExportFormatPrivate *private;
+}
+ NAExportFormat;
+
+typedef struct NAExportFormatClassPrivate NAExportFormatClassPrivate;
+
+typedef struct {
+ GObjectClass parent;
+ NAExportFormatClassPrivate *private;
+}
+ NAExportFormatClass;
+
+GType na_export_format_get_type( void );
+
+NAExportFormat *na_export_format_new( const NAExporterStr *format, const NAIExporter *exporter );
+
+GQuark na_export_format_get_quark ( const NAExportFormat *format );
+gchar *na_export_format_get_id ( const NAExportFormat *format );
+gchar *na_export_format_get_ask_label ( const NAExportFormat *format );
+gchar *na_export_format_get_label ( const NAExportFormat *format );
+gchar *na_export_format_get_description( const NAExportFormat *format );
+
+G_END_DECLS
+
+#endif /* __CORE_NA_EXPORT_FORMAT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]