[epiphany/wip/modern_gobject: 26/31] EphyEncoding: Use G_DECLARE_FINAL_TYPE
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/modern_gobject: 26/31] EphyEncoding: Use G_DECLARE_FINAL_TYPE
- Date: Wed, 16 Sep 2015 02:17:48 +0000 (UTC)
commit 82c66df999ab4715a11561be3ddca83729ca0eba
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Tue Sep 15 20:41:49 2015 -0500
EphyEncoding: Use G_DECLARE_FINAL_TYPE
embed/ephy-encoding.c | 68 +++++++++++++++++++++++-------------------------
embed/ephy-encoding.h | 25 +----------------
2 files changed, 35 insertions(+), 58 deletions(-)
---
diff --git a/embed/ephy-encoding.c b/embed/ephy-encoding.c
index 0319bc9..2268a50 100644
--- a/embed/ephy-encoding.c
+++ b/embed/ephy-encoding.c
@@ -23,10 +23,6 @@
#include <string.h>
-G_DEFINE_TYPE (EphyEncoding, ephy_encoding, G_TYPE_OBJECT)
-
-#define EPHY_ENCODING_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ENCODING,
EphyEncodingPrivate))
-
enum {
PROP_0,
@@ -37,7 +33,10 @@ enum {
PROP_LANGUAGE_GROUPS
};
-struct _EphyEncodingPrivate {
+struct _EphyEncoding
+{
+ GObject parent_instance;
+
char *title;
char *title_elided;
char *collation_key;
@@ -45,15 +44,17 @@ struct _EphyEncodingPrivate {
int language_groups;
};
+G_DEFINE_TYPE (EphyEncoding, ephy_encoding, G_TYPE_OBJECT)
+
static void
ephy_encoding_finalize (GObject *object)
{
- EphyEncodingPrivate *priv = EPHY_ENCODING (object)->priv;
+ EphyEncoding *encoding = EPHY_ENCODING (object);
- g_free (priv->title);
- g_free (priv->title_elided);
- g_free (priv->collation_key);
- g_free (priv->encoding);
+ g_free (encoding->title);
+ g_free (encoding->title_elided);
+ g_free (encoding->collation_key);
+ g_free (encoding->encoding);
G_OBJECT_CLASS (ephy_encoding_parent_class)->finalize (object);
}
@@ -64,23 +65,23 @@ ephy_encoding_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- EphyEncodingPrivate *priv = EPHY_ENCODING (object)->priv;
+ EphyEncoding *encoding = EPHY_ENCODING (object);
switch (prop_id) {
case PROP_TITLE:
- g_value_set_string (value, priv->title);
+ g_value_set_string (value, encoding->title);
break;
case PROP_TITLE_ELIDED:
- g_value_set_string (value, priv->title_elided);
+ g_value_set_string (value, encoding->title_elided);
break;
case PROP_COLLATION_KEY:
- g_value_set_string (value, priv->collation_key);
+ g_value_set_string (value, encoding->collation_key);
break;
case PROP_ENCODING:
- g_value_set_string (value, priv->encoding);
+ g_value_set_string (value, encoding->encoding);
break;
case PROP_LANGUAGE_GROUPS:
- g_value_set_int (value, priv->language_groups);
+ g_value_set_int (value, encoding->language_groups);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -120,16 +121,16 @@ ephy_encoding_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- EphyEncodingPrivate *priv = EPHY_ENCODING (object)->priv;
+ EphyEncoding *encoding = EPHY_ENCODING (object);
switch (prop_id) {
case PROP_TITLE: {
char *elided, *collate_key, *normalised;
- g_free (priv->title);
- priv->title = g_strdup (g_value_get_string (value));
+ g_free (encoding->title);
+ encoding->title = g_strdup (g_value_get_string (value));
- elided = elide_underscores (priv->title);
+ elided = elide_underscores (encoding->title);
normalised = g_utf8_normalize (elided, -1, G_NORMALIZE_DEFAULT);
collate_key = g_utf8_collate_key (normalised, -1);
@@ -145,19 +146,19 @@ ephy_encoding_set_property (GObject *object,
break;
}
case PROP_TITLE_ELIDED:
- g_free (priv->title_elided);
- priv->title_elided = g_strdup (g_value_get_string (value));
+ g_free (encoding->title_elided);
+ encoding->title_elided = g_strdup (g_value_get_string (value));
break;
case PROP_COLLATION_KEY:
- g_free (priv->collation_key);
- priv->collation_key = g_strdup (g_value_get_string (value));
+ g_free (encoding->collation_key);
+ encoding->collation_key = g_strdup (g_value_get_string (value));
break;
case PROP_ENCODING:
- g_free (priv->encoding);
- priv->encoding = g_strdup (g_value_get_string (value));
+ g_free (encoding->encoding);
+ encoding->encoding = g_strdup (g_value_get_string (value));
break;
case PROP_LANGUAGE_GROUPS:
- priv->language_groups = g_value_get_int (value);
+ encoding->language_groups = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -213,14 +214,11 @@ ephy_encoding_class_init (EphyEncodingClass *klass)
LG_NONE, LG_ALL,
LG_NONE,
G_PARAM_READWRITE | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
-
- g_type_class_add_private (gobject_class, sizeof (EphyEncodingPrivate));
}
static void
ephy_encoding_init (EphyEncoding *encoding)
{
- encoding->priv = EPHY_ENCODING_GET_PRIVATE (encoding);
}
const char *
@@ -228,7 +226,7 @@ ephy_encoding_get_title (EphyEncoding *encoding)
{
g_return_val_if_fail (EPHY_IS_ENCODING (encoding), NULL);
- return encoding->priv->title;
+ return encoding->title;
}
const char *
@@ -236,7 +234,7 @@ ephy_encoding_get_title_elided (EphyEncoding *encoding)
{
g_return_val_if_fail (EPHY_IS_ENCODING (encoding), NULL);
- return encoding->priv->title_elided;
+ return encoding->title_elided;
}
const char *
@@ -244,7 +242,7 @@ ephy_encoding_get_collation_key (EphyEncoding *encoding)
{
g_return_val_if_fail (EPHY_IS_ENCODING (encoding), NULL);
- return encoding->priv->collation_key;
+ return encoding->collation_key;
}
const char *
@@ -252,7 +250,7 @@ ephy_encoding_get_encoding (EphyEncoding *encoding)
{
g_return_val_if_fail (EPHY_IS_ENCODING (encoding), NULL);
- return encoding->priv->encoding;
+ return encoding->encoding;
}
int
@@ -260,7 +258,7 @@ ephy_encoding_get_language_groups (EphyEncoding *encoding)
{
g_return_val_if_fail (EPHY_IS_ENCODING (encoding), LG_NONE);
- return encoding->priv->language_groups;
+ return encoding->language_groups;
}
EphyEncoding *
diff --git a/embed/ephy-encoding.h b/embed/ephy-encoding.h
index bed8d05..a09989d 100644
--- a/embed/ephy-encoding.h
+++ b/embed/ephy-encoding.h
@@ -30,29 +30,9 @@
G_BEGIN_DECLS
-#define EPHY_TYPE_ENCODING (ephy_encoding_get_type ())
-#define EPHY_ENCODING(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_ENCODING, EphyEncoding))
-#define EPHY_ENCODING_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_ENCODING, EphyEncodingClass))
-#define EPHY_IS_ENCODING(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_ENCODING))
-#define EPHY_IS_ENCODING_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_ENCODING))
-#define EPHY_ENCODING_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_ENCODING, EphyEncodingClass))
+#define EPHY_TYPE_ENCODING (ephy_encoding_get_type ())
-typedef struct _EphyEncodingClass EphyEncodingClass;
-typedef struct _EphyEncoding EphyEncoding;
-typedef struct _EphyEncodingPrivate EphyEncodingPrivate;
-
-struct _EphyEncoding
-{
- GObject parent;
-
- /*< private >*/
- EphyEncodingPrivate *priv;
-};
-
-struct _EphyEncodingClass
-{
- GObjectClass parent_class;
-};
+G_DECLARE_FINAL_TYPE (EphyEncoding, ephy_encoding, EPHY, ENCODING, GObject)
typedef enum
{
@@ -81,7 +61,6 @@ typedef enum
LG_ALL = 0x3fffff,
} EphyLanguageGroup;
-GType ephy_encoding_get_type (void);
EphyEncoding * ephy_encoding_new (const char *encoding,
const char *title,
int language_groups);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]