[bijiben: 1/11] noteObj : derive from a new BijiItem



commit 69904b8e22cb7c0d9b1b74fc582d3eeaf03aea5b
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Sat Apr 27 01:09:52 2013 +0200

    noteObj : derive from a new BijiItem
    
    Rather than a GObject, NoteObj is an Item
    Item will be able to allow generic getters

 src/libbiji/Makefile.am     |    2 +
 src/libbiji/biji-item.c     |   69 +++++++++++++++++++++++++++++++++++++++++++
 src/libbiji/biji-item.h     |   59 ++++++++++++++++++++++++++++++++++++
 src/libbiji/biji-note-obj.c |    2 +-
 src/libbiji/biji-note-obj.h |    6 ++-
 src/libbiji/libbiji.h       |    1 +
 6 files changed, 136 insertions(+), 3 deletions(-)
---
diff --git a/src/libbiji/Makefile.am b/src/libbiji/Makefile.am
index 868c108..f3ba8c3 100644
--- a/src/libbiji/Makefile.am
+++ b/src/libbiji/Makefile.am
@@ -11,6 +11,8 @@ libbiji_la_SOURCES =  \
        libbiji.h \
        biji-date-time.c \
        biji-date-time.h \
+       biji-item.h \
+       biji-item.c \
        biji-note-id.c \
        biji-note-id.h \
        biji-note-obj.c \
diff --git a/src/libbiji/biji-item.c b/src/libbiji/biji-item.c
new file mode 100644
index 0000000..d30a81c
--- /dev/null
+++ b/src/libbiji/biji-item.c
@@ -0,0 +1,69 @@
+/*
+ * biji-item.c
+ *
+ * Copyright 2013 Pierre-Yves Luyten <py luyten fr>
+ *
+ * Bijiben 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.
+ *
+ * bijiben 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/>.
+ */
+
+#include "biji-item.h"
+
+struct BijiItemPrivate_
+{
+  gpointer dummy;
+};
+
+static void biji_item_finalize (GObject *object);
+
+G_DEFINE_TYPE (BijiItem, biji_item, G_TYPE_OBJECT)
+
+
+static void
+biji_item_class_init (BijiItemClass *klass)
+{
+  GObjectClass *g_object_class;
+
+  g_object_class = G_OBJECT_CLASS (klass);
+
+  g_object_class->finalize = biji_item_finalize;
+
+  g_type_class_add_private ((gpointer)klass, sizeof (BijiItemPrivate));
+}
+
+
+static void
+biji_item_finalize (GObject *object)
+{
+  BijiItem *self;
+
+  g_return_if_fail (BIJI_IS_ITEM (object));
+
+  self = BIJI_ITEM (object);
+
+  G_OBJECT_CLASS (biji_item_parent_class)->finalize (object);
+}
+
+
+static void
+biji_item_init (BijiItem *self)
+{
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_ITEM, BijiItemPrivate);
+}
+
+
+GObject *
+biji_item_new (void)
+{
+  return g_object_new (BIJI_TYPE_ITEM, NULL);
+}
diff --git a/src/libbiji/biji-item.h b/src/libbiji/biji-item.h
new file mode 100644
index 0000000..682e1af
--- /dev/null
+++ b/src/libbiji/biji-item.h
@@ -0,0 +1,59 @@
+/*
+ * biji-item.h
+ *
+ * Copyright 2013 Pierre-Yves Luyten <py luyten fr>
+ *
+ * Bijiben 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.
+ *
+ * bijiben 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 BIJI_ITEM_H_
+#define BIJI_ITEM_H_ 1
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define BIJI_TYPE_ITEM             (biji_item_get_type ())
+#define BIJI_ITEM(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIJI_TYPE_ITEM, BijiItem))
+#define BIJI_ITEM_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), BIJI_TYPE_ITEM, BijiItemClass))
+#define BIJI_IS_ITEM(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIJI_TYPE_ITEM))
+#define BIJI_IS_ITEM_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), BIJI_TYPE_ITEM))
+#define BIJI_ITEM_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), BIJI_TYPE_ITEM, BijiItemClass))
+
+typedef struct BijiItem_         BijiItem;
+typedef struct BijiItemClass_    BijiItemClass;
+typedef struct BijiItemPrivate_  BijiItemPrivate;
+
+struct BijiItem_
+{
+  GObject parent;
+  /* add your public declarations here */
+  BijiItemPrivate *priv;
+};
+
+struct BijiItemClass_
+{
+  GObjectClass parent_class;
+};
+
+
+GType biji_item_get_type (void);
+
+GObject *biji_item_new (void);
+
+
+G_END_DECLS
+
+#endif /* BIJI_ITEM_H_ */
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index 32371be..bc895b0 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -84,7 +84,7 @@ static GParamSpec *properties[BIJI_OBJ_PROPERTIES] = { NULL, };
 
 #define BIJI_NOTE_OBJ_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BIJI_TYPE_NOTE_OBJ, BijiNoteObjPrivate))
 
-G_DEFINE_TYPE (BijiNoteObj, biji_note_obj, G_TYPE_OBJECT);
+G_DEFINE_TYPE (BijiNoteObj, biji_note_obj, BIJI_TYPE_ITEM);
 
 static void
 on_save_timeout (BijiNoteObj *self)
diff --git a/src/libbiji/biji-note-obj.h b/src/libbiji/biji-note-obj.h
index e773263..aa05e88 100644
--- a/src/libbiji/biji-note-obj.h
+++ b/src/libbiji/biji-note-obj.h
@@ -21,6 +21,8 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
+#include "biji-item.h"
+
 G_BEGIN_DECLS
 
 /* Available formating for biji_note_obj_editor_apply_format
@@ -51,12 +53,12 @@ typedef struct _BijiNoteObjPrivate BijiNoteObjPrivate;
 
 struct _BijiNoteObjClass
 {
-  GObjectClass parent_class;
+  BijiItemClass parent_class;
 };
 
 struct _BijiNoteObj
 {
-  GObject parent_instance;
+  BijiItem parent_instance;
   BijiNoteObjPrivate* priv ;
 };
 
diff --git a/src/libbiji/libbiji.h b/src/libbiji/libbiji.h
index 2b0432e..0d29b68 100644
--- a/src/libbiji/libbiji.h
+++ b/src/libbiji/libbiji.h
@@ -22,6 +22,7 @@
 
 #include "biji-date-time.h"
 #include "biji-marshalers.h"
+#include "biji-item.h"
 #include "biji-note-book.h"
 #include "biji-note-obj.h"
 #include "biji-string.h"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]