[file-roller] use G_DEFINE macros to define GObject types
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] use G_DEFINE macros to define GObject types
- Date: Tue, 10 Jul 2012 07:17:39 +0000 (UTC)
commit 051800a167f8e862e79c37c0dfa56a6ba5f5a10a
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jul 10 09:14:57 2012 +0200
use G_DEFINE macros to define GObject types
src/eggtreemultidnd.c | 38 ++-----
src/eggtreemultidnd.h | 6 +-
src/file-data.c | 15 +--
src/fr-archive.c | 250 +++++++++++++++++++------------------------
src/fr-command-7z.c | 88 +++++----------
src/fr-command-ace.c | 96 ++++++-----------
src/fr-command-alz.c | 97 ++++++-----------
src/fr-command-ar.c | 97 ++++++-----------
src/fr-command-arj.c | 118 +++++++-------------
src/fr-command-cfile.c | 99 ++++++-----------
src/fr-command-cpio.c | 93 +++++-----------
src/fr-command-dpkg.c | 90 +++++-----------
src/fr-command-iso.c | 109 ++++++-------------
src/fr-command-jar.c | 80 ++++----------
src/fr-command-lha.c | 97 ++++++-----------
src/fr-command-lrzip.c | 95 ++++++-----------
src/fr-command-rar.c | 103 ++++++------------
src/fr-command-rpm.c | 92 +++++-----------
src/fr-command-tar.c | 150 ++++++++++----------------
src/fr-command-unarchiver.c | 98 ++++++-----------
src/fr-command-unstuff.c | 105 +++++++------------
src/fr-command-zip.c | 109 +++++++------------
src/fr-command-zoo.c | 97 ++++++-----------
src/fr-command.c | 176 +++++++++++++------------------
src/fr-list-model.c | 66 ++++--------
src/fr-list-model.h | 14 ++--
src/fr-process.c | 113 +++++++------------
src/fr-window.c | 120 ++++++++------------
src/open-file.c | 17 +---
29 files changed, 966 insertions(+), 1762 deletions(-)
---
diff --git a/src/eggtreemultidnd.c b/src/eggtreemultidnd.c
index a8ef368..1bfe39a 100644
--- a/src/eggtreemultidnd.c
+++ b/src/eggtreemultidnd.c
@@ -49,33 +49,13 @@ typedef struct
} EggTreeMultiDndData;
-GType
-egg_tree_multi_drag_source_get_type (void)
-{
- static GType our_type = 0;
+G_DEFINE_INTERFACE (EggTreeMultiDragSource, egg_tree_multi_drag_source, 0)
- if (!our_type)
- {
- static const GTypeInfo our_info =
- {
- sizeof (EggTreeMultiDragSourceIface), /* class_size */
- NULL, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- our_type = g_type_register_static (G_TYPE_INTERFACE,
- "EggTreeMultiDragSource",
- &our_info,
- 0);
- }
- return our_type;
+static void
+egg_tree_multi_drag_source_default_init (EggTreeMultiDragSourceInterface *iface)
+{
+ /* void */
}
@@ -94,7 +74,7 @@ gboolean
egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
GList *path_list)
{
- EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
+ EggTreeMultiDragSourceInterface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
g_return_val_if_fail (EGG_IS_TREE_MULTI_DRAG_SOURCE (drag_source), FALSE);
g_return_val_if_fail (iface->row_draggable != NULL, FALSE);
@@ -124,7 +104,7 @@ gboolean
egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source,
GList *path_list)
{
- EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
+ EggTreeMultiDragSourceInterface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
g_return_val_if_fail (EGG_IS_TREE_MULTI_DRAG_SOURCE (drag_source), FALSE);
g_return_val_if_fail (iface->drag_data_delete != NULL, FALSE);
@@ -153,7 +133,7 @@ egg_tree_multi_drag_source_drag_data_get (EggTreeMultiDragSource *drag_source,
GtkSelectionData *selection_data,
GList *path_list)
{
- EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
+ EggTreeMultiDragSourceInterface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
g_return_val_if_fail (EGG_IS_TREE_MULTI_DRAG_SOURCE (drag_source), FALSE);
g_return_val_if_fail (iface->drag_data_get != NULL, FALSE);
diff --git a/src/eggtreemultidnd.h b/src/eggtreemultidnd.h
index 0e8a790..00ba1aa 100644
--- a/src/eggtreemultidnd.h
+++ b/src/eggtreemultidnd.h
@@ -27,12 +27,12 @@ G_BEGIN_DECLS
#define EGG_TYPE_TREE_MULTI_DRAG_SOURCE (egg_tree_multi_drag_source_get_type ())
#define EGG_TREE_MULTI_DRAG_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE, EggTreeMultiDragSource))
#define EGG_IS_TREE_MULTI_DRAG_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE))
-#define EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE, EggTreeMultiDragSourceIface))
+#define EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE, EggTreeMultiDragSourceInterface))
typedef struct _EggTreeMultiDragSource EggTreeMultiDragSource; /* Dummy typedef */
-typedef struct _EggTreeMultiDragSourceIface EggTreeMultiDragSourceIface;
+typedef struct _EggTreeMultiDragSourceInterface EggTreeMultiDragSourceInterface;
-struct _EggTreeMultiDragSourceIface
+struct _EggTreeMultiDragSourceInterface
{
GTypeInterface g_iface;
diff --git a/src/file-data.c b/src/file-data.c
index 5f6f0a1..57e82c5 100644
--- a/src/file-data.c
+++ b/src/file-data.c
@@ -27,6 +27,9 @@
#include "file-data.h"
+G_DEFINE_BOXED_TYPE(FileData, file_data, file_data_copy, file_data_free)
+
+
FileData *
file_data_new (void)
{
@@ -87,18 +90,6 @@ file_data_copy (FileData *src)
}
-GType
-file_data_get_type (void)
-{
- static GType type = 0;
-
- if (type == 0)
- type = g_boxed_type_register_static ("FRFileData", (GBoxedCopyFunc) file_data_copy, (GBoxedFreeFunc) file_data_free);
-
- return type;
-}
-
-
void
file_data_update_content_type (FileData *fdata)
{
diff --git a/src/fr-archive.c b/src/fr-archive.c
index f28ffe5..68bc771 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -179,49 +179,132 @@ enum {
LAST_SIGNAL
};
-static GObjectClass *parent_class;
+
static guint fr_archive_signals[LAST_SIGNAL] = { 0 };
-static void fr_archive_class_init (FrArchiveClass *class);
-static void fr_archive_init (FrArchive *archive);
-static void fr_archive_finalize (GObject *object);
+G_DEFINE_TYPE (FrArchive, fr_archive, G_TYPE_OBJECT)
+
+
+static GFile *
+get_local_copy_for_file (GFile *remote_file)
+{
+ char *temp_dir;
+ GFile *local_copy = NULL;
+
+ temp_dir = _g_path_get_temp_work_dir (NULL);
+ if (temp_dir != NULL) {
+ char *archive_name;
+ char *local_path;
+
+ archive_name = g_file_get_basename (remote_file);
+ local_path = g_build_filename (temp_dir, archive_name, NULL);
+ local_copy = g_file_new_for_path (local_path);
+
+ g_free (local_path);
+ g_free (archive_name);
+ }
+ g_free (temp_dir);
+
+ return local_copy;
+}
+
+
+static void
+fr_archive_set_uri (FrArchive *archive,
+ const char *uri)
+{
+ if ((archive->local_copy != NULL) && archive->is_remote) {
+ GFile *temp_folder;
+ GError *err = NULL;
+
+ g_file_delete (archive->local_copy, NULL, &err);
+ if (err != NULL) {
+ g_warning ("Failed to delete the local copy: %s", err->message);
+ g_clear_error (&err);
+ }
+
+ temp_folder = g_file_get_parent (archive->local_copy);
+ g_file_delete (temp_folder, NULL, &err);
+ if (err != NULL) {
+ g_warning ("Failed to delete temp folder: %s", err->message);
+ g_clear_error (&err);
+ }
+
+ g_object_unref (temp_folder);
+ }
+
+ if (archive->file != NULL) {
+ g_object_unref (archive->file);
+ archive->file = NULL;
+ }
+ if (archive->local_copy != NULL) {
+ g_object_unref (archive->local_copy);
+ archive->local_copy = NULL;
+ }
+ archive->content_type = NULL;
+
+ if (uri == NULL)
+ return;
+
+ archive->file = g_file_new_for_uri (uri);
+ archive->is_remote = ! g_file_has_uri_scheme (archive->file, "file");
+ if (archive->is_remote)
+ archive->local_copy = get_local_copy_for_file (archive->file);
+ else
+ archive->local_copy = g_file_dup (archive->file);
+}
-GType
-fr_archive_get_type (void)
+
+static void
+fr_archive_remove_temp_work_dir (FrArchive *archive)
{
- static GType type = 0;
+ if (archive->priv->temp_dir == NULL)
+ return;
+ _g_path_remove_directory (archive->priv->temp_dir);
+ g_free (archive->priv->temp_dir);
+ archive->priv->temp_dir = NULL;
+}
- if (! type) {
- static const GTypeInfo type_info = {
- sizeof (FrArchiveClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_archive_class_init,
- NULL,
- NULL,
- sizeof (FrArchive),
- 0,
- (GInstanceInitFunc) fr_archive_init
- };
- type = g_type_register_static (G_TYPE_OBJECT,
- "FrArchive",
- &type_info,
- 0);
+static void
+fr_archive_finalize (GObject *object)
+{
+ FrArchive *archive;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_ARCHIVE (object));
+
+ archive = FR_ARCHIVE (object);
+
+ fr_archive_set_uri (archive, NULL);
+ fr_archive_remove_temp_work_dir (archive);
+ if (archive->command != NULL)
+ g_object_unref (archive->command);
+ g_object_unref (archive->process);
+ if (archive->priv->dropped_items_data != NULL) {
+ dropped_items_data_free (archive->priv->dropped_items_data);
+ archive->priv->dropped_items_data = NULL;
}
+ g_free (archive->priv->temp_extraction_dir);
+ g_free (archive->priv->extraction_destination);
+ g_free (archive->priv);
+
+ /* Chain up */
- return type;
+ if (G_OBJECT_CLASS (fr_archive_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_archive_parent_class)->finalize (object);
}
static void
fr_archive_class_init (FrArchiveClass *class)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ GObjectClass *gobject_class;
- parent_class = g_type_class_peek_parent (class);
+ fr_archive_parent_class = g_type_class_peek_parent (class);
+ gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = fr_archive_finalize;
class->start = NULL;
@@ -377,117 +460,6 @@ fr_archive_new (void)
}
-static GFile *
-get_local_copy_for_file (GFile *remote_file)
-{
- char *temp_dir;
- GFile *local_copy = NULL;
-
- temp_dir = _g_path_get_temp_work_dir (NULL);
- if (temp_dir != NULL) {
- char *archive_name;
- char *local_path;
-
- archive_name = g_file_get_basename (remote_file);
- local_path = g_build_filename (temp_dir, archive_name, NULL);
- local_copy = g_file_new_for_path (local_path);
-
- g_free (local_path);
- g_free (archive_name);
- }
- g_free (temp_dir);
-
- return local_copy;
-}
-
-
-static void
-fr_archive_set_uri (FrArchive *archive,
- const char *uri)
-{
- if ((archive->local_copy != NULL) && archive->is_remote) {
- GFile *temp_folder;
- GError *err = NULL;
-
- g_file_delete (archive->local_copy, NULL, &err);
- if (err != NULL) {
- g_warning ("Failed to delete the local copy: %s", err->message);
- g_clear_error (&err);
- }
-
- temp_folder = g_file_get_parent (archive->local_copy);
- g_file_delete (temp_folder, NULL, &err);
- if (err != NULL) {
- g_warning ("Failed to delete temp folder: %s", err->message);
- g_clear_error (&err);
- }
-
- g_object_unref (temp_folder);
- }
-
- if (archive->file != NULL) {
- g_object_unref (archive->file);
- archive->file = NULL;
- }
- if (archive->local_copy != NULL) {
- g_object_unref (archive->local_copy);
- archive->local_copy = NULL;
- }
- archive->content_type = NULL;
-
- if (uri == NULL)
- return;
-
- archive->file = g_file_new_for_uri (uri);
- archive->is_remote = ! g_file_has_uri_scheme (archive->file, "file");
- if (archive->is_remote)
- archive->local_copy = get_local_copy_for_file (archive->file);
- else
- archive->local_copy = g_file_dup (archive->file);
-}
-
-
-static void
-fr_archive_remove_temp_work_dir (FrArchive *archive)
-{
- if (archive->priv->temp_dir == NULL)
- return;
- _g_path_remove_directory (archive->priv->temp_dir);
- g_free (archive->priv->temp_dir);
- archive->priv->temp_dir = NULL;
-}
-
-
-static void
-fr_archive_finalize (GObject *object)
-{
- FrArchive *archive;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_ARCHIVE (object));
-
- archive = FR_ARCHIVE (object);
-
- fr_archive_set_uri (archive, NULL);
- fr_archive_remove_temp_work_dir (archive);
- if (archive->command != NULL)
- g_object_unref (archive->command);
- g_object_unref (archive->process);
- if (archive->priv->dropped_items_data != NULL) {
- dropped_items_data_free (archive->priv->dropped_items_data);
- archive->priv->dropped_items_data = NULL;
- }
- g_free (archive->priv->temp_extraction_dir);
- g_free (archive->priv->extraction_destination);
- g_free (archive->priv);
-
- /* Chain up */
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
static const char *
get_mime_type_from_content (GFile *file)
{
diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c
index 5980ec0..f35c2b6 100644
--- a/src/fr-command-7z.c
+++ b/src/fr-command-7z.c
@@ -24,10 +24,8 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
#include <glib/gi18n.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
@@ -35,13 +33,8 @@
#include "fr-command-7z.h"
#include "rar-utils.h"
-static void fr_command_7z_class_init (FrCommand7zClass *class);
-static void fr_command_7z_init (FrCommand *afile);
-static void fr_command_7z_finalize (GObject *object);
-/* Parent Class */
-
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommand7z, fr_command_7z, FR_TYPE_COMMAND)
/* -- list -- */
@@ -622,14 +615,27 @@ fr_command_7z_get_packages (FrCommand *comm,
static void
+fr_command_7z_finalize (GObject *object)
+{
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_7Z (object));
+
+ /* Chain up */
+ if (G_OBJECT_CLASS (fr_command_7z_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_7z_parent_class)->finalize (object);
+}
+
+
+static void
fr_command_7z_class_init (FrCommand7zClass *class)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ GObjectClass *gobject_class;
FrCommandClass *afc;
- parent_class = g_type_class_peek_parent (class);
+ fr_command_7z_parent_class = g_type_class_peek_parent (class);
afc = (FrCommandClass*) class;
+ gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = fr_command_7z_finalize;
afc->list = fr_command_7z_list;
@@ -645,55 +651,17 @@ fr_command_7z_class_init (FrCommand7zClass *class)
static void
-fr_command_7z_init (FrCommand *comm)
+fr_command_7z_init (FrCommand7z *self)
{
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = TRUE;
- comm->propAddCanStoreFolders = TRUE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = TRUE;
- comm->propPassword = TRUE;
- comm->propTest = TRUE;
- comm->propListFromFile = TRUE;
-}
-
-
-static void
-fr_command_7z_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_7Z (object));
-
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
-GType
-fr_command_7z_get_type ()
-{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommand7zClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_7z_class_init,
- NULL,
- NULL,
- sizeof (FrCommand7z),
- 0,
- (GInstanceInitFunc) fr_command_7z_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommand7z",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = TRUE;
+ base->propAddCanStoreFolders = TRUE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = TRUE;
+ base->propPassword = TRUE;
+ base->propTest = TRUE;
+ base->propListFromFile = TRUE;
}
diff --git a/src/fr-command-ace.c b/src/fr-command-ace.c
index 8536623..1ddb5a8 100644
--- a/src/fr-command-ace.c
+++ b/src/fr-command-ace.c
@@ -22,23 +22,15 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-ace.h"
-static void fr_command_ace_class_init (FrCommandAceClass *class);
-static void fr_command_ace_init (FrCommand *afile);
-static void fr_command_ace_finalize (GObject *object);
-
-/* Parent Class */
-
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandAce, fr_command_ace, FR_TYPE_COMMAND)
/* -- list -- */
@@ -268,74 +260,48 @@ fr_command_ace_get_packages (FrCommand *comm,
static void
-fr_command_ace_class_init (FrCommandAceClass *class)
+fr_command_ace_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_ace_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_ACE (object));
- afc->list = fr_command_ace_list;
- afc->extract = fr_command_ace_extract;
- afc->test = fr_command_ace_test;
- afc->handle_error = fr_command_ace_handle_error;
- afc->get_mime_types = fr_command_ace_get_mime_types;
- afc->get_capabilities = fr_command_ace_get_capabilities;
- afc->get_packages = fr_command_ace_get_packages;
+ if (G_OBJECT_CLASS (fr_command_ace_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_ace_parent_class)->finalize (object);
}
static void
-fr_command_ace_init (FrCommand *comm)
+fr_command_ace_class_init (FrCommandAceClass *klass)
{
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = TRUE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = TRUE;
- comm->propPassword = FALSE;
- comm->propTest = TRUE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_ace_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_ace_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_ACE (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_ace_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_ace_list;
+ command_class->extract = fr_command_ace_extract;
+ command_class->test = fr_command_ace_test;
+ command_class->handle_error = fr_command_ace_handle_error;
+ command_class->get_mime_types = fr_command_ace_get_mime_types;
+ command_class->get_capabilities = fr_command_ace_get_capabilities;
+ command_class->get_packages = fr_command_ace_get_packages;
}
-GType
-fr_command_ace_get_type ()
+static void
+fr_command_ace_init (FrCommandAce *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandAceClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_ace_class_init,
- NULL,
- NULL,
- sizeof (FrCommandAce),
- 0,
- (GInstanceInitFunc) fr_command_ace_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandAce",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = TRUE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = TRUE;
+ base->propPassword = FALSE;
+ base->propTest = TRUE;
}
diff --git a/src/fr-command-alz.c b/src/fr-command-alz.c
index b12af0e..232cce2 100644
--- a/src/fr-command-alz.c
+++ b/src/fr-command-alz.c
@@ -23,22 +23,15 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "fr-command.h"
#include "fr-command-alz.h"
#include "glib-utils.h"
-static void fr_command_alz_class_init (FrCommandAlzClass *class);
-static void fr_command_alz_init (FrCommand *afile);
-static void fr_command_alz_finalize (GObject *object);
-
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandAlz, fr_command_alz, FR_TYPE_COMMAND)
/* -- list -- */
@@ -331,75 +324,49 @@ fr_command_alz_get_packages (FrCommand *comm,
static void
-fr_command_alz_class_init (FrCommandAlzClass *class)
+fr_command_alz_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_alz_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_ALZ (object));
- afc->list = fr_command_alz_list;
- afc->add = NULL;
- afc->delete = NULL;
- afc->extract = fr_command_alz_extract;
- afc->handle_error = fr_command_alz_handle_error;
- afc->get_mime_types = fr_command_alz_get_mime_types;
- afc->get_capabilities = fr_command_alz_get_capabilities;
- afc->get_packages = fr_command_alz_get_packages;
+ if (G_OBJECT_CLASS (fr_command_alz_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_alz_parent_class)->finalize (object);
}
static void
-fr_command_alz_init (FrCommand *comm)
+fr_command_alz_class_init (FrCommandAlzClass *klass)
{
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = TRUE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = TRUE;
- comm->propTest = FALSE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_alz_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_alz_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_ALZ (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_alz_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = (FrCommandClass*) klass;
+ command_class->list = fr_command_alz_list;
+ command_class->add = NULL;
+ command_class->delete = NULL;
+ command_class->extract = fr_command_alz_extract;
+ command_class->handle_error = fr_command_alz_handle_error;
+ command_class->get_mime_types = fr_command_alz_get_mime_types;
+ command_class->get_capabilities = fr_command_alz_get_capabilities;
+ command_class->get_packages = fr_command_alz_get_packages;
}
-GType
-fr_command_alz_get_type ()
+static void
+fr_command_alz_init (FrCommandAlz *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandAlzClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_alz_class_init,
- NULL,
- NULL,
- sizeof (FrCommandAlz),
- 0,
- (GInstanceInitFunc) fr_command_alz_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FrCommandAlz",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = TRUE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = TRUE;
+ base->propTest = FALSE;
}
diff --git a/src/fr-command-ar.c b/src/fr-command-ar.c
index 09ec9aa..2eb4e7f 100644
--- a/src/fr-command-ar.c
+++ b/src/fr-command-ar.c
@@ -29,13 +29,8 @@
#include "fr-command-ar.h"
#include "glib-utils.h"
-static void fr_command_ar_class_init (FrCommandArClass *class);
-static void fr_command_ar_init (FrCommand *afile);
-static void fr_command_ar_finalize (GObject *object);
-/* Parent Class */
-
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandAr, fr_command_ar, FR_TYPE_COMMAND)
/* -- list -- */
@@ -315,76 +310,50 @@ fr_command_ar_get_packages (FrCommand *comm,
static void
-fr_command_ar_class_init (FrCommandArClass *class)
+fr_command_ar_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_ar_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_AR (object));
- afc->list = fr_command_ar_list;
- afc->add = fr_command_ar_add;
- afc->delete = fr_command_ar_delete;
- afc->extract = fr_command_ar_extract;
- afc->handle_error = fr_command_ar_handle_error;
- afc->get_mime_types = fr_command_ar_get_mime_types;
- afc->get_capabilities = fr_command_ar_get_capabilities;
- afc->get_packages = fr_command_ar_get_packages;
+ if (G_OBJECT_CLASS (fr_command_ar_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_ar_parent_class)->finalize (object);
}
static void
-fr_command_ar_init (FrCommand *comm)
+fr_command_ar_class_init (FrCommandArClass *klass)
{
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = TRUE;
- comm->propAddCanStoreFolders = FALSE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_ar_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_ar_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_AR (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_ar_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_ar_list;
+ command_class->add = fr_command_ar_add;
+ command_class->delete = fr_command_ar_delete;
+ command_class->extract = fr_command_ar_extract;
+ command_class->handle_error = fr_command_ar_handle_error;
+ command_class->get_mime_types = fr_command_ar_get_mime_types;
+ command_class->get_capabilities = fr_command_ar_get_capabilities;
+ command_class->get_packages = fr_command_ar_get_packages;
}
-GType
-fr_command_ar_get_type ()
+static void
+fr_command_ar_init (FrCommandAr *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandArClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_ar_class_init,
- NULL,
- NULL,
- sizeof (FrCommandAr),
- 0,
- (GInstanceInitFunc) fr_command_ar_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandAr",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = TRUE;
+ base->propAddCanStoreFolders = FALSE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = FALSE;
+ base->propTest = FALSE;
}
diff --git a/src/fr-command-arj.c b/src/fr-command-arj.c
index 867ba4b..b8e68bc 100644
--- a/src/fr-command-arj.c
+++ b/src/fr-command-arj.c
@@ -22,22 +22,15 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-arj.h"
-static void fr_command_arj_class_init (FrCommandArjClass *class);
-static void fr_command_arj_init (FrCommand *afile);
-static void fr_command_arj_finalize (GObject *object);
-
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandArj, fr_command_arj, FR_TYPE_COMMAND)
/* -- list -- */
@@ -349,89 +342,60 @@ fr_command_arj_get_packages (FrCommand *comm,
static void
-fr_command_arj_class_init (FrCommandArjClass *class)
+fr_command_arj_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
+ FrCommandArj *self;
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_ARJ (object));
- gobject_class->finalize = fr_command_arj_finalize;
+ self = FR_COMMAND_ARJ (object);
+ g_regex_unref (self->filename_line_regex);
- afc->list = fr_command_arj_list;
- afc->add = fr_command_arj_add;
- afc->delete = fr_command_arj_delete;
- afc->extract = fr_command_arj_extract;
- afc->test = fr_command_arj_test;
- afc->handle_error = fr_command_arj_handle_error;
- afc->get_mime_types = fr_command_arj_get_mime_types;
- afc->get_capabilities = fr_command_arj_get_capabilities;
- afc->get_packages = fr_command_arj_get_packages;
+ if (G_OBJECT_CLASS (fr_command_arj_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_arj_parent_class)->finalize (object);
}
static void
-fr_command_arj_init (FrCommand *comm)
+fr_command_arj_class_init (FrCommandArjClass *klass)
{
- FrCommandArj *arj_comm;
-
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = TRUE;
- comm->propAddCanStoreFolders = FALSE;
- comm->propExtractCanAvoidOverwrite = TRUE;
- comm->propExtractCanSkipOlder = TRUE;
- comm->propExtractCanJunkPaths = TRUE;
- comm->propPassword = TRUE;
- comm->propTest = TRUE;
-
- arj_comm = FR_COMMAND_ARJ (comm);
- arj_comm->list_started = FALSE;
- arj_comm->fdata = FALSE;
- arj_comm->filename_line_regex = g_regex_new ("[0-9]+\\) ", G_REGEX_OPTIMIZE, 0, NULL);
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_arj_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_arj_finalize (GObject *object)
-{
- FrCommandArj *arj_comm;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_ARJ (object));
-
- arj_comm = FR_COMMAND_ARJ (object);
- g_regex_unref (arj_comm->filename_line_regex);
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_arj_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_arj_list;
+ command_class->add = fr_command_arj_add;
+ command_class->delete = fr_command_arj_delete;
+ command_class->extract = fr_command_arj_extract;
+ command_class->test = fr_command_arj_test;
+ command_class->handle_error = fr_command_arj_handle_error;
+ command_class->get_mime_types = fr_command_arj_get_mime_types;
+ command_class->get_capabilities = fr_command_arj_get_capabilities;
+ command_class->get_packages = fr_command_arj_get_packages;
}
-GType
-fr_command_arj_get_type ()
+static void
+fr_command_arj_init (FrCommandArj *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandArjClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_arj_class_init,
- NULL,
- NULL,
- sizeof (FrCommandArj),
- 0,
- (GInstanceInitFunc) fr_command_arj_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandArj",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);;
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = TRUE;
+ base->propAddCanStoreFolders = FALSE;
+ base->propExtractCanAvoidOverwrite = TRUE;
+ base->propExtractCanSkipOlder = TRUE;
+ base->propExtractCanJunkPaths = TRUE;
+ base->propPassword = TRUE;
+ base->propTest = TRUE;
+
+ self->list_started = FALSE;
+ self->fdata = FALSE;
+ self->filename_line_regex = g_regex_new ("[0-9]+\\) ", G_REGEX_OPTIMIZE, 0, NULL);
}
diff --git a/src/fr-command-cfile.c b/src/fr-command-cfile.c
index ae834e7..32812ca 100644
--- a/src/fr-command-cfile.c
+++ b/src/fr-command-cfile.c
@@ -25,9 +25,7 @@
#include <string.h>
#include <time.h>
#include <fcntl.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
@@ -35,9 +33,7 @@
#include "fr-command-cfile.h"
-/* Parent Class */
-
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandCFile, fr_command_cfile, FR_TYPE_COMMAND)
static char *
@@ -519,18 +515,6 @@ fr_command_cfile_get_capabilities (FrCommand *comm,
}
-static void
-fr_command_cfile_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_CFILE (object));
-
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
static const char *
fr_command_cfile_get_packages (FrCommand *comm,
const char *mime_type)
@@ -557,62 +541,49 @@ fr_command_cfile_get_packages (FrCommand *comm,
static void
-fr_command_cfile_class_init (FrCommandCFileClass *class)
+fr_command_cfile_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_cfile_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_CFILE (object));
- afc->list = fr_command_cfile_list;
- afc->add = fr_command_cfile_add;
- afc->delete = fr_command_cfile_delete;
- afc->extract = fr_command_cfile_extract;
- afc->get_mime_types = fr_command_cfile_get_mime_types;
- afc->get_capabilities = fr_command_cfile_get_capabilities;
- afc->get_packages = fr_command_cfile_get_packages;
+ /* Chain up */
+ if (G_OBJECT_CLASS (fr_command_cfile_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_cfile_parent_class)->finalize (object);
}
static void
-fr_command_cfile_init (FrCommand *comm)
+fr_command_cfile_class_init (FrCommandCFileClass *klass)
{
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = TRUE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+
+ fr_command_cfile_parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_cfile_finalize;
+
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_cfile_list;
+ command_class->add = fr_command_cfile_add;
+ command_class->delete = fr_command_cfile_delete;
+ command_class->extract = fr_command_cfile_extract;
+ command_class->get_mime_types = fr_command_cfile_get_mime_types;
+ command_class->get_capabilities = fr_command_cfile_get_capabilities;
+ command_class->get_packages = fr_command_cfile_get_packages;
}
-GType
-fr_command_cfile_get_type ()
+static void
+fr_command_cfile_init (FrCommandCFile *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandCFileClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_cfile_class_init,
- NULL,
- NULL,
- sizeof (FrCommandCFile),
- 0,
- (GInstanceInitFunc) fr_command_cfile_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandCFile",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = TRUE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = FALSE;
+ base->propTest = FALSE;
}
diff --git a/src/fr-command-cpio.c b/src/fr-command-cpio.c
index 21e681b..40201c7 100644
--- a/src/fr-command-cpio.c
+++ b/src/fr-command-cpio.c
@@ -23,22 +23,15 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-cpio.h"
-static void fr_command_cpio_class_init (FrCommandCpioClass *class);
-static void fr_command_cpio_init (FrCommand *afile);
-static void fr_command_cpio_finalize (GObject *object);
-
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandCpio, fr_command_cpio, FR_TYPE_COMMAND)
/* -- list -- */
@@ -255,73 +248,47 @@ fr_command_cpio_get_packages (FrCommand *comm,
static void
-fr_command_cpio_class_init (FrCommandCpioClass *class)
+fr_command_cpio_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_cpio_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_CPIO (object));
- afc->list = fr_command_cpio_list;
- afc->extract = fr_command_cpio_extract;
- afc->get_mime_types = fr_command_cpio_get_mime_types;
- afc->get_capabilities = fr_command_cpio_get_capabilities;
- afc->get_packages = fr_command_cpio_get_packages;
+ if (G_OBJECT_CLASS (fr_command_cpio_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_cpio_parent_class)->finalize (object);
}
static void
-fr_command_cpio_init (FrCommand *comm)
+fr_command_cpio_class_init (FrCommandCpioClass *class)
{
- comm->propAddCanUpdate = FALSE;
- comm->propAddCanReplace = FALSE;
- comm->propAddCanStoreFolders = FALSE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_cpio_parent_class = g_type_class_peek_parent (class);
-static void
-fr_command_cpio_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_CPIO (object));
+ gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->finalize = fr_command_cpio_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (class);
+ command_class->list = fr_command_cpio_list;
+ command_class->extract = fr_command_cpio_extract;
+ command_class->get_mime_types = fr_command_cpio_get_mime_types;
+ command_class->get_capabilities = fr_command_cpio_get_capabilities;
+ command_class->get_packages = fr_command_cpio_get_packages;
}
-GType
-fr_command_cpio_get_type ()
+static void
+fr_command_cpio_init (FrCommandCpio *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandCpioClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_cpio_class_init,
- NULL,
- NULL,
- sizeof (FrCommandCpio),
- 0,
- (GInstanceInitFunc) fr_command_cpio_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandCpio",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = FALSE;
+ base->propAddCanReplace = FALSE;
+ base->propAddCanStoreFolders = FALSE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = FALSE;
+ base->propTest = FALSE;
}
diff --git a/src/fr-command-dpkg.c b/src/fr-command-dpkg.c
index 5efcb79..309995c 100644
--- a/src/fr-command-dpkg.c
+++ b/src/fr-command-dpkg.c
@@ -23,22 +23,16 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-dpkg.h"
-static void fr_command_dpkg_class_init (FrCommandDpkgClass *class);
-static void fr_command_dpkg_init (FrCommand *afile);
-static void fr_command_dpkg_finalize (GObject *object);
-/* Parent Class */
+G_DEFINE_TYPE (FrCommandDpkg, fr_command_dpkg, FR_TYPE_COMMAND)
-static FrCommandClass *parent_class = NULL;
static void
process_metadata_line (char *line,
@@ -240,72 +234,46 @@ fr_command_dpkg_get_packages (FrCommand *comm,
static void
-fr_command_dpkg_class_init (FrCommandDpkgClass *class)
+fr_command_dpkg_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_dpkg_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_DPKG (object));
- afc->list = fr_command_dpkg_list;
- afc->extract = fr_command_dpkg_extract;
- afc->get_mime_types = fr_command_dpkg_get_mime_types;
- afc->get_capabilities = fr_command_dpkg_get_capabilities;
- afc->get_packages = fr_command_dpkg_get_packages;
+ if (G_OBJECT_CLASS (fr_command_dpkg_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_dpkg_parent_class)->finalize (object);
}
static void
-fr_command_dpkg_init (FrCommand *comm)
+fr_command_dpkg_class_init (FrCommandDpkgClass *klass)
{
- comm->propAddCanUpdate = FALSE;
- comm->propAddCanReplace = FALSE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_dpkg_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_dpkg_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_DPKG (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_dpkg_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_dpkg_list;
+ command_class->extract = fr_command_dpkg_extract;
+ command_class->get_mime_types = fr_command_dpkg_get_mime_types;
+ command_class->get_capabilities = fr_command_dpkg_get_capabilities;
+ command_class->get_packages = fr_command_dpkg_get_packages;
}
-GType
-fr_command_dpkg_get_type ()
+static void
+fr_command_dpkg_init (FrCommandDpkg *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandDpkgClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_dpkg_class_init,
- NULL,
- NULL,
- sizeof (FrCommandDpkg),
- 0,
- (GInstanceInitFunc) fr_command_dpkg_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandDpkg",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = FALSE;
+ base->propAddCanReplace = FALSE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = FALSE;
+ base->propTest = FALSE;
}
diff --git a/src/fr-command-iso.c b/src/fr-command-iso.c
index 39826ff..f925002 100644
--- a/src/fr-command-iso.c
+++ b/src/fr-command-iso.c
@@ -23,22 +23,15 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-iso.h"
-static void fr_command_iso_class_init (FrCommandIsoClass *class);
-static void fr_command_iso_init (FrCommand *afile);
-static void fr_command_iso_finalize (GObject *object);
-
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandIso, fr_command_iso, FR_TYPE_COMMAND)
static time_t
@@ -232,85 +225,55 @@ fr_command_iso_get_packages (FrCommand *comm,
static void
-fr_command_iso_class_init (FrCommandIsoClass *class)
+fr_command_iso_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
+ FrCommandIso *self;
- gobject_class->finalize = fr_command_iso_finalize;
-
- afc->list = fr_command_iso_list;
- afc->extract = fr_command_iso_extract;
- afc->get_mime_types = fr_command_iso_get_mime_types;
- afc->get_capabilities = fr_command_iso_get_capabilities;
- afc->get_packages = fr_command_iso_get_packages;
-}
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_ISO (object));
+ self = FR_COMMAND_ISO (object);
+ g_free (self->cur_path);
-static void
-fr_command_iso_init (FrCommand *comm)
-{
- FrCommandIso *comm_iso = FR_COMMAND_ISO (comm);
-
- comm_iso->cur_path = NULL;
- comm_iso->joliet = TRUE;
-
- comm->propAddCanUpdate = FALSE;
- comm->propAddCanReplace = FALSE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
- comm->propCanExtractAll = FALSE;
+ if (G_OBJECT_CLASS (fr_command_iso_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_iso_parent_class)->finalize (object);
}
static void
-fr_command_iso_finalize (GObject *object)
+fr_command_iso_class_init (FrCommandIsoClass *class)
{
- FrCommandIso *comm_iso;
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_ISO (object));
+ fr_command_iso_parent_class = g_type_class_peek_parent (class);
- comm_iso = FR_COMMAND_ISO (object);
-
- g_free (comm_iso->cur_path);
- comm_iso->cur_path = NULL;
+ gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->finalize = fr_command_iso_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (class);
+ command_class->list = fr_command_iso_list;
+ command_class->extract = fr_command_iso_extract;
+ command_class->get_mime_types = fr_command_iso_get_mime_types;
+ command_class->get_capabilities = fr_command_iso_get_capabilities;
+ command_class->get_packages = fr_command_iso_get_packages;
}
-GType
-fr_command_iso_get_type ()
+static void
+fr_command_iso_init (FrCommandIso *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandIsoClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_iso_class_init,
- NULL,
- NULL,
- sizeof (FrCommandIso),
- 0,
- (GInstanceInitFunc) fr_command_iso_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandIso",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = FALSE;
+ base->propAddCanReplace = FALSE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = FALSE;
+ base->propTest = FALSE;
+ base->propCanExtractAll = FALSE;
+
+ self->cur_path = NULL;
+ self->joliet = TRUE;
}
diff --git a/src/fr-command-jar.c b/src/fr-command-jar.c
index 50de842..f7f0ef2 100644
--- a/src/fr-command-jar.c
+++ b/src/fr-command-jar.c
@@ -23,7 +23,6 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
-
#include "file-utils.h"
#include "fr-command.h"
#include "fr-command-zip.h"
@@ -32,6 +31,9 @@
#include "java-utils.h"
+G_DEFINE_TYPE (FrCommandJar, fr_command_jar, FR_TYPE_COMMAND_ZIP)
+
+
typedef struct {
char *filename;
char *rel_path;
@@ -40,14 +42,6 @@ typedef struct {
} JarData;
-static void fr_command_jar_class_init (FrCommandJarClass *class);
-static void fr_command_jar_init (FrCommand *afile);
-static void fr_command_jar_finalize (GObject *object);
-
-
-static FrCommandClass *parent_class = NULL;
-
-
static void
fr_command_jar_add (FrCommand *comm,
const char *from_file,
@@ -118,10 +112,10 @@ fr_command_jar_add (FrCommand *comm,
}
if (zip_list != NULL)
- parent_class->add (comm, NULL, zip_list, base_dir, update, FALSE);
+ FR_COMMAND_CLASS (fr_command_jar_parent_class)->add (comm, NULL, zip_list, base_dir, update, FALSE);
if (jar_list != NULL)
- parent_class->add (comm, NULL, jar_list, tmp_dir, update, FALSE);
+ FR_COMMAND_CLASS (fr_command_jar_parent_class)->add (comm, NULL, jar_list, tmp_dir, update, FALSE);
fr_process_begin_command (proc, "rm");
fr_process_set_working_dir (proc, "/");
@@ -181,63 +175,37 @@ fr_command_jar_get_packages (FrCommand *comm,
static void
-fr_command_jar_class_init (FrCommandJarClass *class)
+fr_command_jar_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS(class);
- FrCommandClass *afc = FR_COMMAND_CLASS (class);
-
- parent_class = g_type_class_peek_parent (class);
-
- gobject_class->finalize = fr_command_jar_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_JAR (object));
- afc->add = fr_command_jar_add;
- afc->get_mime_types = fr_command_jar_get_mime_types;
- afc->get_capabilities = fr_command_jar_get_capabilities;
- afc->get_packages = fr_command_jar_get_packages;
+ if (G_OBJECT_CLASS (fr_command_jar_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_jar_parent_class)->finalize (object);
}
static void
-fr_command_jar_init (FrCommand *comm)
+fr_command_jar_class_init (FrCommandJarClass *klass)
{
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_jar_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_jar_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_JAR (object));
+ gobject_class = G_OBJECT_CLASS(klass);
+ gobject_class->finalize = fr_command_jar_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->add = fr_command_jar_add;
+ command_class->get_mime_types = fr_command_jar_get_mime_types;
+ command_class->get_capabilities = fr_command_jar_get_capabilities;
+ command_class->get_packages = fr_command_jar_get_packages;
}
-GType
-fr_command_jar_get_type ()
+static void
+fr_command_jar_init (FrCommandJar *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandJarClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_jar_class_init,
- NULL,
- NULL,
- sizeof (FrCommandJar),
- 0,
- (GInstanceInitFunc) fr_command_jar_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND_ZIP,
- "FRCommandJar",
- &type_info,
- 0);
- }
-
- return type;
+ /* void */
}
diff --git a/src/fr-command-lha.c b/src/fr-command-lha.c
index 0860065..dff2e54 100644
--- a/src/fr-command-lha.c
+++ b/src/fr-command-lha.c
@@ -22,22 +22,15 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-lha.h"
-static void fr_command_lha_class_init (FrCommandLhaClass *class);
-static void fr_command_lha_init (FrCommand *afile);
-static void fr_command_lha_finalize (GObject *object);
-
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandLha, fr_command_lha, FR_TYPE_COMMAND)
/* -- list -- */
@@ -334,75 +327,49 @@ fr_command_lha_get_packages (FrCommand *comm,
static void
-fr_command_lha_class_init (FrCommandLhaClass *class)
+fr_command_lha_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_lha_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_LHA (object));
- afc->list = fr_command_lha_list;
- afc->add = fr_command_lha_add;
- afc->delete = fr_command_lha_delete;
- afc->extract = fr_command_lha_extract;
- afc->get_mime_types = fr_command_lha_get_mime_types;
- afc->get_capabilities = fr_command_lha_get_capabilities;
- afc->get_packages = fr_command_lha_get_packages;
+ if (G_OBJECT_CLASS (fr_command_lha_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_lha_parent_class)->finalize (object);
}
static void
-fr_command_lha_init (FrCommand *comm)
+fr_command_lha_class_init (FrCommandLhaClass *klass)
{
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = TRUE;
- comm->propAddCanStoreFolders = TRUE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = TRUE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_lha_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_lha_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_LHA (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_lha_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_lha_list;
+ command_class->add = fr_command_lha_add;
+ command_class->delete = fr_command_lha_delete;
+ command_class->extract = fr_command_lha_extract;
+ command_class->get_mime_types = fr_command_lha_get_mime_types;
+ command_class->get_capabilities = fr_command_lha_get_capabilities;
+ command_class->get_packages = fr_command_lha_get_packages;
}
-GType
-fr_command_lha_get_type ()
+static void
+fr_command_lha_init (FrCommandLha *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandLhaClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_lha_class_init,
- NULL,
- NULL,
- sizeof (FrCommandLha),
- 0,
- (GInstanceInitFunc) fr_command_lha_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandLha",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = TRUE;
+ base->propAddCanStoreFolders = TRUE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = TRUE;
+ base->propPassword = FALSE;
+ base->propTest = FALSE;
}
diff --git a/src/fr-command-lrzip.c b/src/fr-command-lrzip.c
index 7cbc9c7..7eb48ce 100644
--- a/src/fr-command-lrzip.c
+++ b/src/fr-command-lrzip.c
@@ -11,22 +11,15 @@
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-lrzip.h"
-static void fr_command_lrzip_class_init (FrCommandLrzipClass *class);
-static void fr_command_lrzip_init (FrCommand *afile);
-static void fr_command_lrzip_finalize (GObject *object);
-
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandLrzip, fr_command_lrzip, FR_TYPE_COMMAND)
/* -- list -- */
@@ -197,74 +190,48 @@ fr_command_lrzip_get_packages (FrCommand *comm,
static void
-fr_command_lrzip_class_init (FrCommandLrzipClass *class)
+fr_command_lrzip_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_lrzip_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_LRZIP (object));
- afc->list = fr_command_lrzip_list;
- afc->add = fr_command_lrzip_add;
- afc->extract = fr_command_lrzip_extract;
- afc->get_mime_types = fr_command_lrzip_get_mime_types;
- afc->get_capabilities = fr_command_lrzip_get_capabilities;
- afc->get_packages = fr_command_lrzip_get_packages;
+ if (G_OBJECT_CLASS (fr_command_lrzip_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_lrzip_parent_class)->finalize (object);
}
static void
-fr_command_lrzip_init (FrCommand *comm)
+fr_command_lrzip_class_init (FrCommandLrzipClass *klass)
{
- comm->propAddCanUpdate = FALSE;
- comm->propAddCanReplace = FALSE;
- comm->propAddCanStoreFolders = FALSE;
- comm->propExtractCanAvoidOverwrite = TRUE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_lrzip_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_lrzip_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_LRZIP (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_lrzip_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_lrzip_list;
+ command_class->add = fr_command_lrzip_add;
+ command_class->extract = fr_command_lrzip_extract;
+ command_class->get_mime_types = fr_command_lrzip_get_mime_types;
+ command_class->get_capabilities = fr_command_lrzip_get_capabilities;
+ command_class->get_packages = fr_command_lrzip_get_packages;
}
-GType
-fr_command_lrzip_get_type ()
+static void
+fr_command_lrzip_init (FrCommandLrzip *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandLrzipClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_lrzip_class_init,
- NULL,
- NULL,
- sizeof (FrCommandLrzip),
- 0,
- (GInstanceInitFunc) fr_command_lrzip_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandLrzip",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = FALSE;
+ base->propAddCanReplace = FALSE;
+ base->propAddCanStoreFolders = FALSE;
+ base->propExtractCanAvoidOverwrite = TRUE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = FALSE;
+ base->propTest = FALSE;
}
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index f47448a..cd70e59 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -23,10 +23,8 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
#include <glib/gi18n.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "gio-utils.h"
@@ -36,13 +34,8 @@
#include "fr-error.h"
#include "rar-utils.h"
-static void fr_command_rar_class_init (FrCommandRarClass *class);
-static void fr_command_rar_init (FrCommand *afile);
-static void fr_command_rar_finalize (GObject *object);
-
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandRar, fr_command_rar, FR_TYPE_COMMAND)
static gboolean
@@ -637,78 +630,52 @@ fr_command_rar_get_packages (FrCommand *comm,
static void
-fr_command_rar_class_init (FrCommandRarClass *class)
+fr_command_rar_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_rar_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_RAR (object));
- afc->list = fr_command_rar_list;
- afc->add = fr_command_rar_add;
- afc->delete = fr_command_rar_delete;
- afc->extract = fr_command_rar_extract;
- afc->test = fr_command_rar_test;
- afc->handle_error = fr_command_rar_handle_error;
- afc->get_mime_types = fr_command_rar_get_mime_types;
- afc->get_capabilities = fr_command_rar_get_capabilities;
- afc->get_packages = fr_command_rar_get_packages;
+ if (G_OBJECT_CLASS (fr_command_rar_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_rar_parent_class)->finalize (object);
}
static void
-fr_command_rar_init (FrCommand *comm)
+fr_command_rar_class_init (FrCommandRarClass *klass)
{
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = TRUE;
- comm->propAddCanStoreFolders = TRUE;
- comm->propExtractCanAvoidOverwrite = TRUE;
- comm->propExtractCanSkipOlder = TRUE;
- comm->propExtractCanJunkPaths = TRUE;
- comm->propPassword = TRUE;
- comm->propTest = TRUE;
- comm->propListFromFile = TRUE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_rar_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_rar_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_RAR (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_rar_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_rar_list;
+ command_class->add = fr_command_rar_add;
+ command_class->delete = fr_command_rar_delete;
+ command_class->extract = fr_command_rar_extract;
+ command_class->test = fr_command_rar_test;
+ command_class->handle_error = fr_command_rar_handle_error;
+ command_class->get_mime_types = fr_command_rar_get_mime_types;
+ command_class->get_capabilities = fr_command_rar_get_capabilities;
+ command_class->get_packages = fr_command_rar_get_packages;
}
-GType
-fr_command_rar_get_type ()
+static void
+fr_command_rar_init (FrCommandRar *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandRarClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_rar_class_init,
- NULL,
- NULL,
- sizeof (FrCommandRar),
- 0,
- (GInstanceInitFunc) fr_command_rar_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandRar",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = TRUE;
+ base->propAddCanStoreFolders = TRUE;
+ base->propExtractCanAvoidOverwrite = TRUE;
+ base->propExtractCanSkipOlder = TRUE;
+ base->propExtractCanJunkPaths = TRUE;
+ base->propPassword = TRUE;
+ base->propTest = TRUE;
+ base->propListFromFile = TRUE;
}
diff --git a/src/fr-command-rpm.c b/src/fr-command-rpm.c
index 9a8d395..39bb3a1 100644
--- a/src/fr-command-rpm.c
+++ b/src/fr-command-rpm.c
@@ -23,22 +23,15 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-rpm.h"
-static void fr_command_rpm_class_init (FrCommandRpmClass *class);
-static void fr_command_rpm_init (FrCommand *afile);
-static void fr_command_rpm_finalize (GObject *object);
-
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandRpm, fr_command_rpm, FR_TYPE_COMMAND)
/* -- list -- */
@@ -256,72 +249,47 @@ fr_command_rpm_get_packages (FrCommand *comm,
static void
-fr_command_rpm_class_init (FrCommandRpmClass *class)
+fr_command_rpm_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_rpm_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_RPM (object));
- afc->list = fr_command_rpm_list;
- afc->extract = fr_command_rpm_extract;
- afc->get_mime_types = fr_command_rpm_get_mime_types;
- afc->get_capabilities = fr_command_rpm_get_capabilities;
- afc->get_packages = fr_command_rpm_get_packages;
+ /* Chain up */
+ if (G_OBJECT_CLASS (fr_command_rpm_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_rpm_parent_class)->finalize (object);
}
static void
-fr_command_rpm_init (FrCommand *comm)
+fr_command_rpm_class_init (FrCommandRpmClass *klass)
{
- comm->propAddCanUpdate = FALSE;
- comm->propAddCanReplace = FALSE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_rpm_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_rpm_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_RPM (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_rpm_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_rpm_list;
+ command_class->extract = fr_command_rpm_extract;
+ command_class->get_mime_types = fr_command_rpm_get_mime_types;
+ command_class->get_capabilities = fr_command_rpm_get_capabilities;
+ command_class->get_packages = fr_command_rpm_get_packages;
}
-GType
-fr_command_rpm_get_type ()
+static void
+fr_command_rpm_init (FrCommandRpm *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandRpmClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_rpm_class_init,
- NULL,
- NULL,
- sizeof (FrCommandRpm),
- 0,
- (GInstanceInitFunc) fr_command_rpm_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandRpm",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = FALSE;
+ base->propAddCanReplace = FALSE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = FALSE;
+ base->propTest = FALSE;
}
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index 27e2b17..6cc3d85 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -39,13 +39,8 @@
#define ACTIVITY_DELAY 20
-static void fr_command_tar_class_init (FrCommandTarClass *class);
-static void fr_command_tar_init (FrCommand *afile);
-static void fr_command_tar_finalize (GObject *object);
-/* Parent Class */
-
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandTar, fr_command_tar, FR_TYPE_COMMAND)
/* -- list -- */
@@ -1067,7 +1062,7 @@ fr_command_tar_set_mime_type (FrCommand *comm,
{
FrCommandTar *comm_tar = FR_COMMAND_TAR (comm);
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FR_COMMAND_CLASS (fr_command_tar_parent_class)->set_mime_type (comm, mime_type);
if (_g_mime_type_matches (mime_type, "application/x-7z-compressed-tar")) {
char *try_command[3] = { "7za", "7zr", "7z" };
@@ -1113,106 +1108,79 @@ fr_command_tar_get_packages (FrCommand *comm,
static void
-fr_command_tar_class_init (FrCommandTarClass *class)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_tar_finalize;
-
- afc->list = fr_command_tar_list;
- afc->add = fr_command_tar_add;
- afc->delete = fr_command_tar_delete;
- afc->extract = fr_command_tar_extract;
- afc->handle_error = fr_command_tar_handle_error;
- afc->get_mime_types = fr_command_tar_get_mime_types;
- afc->get_capabilities = fr_command_tar_get_capabilities;
- afc->set_mime_type = fr_command_tar_set_mime_type;
- afc->recompress = fr_command_tar_recompress;
- afc->uncompress = fr_command_tar_uncompress;
- afc->get_packages = fr_command_tar_get_packages;
-}
-
-
-static void
-fr_command_tar_init (FrCommand *comm)
-{
- FrCommandTar *comm_tar = (FrCommandTar*) comm;
-
- comm->propAddCanUpdate = FALSE;
- comm->propAddCanReplace = FALSE;
- comm->propAddCanStoreFolders = TRUE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = TRUE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
- comm->propCanDeleteNonEmptyFolders = FALSE;
- comm->propCanExtractNonEmptyFolders = FALSE;
- comm->propListFromFile = TRUE;
-
- comm_tar->msg = NULL;
- comm_tar->uncomp_filename = NULL;
-}
-
-
-static void
fr_command_tar_finalize (GObject *object)
{
- FrCommandTar *comm_tar;
+ FrCommandTar *self;
g_return_if_fail (object != NULL);
g_return_if_fail (FR_IS_COMMAND_TAR (object));
- comm_tar = FR_COMMAND_TAR (object);
+ self = FR_COMMAND_TAR (object);
- if (comm_tar->uncomp_filename != NULL) {
- g_free (comm_tar->uncomp_filename);
- comm_tar->uncomp_filename = NULL;
+ if (self->uncomp_filename != NULL) {
+ g_free (self->uncomp_filename);
+ self->uncomp_filename = NULL;
}
- if (comm_tar->msg != NULL) {
- g_free (comm_tar->msg);
- comm_tar->msg = NULL;
+ if (self->msg != NULL) {
+ g_free (self->msg);
+ self->msg = NULL;
}
- if (comm_tar->compress_command != NULL) {
- g_free (comm_tar->compress_command);
- comm_tar->compress_command = NULL;
+ if (self->compress_command != NULL) {
+ g_free (self->compress_command);
+ self->compress_command = NULL;
}
/* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ if (G_OBJECT_CLASS (fr_command_tar_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_tar_parent_class)->finalize (object);
+}
+
+
+static void
+fr_command_tar_class_init (FrCommandTarClass *klass)
+{
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+
+ fr_command_tar_parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_tar_finalize;
+
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_tar_list;
+ command_class->add = fr_command_tar_add;
+ command_class->delete = fr_command_tar_delete;
+ command_class->extract = fr_command_tar_extract;
+ command_class->handle_error = fr_command_tar_handle_error;
+ command_class->get_mime_types = fr_command_tar_get_mime_types;
+ command_class->get_capabilities = fr_command_tar_get_capabilities;
+ command_class->set_mime_type = fr_command_tar_set_mime_type;
+ command_class->recompress = fr_command_tar_recompress;
+ command_class->uncompress = fr_command_tar_uncompress;
+ command_class->get_packages = fr_command_tar_get_packages;
}
-GType
-fr_command_tar_get_type ()
+static void
+fr_command_tar_init (FrCommandTar *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandTarClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_tar_class_init,
- NULL,
- NULL,
- sizeof (FrCommandTar),
- 0,
- (GInstanceInitFunc) fr_command_tar_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandTar",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = FALSE;
+ base->propAddCanReplace = FALSE;
+ base->propAddCanStoreFolders = TRUE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = TRUE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = FALSE;
+ base->propTest = FALSE;
+ base->propCanDeleteNonEmptyFolders = FALSE;
+ base->propCanExtractNonEmptyFolders = FALSE;
+ base->propListFromFile = TRUE;
+
+ self->msg = NULL;
+ self->uncomp_filename = NULL;
}
diff --git a/src/fr-command-unarchiver.c b/src/fr-command-unarchiver.c
index 00bf3e2..0a7e97f 100644
--- a/src/fr-command-unarchiver.c
+++ b/src/fr-command-unarchiver.c
@@ -38,13 +38,8 @@
#define LSAR_SUPPORTED_FORMAT 2
#define LSAR_DATE_FORMAT "%Y-%m-%d %H:%M:%S %z"
-static void fr_command_unarchiver_class_init (FrCommandUnarchiverClass *class);
-static void fr_command_unarchiver_init (FrCommand *afile);
-static void fr_command_unarchiver_finalize (GObject *object);
-/* Parent Class */
-
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandUnarchiver, fr_command_unarchiver, FR_TYPE_COMMAND)
/* -- list -- */
@@ -280,82 +275,53 @@ fr_command_unarchiver_get_packages (FrCommand *comm,
static void
-fr_command_unarchiver_class_init (FrCommandUnarchiverClass *class)
+fr_command_unarchiver_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
+ FrCommandUnarchiver *self;
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_UNARCHIVER (object));
- gobject_class->finalize = fr_command_unarchiver_finalize;
+ self = FR_COMMAND_UNARCHIVER (object);
+ _g_object_unref (self->stream);
- afc->list = fr_command_unarchiver_list;
- afc->extract = fr_command_unarchiver_extract;
- afc->handle_error = fr_command_unarchiver_handle_error;
- afc->get_mime_types = fr_command_unarchiver_get_mime_types;
- afc->get_capabilities = fr_command_unarchiver_get_capabilities;
- afc->get_packages = fr_command_unarchiver_get_packages;
+ if (G_OBJECT_CLASS (fr_command_unarchiver_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_unarchiver_parent_class)->finalize (object);
}
static void
-fr_command_unarchiver_init (FrCommand *comm)
+fr_command_unarchiver_class_init (FrCommandUnarchiverClass *klass)
{
- FrCommandUnarchiver *unar_comm;
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
- comm->propExtractCanAvoidOverwrite = TRUE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = TRUE;
- comm->propPassword = TRUE;
- comm->propTest = FALSE;
- comm->propListFromFile = FALSE;
+ fr_command_unarchiver_parent_class = g_type_class_peek_parent (klass);
- unar_comm = FR_COMMAND_UNARCHIVER (comm);
- unar_comm->stream = NULL;
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_unarchiver_finalize;
+
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_unarchiver_list;
+ command_class->extract = fr_command_unarchiver_extract;
+ command_class->handle_error = fr_command_unarchiver_handle_error;
+ command_class->get_mime_types = fr_command_unarchiver_get_mime_types;
+ command_class->get_capabilities = fr_command_unarchiver_get_capabilities;
+ command_class->get_packages = fr_command_unarchiver_get_packages;
}
static void
-fr_command_unarchiver_finalize (GObject *object)
+fr_command_unarchiver_init (FrCommandUnarchiver *self)
{
- FrCommandUnarchiver *unar_comm;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_UNARCHIVER (object));
+ FrCommand *base = FR_COMMAND (self);;
- unar_comm = FR_COMMAND_UNARCHIVER (object);
- _g_object_unref (unar_comm->stream);
-
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
-GType
-fr_command_unarchiver_get_type ()
-{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandUnarchiverClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_unarchiver_class_init,
- NULL,
- NULL,
- sizeof (FrCommandUnarchiver),
- 0,
- (GInstanceInitFunc) fr_command_unarchiver_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FrCommandUnarchiver",
- &type_info,
- 0);
- }
+ base->propExtractCanAvoidOverwrite = TRUE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = TRUE;
+ base->propPassword = TRUE;
+ base->propTest = FALSE;
+ base->propListFromFile = FALSE;
- return type;
+ self->stream = NULL;
}
diff --git a/src/fr-command-unstuff.c b/src/fr-command-unstuff.c
index 7a461c4..f696fc6 100644
--- a/src/fr-command-unstuff.c
+++ b/src/fr-command-unstuff.c
@@ -30,13 +30,9 @@
#include "fr-command-unstuff.h"
#include "glib-utils.h"
-static void fr_command_unstuff_class_init (FrCommandUnstuffClass *class);
-static void fr_command_unstuff_init (FrCommand *afile);
-static void fr_command_unstuff_finalize (GObject *object);
-/* Parent Class */
+G_DEFINE_TYPE (FrCommandUnstuff, fr_command_unstuff, FR_TYPE_COMMAND)
-static FrCommandClass *parent_class = NULL;
/* recursive rmdir to remove the left-overs from unstuff */
static void
@@ -300,7 +296,7 @@ fr_command_unstuff_get_capabilities (FrCommand *comm,
static const char *
-fr_command_unstaff_get_packages (FrCommand *comm,
+fr_command_unstuff_get_packages (FrCommand *comm,
const char *mime_type)
{
return PACKAGES ("unstaff");
@@ -308,81 +304,56 @@ fr_command_unstaff_get_packages (FrCommand *comm,
static void
-fr_command_unstuff_class_init (FrCommandUnstuffClass *class)
+fr_command_unstuff_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
+ FrCommandUnstuff *self;
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_UNSTUFF (object));
- gobject_class->finalize = fr_command_unstuff_finalize;
-
- afc->list = fr_command_unstuff_list;
- afc->add = NULL;
- afc->delete = NULL;
- afc->extract = fr_command_unstuff_extract;
- afc->handle_error = fr_command_unstuff_handle_error;
- afc->get_mime_types = fr_command_unstuff_get_mime_types;
- afc->get_capabilities = fr_command_unstuff_get_capabilities;
- afc->get_packages = fr_command_unstaff_get_packages;
-}
+ self = FR_COMMAND_UNSTUFF (object);
+ if (self->target_dir != NULL) {
+ recursive_rmdir (self->target_dir);
+ g_free (self->target_dir);
+ }
-static void
-fr_command_unstuff_init (FrCommand *comm)
-{
- comm->propAddCanUpdate = FALSE;
- comm->propAddCanReplace = FALSE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = TRUE;
- comm->propTest = FALSE;
+ if (G_OBJECT_CLASS (fr_command_unstuff_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_unstuff_parent_class)->finalize (object);
}
static void
-fr_command_unstuff_finalize (GObject *object)
+fr_command_unstuff_class_init (FrCommandUnstuffClass *klass)
{
- FrCommandUnstuff *unstuff_comm = FR_COMMAND_UNSTUFF (object);
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_UNSTUFF (object));
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
- if (unstuff_comm->target_dir != NULL) {
- recursive_rmdir (unstuff_comm->target_dir);
- g_free (unstuff_comm->target_dir);
- }
+ fr_command_unstuff_parent_class = g_type_class_peek_parent (klass);
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_unstuff_finalize;
+
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_unstuff_list;
+ command_class->extract = fr_command_unstuff_extract;
+ command_class->handle_error = fr_command_unstuff_handle_error;
+ command_class->get_mime_types = fr_command_unstuff_get_mime_types;
+ command_class->get_capabilities = fr_command_unstuff_get_capabilities;
+ command_class->get_packages = fr_command_unstuff_get_packages;
}
-GType
-fr_command_unstuff_get_type ()
+static void
+fr_command_unstuff_init (FrCommandUnstuff *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandUnstuffClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_unstuff_class_init,
- NULL,
- NULL,
- sizeof (FrCommandUnstuff),
- 0,
- (GInstanceInitFunc) fr_command_unstuff_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandUnstuff",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = FALSE;
+ base->propAddCanReplace = FALSE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = TRUE;
+ base->propTest = FALSE;
}
diff --git a/src/fr-command-zip.c b/src/fr-command-zip.c
index a929f2d..189aff4 100644
--- a/src/fr-command-zip.c
+++ b/src/fr-command-zip.c
@@ -23,25 +23,18 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-zip.h"
-#define EMPTY_ARCHIVE_WARNING "Empty zipfile."
-#define ZIP_SPECIAL_CHARACTERS "[]*?!^-\\"
-
-static void fr_command_zip_class_init (FrCommandZipClass *class);
-static void fr_command_zip_init (FrCommand *afile);
-static void fr_command_zip_finalize (GObject *object);
+#define EMPTY_ARCHIVE_WARNING "Empty zipfile."
+#define ZIP_SPECIAL_CHARACTERS "[]*?!^-\\"
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandZip, fr_command_zip, FR_TYPE_COMMAND)
/* -- list -- */
@@ -423,79 +416,53 @@ fr_command_zip_get_packages (FrCommand *comm,
static void
-fr_command_zip_class_init (FrCommandZipClass *class)
+fr_command_zip_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_zip_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_ZIP (object));
- afc->list = fr_command_zip_list;
- afc->add = fr_command_zip_add;
- afc->delete = fr_command_zip_delete;
- afc->extract = fr_command_zip_extract;
- afc->test = fr_command_zip_test;
- afc->handle_error = fr_command_zip_handle_error;
- afc->get_mime_types = fr_command_zip_get_mime_types;
- afc->get_capabilities = fr_command_zip_get_capabilities;
- afc->get_packages = fr_command_zip_get_packages;
+ if (G_OBJECT_CLASS (fr_command_zip_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_zip_parent_class)->finalize (object);
}
static void
-fr_command_zip_init (FrCommand *comm)
+fr_command_zip_class_init (FrCommandZipClass *klass)
{
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = TRUE;
- comm->propAddCanStoreFolders = TRUE;
- comm->propExtractCanAvoidOverwrite = TRUE;
- comm->propExtractCanSkipOlder = TRUE;
- comm->propExtractCanJunkPaths = TRUE;
- comm->propPassword = TRUE;
- comm->propTest = TRUE;
-
- FR_COMMAND_ZIP (comm)->is_empty = FALSE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_zip_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_zip_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_ZIP (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_zip_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_zip_list;
+ command_class->add = fr_command_zip_add;
+ command_class->delete = fr_command_zip_delete;
+ command_class->extract = fr_command_zip_extract;
+ command_class->test = fr_command_zip_test;
+ command_class->handle_error = fr_command_zip_handle_error;
+ command_class->get_mime_types = fr_command_zip_get_mime_types;
+ command_class->get_capabilities = fr_command_zip_get_capabilities;
+ command_class->get_packages = fr_command_zip_get_packages;
}
-GType
-fr_command_zip_get_type ()
+static void
+fr_command_zip_init (FrCommandZip *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandZipClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_zip_class_init,
- NULL,
- NULL,
- sizeof (FrCommandZip),
- 0,
- (GInstanceInitFunc) fr_command_zip_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandZip",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = TRUE;
+ base->propAddCanStoreFolders = TRUE;
+ base->propExtractCanAvoidOverwrite = TRUE;
+ base->propExtractCanSkipOlder = TRUE;
+ base->propExtractCanJunkPaths = TRUE;
+ base->propPassword = TRUE;
+ base->propTest = TRUE;
+
+ self->is_empty = FALSE;
}
diff --git a/src/fr-command-zoo.c b/src/fr-command-zoo.c
index 99a4baf..955a61a 100644
--- a/src/fr-command-zoo.c
+++ b/src/fr-command-zoo.c
@@ -22,22 +22,15 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <glib.h>
-
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
#include "fr-command.h"
#include "fr-command-zoo.h"
-static void fr_command_zoo_class_init (FrCommandZooClass *class);
-static void fr_command_zoo_init (FrCommand *afile);
-static void fr_command_zoo_finalize (GObject *object);
-
-/* Parent Class */
-static FrCommandClass *parent_class = NULL;
+G_DEFINE_TYPE (FrCommandZoo, fr_command_zoo, FR_TYPE_COMMAND)
/* -- list -- */
@@ -353,75 +346,49 @@ fr_command_zoo_get_packages (FrCommand *comm,
static void
-fr_command_zoo_class_init (FrCommandZooClass *class)
+fr_command_zoo_finalize (GObject *object)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- FrCommandClass *afc;
-
- parent_class = g_type_class_peek_parent (class);
- afc = (FrCommandClass*) class;
-
- gobject_class->finalize = fr_command_zoo_finalize;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND_ZOO (object));
- afc->list = fr_command_zoo_list;
- afc->add = fr_command_zoo_add;
- afc->delete = fr_command_zoo_delete;
- afc->extract = fr_command_zoo_extract;
- afc->test = fr_command_zoo_test;
- afc->get_mime_types = fr_command_zoo_get_mime_types;
- afc->get_capabilities = fr_command_zoo_get_capabilities;
- afc->get_packages = fr_command_zoo_get_packages;
+ if (G_OBJECT_CLASS (fr_command_zoo_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_zoo_parent_class)->finalize (object);
}
static void
-fr_command_zoo_init (FrCommand *comm)
+fr_command_zoo_class_init (FrCommandZooClass *klass)
{
- comm->propAddCanUpdate = TRUE;
- comm->propAddCanReplace = FALSE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = TRUE;
-}
+ GObjectClass *gobject_class;
+ FrCommandClass *command_class;
+ fr_command_zoo_parent_class = g_type_class_peek_parent (klass);
-static void
-fr_command_zoo_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND_ZOO (object));
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = fr_command_zoo_finalize;
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ command_class = FR_COMMAND_CLASS (klass);
+ command_class->list = fr_command_zoo_list;
+ command_class->add = fr_command_zoo_add;
+ command_class->delete = fr_command_zoo_delete;
+ command_class->extract = fr_command_zoo_extract;
+ command_class->test = fr_command_zoo_test;
+ command_class->get_mime_types = fr_command_zoo_get_mime_types;
+ command_class->get_capabilities = fr_command_zoo_get_capabilities;
+ command_class->get_packages = fr_command_zoo_get_packages;
}
-GType
-fr_command_zoo_get_type ()
+static void
+fr_command_zoo_init (FrCommandZoo *self)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandZooClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_zoo_class_init,
- NULL,
- NULL,
- sizeof (FrCommandZoo),
- 0,
- (GInstanceInitFunc) fr_command_zoo_init
- };
-
- type = g_type_register_static (FR_TYPE_COMMAND,
- "FRCommandZoo",
- &type_info,
- 0);
- }
-
- return type;
+ FrCommand *base = FR_COMMAND (self);
+
+ base->propAddCanUpdate = TRUE;
+ base->propAddCanReplace = FALSE;
+ base->propExtractCanAvoidOverwrite = FALSE;
+ base->propExtractCanSkipOlder = FALSE;
+ base->propExtractCanJunkPaths = FALSE;
+ base->propPassword = FALSE;
+ base->propTest = TRUE;
}
diff --git a/src/fr-command.c b/src/fr-command.c
index 41e15e0..7baf4c3 100644
--- a/src/fr-command.c
+++ b/src/fr-command.c
@@ -35,6 +35,9 @@
#define INITIAL_SIZE 256
+G_DEFINE_TYPE (FrCommand, fr_command, G_TYPE_OBJECT)
+
+
/* Signals */
enum {
START,
@@ -57,12 +60,9 @@ enum {
PROP_VOLUME_SIZE
};
-static GObjectClass *parent_class = NULL;
+
static guint fr_command_signals[LAST_SIGNAL] = { 0 };
-static void fr_command_class_init (FrCommandClass *class);
-static void fr_command_init (FrCommand *afile);
-static void fr_command_finalize (GObject *object);
char *action_names[] = { "NONE",
"CREATING_NEW_ARCHIVE",
@@ -78,33 +78,6 @@ char *action_names[] = { "NONE",
"CREATING_ARCHIVE",
"SAVING_REMOTE_ARCHIVE" };
-GType
-fr_command_get_type ()
-{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrCommandClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_command_class_init,
- NULL,
- NULL,
- sizeof (FrCommand),
- 0,
- (GInstanceInitFunc) fr_command_init
- };
-
- type = g_type_register_static (G_TYPE_OBJECT,
- "FRCommand",
- &type_info,
- 0);
- }
-
- return type;
-}
-
static void
base_fr_command_list (FrCommand *comm)
@@ -356,42 +329,64 @@ fr_command_get_property (GObject *object,
static void
-fr_command_class_init (FrCommandClass *class)
+fr_command_finalize (GObject *object)
{
- GObjectClass *gobject_class;
+ FrCommand* comm;
- parent_class = g_type_class_peek_parent (class);
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_COMMAND (object));
- gobject_class = G_OBJECT_CLASS (class);
+ comm = FR_COMMAND (object);
+
+ g_free (comm->filename);
+ g_free (comm->e_filename);
+ g_free (comm->password);
+ if (comm->files != NULL)
+ _g_ptr_array_free_full (comm->files, (GFunc) file_data_free, NULL);
+ fr_command_set_process (comm, NULL);
+
+ /* Chain up */
+ if (G_OBJECT_CLASS (fr_command_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_command_parent_class)->finalize (object);
+}
+
+
+static void
+fr_command_class_init (FrCommandClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ fr_command_parent_class = g_type_class_peek_parent (klass);
/* virtual functions */
+ gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = fr_command_finalize;
gobject_class->set_property = fr_command_set_property;
gobject_class->get_property = fr_command_get_property;
- class->list = base_fr_command_list;
- class->add = base_fr_command_add;
- class->delete = base_fr_command_delete;
- class->extract = base_fr_command_extract;
- class->test = base_fr_command_test;
- class->uncompress = base_fr_command_uncompress;
- class->recompress = base_fr_command_recompress;
- class->handle_error = base_fr_command_handle_error;
- class->get_mime_types = base_fr_command_get_mime_types;
- class->get_capabilities = base_fr_command_get_capabilities;
- class->set_mime_type = base_fr_command_set_mime_type;
- class->get_packages = base_fr_command_get_packages;
- class->start = NULL;
- class->done = NULL;
- class->progress = NULL;
- class->message = NULL;
+ klass->list = base_fr_command_list;
+ klass->add = base_fr_command_add;
+ klass->delete = base_fr_command_delete;
+ klass->extract = base_fr_command_extract;
+ klass->test = base_fr_command_test;
+ klass->uncompress = base_fr_command_uncompress;
+ klass->recompress = base_fr_command_recompress;
+ klass->handle_error = base_fr_command_handle_error;
+ klass->get_mime_types = base_fr_command_get_mime_types;
+ klass->get_capabilities = base_fr_command_get_capabilities;
+ klass->set_mime_type = base_fr_command_set_mime_type;
+ klass->get_packages = base_fr_command_get_packages;
+ klass->start = NULL;
+ klass->done = NULL;
+ klass->progress = NULL;
+ klass->message = NULL;
/* signals */
fr_command_signals[START] =
g_signal_new ("start",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrCommandClass, start),
NULL, NULL,
@@ -400,7 +395,7 @@ fr_command_class_init (FrCommandClass *class)
1, G_TYPE_INT);
fr_command_signals[DONE] =
g_signal_new ("done",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrCommandClass, done),
NULL, NULL,
@@ -410,7 +405,7 @@ fr_command_class_init (FrCommandClass *class)
FR_TYPE_PROC_ERROR);
fr_command_signals[PROGRESS] =
g_signal_new ("progress",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrCommandClass, progress),
NULL, NULL,
@@ -419,7 +414,7 @@ fr_command_class_init (FrCommandClass *class)
G_TYPE_DOUBLE);
fr_command_signals[MESSAGE] =
g_signal_new ("message",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrCommandClass, message),
NULL, NULL,
@@ -428,7 +423,7 @@ fr_command_class_init (FrCommandClass *class)
G_TYPE_STRING);
fr_command_signals[WORKING_ARCHIVE] =
g_signal_new ("working_archive",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrCommandClass, working_archive),
NULL, NULL,
@@ -494,53 +489,30 @@ fr_command_class_init (FrCommandClass *class)
static void
-fr_command_init (FrCommand *comm)
-{
- comm->files = g_ptr_array_sized_new (INITIAL_SIZE);
-
- comm->password = NULL;
- comm->encrypt_header = FALSE;
- comm->compression = FR_COMPRESSION_NORMAL;
- comm->volume_size = 0;
- comm->filename = NULL;
- comm->e_filename = NULL;
- comm->fake_load = FALSE;
-
- comm->propAddCanUpdate = FALSE;
- comm->propAddCanReplace = FALSE;
- comm->propAddCanStoreFolders = FALSE;
- comm->propExtractCanAvoidOverwrite = FALSE;
- comm->propExtractCanSkipOlder = FALSE;
- comm->propExtractCanJunkPaths = FALSE;
- comm->propPassword = FALSE;
- comm->propTest = FALSE;
- comm->propCanExtractAll = TRUE;
- comm->propCanDeleteNonEmptyFolders = TRUE;
- comm->propCanExtractNonEmptyFolders = TRUE;
- comm->propListFromFile = FALSE;
-}
-
-
-static void
-fr_command_finalize (GObject *object)
-{
- FrCommand* comm;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_COMMAND (object));
-
- comm = FR_COMMAND (object);
-
- g_free (comm->filename);
- g_free (comm->e_filename);
- g_free (comm->password);
- if (comm->files != NULL)
- _g_ptr_array_free_full (comm->files, (GFunc) file_data_free, NULL);
- fr_command_set_process (comm, NULL);
-
- /* Chain up */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+fr_command_init (FrCommand *self)
+{
+ self->files = g_ptr_array_sized_new (INITIAL_SIZE);
+
+ self->password = NULL;
+ self->encrypt_header = FALSE;
+ self->compression = FR_COMPRESSION_NORMAL;
+ self->volume_size = 0;
+ self->filename = NULL;
+ self->e_filename = NULL;
+ self->fake_load = FALSE;
+
+ self->propAddCanUpdate = FALSE;
+ self->propAddCanReplace = FALSE;
+ self->propAddCanStoreFolders = FALSE;
+ self->propExtractCanAvoidOverwrite = FALSE;
+ self->propExtractCanSkipOlder = FALSE;
+ self->propExtractCanJunkPaths = FALSE;
+ self->propPassword = FALSE;
+ self->propTest = FALSE;
+ self->propCanExtractAll = TRUE;
+ self->propCanDeleteNonEmptyFolders = TRUE;
+ self->propCanExtractNonEmptyFolders = TRUE;
+ self->propListFromFile = FALSE;
}
diff --git a/src/fr-list-model.c b/src/fr-list-model.c
index 5462d45..d81b904 100644
--- a/src/fr-list-model.c
+++ b/src/fr-list-model.c
@@ -25,7 +25,14 @@
#include "fr-window.h"
-static GtkListStoreClass *parent_class;
+static void fr_list_model_multi_drag_source_init (EggTreeMultiDragSourceInterface *iface);
+
+
+G_DEFINE_TYPE_WITH_CODE (FrListModel,
+ fr_list_model,
+ GTK_TYPE_LIST_STORE,
+ G_IMPLEMENT_INTERFACE (EGG_TYPE_TREE_MULTI_DRAG_SOURCE,
+ fr_list_model_multi_drag_source_init))
static gboolean
@@ -95,70 +102,35 @@ fr_list_model_multi_drag_data_delete (EggTreeMultiDragSource *drag_source,
static void
fr_list_model_finalize (GObject *object)
{
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ if (G_OBJECT_CLASS (fr_list_model_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_list_model_parent_class)->finalize (object);
}
static void
-fr_list_model_init (FRListModel *model)
-{
-}
-
-
-static void
-fr_list_model_class_init (FRListModelClass *klass)
+fr_list_model_class_init (FrListModelClass *klass)
{
GObjectClass *object_class;
- object_class = (GObjectClass *)klass;
- parent_class = g_type_class_peek_parent (klass);
+ fr_list_model_parent_class = g_type_class_peek_parent (klass);
+ object_class = G_OBJECT_CLASS (klass);
object_class->finalize = fr_list_model_finalize;
}
-
static void
-fr_list_model_multi_drag_source_init (EggTreeMultiDragSourceIface *iface)
+fr_list_model_init (FrListModel *model)
{
- iface->row_draggable = fr_list_model_multi_row_draggable;
- iface->drag_data_get = fr_list_model_multi_drag_data_get;
- iface->drag_data_delete = fr_list_model_multi_drag_data_delete;
}
-GType
-fr_list_model_get_type (void)
+static void
+fr_list_model_multi_drag_source_init (EggTreeMultiDragSourceInterface *iface)
{
- static GType object_type = 0;
-
- if (object_type == 0) {
- static const GTypeInfo object_info = {
- sizeof (FRListModelClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) fr_list_model_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (FRListModel),
- 0,
- (GInstanceInitFunc) fr_list_model_init,
- };
-
- static const GInterfaceInfo multi_drag_source_info = {
- (GInterfaceInitFunc) fr_list_model_multi_drag_source_init,
- NULL,
- NULL
- };
-
- object_type = g_type_register_static (GTK_TYPE_LIST_STORE, "FRListModel", &object_info, 0);
- g_type_add_interface_static (object_type,
- EGG_TYPE_TREE_MULTI_DRAG_SOURCE,
- &multi_drag_source_info);
- }
-
- return object_type;
+ iface->row_draggable = fr_list_model_multi_row_draggable;
+ iface->drag_data_get = fr_list_model_multi_drag_data_get;
+ iface->drag_data_delete = fr_list_model_multi_drag_data_delete;
}
diff --git a/src/fr-list-model.h b/src/fr-list-model.h
index 2a98d62..b57cef4 100644
--- a/src/fr-list-model.h
+++ b/src/fr-list-model.h
@@ -25,19 +25,19 @@
#include <gtk/gtk.h>
#define FR_TYPE_LIST_MODEL (fr_list_model_get_type ())
-#define FR_LIST_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FR_TYPE_LIST_MODEL, FRListModel))
-#define FR_LIST_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FR_TYPE_LIST_MODEL, FRListModelClass))
+#define FR_LIST_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FR_TYPE_LIST_MODEL, FrListModel))
+#define FR_LIST_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FR_TYPE_LIST_MODEL, FrListModelClass))
#define FR_IS_LIST_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FR_TYPE_LIST_MODEL))
#define FR_IS_LIST_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FR_TYPE_LIST_MODEL))
-#define FR_LIST_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FR_TYPE_LIST_MODEL, FRListModelClass))
+#define FR_LIST_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FR_TYPE_LIST_MODEL, FrListModelClass))
-typedef struct FRListModel {
+typedef struct FrListModel {
GtkListStore __parent;
-} FRListModel;
+} FrListModel;
-typedef struct FRListModelClass {
+typedef struct FrListModelClass {
GtkListStoreClass __parent_class;
-} FRListModelClass;
+} FrListModelClass;
GType fr_list_model_get_type (void);
GtkListStore *fr_list_model_new (int n_columns, ...);
diff --git a/src/fr-process.c b/src/fr-process.c
index 1ed0dc7..2725e45 100644
--- a/src/fr-process.c
+++ b/src/fr-process.c
@@ -38,6 +38,10 @@
#define REFRESH_RATE 20
#define BUFFER_SIZE 16384
+
+G_DEFINE_TYPE (FrProcess, fr_process, G_TYPE_OBJECT)
+
+
enum {
START,
DONE,
@@ -45,12 +49,8 @@ enum {
LAST_SIGNAL
};
-static GObjectClass *parent_class;
-static guint fr_process_signals[LAST_SIGNAL] = { 0 };
-static void fr_process_class_init (FrProcessClass *class);
-static void fr_process_init (FrProcess *process);
-static void fr_process_finalize (GObject *object);
+static guint fr_process_signals[LAST_SIGNAL] = { 0 };
typedef struct {
@@ -230,44 +230,49 @@ struct _FrProcessPrivate {
};
-GType
-fr_process_get_type (void)
+static void fr_process_stop_priv (FrProcess *process, gboolean emit_signal);
+
+
+static void
+fr_process_finalize (GObject *object)
{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrProcessClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_process_class_init,
- NULL,
- NULL,
- sizeof (FrProcess),
- 0,
- (GInstanceInitFunc) fr_process_init
- };
-
- type = g_type_register_static (G_TYPE_OBJECT,
- "FRProcess",
- &type_info,
- 0);
- }
+ FrProcess *process;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (FR_IS_PROCESS (object));
+
+ process = FR_PROCESS (object);
+
+ fr_process_stop_priv (process, FALSE);
+ fr_process_clear (process);
+
+ g_ptr_array_free (process->priv->comm, FALSE);
+
+ fr_channel_data_free (&process->out);
+ fr_channel_data_free (&process->err);
+
+ g_clear_error (&process->error.gerror);
+ g_clear_error (&process->priv->first_error.gerror);
+ _g_string_list_free (process->priv->first_error_stdout);
+ _g_string_list_free (process->priv->first_error_stderr);
+
+ g_free (process->priv);
- return type;
+ if (G_OBJECT_CLASS (fr_process_parent_class)->finalize)
+ G_OBJECT_CLASS (fr_process_parent_class)->finalize (object);
}
static void
-fr_process_class_init (FrProcessClass *class)
+fr_process_class_init (FrProcessClass *klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ GObjectClass *gobject_class;
- parent_class = g_type_class_peek_parent (class);
+ fr_process_parent_class = g_type_class_peek_parent (klass);
fr_process_signals[START] =
g_signal_new ("start",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrProcessClass, start),
NULL, NULL,
@@ -275,7 +280,7 @@ fr_process_class_init (FrProcessClass *class)
G_TYPE_NONE, 0);
fr_process_signals[DONE] =
g_signal_new ("done",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrProcessClass, done),
NULL, NULL,
@@ -284,17 +289,18 @@ fr_process_class_init (FrProcessClass *class)
FR_TYPE_PROC_ERROR);
fr_process_signals[STICKY_ONLY] =
g_signal_new ("sticky_only",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrProcessClass, sticky_only),
NULL, NULL,
fr_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = fr_process_finalize;
- class->start = NULL;
- class->done = NULL;
+ klass->start = NULL;
+ klass->done = NULL;
}
@@ -336,41 +342,6 @@ fr_process_new (void)
}
-static void fr_process_stop_priv (FrProcess *process, gboolean emit_signal);
-
-
-static void
-fr_process_finalize (GObject *object)
-{
- FrProcess *process;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (FR_IS_PROCESS (object));
-
- process = FR_PROCESS (object);
-
- fr_process_stop_priv (process, FALSE);
- fr_process_clear (process);
-
- g_ptr_array_free (process->priv->comm, FALSE);
-
- fr_channel_data_free (&process->out);
- fr_channel_data_free (&process->err);
-
- g_clear_error (&process->error.gerror);
- g_clear_error (&process->priv->first_error.gerror);
- _g_string_list_free (process->priv->first_error_stdout);
- _g_string_list_free (process->priv->first_error_stderr);
-
- g_free (process->priv);
-
- /* Chain up */
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
void
fr_process_begin_command (FrProcess *process,
const char *arg)
diff --git a/src/fr-window.c b/src/fr-window.c
index 87df489..247eaa6 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -232,6 +232,10 @@ fr_clipboard_data_set_password (FrClipboardData *clipboard_data,
/**/
+
+G_DEFINE_TYPE (FrWindow, fr_window, GTK_TYPE_APPLICATION_WINDOW)
+
+
enum {
ARCHIVE_LOADED,
PROGRESS,
@@ -239,7 +243,6 @@ enum {
LAST_SIGNAL
};
-static GtkApplicationWindowClass *parent_class = NULL;
static guint fr_window_signals[LAST_SIGNAL] = { 0 };
struct _FrWindowPrivateData {
@@ -629,6 +632,43 @@ fr_window_free_private_data (FrWindow *window)
}
+static gboolean
+close__step2 (gpointer data)
+{
+ gtk_widget_destroy (GTK_WIDGET (data));
+ return FALSE;
+}
+
+
+void
+fr_window_close (FrWindow *window)
+{
+ if (window->priv->activity_ref > 0)
+ return;
+
+ window->priv->closing = TRUE;
+
+ if (gtk_widget_get_realized (GTK_WIDGET (window))) {
+ int width, height;
+
+ width = gtk_widget_get_allocated_width (GTK_WIDGET (window));
+ height = gtk_widget_get_allocated_height (GTK_WIDGET (window));
+ g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH, width);
+ g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT, height);
+
+ width = gtk_paned_get_position (GTK_PANED (window->priv->paned));
+ if (width > 0)
+ g_settings_set_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH, width);
+
+ width = gtk_tree_view_column_get_width (window->priv->filename_column);
+ if (width > 0)
+ g_settings_set_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH, width);
+ }
+
+ g_idle_add (close__step2, window);
+}
+
+
static void
fr_window_finalize (GObject *object)
{
@@ -664,57 +704,20 @@ fr_window_finalize (GObject *object)
}
}
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
-static gboolean
-close__step2 (gpointer data)
-{
- gtk_widget_destroy (GTK_WIDGET (data));
- return FALSE;
-}
-
-
-void
-fr_window_close (FrWindow *window)
-{
- if (window->priv->activity_ref > 0)
- return;
-
- window->priv->closing = TRUE;
-
- if (gtk_widget_get_realized (GTK_WIDGET (window))) {
- int width, height;
-
- width = gtk_widget_get_allocated_width (GTK_WIDGET (window));
- height = gtk_widget_get_allocated_height (GTK_WIDGET (window));
- g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH, width);
- g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT, height);
-
- width = gtk_paned_get_position (GTK_PANED (window->priv->paned));
- if (width > 0)
- g_settings_set_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH, width);
-
- width = gtk_tree_view_column_get_width (window->priv->filename_column);
- if (width > 0)
- g_settings_set_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH, width);
- }
-
- g_idle_add (close__step2, window);
+ G_OBJECT_CLASS (fr_window_parent_class)->finalize (object);
}
static void
-fr_window_class_init (FrWindowClass *class)
+fr_window_class_init (FrWindowClass *klass)
{
GObjectClass *gobject_class;
- parent_class = g_type_class_peek_parent (class);
+ fr_window_parent_class = g_type_class_peek_parent (klass);
fr_window_signals[ARCHIVE_LOADED] =
g_signal_new ("archive-loaded",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrWindowClass, archive_loaded),
NULL, NULL,
@@ -723,7 +726,7 @@ fr_window_class_init (FrWindowClass *class)
G_TYPE_BOOLEAN);
fr_window_signals[PROGRESS] =
g_signal_new ("progress",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrWindowClass, progress),
NULL, NULL,
@@ -733,7 +736,7 @@ fr_window_class_init (FrWindowClass *class)
G_TYPE_STRING);
fr_window_signals[READY] =
g_signal_new ("ready",
- G_TYPE_FROM_CLASS (class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FrWindowClass, ready),
NULL, NULL,
@@ -741,7 +744,7 @@ fr_window_class_init (FrWindowClass *class)
G_TYPE_NONE, 1,
G_TYPE_POINTER);
- gobject_class = (GObjectClass*) class;
+ gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = fr_window_finalize;
}
@@ -805,33 +808,6 @@ fr_window_init (FrWindow *window)
}
-GType
-fr_window_get_type (void)
-{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (FrWindowClass),
- NULL,
- NULL,
- (GClassInitFunc) fr_window_class_init,
- NULL,
- NULL,
- sizeof (FrWindow),
- 0,
- (GInstanceInitFunc) fr_window_init
- };
-
- type = g_type_register_static (GTK_TYPE_APPLICATION_WINDOW,
- "FrWindow",
- &type_info,
- 0);
- }
-
- return type;
-}
-
/* -- window history -- */
diff --git a/src/open-file.c b/src/open-file.c
index 14eb5b6..1eaf9b3 100644
--- a/src/open-file.c
+++ b/src/open-file.c
@@ -30,17 +30,17 @@ open_file_new (const char *path,
const char *temp_dir)
{
OpenFile *ofile;
-
+
ofile = g_new0 (OpenFile, 1);
ofile->path = g_strdup (path);
ofile->extracted_uri = g_filename_to_uri (extracted_path, NULL, NULL);
if (! _g_uri_query_exists (ofile->extracted_uri)) {
open_file_free (ofile);
return NULL;
- }
+ }
ofile->temp_dir = g_strdup (temp_dir);
ofile->last_modified = _g_uri_get_file_mtime (ofile->extracted_uri);
-
+
return ofile;
}
@@ -74,13 +74,4 @@ open_file_copy (OpenFile *src)
}
-GType
-open_file_get_type (void)
-{
- static GType type = 0;
-
- if (type == 0)
- type = g_boxed_type_register_static ("FROpenFile", (GBoxedCopyFunc) open_file_copy, (GBoxedFreeFunc) open_file_free);
-
- return type;
-}
+G_DEFINE_BOXED_TYPE (OpenFile, open_file, open_file_copy, open_file_free)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]