[gtranslator] Use G_DEFINE_TYPE_EXTENDED in table model
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Use G_DEFINE_TYPE_EXTENDED in table model
- Date: Tue, 1 May 2012 18:24:09 +0000 (UTC)
commit 4f6c479a6aa694e4e5be42ab301db7ed278f416d
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Tue May 1 20:23:31 2012 +0200
Use G_DEFINE_TYPE_EXTENDED in table model
src/gtr-message-table-model.c | 85 ++++++++++++-----------------------------
src/gtr-message-table-model.h | 64 +++++++++++--------------------
2 files changed, 48 insertions(+), 101 deletions(-)
---
diff --git a/src/gtr-message-table-model.c b/src/gtr-message-table-model.c
index 6419dc6..f2483f1 100644
--- a/src/gtr-message-table-model.c
+++ b/src/gtr-message-table-model.c
@@ -1,19 +1,18 @@
/*
* Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANMsgILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANMsgILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -31,16 +30,21 @@
#define G_LIST(x) ((GList *) x)
-#define TABLE_FUZZY_ICON "gtk-dialog-warning"
-#define TABLE_UNTRANSLATED_ICON "gtk-dialog-error"
-#define TABLE_TRANSLATED_ICON NULL
+#define TABLE_FUZZY_ICON "gtk-dialog-warning"
+#define TABLE_UNTRANSLATED_ICON "gtk-dialog-error"
+#define TABLE_TRANSLATED_ICON NULL
enum {
PROP_0,
PROP_CONTAINER
};
-static GObjectClass *parent_class;
+static void gtr_message_table_model_tree_model_init (GtkTreeModelIface *iface);
+
+G_DEFINE_TYPE_EXTENDED (GtrMessageTableModel, gtr_message_table_model, G_TYPE_OBJECT,
+ 0,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL,
+ gtr_message_table_model_tree_model_init))
static guint
gtr_message_table_model_get_flags (GtkTreeModel * self)
@@ -330,7 +334,8 @@ static void
gtr_message_table_model_finalize (GObject * object)
{
g_object_unref (GTR_MESSAGE_TABLE_MODEL (object)->container);
- parent_class->finalize (object);
+
+ G_OBJECT_CLASS (gtr_message_table_model_parent_class)->finalize (object);
}
static void
@@ -388,8 +393,6 @@ gtr_message_table_model_class_init (GtrMessageTableModelClass * klass)
GTR_TYPE_MESSAGE_CONTAINER,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
-
- parent_class = g_type_class_peek_parent (klass);
}
/***************************** Public funcs ***********************************/
@@ -433,8 +436,8 @@ gtr_message_table_get_message_iter (GtrMessageTableModel * model,
}
void
-gtr_message_table_model_update_row (GtrMessageTableModel *
- model, GtkTreePath * path)
+gtr_message_table_model_update_row (GtrMessageTableModel *model,
+ GtkTreePath *path)
{
GtkTreeIter iter;
@@ -442,41 +445,3 @@ gtr_message_table_model_update_row (GtrMessageTableModel *
gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
}
-
-GType
-gtr_message_table_model_get_type (void)
-{
- static GType object_type = 0;
-
- if (G_UNLIKELY (object_type == 0))
- {
- static const GTypeInfo object_info = {
- sizeof (GtrMessageTableModelClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gtr_message_table_model_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtrMessageTableModel),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gtr_message_table_model_init,
- NULL
- };
-
- static const GInterfaceInfo tree_model_info = {
- (GInterfaceInitFunc) gtr_message_table_model_tree_model_init,
- NULL,
- NULL
- };
-
- object_type = g_type_register_static (G_TYPE_OBJECT,
- "GtrMessageTableModel",
- &object_info, 0);
-
- g_type_add_interface_static (object_type, GTK_TYPE_TREE_MODEL,
- &tree_model_info);
-
- }
-
- return object_type;
-}
diff --git a/src/gtr-message-table-model.h b/src/gtr-message-table-model.h
index 000fda6..59cdc6d 100644
--- a/src/gtr-message-table-model.h
+++ b/src/gtr-message-table-model.h
@@ -1,19 +1,18 @@
/*
* Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MESSAGE_TABLE_MODEL_H__
@@ -28,22 +27,17 @@
#include "gtr-message-container.h"
G_BEGIN_DECLS
-/*
- * Type checking and casting macros
- */
+
#define GTR_TYPE_MESSAGE_TABLE_MODEL (gtr_message_table_model_get_type ())
#define GTR_MESSAGE_TABLE_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_MESSAGE_TABLE_MODEL, GtrMessageTableModel))
#define GTR_MESSAGE_TABLE_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_MESSAGE_TABLE_MODEL, GtrMessageTableModelClass))
#define GTR_IS_MESSAGE_TABLE_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_MESSAGE_TABLE_MODEL))
#define GTR_IS_MESSAGE_TABLE_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_MESSAGE_TABLE_MODEL))
#define GTR_MESSAGE_TABLE_MODEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_MESSAGE_TABLE_MODEL, GtrMessageTableModelClass))
-/* Private structure type */
-typedef struct _GtrMessageTableModelPrivate GtrMessageTableModelPrivate;
-/*
- * Main object structure
- */
-typedef struct _GtrMessageTableModel GtrMessageTableModel;
+typedef struct _GtrMessageTableModel GtrMessageTableModel;
+typedef struct _GtrMessageTableModelClass GtrMessageTableModelClass;
+typedef struct _GtrMessageTableModelPrivate GtrMessageTableModelPrivate;
struct _GtrMessageTableModel
{
@@ -53,11 +47,6 @@ struct _GtrMessageTableModel
gint stamp;
};
-/*
- * Class definition
- */
-typedef struct _GtrMessageTableModelClass GtrMessageTableModelClass;
-
struct _GtrMessageTableModelClass
{
GObjectClass parent_class;
@@ -76,23 +65,16 @@ enum _GtrMessageTableModelColumn
GTR_MESSAGE_TABLE_MODEL_N_COLUMNS
};
-/*
- * Public methods
- */
-GType
-gtr_message_table_model_get_type (void)
- G_GNUC_CONST;
+GType gtr_message_table_model_get_type (void) G_GNUC_CONST;
- GType gtr_message_table_model_register_type (GTypeModule * module);
+GtrMessageTableModel *gtr_message_table_model_new (GtrMessageContainer *container);
- GtrMessageTableModel *gtr_message_table_model_new (GtrMessageContainer * container);
+gboolean gtr_message_table_get_message_iter (GtrMessageTableModel *model,
+ GtrMsg *msg,
+ GtkTreeIter *iter);
- gboolean gtr_message_table_get_message_iter (GtrMessageTableModel * model,
- GtrMsg * msg,
- GtkTreeIter * iter);
- void
- gtr_message_table_model_update_row
- (GtrMessageTableModel * model, GtkTreePath * path);
+void gtr_message_table_model_update_row (GtrMessageTableModel *model,
+ GtkTreePath *path);
G_END_DECLS
#endif /* __MESSAGE_TABLE_MODEL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]