gtkieembed r199 - in trunk: . src test



Author: hiikezoe
Date: Mon Feb  2 01:52:31 2009
New Revision: 199
URL: http://svn.gnome.org/viewvc/gtkieembed?rev=199&view=rev

Log:
2009-02-02  Hiroyuki Ikezoe  <poincare ikezoe net>

	* src/gtk-ite-embed-history-item.[ch]: Added GtkIEEmbedHistoryItem
	object to handle store URI and title.




Added:
   trunk/src/gtk-ie-embed-history-item.c
   trunk/src/gtk-ie-embed-history-item.h
   trunk/test/test-gtk-ie-embed-history-item.c
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/gtkieembed.def
   trunk/test/Makefile.am

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Mon Feb  2 01:52:31 2009
@@ -28,7 +28,8 @@
 	-export-dynamic $(no_undefined) $(LIBTOOL_EXPORT_OPTIONS)
 
 pkginclude_HEADERS =				\
-	gtk-ie-embed.h
+	gtk-ie-embed.h				\
+	gtk-ie-embed-history-item.h
 
 noinst_HEADERS =				\
 	gtk-ie-embed-private.h			\
@@ -53,7 +54,8 @@
 	ie-browser-event-dispatcher.cpp		\
 	ie-bridge.cpp				\
 	ie-utils.cpp				\
-	gtk-ie-embed.c
+	gtk-ie-embed.c				\
+	gtk-ie-embed-history-item.c
 
 libgtkieembed_la_LIBADD = 			\
 	$(GTK_LIBS)

