[Pkg-privacy-commits] [nautilus-wipe] 158/224: Use helper macros to define NautilusWipe's GType
Ulrike Uhlig
u-guest at moszumanska.debian.org
Thu Jul 7 19:45:45 UTC 2016
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch master
in repository nautilus-wipe.
commit e322bb753750ae643acc26abf879f2792d833967
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Wed May 16 18:07:54 2012 +0200
Use helper macros to define NautilusWipe's GType
---
nautilus-wipe/Makefile.am | 1 +
nautilus-wipe/nautilus-wipe.c | 66 +++++++------------------
nautilus-wipe/nautilus-wipe.h | 1 +
nautilus-wipe/type-utils.h | 110 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 129 insertions(+), 49 deletions(-)
diff --git a/nautilus-wipe/Makefile.am b/nautilus-wipe/Makefile.am
index b7bdc48..a9e3188 100644
--- a/nautilus-wipe/Makefile.am
+++ b/nautilus-wipe/Makefile.am
@@ -14,6 +14,7 @@ libnautilus_wipe_la_SOURCES = nautilus-wipe.c \
fill-operation.h \
progress-dialog.c \
progress-dialog.h \
+ type-utils.h \
compat.h
libnautilus_wipe_la_CPPFLAGS = -DG_LOG_DOMAIN=\"$(PACKAGE)\" \
-DLOCALEDIR=\"$(localedir)\"
diff --git a/nautilus-wipe/nautilus-wipe.c b/nautilus-wipe/nautilus-wipe.c
index e7fd4b0..5bff93e 100644
--- a/nautilus-wipe/nautilus-wipe.c
+++ b/nautilus-wipe/nautilus-wipe.c
@@ -1,7 +1,7 @@
/*
* nautilus-wipe - a nautilus extension to wipe file(s)
*
- * Copyright (C) 2009-2011 Colomban Wendling <ban at herbesfolles.org>
+ * Copyright (C) 2009-2012 Colomban Wendling <ban at herbesfolles.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -40,19 +40,19 @@
#include "delete-operation.h"
#include "fill-operation.h"
#include "compat.h"
+#include "type-utils.h"
static GType provider_types[1];
-static GType nautilus_wipe_type = 0;
/* private prototypes */
-static void nautilus_wipe_register_type (GTypeModule *module);
-static GList *nautilus_wipe_get_file_items (NautilusMenuProvider *provider,
- GtkWidget *window,
- GList *files);
-static GList *nautilus_wipe_get_background_items (NautilusMenuProvider *provider,
- GtkWidget *window,
- NautilusFileInfo *current_folder);
+static GList *nautilus_wipe_get_file_items (NautilusMenuProvider *provider,
+ GtkWidget *window,
+ GList *files);
+static GList *nautilus_wipe_get_background_items (NautilusMenuProvider *provider,
+ GtkWidget *window,
+ NautilusFileInfo *current_folder);
+static void nautilus_wipe_menu_provider_iface_init (NautilusMenuProviderIface *iface);
/*=== Nautilus interface functions ===*/
@@ -62,8 +62,7 @@ nautilus_module_initialize (GTypeModule *module)
{
g_message ("Initializing");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- nautilus_wipe_register_type (module);
- provider_types[0] = nautilus_wipe_get_type ();
+ provider_types[0] = nautilus_wipe_register_type (module);
}
/* The next function returns the type of object Nautilus needs to create for your extension. */
@@ -99,6 +98,12 @@ nautilus_wipe_error_quark (void)
return error_quark;
}
+NAUTILUS_WIPE_DEFINE_TYPE_MODULE_WITH_CODE (NautilusWipe,
+ nautilus_wipe,
+ G_TYPE_OBJECT,
+ NAUTILUS_WIPE_TYPE_MODULE_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_MENU_PROVIDER,
+ nautilus_wipe_menu_provider_iface_init))
+
static void
nautilus_wipe_menu_provider_iface_init (NautilusMenuProviderIface *iface)
{
@@ -107,7 +112,7 @@ nautilus_wipe_menu_provider_iface_init (NautilusMenuProviderIface *iface)
}
static void
-nautilus_wipe_instance_init (NautilusWipe *self)
+nautilus_wipe_init (NautilusWipe *self)
{
/* instance initialization */
}
@@ -118,43 +123,6 @@ nautilus_wipe_class_init (NautilusWipeClass *class)
/* class initialization */
}
-GType
-nautilus_wipe_get_type (void)
-{
- return nautilus_wipe_type;
-}
-
-/* Register our type into glib */
-static void
-nautilus_wipe_register_type (GTypeModule *module)
-{
- static const GTypeInfo info = {
- sizeof (NautilusWipeClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) nautilus_wipe_class_init,
- NULL,
- NULL,
- sizeof (NautilusWipe),
- 0,
- (GInstanceInitFunc) nautilus_wipe_instance_init,
- };
- /* Nautilus Menu Provider Interface */
- static const GInterfaceInfo menu_provider_iface_info = {
- (GInterfaceInitFunc) nautilus_wipe_menu_provider_iface_init,
- NULL,
- NULL
- };
-
- nautilus_wipe_type = g_type_module_register_type (module,
- G_TYPE_OBJECT,
- "NautilusWipe",
- &info, 0);
- g_type_module_add_interface (module, nautilus_wipe_type,
- NAUTILUS_TYPE_MENU_PROVIDER,
- &menu_provider_iface_info);
-}
-
/*=== Actual extension ===*/
diff --git a/nautilus-wipe/nautilus-wipe.h b/nautilus-wipe/nautilus-wipe.h
index 14d4ab6..5ca862d 100644
--- a/nautilus-wipe/nautilus-wipe.h
+++ b/nautilus-wipe/nautilus-wipe.h
@@ -64,6 +64,7 @@ struct _NautilusWipeClass {
};
GType nautilus_wipe_get_type (void) G_GNUC_CONST;
+GType nautilus_wipe_register_type (GTypeModule *module);
GQuark nautilus_wipe_error_quark (void) G_GNUC_CONST;
void nautilus_wipe_path_list_free (GList *paths);
diff --git a/nautilus-wipe/type-utils.h b/nautilus-wipe/type-utils.h
new file mode 100644
index 0000000..6da1250
--- /dev/null
+++ b/nautilus-wipe/type-utils.h
@@ -0,0 +1,110 @@
+/*
+ * nautilus-wipe - a nautilus extension to wipe file(s)
+ *
+ * Copyright (C) 2012 Colomban Wendling <ban at herbesfolles.org>
+ *
+ * This library 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.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef NAUTILUS_WIPE_TYPE_UTILS_H
+#define NAUTILUS_WIPE_TYPE_UTILS_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+
+#define _NAUTILUS_WIPE_DEFINE_TYPE_MODULE_EXTENDED_BEGIN(TN, t_n, T_P, _f_) \
+ \
+static void t_n##_init (TN *self); \
+static void t_n##_class_init (TN##Class *klass); \
+ \
+static gpointer t_n##_parent_class = NULL; \
+static GType t_n##__GType = 0; \
+ \
+static void \
+t_n##_class_intern_init (gpointer klass) \
+{ \
+ t_n##_parent_class = g_type_class_peek_parent (klass); \
+ t_n##_class_init ((TN##Class*) klass); \
+} \
+ \
+GType \
+t_n##_get_type (void) \
+{ \
+ g_assert (t_n##__GType != 0); \
+ \
+ return t_n##__GType; \
+} \
+ \
+GType \
+t_n##_register_type (GTypeModule *nw_define_type_module_module) \
+{ \
+ static const GTypeInfo type_info = { \
+ sizeof (TN##Class), /* class size */ \
+ NULL, /* base init */ \
+ NULL, /* base finalize */ \
+ (GClassInitFunc) t_n##_class_intern_init, /* class init */ \
+ NULL, /* class finalize */ \
+ NULL, /* class data */ \
+ sizeof (TN), /* instance size */ \
+ 0, /* n perallocs */ \
+ (GInstanceInitFunc) t_n##_init, /* instance init */ \
+ NULL /* value table */ \
+ }; \
+ GType nw_define_type_module_id = 0; \
+ \
+ nw_define_type_module_id = g_type_module_register_type (nw_define_type_module_module, \
+ T_P, #TN, \
+ &type_info, _f_); \
+ t_n##__GType = nw_define_type_module_id; \
+ { /* custom code follows */
+#define _NAUTILUS_WIPE_DEFINE_TYPE_MODULE_EXTENDED_END() \
+ /* following custom code */ \
+ } \
+ return nw_define_type_module_id; \
+}
+
+#define NAUTILUS_WIPE_DEFINE_TYPE_MODULE_EXTENDED(TN, t_n, T_P, _f_, _C_) \
+ _NAUTILUS_WIPE_DEFINE_TYPE_MODULE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) \
+ { _C_; } \
+ _NAUTILUS_WIPE_DEFINE_TYPE_MODULE_EXTENDED_END ()
+
+#define NAUTILUS_WIPE_DEFINE_TYPE_MODULE_WITH_CODE(TN, t_n, T_P, _C_) \
+ _NAUTILUS_WIPE_DEFINE_TYPE_MODULE_EXTENDED_BEGIN (TN, t_n, T_P, 0) \
+ { _C_; } \
+ _NAUTILUS_WIPE_DEFINE_TYPE_MODULE_EXTENDED_END ()
+
+#define NAUTILUS_WIPE_DEFINE_TYPE_MODULE(TN, t_n, T_P) \
+ NAUTILUS_WIPE_DEFINE_TYPE_MODULE_EXTENDED (TN, t_n, T_P, 0, {})
+
+#define NAUTILUS_WIPE_TYPE_MODULE_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \
+{ \
+ static const GInterfaceInfo nw_type_module_implement_interface_info = { \
+ (GInterfaceInitFunc) iface_init, NULL, NULL \
+ }; \
+ \
+ g_type_module_add_interface (nw_define_type_module_module, \
+ nw_define_type_module_id, \
+ TYPE_IFACE, \
+ &nw_type_module_implement_interface_info); \
+}
+
+
+G_END_DECLS
+
+#endif /* guard */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/nautilus-wipe.git
More information about the Pkg-privacy-commits
mailing list