Added: trunk/src/gtk-ie-embed-history-item.c
==============================================================================
--- (empty file)
+++ trunk/src/gtk-ie-embed-history-item.c	Mon Feb  2 01:52:31 2009
@@ -0,0 +1,189 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *  Copyright (C) 2009 Hiroyuki Ikezoe  <poincare ikezoe net>
+ *
+ *  This library is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "gtk-ie-embed-history-item.h"
+
+enum {
+    PROP_0,
+    PROP_URI,
+    PROP_TITLE
+};
+
+typedef struct _GtkIEEmbedHistoryItemPriv GtkIEEmbedHistoryItemPriv;
+struct _GtkIEEmbedHistoryItemPriv
+{
+    gchar *uri;
+    gchar *title;
+};
+
+#define GTK_IE_EMBED_HISTORY_ITEM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_IE_EMBED_HISTORY_ITEM, GtkIEEmbedHistoryItemPriv))
+
+G_DEFINE_TYPE (GtkIEEmbedHistoryItem, gtk_ie_embed_history_item, G_TYPE_OBJECT)
+
+static void   dispose              (GObject           *object);
+static void   set_property         (GObject           *object,
+                                    guint              prop_id,
+                                    const GValue      *value,
+                                    GParamSpec        *pspec);
+static void   get_property         (GObject           *object,
+                                    guint              prop_id,
+                                    GValue            *value,
+                                    GParamSpec        *pspec);
+static void
+gtk_ie_embed_history_item_class_init (GtkIEEmbedHistoryItemClass *klass)
+{
+    GObjectClass   *gobject_class = G_OBJECT_CLASS (klass);
+
+    gobject_class->dispose             = dispose;
+    gobject_class->set_property        = set_property;
+    gobject_class->get_property        = get_property;
+
+    g_object_class_install_property (
+        gobject_class,
+        PROP_URI,
+        g_param_spec_string (
+            "uri",
+            "URI",
+            "The URI address of the history item",
+            NULL,
+            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+    g_object_class_install_property (
+        gobject_class,
+        PROP_TITLE,
+        g_param_spec_string (
+            "title",
+            "Title",
+            "The title of the history item",
+            NULL,
+            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+    g_type_class_add_private (gobject_class, sizeof (GtkIEEmbedHistoryItemPriv));
+}
+
+static void
+gtk_ie_embed_history_item_init (GtkIEEmbedHistoryItem *item)
+{
+    GtkIEEmbedHistoryItemPriv *priv = GTK_IE_EMBED_HISTORY_ITEM_GET_PRIVATE (item);
+
+    priv->uri = NULL;
+    priv->title = NULL;
+}
+
+static void
+dispose (GObject *object)
+{
+    GtkIEEmbedHistoryItemPriv *priv = GTK_IE_EMBED_HISTORY_ITEM_GET_PRIVATE (object);
+
+    g_free (priv->uri);
+    g_free (priv->title);
+
+    if (G_OBJECT_CLASS (gtk_ie_embed_history_item_parent_class)->dispose)
+        G_OBJECT_CLASS (gtk_ie_embed_history_item_parent_class)->dispose (object);
+}
+
+static void
+set_property (GObject *object,
+              guint prop_id,
+              const GValue *value,
+              GParamSpec *pspec)
+{
+    switch (prop_id) {
+    case PROP_URI:
+        gtk_ie_embed_history_item_set_uri (GTK_IE_EMBED_HISTORY_ITEM (object),
+                                           g_value_get_string (value));
+        break;
+    case PROP_TITLE:
+        gtk_ie_embed_history_item_set_title (GTK_IE_EMBED_HISTORY_ITEM (object),
+                                             g_value_get_string (value));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+get_property (GObject *object,
+              guint prop_id,
+              GValue *value,
+              GParamSpec *pspec)
+{
+    GtkIEEmbedHistoryItemPriv *priv = GTK_IE_EMBED_HISTORY_ITEM_GET_PRIVATE (object);
+
+    switch (prop_id) {
+    case PROP_URI:
+        g_value_set_string (value, priv->uri);
+        break;
+    case PROP_TITLE:
+        g_value_set_string (value, priv->title);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+GtkIEEmbedHistoryItem *
+gtk_ie_embed_history_item_new (const gchar *uri, const gchar *title)
+{
+    return g_object_new (GTK_TYPE_IE_EMBED_HISTORY_ITEM,
+                         "uri", uri,
+                         "title", title,
+                         NULL);
+}
+
+const gchar *
+gtk_ie_embed_history_item_get_uri (GtkIEEmbedHistoryItem *item)
+{
+    return GTK_IE_EMBED_HISTORY_ITEM_GET_PRIVATE (item)->uri;
+}
+
+const gchar *
+gtk_ie_embed_history_item_get_title (GtkIEEmbedHistoryItem *item)
+{
+    return GTK_IE_EMBED_HISTORY_ITEM_GET_PRIVATE (item)->title;
+}
+
+void
+gtk_ie_embed_history_item_set_uri (GtkIEEmbedHistoryItem *item, const gchar *uri)
+{
+    GtkIEEmbedHistoryItemPriv *priv = GTK_IE_EMBED_HISTORY_ITEM_GET_PRIVATE (item);
+
+    g_free (priv->uri);
+
+    priv->uri = g_strdup (uri);
+}
+
+void
+gtk_ie_embed_history_item_set_title (GtkIEEmbedHistoryItem *item, const gchar *title)
+{
+    GtkIEEmbedHistoryItemPriv *priv = GTK_IE_EMBED_HISTORY_ITEM_GET_PRIVATE (item);
+
+    g_free (priv->title);
+
+    priv->title = g_strdup (title);
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/

Added: trunk/src/gtk-ie-embed-history-item.h
==============================================================================
--- (empty file)
+++ trunk/src/gtk-ie-embed-history-item.h	Mon Feb  2 01:52:31 2009
@@ -0,0 +1,67 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *  Copyright (C) 2009 Hiroyuki Ikezoe  <poincare ikezoe net>
+ *
+ *  This library is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __GTK_IE_EMBED_HISTORY_ITEM_H__
+#define __GTK_IE_EMBED_HISTORY_ITEM_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_IE_EMBED_HISTORY_ITEM            (gtk_ie_embed_history_item_get_type ())
+#define GTK_IE_EMBED_HISTORY_ITEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IE_EMBED_HISTORY_ITEM, GtkIEEmbedHistoryItem))
+#define GTK_IE_EMBED_HISTORY_ITEM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IE_EMBED_HISTORY_ITEM, GtkIEEmbedHistoryItemClass))
+#define GTK_IS_IE_EMBED_HISTORY_ITEM(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IE_EMBED_HISTORY_ITEM))
+#define GTK_IS_IE_EMBED_HISTORY_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IE_EMBED_HISTORY_ITEM))
+#define GTK_IE_EMBED_HISTORY_ITEM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_IE_EMBED_HISTORY_ITEM, GtkIEEmbedHistoryItemClass))
+
+typedef struct _GtkIEEmbedHistoryItem GtkIEEmbedHistoryItem;
+typedef struct _GtkIEEmbedHistoryItemClass GtkIEEmbedHistoryItemClass;
+
+struct _GtkIEEmbedHistoryItem
+{
+    GObject parent;
+};
+
+struct _GtkIEEmbedHistoryItemClass
+{
+    GObjectClass parent_class;
+};
+
+GType        gtk_ie_embed_history_item_get_type        (void) G_GNUC_CONST;
+
+GtkIEEmbedHistoryItem
+            *gtk_ie_embed_history_item_new             (const gchar *uri,
+                                                        const gchar *title);
+
+const gchar *gtk_ie_embed_history_item_get_uri         (GtkIEEmbedHistoryItem *item);
+void         gtk_ie_embed_history_item_set_uri         (GtkIEEmbedHistoryItem *item,
+                                                        const gchar *uri);
+const gchar *gtk_ie_embed_history_item_get_title       (GtkIEEmbedHistoryItem *item);
+void         gtk_ie_embed_history_item_set_title       (GtkIEEmbedHistoryItem *item,
+                                                        const gchar *title);
+
+G_END_DECLS
+
+#endif /* __GTK_IE_EMBED_HISTORY_ITEM_H__ */
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
+

Modified: trunk/src/gtkieembed.def
==============================================================================
--- trunk/src/gtkieembed.def	(original)
+++ trunk/src/gtkieembed.def	Mon Feb  2 01:52:31 2009
@@ -1,9 +1,6 @@
-; gtkieembed.def : DLL ‚Ì‚ƒWƒ…[ƒ‹ ƒpƒ‰ƒ[ƒ^‚𾂵‚Ü·B
-
 LIBRARY      "gtkieembed"
 
 EXPORTS
-    ; –¾Ž¦“I‚ÈGƒNƒXƒ|[ƒg‚ͱ‚±‚ÖLq‚Å«‚Ü·
     gtk_ie_embed_get_type
     gtk_ie_embed_new
     gtk_ie_embed_load_url
@@ -41,3 +38,9 @@
     gtk_ie_embed_dom_event_target_get_attribute_value
     gtk_ie_embed_dom_event_target_get_attributes
     gtk_ie_embed_dom_event_target_free
+    gtk_ie_embed_history_item_get_type
+    gtk_ie_embed_history_item_new
+    gtk_ie_embed_history_item_get_uri
+    gtk_ie_embed_history_item_get_title
+    gtk_ie_embed_history_item_set_uri
+    gtk_ie_embed_history_item_set_title

Modified: trunk/test/Makefile.am
==============================================================================
--- trunk/test/Makefile.am	(original)
+++ trunk/test/Makefile.am	Mon Feb  2 01:52:31 2009
@@ -2,8 +2,9 @@
 TESTS = run-test.sh
 TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)"
 
-noinst_LTLIBRARIES =			\
-	test-gtk-ie-embed.la		\
+noinst_LTLIBRARIES =				\
+	test-gtk-ie-embed.la			\
+	test-gtk-ie-embed-history-item.la	\
 	test-utils.la
 endif
 
@@ -30,6 +31,7 @@
 	$(GCUTTER_LIBS)
 
 test_gtk_ie_embed_la_SOURCES = test-gtk-ie-embed.c
+test_gtk_ie_embed_history_item_la_SOURCES = test-gtk-ie-embed-history-item.c
 test_utils_la_SOURCES = test-utils.c
 test_utils_la_LIBADD = $(top_builddir)/src/libgtkieembed_la-ie-utils.lo
 

Added: trunk/test/test-gtk-ie-embed-history-item.c
==============================================================================
--- (empty file)
+++ trunk/test/test-gtk-ie-embed-history-item.c	Mon Feb  2 01:52:31 2009
@@ -0,0 +1,55 @@
+#include "ie-utils.h"
+#include <gcutter.h>
+
+#include "gtk-ie-embed-history-item.h"
+
+void test_new (void);
+void test_uri (void);
+void test_title (void);
+
+static GtkIEEmbedHistoryItem *item;
+
+void
+setup (void)
+{
+    item =  NULL;
+}
+
+void
+teardown (void)
+{
+    if (item)
+        g_object_unref(item);
+}
+
+void
+test_new (void)
+{
+    item = gtk_ie_embed_history_item_new("URI", "Title");
+    cut_assert(item);
+
+    cut_assert_equal_string("URI", gtk_ie_embed_history_item_get_uri(item));
+    cut_assert_equal_string("Title", gtk_ie_embed_history_item_get_title(item));
+}
+
+void
+test_uri (void)
+{
+    cut_trace(test_new());
+
+    gtk_ie_embed_history_item_set_uri(item, "New URI");
+    cut_assert_equal_string("New URI", gtk_ie_embed_history_item_get_uri(item));
+}
+
+void
+test_title (void)
+{
+    cut_trace(test_new());
+
+    gtk_ie_embed_history_item_set_title(item, "New Title");
+    cut_assert_equal_string("New Title", gtk_ie_embed_history_item_get_title(item));
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/



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