]> spindle.queued.net Git - midori/commitdiff
Rework MidoriWebList into KatzeList and KatzeArray
authorChristian Dywan <christian@twotoasts.de>
Mon, 25 Aug 2008 23:19:38 +0000 (01:19 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 25 Aug 2008 23:19:38 +0000 (01:19 +0200)
21 files changed:
katze/Makefile.am
katze/katze-array.c [new file with mode: 0644]
katze/katze-array.h [new file with mode: 0644]
katze/katze-item.c
katze/katze-item.h
katze/katze-list.c [new file with mode: 0644]
katze/katze-list.h [new file with mode: 0644]
katze/katze-weblist.c [deleted file]
katze/katze-weblist.h [deleted file]
katze/katze.h
midori/main.c
midori/midori-app.c
midori/midori-app.h
midori/midori-browser.c
midori/midori-searchentry.c
midori/midori-searchentry.h
midori/midori-webview.c
midori/midori-webview.h
midori/sokoke.c
midori/sokoke.h
po/POTFILES.in

index 5aa7f435255650dd6284c15857d79d93bad2eea8..1611514863f83def9aa21d5a18c177299e7bb418 100644 (file)
@@ -15,5 +15,6 @@ libkatze_la_SOURCES = \
     katze-throbber.c katze-throbber.h \
     katze-utils.c    katze-utils.h    \
     katze-item.c     katze-item.h     \
-    katze-weblist.c  katze-weblist.h  \
+    katze-list.c     katze-list.h     \
+    katze-array.c    katze-array.h    \
     katze-xbel.c     katze-xbel.h
diff --git a/katze/katze-array.c b/katze/katze-array.c
new file mode 100644 (file)
index 0000000..95f6900
--- /dev/null
@@ -0,0 +1,305 @@
+/*
+ Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
+
+ 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 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#include "katze-array.h"
+
+#include "katze-utils.h"
+
+#include <glib/gi18n.h>
+#include <string.h>
+
+/**
+ * SECTION:katze-array
+ * @short_description: A type aware item container
+ * @see_also: #KatzeArray
+ *
+ * #KatzeArray is a type aware container for items.
+ */
+
+struct _KatzeArray
+{
+    KatzeList parent_instance;
+
+    GType type;
+};
+
+struct _KatzeArrayClass
+{
+    KatzeListClass parent_class;
+};
+
+G_DEFINE_TYPE (KatzeArray, katze_array, KATZE_TYPE_LIST)
+
+static void
+katze_array_finalize (GObject* object);
+
+static void
+_katze_array_add_item (KatzeList* list,
+                       gpointer   item)
+{
+    if (katze_array_is_a ((KatzeArray*)list, G_TYPE_OBJECT))
+        g_object_ref (item);
+    KATZE_LIST_CLASS (katze_array_parent_class)->add_item (list, item);
+}
+
+static void
+_katze_array_remove_item (KatzeList* list,
+                          gpointer   item)
+{
+    KATZE_LIST_CLASS (katze_array_parent_class)->remove_item (list, item);
+    if (katze_array_is_a ((KatzeArray*)list, G_TYPE_OBJECT))
+        g_object_unref (item);
+}
+
+static void
+katze_array_class_init (KatzeArrayClass* class)
+{
+    GObjectClass* gobject_class;
+    KatzeListClass* katzelist_class;
+
+    gobject_class = G_OBJECT_CLASS (class);
+    gobject_class->finalize = katze_array_finalize;
+
+    katzelist_class = KATZE_LIST_CLASS (class);
+    katzelist_class->add_item = _katze_array_add_item;
+    katzelist_class->remove_item = _katze_array_remove_item;
+}
+
+static void
+katze_array_init (KatzeArray* array)
+{
+    array->type = G_TYPE_NONE;
+}
+
+static void
+katze_array_finalize (GObject* object)
+{
+    KatzeArray* array;
+    guint n, i;
+
+    array = KATZE_ARRAY (object);
+    if (katze_array_is_a (array, G_TYPE_OBJECT))
+    {
+        n = katze_list_get_length ((KatzeList*)array);
+        for (i = 0; i < n; i++)
+            g_object_unref (katze_list_get_nth_item ((KatzeList*)array, i));
+    }
+
+    G_OBJECT_CLASS (katze_array_parent_class)->finalize (object);
+}
+
+/**
+ * katze_array_new:
+ * @type: the expected item type
+ *
+ * Creates a new #KatzeArray for @type items.
+ *
+ * You may only add items of the given type or inherited
+ * from it to this array.
+ *
+ * The array will keep a reference on each object until
+ * it is removed from the array.
+ *
+ * Note: While you *can* (currently) use #KatzeList accessors
+ * to circumvent type safety, you are *encouraged* to use
+ * only #KatzeArray accessors, or behaviour is undefined.
+ *
+ * Return value: a new #KatzeArray
+ **/
+KatzeArray*
+katze_array_new (GType type)
+{
+    KatzeArray* array = g_object_new (KATZE_TYPE_ARRAY, NULL);
+    array->type = type;
+
+    return array;
+}
+
+/**
+ *
+ * katze_array_is_a:
+ * @array: a #KatzeArray
+ * @is_a_type: type to compare with
+ *
+ * Checks whether the array is compatible
+ * with items of the specified type.
+ *
+ * Retur value: %TRUE if @array is compatible with @is_a_type
+ **/
+gboolean
+katze_array_is_a (KatzeArray* array,
+                  GType       is_a_type)
+{
+    g_return_val_if_fail (KATZE_IS_ARRAY (array), FALSE);
+
+    return g_type_is_a (array->type, is_a_type);
+}
+
+/**
+ * katze_array_add_item:
+ * @array: a #KatzeArray
+ * @item: a #GObject
+ *
+ * Adds an item to the array.
+ **/
+void
+katze_array_add_item (KatzeArray* array,
+                      gpointer    item)
+{
+    g_return_if_fail (KATZE_IS_ARRAY (array));
+    if (katze_array_is_a (array, G_TYPE_OBJECT))
+        g_return_if_fail (katze_array_is_a (array, G_OBJECT_TYPE (item)));
+
+    g_signal_emit_by_name (array, "add-item", item);
+}
+
+/**
+ * katze_array_add_item:
+ * @array: a #KatzeArray
+ * @item: a #GObject
+ *
+ * Removes an item from the array.
+ **/
+void
+katze_array_remove_item (KatzeArray* array,
+                         gpointer    item)
+{
+    g_return_if_fail (KATZE_IS_ARRAY (array));
+    if (katze_array_is_a (array, G_TYPE_OBJECT))
+        g_return_if_fail (katze_array_is_a (array, G_OBJECT_TYPE (item)));
+
+    g_signal_emit_by_name (array, "remove-item", item);
+}
+
+/**
+ * katze_array_get_nth_item:
+ * @array: a #KatzeArray
+ * @n: an index in the array
+ *
+ * Retrieves the item in @array at the position @n.
+ *
+ * Return value: an item, or %NULL
+ **/
+gpointer
+katze_array_get_nth_item (KatzeArray* array,
+                          guint       n)
+{
+    g_return_val_if_fail (KATZE_IS_ARRAY (array), NULL);
+
+    return katze_list_get_nth_item (KATZE_LIST (array), n);
+}
+
+/**
+ * katze_array_is_empty:
+ * @array: a #KatzeArray
+ *
+ * Determines if @array is empty.
+ *
+ * Return value: an item, or %NULL
+ **/
+gboolean
+katze_array_is_empty (KatzeArray* array)
+{
+    g_return_val_if_fail (KATZE_IS_ARRAY (array), TRUE);
+
+    return katze_list_is_empty (KATZE_LIST (array));
+}
+
+/**
+ * katze_array_get_item_position:
+ * @array: a #KatzeArray
+ * @item: an item in the array
+ *
+ * Retrieves the index of the item in @array.
+ *
+ * Return value: an item, or -1
+ **/
+gint
+katze_array_get_item_index (KatzeArray* array,
+                            gpointer    item)
+{
+    g_return_val_if_fail (KATZE_IS_ARRAY (array), -1);
+    if (katze_array_is_a (array, G_TYPE_OBJECT))
+        g_return_val_if_fail (katze_array_is_a (array, G_OBJECT_TYPE (item)), -1);
+
+    return katze_list_get_item_index (KATZE_LIST (array), item);
+}
+
+/**
+ * katze_array_find_token:
+ * @array: a #KatzeArray
+ * @token: a token string
+ *
+ * Looks up an item in the array which has the specified token.
+ *
+ * This function will silently fail if the type of the list
+ * is not based on #GObject and only #KatzeItem children
+ * are checked for their token, any other objects are skipped.
+ *
+ * Note that @token is by definition unique to one item.
+ *
+ * Return value: an item, or %NULL
+ **/
+gpointer
+katze_array_find_token (KatzeArray*  array,
+                        const gchar* token)
+{
+    guint n, i;
+    gpointer item;
+    const gchar* found_token;
+
+    g_return_val_if_fail (KATZE_IS_ARRAY (array), NULL);
+
+    if (!katze_array_is_a (array, G_TYPE_OBJECT))
+        return NULL;
+
+    n = katze_list_get_length ((KatzeList*)array);
+    for (i = 0; i < n; i++)
+    {
+        item = katze_list_get_nth_item ((KatzeList*)array, i);
+        if (!g_type_is_a (G_OBJECT_TYPE (item), KATZE_TYPE_ITEM))
+            continue;
+        found_token = katze_item_get_token ((KatzeItem*)item);
+        if (found_token && !strcmp (found_token, token))
+            return item;
+    }
+    return NULL;
+}
+
+/**
+ * katze_array_get_length:
+ * @array: a #KatzeArray
+ *
+ * Retrieves the number of items in @array.
+ *
+ * Return value: the length of the list
+ **/
+guint
+katze_array_get_length (KatzeArray* array)
+{
+    g_return_val_if_fail (KATZE_IS_ARRAY (array), 0);
+
+    return katze_list_get_length (KATZE_LIST (array));
+}
+
+/**
+ * katze_array_clear:
+ * @array: a #KatzeArray
+ *
+ * Deletes all items currently contained in @array.
+ **/
+void
+katze_array_clear (KatzeArray* array)
+{
+    g_return_if_fail (KATZE_IS_ARRAY (array));
+
+    katze_list_clear (KATZE_LIST (array));
+}
diff --git a/katze/katze-array.h b/katze/katze-array.h
new file mode 100644 (file)
index 0000000..1caf43e
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
+
+ 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 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#ifndef __KATZE_ARRAY_H__
+#define __KATZE_ARRAY_H__
+
+#include "katze-list.h"
+
+G_BEGIN_DECLS
+
+#define KATZE_TYPE_ARRAY \
+    (katze_array_get_type ())
+#define KATZE_ARRAY(obj) \
+    (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_ARRAY, KatzeArray))
+#define KATZE_ARRAY_CLASS(klass) \
+    (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_ARRAY, KatzeArrayClass))
+#define KATZE_IS_ARRAY(obj) \
+    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_ARRAY))
+#define KATZE_IS_ARRAY_CLASS(klass) \
+    (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_ARRAY))
+#define KATZE_ARRAY_GET_CLASS(obj) \
+    (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_ARRAY, KatzeArrayClass))
+
+typedef struct _KatzeArray                       KatzeArray;
+typedef struct _KatzeArrayClass                  KatzeArrayClass;
+
+GType
+katze_array_get_type               (void);
+
+KatzeArray*
+katze_array_new                    (GType         type);
+
+gboolean
+katze_array_is_a                   (KatzeArray*   array,
+                                    GType         is_a_type);
+
+void
+katze_array_add_item               (KatzeArray*   array,
+                                    gpointer      item);
+
+void
+katze_array_remove_item            (KatzeArray*   array,
+                                    gpointer      item);
+
+gpointer
+katze_array_get_nth_item           (KatzeArray*   array,
+                                    guint         n);
+
+gboolean
+katze_array_is_empty               (KatzeArray*   array);
+
+gint
+katze_array_get_item_index         (KatzeArray*   array,
+                                    gpointer      item);
+
+gpointer
+katze_array_find_token             (KatzeArray*   array,
+                                    const gchar*  token);
+
+guint
+katze_array_get_length             (KatzeArray*   array);
+
+void
+katze_array_clear                  (KatzeArray*   array);
+
+G_END_DECLS
+
+#endif /* __KATZE_ARRAY_H__ */
index c4b36f8b0fbb9274df615b94697e9dacfef71ae6..1e9262b698a5ec70776d6e24ebe222969b2eeca0 100644 (file)
@@ -18,7 +18,7 @@
 /**
  * SECTION:katze-item
  * @short_description: A useful item
- * @see_also: #MidoriWebList
+ * @see_also: #KatzeArray
  *
  * #KatzeItem is a particularly useful item that provides
  * several commonly needed properties.
index fa61cbca7424c87319b0d285ce9570f4de2420e4..8f1385920c3fec8c06d0a4debaef042be6d7f1e9 100644 (file)
@@ -9,8 +9,8 @@
  See the file COPYING for the full license text.
 */
 
-#ifndef __MIDORI_WEB_ITEM_H__
-#define __MIDORI_WEB_ITEM_H__
+#ifndef __KATZE_ITEM_H__
+#define __KATZE_ITEM_H__
 
 #include <glib-object.h>
 
diff --git a/katze/katze-list.c b/katze/katze-list.c
new file mode 100644 (file)
index 0000000..15bb0e1
--- /dev/null
@@ -0,0 +1,244 @@
+/*
+ Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
+
+ 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 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#include "katze-list.h"
+
+#include "katze-utils.h"
+
+#include <glib/gi18n.h>
+#include <string.h>
+
+/**
+ * SECTION:katze-list
+ * @short_description: A verbose and versatile item container
+ * @see_also: #KatzeItem
+ *
+ * #KatzeList is a verbose and versatile container for items.
+ */
+
+G_DEFINE_TYPE (KatzeList, katze_list, KATZE_TYPE_ITEM)
+
+enum {
+    ADD_ITEM,
+    REMOVE_ITEM,
+
+    LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+static void
+katze_list_finalize (GObject* object);
+
+static void
+_katze_list_add_item (KatzeList* list,
+                      gpointer   item)
+{
+    list->items = g_list_append (list->items, item);
+}
+
+static void
+_katze_list_remove_item (KatzeList* list,
+                         gpointer   item)
+{
+    list->items = g_list_remove (list->items, item);
+}
+
+static void
+katze_list_class_init (KatzeListClass* class)
+{
+    GObjectClass* gobject_class;
+
+    signals[ADD_ITEM] = g_signal_new (
+        "add-item",
+        G_TYPE_FROM_CLASS (class),
+        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+        G_STRUCT_OFFSET (KatzeListClass, add_item),
+        0,
+        NULL,
+        g_cclosure_marshal_VOID__POINTER,
+        G_TYPE_NONE, 1,
+        G_TYPE_POINTER);
+
+    signals[REMOVE_ITEM] = g_signal_new (
+        "remove-item",
+        G_TYPE_FROM_CLASS (class),
+        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+        G_STRUCT_OFFSET (KatzeListClass, remove_item),
+        0,
+        NULL,
+        g_cclosure_marshal_VOID__POINTER,
+        G_TYPE_NONE, 1,
+        G_TYPE_POINTER);
+
+    gobject_class = G_OBJECT_CLASS (class);
+    gobject_class->finalize = katze_list_finalize;
+
+    class->add_item = _katze_list_add_item;
+    class->remove_item = _katze_list_remove_item;
+}
+
+static void
+katze_list_init (KatzeList* list)
+{
+    list->items = NULL;
+}
+
+static void
+katze_list_finalize (GObject* object)
+{
+    KatzeList* list;
+
+    list = KATZE_LIST (object);
+    g_list_free (list->items);
+
+    G_OBJECT_CLASS (katze_list_parent_class)->finalize (object);
+}
+
+/**
+ * katze_list_new:
+ *
+ * Creates a new #KatzeList.
+ *
+ * Return value: a new #KatzeList
+ **/
+KatzeList*
+katze_list_new (void)
+{
+    KatzeList* list = g_object_new (KATZE_TYPE_LIST, NULL);
+
+    return list;
+}
+
+/**
+ * katze_list_add_item:
+ * @list: a #KatzeList
+ * @item: a #GObject
+ *
+ * Adds an item to the list.
+ **/
+void
+katze_list_add_item (KatzeList* list,
+                     gpointer   item)
+{
+    g_return_if_fail (KATZE_IS_LIST (list));
+
+    g_signal_emit (list, signals[ADD_ITEM], 0, item);
+}
+
+/**
+ * katze_list_add_item:
+ * @list: a #KatzeList
+ * @item: a #GObject
+ *
+ * Removes an item from the list.
+ **/
+void
+katze_list_remove_item (KatzeList* list,
+                        gpointer   item)
+{
+    g_return_if_fail (KATZE_IS_LIST (list));
+
+    g_signal_emit (list, signals[REMOVE_ITEM], 0, item);
+}
+
+/**
+ * katze_list_get_nth_item:
+ * @list: a #KatzeList
+ * @n: an index in the list
+ *
+ * Retrieves the item in @list at the position @n.
+ *
+ * Return value: an item, or %NULL
+ **/
+gpointer
+katze_list_get_nth_item (KatzeList* list,
+                         guint      n)
+{
+    g_return_val_if_fail (KATZE_IS_LIST (list), NULL);
+
+    return g_list_nth_data (list->items, n);
+}
+
+/**
+ * katze_list_is_empty:
+ * @list: a #KatzeList
+ *
+ * Determines if @list is empty.
+ *
+ * Return value: an item, or %NULL
+ **/
+gboolean
+katze_list_is_empty (KatzeList* list)
+{
+    g_return_val_if_fail (KATZE_IS_LIST (list), TRUE);
+
+    return !g_list_nth_data (list->items, 0);
+}
+
+/**
+ * katze_list_get_item_position:
+ * @list: a #KatzeList
+ * @item: an item in the list
+ *
+ * Retrieves the index of the item in @list.
+ *
+ * Return value: an item, or -1
+ **/
+gint
+katze_list_get_item_index (KatzeList* list,
+                           gpointer   item)
+{
+    g_return_val_if_fail (KATZE_IS_LIST (list), -1);
+
+    return g_list_index (list->items, item);
+}
+
+/**
+ * katze_list_get_length:
+ * @list: a #KatzeList
+ *
+ * Retrieves the number of items in @list.
+ *
+ * Return value: the length of the list
+ **/
+guint
+katze_list_get_length (KatzeList* list)
+{
+    g_return_val_if_fail (KATZE_IS_LIST (list), 0);
+
+    return g_list_length (list->items);
+}
+
+/**
+ * katze_list_clear:
+ * @list: a #KatzeList
+ *
+ * Deletes all items currently contained in @list.
+ **/
+void
+katze_list_clear (KatzeList* list)
+{
+    guint n;
+    guint i;
+    GObject* item;
+
+    g_return_if_fail (KATZE_IS_LIST (list));
+
+    n = g_list_length (list->items);
+    for (i = 0; i < n; i++)
+    {
+        if ((item = g_list_nth_data (list->items, i)))
+            katze_list_remove_item (list, item);
+    }
+    g_list_free (list->items);
+    list->items = NULL;
+}
diff --git a/katze/katze-list.h b/katze/katze-list.h
new file mode 100644 (file)
index 0000000..0e2570d
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
+
+ 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 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#ifndef __KATZE_LIST_H__
+#define __KATZE_LIST_H__
+
+#include "katze-item.h"
+
+G_BEGIN_DECLS
+
+#define KATZE_TYPE_LIST \
+    (katze_list_get_type ())
+#define KATZE_LIST(obj) \
+    (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_LIST, KatzeList))
+#define KATZE_LIST_CLASS(klass) \
+    (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_LIST, KatzeListClass))
+#define KATZE_IS_LIST(obj) \
+    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_LIST))
+#define KATZE_IS_LIST_CLASS(klass) \
+    (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_LIST))
+#define KATZE_LIST_GET_CLASS(obj) \
+    (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_LIST, KatzeListClass))
+
+typedef struct _KatzeList                       KatzeList;
+typedef struct _KatzeListClass                  KatzeListClass;
+
+struct _KatzeList
+{
+    KatzeItem parent_instance;
+
+    GList* items;
+};
+
+struct _KatzeListClass
+{
+    KatzeItemClass parent_class;
+
+    /* Signals */
+    void
+    (*add_item)               (KatzeList* list,
+                               gpointer   item);
+    void
+    (*remove_item)            (KatzeList* list,
+                               gpointer   item);
+};
+
+GType
+katze_list_get_type               (void);
+
+KatzeList*
+katze_list_new                    (void);
+
+void
+katze_list_add_item               (KatzeList*   list,
+                                   gpointer     item);
+
+void
+katze_list_remove_item            (KatzeList*   list,
+                                   gpointer     item);
+
+gpointer
+katze_list_get_nth_item           (KatzeList*   list,
+                                   guint        n);
+
+gboolean
+katze_list_is_empty               (KatzeList*   list);
+
+gint
+katze_list_get_item_index         (KatzeList*   list,
+                                   gpointer     item);
+
+guint
+katze_list_get_length             (KatzeList*   list);
+
+void
+katze_list_clear                  (KatzeList*   list);
+
+G_END_DECLS
+
+#endif /* __KATZE_LIST_H__ */
diff --git a/katze/katze-weblist.c b/katze/katze-weblist.c
deleted file mode 100644 (file)
index 0d780bc..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
-
- 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 2.1 of the License, or (at your option) any later version.
-
- See the file COPYING for the full license text.
-*/
-
-#include "katze-weblist.h"
-
-#include "katze-utils.h"
-
-#include <glib/gi18n.h>
-#include <string.h>
-
-/**
- * SECTION:midori-weblist
- * @short_description: A versatile object container
- * @see_also: #KatzeItem
- *
- * #MidoriWebList is a versatile container for objects.
- */
-
-struct _MidoriWebList
-{
-    KatzeItem parent_instance;
-
-    GList* items;
-};
-
-struct _MidoriWebListClass
-{
-    KatzeItemClass parent_class;
-
-    /* Signals */
-    void
-    (*add_item)               (MidoriWebList* web_list,
-                               GObject*       item);
-    void
-    (*remove_item)            (MidoriWebList* web_list,
-                               GObject*       item);
-};
-
-G_DEFINE_TYPE (MidoriWebList, midori_web_list, KATZE_TYPE_ITEM)
-
-enum {
-    ADD_ITEM,
-    REMOVE_ITEM,
-
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-midori_web_list_finalize (GObject* object);
-
-static void
-_midori_web_list_add_item (MidoriWebList* web_list,
-                           GObject*       item)
-{
-    g_object_ref (item);
-    web_list->items = g_list_append (web_list->items, item);
-}
-
-static void
-_midori_web_list_remove_item (MidoriWebList* web_list,
-                              GObject*       item)
-{
-    web_list->items = g_list_remove (web_list->items, item);
-    g_object_unref (item);
-}
-
-static void
-midori_web_list_class_init (MidoriWebListClass* class)
-{
-    signals[ADD_ITEM] = g_signal_new (
-        "add-item",
-        G_TYPE_FROM_CLASS (class),
-        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
-        G_STRUCT_OFFSET (MidoriWebListClass, add_item),
-        0,
-        NULL,
-        g_cclosure_marshal_VOID__OBJECT,
-        G_TYPE_NONE, 1,
-        G_TYPE_OBJECT);
-
-    signals[REMOVE_ITEM] = g_signal_new (
-        "remove-item",
-        G_TYPE_FROM_CLASS (class),
-        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
-        G_STRUCT_OFFSET (MidoriWebListClass, remove_item),
-        0,
-        NULL,
-        g_cclosure_marshal_VOID__OBJECT,
-        G_TYPE_NONE, 1,
-        G_TYPE_OBJECT);
-
-    class->add_item = _midori_web_list_add_item;
-    class->remove_item = _midori_web_list_remove_item;
-
-    GObjectClass* gobject_class = G_OBJECT_CLASS (class);
-    gobject_class->finalize = midori_web_list_finalize;
-}
-
-static void
-midori_web_list_init (MidoriWebList* web_list)
-{
-    web_list->items = NULL;
-}
-
-static void
-midori_web_list_finalize (GObject* object)
-{
-    MidoriWebList* web_list = MIDORI_WEB_LIST (object);
-    guint n, i;
-
-    /* Scruffily remove all items, no need for signals */
-    n = g_list_length (web_list->items);
-    for (i = 0; i < n; i++)
-        g_object_unref (g_list_nth_data (web_list->items, i));
-    g_list_free (web_list->items);
-
-    G_OBJECT_CLASS (midori_web_list_parent_class)->finalize (object);
-}
-
-/**
- * midori_web_list_new:
- *
- * Creates a new #MidoriWebList.
- *
- * Return value: a new #MidoriWebList
- **/
-MidoriWebList*
-midori_web_list_new (void)
-{
-    MidoriWebList* web_list = g_object_new (MIDORI_TYPE_WEB_LIST,
-                                            NULL);
-
-    return web_list;
-}
-
-/**
- * midori_web_list_add_item:
- * @web_list: a #MidoriWebList
- * @item: a #GObject
- *
- * Adds an item to the list.
- **/
-void
-midori_web_list_add_item (MidoriWebList* web_list,
-                          gpointer       item)
-{
-    g_return_if_fail (MIDORI_IS_WEB_LIST (web_list));
-    g_return_if_fail (G_IS_OBJECT (item));
-
-    g_signal_emit (web_list, signals[ADD_ITEM], 0, item);
-}
-
-/**
- * midori_web_list_add_item:
- * @web_list: a #MidoriWebList
- * @item: a #GObject
- *
- * Removes an item from the list.
- **/
-void
-midori_web_list_remove_item (MidoriWebList* web_list,
-                             gpointer       item)
-{
-    g_return_if_fail (MIDORI_IS_WEB_LIST (web_list));
-    g_return_if_fail (G_IS_OBJECT (item));
-
-    g_signal_emit (web_list, signals[REMOVE_ITEM], 0, item);
-}
-
-/**
- * midori_web_list_get_nth_item:
- * @web_list: a #MidoriWebList
- * @n: an index in the list
- *
- * Retrieves the item in @web_list at the position @n.
- *
- * Return value: an item, or %NULL
- **/
-gpointer
-midori_web_list_get_nth_item (MidoriWebList* web_list,
-                              guint          n)
-{
-    g_return_val_if_fail (MIDORI_IS_WEB_LIST (web_list), NULL);
-
-    return g_list_nth_data (web_list->items, n);
-}
-
-/**
- * midori_web_list_is_empty:
- * @web_list: a #MidoriWebList
- *
- * Determines if @web_list is empty.
- *
- * Return value: an item, or %NULL
- **/
-gboolean
-midori_web_list_is_empty (MidoriWebList* web_list)
-{
-    g_return_val_if_fail (MIDORI_IS_WEB_LIST (web_list), TRUE);
-
-    return !g_list_nth_data (web_list->items, 0);
-}
-
-/**
- * midori_web_list_get_item_position:
- * @web_list: a #MidoriWebList
- * @item: an item in the list
- *
- * Retrieves the index of the item in @web_list.
- *
- * Return value: an item, or -1
- **/
-gint
-midori_web_list_get_item_index (MidoriWebList* web_list,
-                                gpointer       item)
-{
-    g_return_val_if_fail (MIDORI_IS_WEB_LIST (web_list), -1);
-    g_return_val_if_fail (G_IS_OBJECT (item), -1);
-
-    return g_list_index (web_list->items, item);
-}
-
-/**
- * midori_web_list_find_token:
- * @web_list: a #MidoriWebList
- * @token: a token string
- *
- * Looks up an item in the list which has the specified token.
- *
- * Currently only #KatzeItem is supported.
- *
- * Note that @token is by definition unique to one item.
- *
- * Return value: an item, or %NULL
- **/
-gpointer
-midori_web_list_find_token (MidoriWebList* web_list,
-                            const gchar*   token)
-{
-    guint n, i;
-    gpointer item;
-    const gchar* found_token;
-
-    g_return_val_if_fail (MIDORI_IS_WEB_LIST (web_list), NULL);
-
-    n = g_list_length (web_list->items);
-    for (i = 0; i < n; i++)
-    {
-        item = g_list_nth_data (web_list->items, i);
-        if (!KATZE_IS_ITEM (item))
-            continue;
-        found_token = katze_item_get_token ((KatzeItem*)item);
-        if (found_token && !strcmp (found_token, token))
-            return item;
-    }
-    return NULL;
-}
-
-/**
- * midori_web_list_get_length:
- * @web_list: a #MidoriWebList
- *
- * Retrieves the number of items in @web_list.
- *
- * Return value: the length of the list
- **/
-guint
-midori_web_list_get_length (MidoriWebList* web_list)
-{
-    g_return_val_if_fail (MIDORI_IS_WEB_LIST (web_list), 0);
-
-    return g_list_length (web_list->items);
-}
-
-/**
- * midori_web_list_clear:
- * @web_list: a #MidoriWebList
- *
- * Deletes all items currently contained in @web_list.
- **/
-void
-midori_web_list_clear (MidoriWebList* web_list)
-{
-    guint n;
-    guint i;
-    GObject* item;
-
-    g_return_if_fail (MIDORI_IS_WEB_LIST (web_list));
-
-    n = g_list_length (web_list->items);
-    for (i = 0; i < n; i++)
-    {
-        if ((item = g_list_nth_data (web_list->items, i)))
-            midori_web_list_remove_item (web_list, item);
-    }
-    g_list_free (web_list->items);
-    web_list->items = NULL;
-}
diff --git a/katze/katze-weblist.h b/katze/katze-weblist.h
deleted file mode 100644 (file)
index 0117f7d..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
-
- 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 2.1 of the License, or (at your option) any later version.
-
- See the file COPYING for the full license text.
-*/
-
-#ifndef __MIDORI_WEB_LIST_H__
-#define __MIDORI_WEB_LIST_H__
-
-#include "katze-item.h"
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_WEB_LIST \
-    (midori_web_list_get_type ())
-#define MIDORI_WEB_LIST(obj) \
-    (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_WEB_LIST, MidoriWebList))
-#define MIDORI_WEB_LIST_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_WEB_LIST, MidoriWebListClass))
-#define MIDORI_IS_WEB_LIST(obj) \
-    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_WEB_LIST))
-#define MIDORI_IS_WEB_LIST_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_WEB_LIST))
-#define MIDORI_WEB_LIST_GET_CLASS(obj) \
-    (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_WEB_LIST, MidoriWebListClass))
-
-typedef struct _MidoriWebList                MidoriWebList;
-typedef struct _MidoriWebListClass           MidoriWebListClass;
-
-GType
-midori_web_list_get_type               (void);
-
-MidoriWebList*
-midori_web_list_new                    (void);
-
-void
-midori_web_list_add_item               (MidoriWebList* web_list,
-                                        gpointer       item);
-
-void
-midori_web_list_remove_item            (MidoriWebList* web_list,
-                                        gpointer       item);
-
-gpointer
-midori_web_list_get_nth_item           (MidoriWebList* web_list,
-                                        guint          n);
-
-gboolean
-midori_web_list_is_empty               (MidoriWebList* web_list);
-
-gint
-midori_web_list_get_item_index         (MidoriWebList* web_list,
-                                        gpointer       item);
-
-gpointer
-midori_web_list_find_token             (MidoriWebList* web_list,
-                                        const gchar*   token);
-
-guint
-midori_web_list_get_length             (MidoriWebList* web_list);
-
-void
-midori_web_list_clear                  (MidoriWebList* web_list);
-
-G_END_DECLS
-
-#endif /* __MIDORI_WEB_LIST_H__ */
index 159adf1b6cdc00b7a1b59f7217ef52d85a87774c..fbe418b33b8b5560af4e23787bf73f930b12051c 100644 (file)
@@ -9,13 +9,14 @@
  See the file COPYING for the full license text.
 */
 
-#ifndef __KATZE__
-#define __KATZE__
+#ifndef __KATZE_H__
+#define __KATZE_H__
 
 #include "katze-throbber.h"
 #include "katze-utils.h"
 #include "katze-item.h"
-#include "katze-weblist.h"
+#include "katze-list.h"
+#include "katze-array.h"
 #include "katze-xbel.h"
 
 #endif /* __KATZE_H__ */
index e3a666ba317dcf32d4caa92a1cdb8ea81fbacc40..efd1956d9eb2bcca01b0395033249429f95803b7 100644 (file)
@@ -257,11 +257,11 @@ settings_save_to_file (MidoriWebSettings* settings,
     return saved;
 }
 
-static MidoriWebList*
+static KatzeArray*
 search_engines_new_from_file (const gchar* filename,
                               GError**     error)
 {
-    MidoriWebList* search_engines;
+    KatzeArray* search_engines;
     GKeyFile* key_file;
     gchar** engines;
     guint i, j, n_properties;
@@ -270,7 +270,7 @@ search_engines_new_from_file (const gchar* filename,
     const gchar* property;
     gchar* value;
 
-    search_engines = midori_web_list_new ();
+    search_engines = katze_array_new (KATZE_TYPE_ITEM);
     key_file = g_key_file_new ();
     g_key_file_load_from_file (key_file, filename,
                                G_KEY_FILE_KEEP_COMMENTS, error);
@@ -290,7 +290,7 @@ search_engines_new_from_file (const gchar* filename,
             g_object_set (item, property, value, NULL);
             g_free (value);
         }
-        midori_web_list_add_item (search_engines, item);
+        katze_array_add_item (search_engines, item);
     }
     g_strfreev (engines);
     g_key_file_free (key_file);
@@ -298,9 +298,9 @@ search_engines_new_from_file (const gchar* filename,
 }
 
 static gboolean
-search_engines_save_to_file (MidoriWebList* search_engines,
-                             const gchar*   filename,
-                             GError**       error)
+search_engines_save_to_file (KatzeArray*  search_engines,
+                             const gchar* filename,
+                             GError**     error)
 {
     GKeyFile* key_file;
     guint n, i, j, n_properties;
@@ -312,12 +312,12 @@ search_engines_save_to_file (MidoriWebList* search_engines,
     gboolean saved;
 
     key_file = g_key_file_new ();
-    n = midori_web_list_get_length (search_engines);
+    n = katze_array_get_length (search_engines);
     pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (search_engines),
                                              &n_properties);
     for (i = 0; i < n; i++)
     {
-        item = midori_web_list_get_nth_item (search_engines, i);
+        item = katze_array_get_nth_item (search_engines, i);
         name = katze_item_get_name (item);
         for (j = 0; j < n_properties; j++)
         {
@@ -335,13 +335,16 @@ search_engines_save_to_file (MidoriWebList* search_engines,
 }
 
 static void
-midori_web_list_add_item_cb (MidoriWebList* trash,
-                             GObject*       item)
+midori_web_list_add_item_cb (KatzeArray* trash,
+                             GObject*    item)
 {
-    guint n = midori_web_list_get_length (trash);
+    guint n;
+    GObject* obsolete_item;
+
+    n = katze_array_get_length (trash);
     if (n > 10)
     {
-        GObject* obsolete_item = midori_web_list_get_nth_item (trash, 0);
+        obsolete_item = katze_array_get_nth_item (trash, 0);
         g_object_unref (obsolete_item);
     }
 }
@@ -380,7 +383,7 @@ midori_browser_weak_notify_cb (MidoriBrowser* browser,
 
 
 int
-main (int argc,
+main (int    argc,
       char** argv)
 {
     gboolean version;
@@ -395,7 +398,7 @@ main (int argc,
     };
     MidoriStartup load_on_startup;
     gchar* homepage;
-    MidoriWebList* search_engines;
+    KatzeArray* search_engines;
 
     #if ENABLE_NLS
     bindtextdomain (GETTEXT_PACKAGE, MIDORI_LOCALEDIR);
@@ -598,13 +601,13 @@ main (int argc,
 
     stock_items_init ();
 
-    MidoriWebList* trash = midori_web_list_new ();
+    KatzeArray* trash = katze_array_new (KATZE_TYPE_XBEL_ITEM);
     guint n = katze_xbel_folder_get_n_items (xbel_trash);
     guint i;
     for (i = 0; i < n; i++)
     {
         KatzeXbelItem* item = katze_xbel_folder_get_nth_item (xbel_trash, i);
-        midori_web_list_add_item (trash, item);
+        katze_array_add_item (trash, item);
     }
     g_signal_connect_after (trash, "add-item",
         G_CALLBACK (midori_web_list_add_item_cb), NULL);
index 7314957c0251986c4182b64e8b154f6b3fc892b5..309d3622f3a2268a9e4b03f858504fdd88177d87 100644 (file)
@@ -32,8 +32,8 @@ struct _MidoriApp
     GtkAccelGroup* accel_group;
 
     MidoriWebSettings* settings;
-    MidoriWebList* trash;
-    MidoriWebList* search_engines;
+    KatzeArray* trash;
+    KatzeArray* search_engines;
 
     gpointer instance;
 };
@@ -131,7 +131,7 @@ midori_app_class_init (MidoriAppClass* class)
                                      "trash",
                                      _("Trash"),
                                      _("The trash, collecting recently closed tabs and windows"),
-                                     MIDORI_TYPE_WEB_LIST,
+                                     KATZE_TYPE_ARRAY,
                                      G_PARAM_READWRITE));
 
     g_object_class_install_property (gobject_class,
@@ -158,7 +158,7 @@ midori_app_class_init (MidoriAppClass* class)
                                      "search-engines",
                                      _("Search Engines"),
                                      _("The list of search engines"),
-                                     MIDORI_TYPE_WEB_LIST,
+                                     KATZE_TYPE_ARRAY,
                                      G_PARAM_READWRITE));
 }
 
@@ -188,24 +188,20 @@ midori_browser_message_received_cb (UniqueApp*         instance,
   switch (command)
   {
   case UNIQUE_ACTIVATE:
-      g_print("activate\n");
       gtk_window_set_screen (GTK_WINDOW (app->browser),
                              unique_message_data_get_screen (message));
       gtk_window_present (GTK_WINDOW (app->browser));
       response = UNIQUE_RESPONSE_OK;
       break;
   case UNIQUE_OPEN:
-      g_print("open\n");
       uris = unique_message_data_get_uris (message);
       if (!uris)
           response = UNIQUE_RESPONSE_FAIL;
       else
       {
-          g_print("open uris\n");
           while (*uris)
           {
               midori_browser_add_uri (app->browser, *uris);
-              g_print ("uri: %s\n", *uris);
               uris++;
           }
           /* g_strfreev (uris); */
@@ -213,7 +209,6 @@ midori_browser_message_received_cb (UniqueApp*         instance,
       }
       break;
   default:
-      g_print("fail\n");
       response = UNIQUE_RESPONSE_FAIL;
       break;
   }
@@ -238,8 +233,8 @@ midori_app_init (MidoriApp* app)
     app->accel_group = gtk_accel_group_new ();
 
     app->settings = midori_web_settings_new ();
-    app->trash = midori_web_list_new ();
-    app->search_engines = midori_web_list_new ();
+    app->trash = katze_array_new (KATZE_TYPE_XBEL_ITEM);
+    app->search_engines = katze_array_new (KATZE_TYPE_ITEM);
 
     #if HAVE_UNIQUE
     display_name = g_strdup (gdk_display_get_name (gdk_display_get_default ()));
@@ -572,7 +567,7 @@ midori_app_set_settings (MidoriApp*         app,
  *
  * Return value: the assigned #MidoriTrash
  **/
-MidoriWebList*
+KatzeArray*
 midori_app_get_trash (MidoriApp* app)
 {
     g_return_val_if_fail (MIDORI_IS_APP (app), NULL);
index 637cb6ef9fe8b2ed61085ee5fd9a02225d5e5001..641aa2f71b3c37db9480ba54b1d2da81a747c1a3 100644 (file)
@@ -44,7 +44,7 @@ struct _MidoriAppClass
     (*add_browser)            (MidoriApp*     app,
                                MidoriBrowser* browser);
     void
-    (*quit)                   (MidoriApp* app);
+    (*quit)                   (MidoriApp*     app);
 };
 
 GType
@@ -74,7 +74,7 @@ void
 midori_app_set_settings           (MidoriApp*         app,
                                    MidoriWebSettings* settings);
 
-MidoriWebList*
+KatzeArray*
 midori_app_get_trash              (MidoriApp*         app);
 
 void
index 6ac960595fcdd36fba298430233aaf61b4cc0119..cba3ddfb091642fcc4c97ddc0449f98fc209fa4c 100644 (file)
@@ -78,8 +78,8 @@ struct _MidoriBrowser
     GList* close_buttons;
 
     KatzeXbelItem* proxy_xbel_folder;
-    MidoriWebList* trash;
-    MidoriWebList* search_engines;
+    KatzeArray* trash;
+    KatzeArray* search_engines;
 };
 
 G_DEFINE_TYPE (MidoriBrowser, midori_browser, GTK_TYPE_WINDOW)
@@ -216,6 +216,7 @@ static void
 _midori_browser_update_actions (MidoriBrowser* browser)
 {
     guint n;
+    gboolean trash_empty;
 
     n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
     gtk_notebook_set_show_tabs (GTK_NOTEBOOK (browser->notebook), n > 1);
@@ -225,7 +226,7 @@ _midori_browser_update_actions (MidoriBrowser* browser)
 
     if (browser->trash)
     {
-        gboolean trash_empty = midori_web_list_is_empty (browser->trash);
+        trash_empty = katze_array_is_empty (browser->trash);
         _action_set_sensitive (browser, "UndoTabClose", !trash_empty);
         _action_set_sensitive (browser, "Trash", !trash_empty);
     }
@@ -790,7 +791,7 @@ midori_browser_tab_destroy_cb (GtkWidget*     widget,
             MIDORI_WEB_VIEW (widget));
         uri = katze_xbel_bookmark_get_href (xbel_item);
         if (browser->trash && uri && *uri)
-            midori_web_list_add_item (browser->trash, xbel_item);
+            katze_array_add_item (browser->trash, xbel_item);
         katze_xbel_folder_remove_item (browser->proxy_xbel_folder, xbel_item);
         katze_xbel_item_unref (xbel_item);
     }
@@ -1318,7 +1319,7 @@ midori_browser_class_init (MidoriBrowserClass* class)
                                      "trash",
                                      _("Trash"),
                                      _("The trash, collecting recently closed tabs and windows"),
-                                     MIDORI_TYPE_WEB_LIST,
+                                     KATZE_TYPE_ARRAY,
                                      G_PARAM_READWRITE));
 
     /**
@@ -1332,7 +1333,7 @@ midori_browser_class_init (MidoriBrowserClass* class)
                                      "search-engines",
                                      _("Search Engines"),
                                      _("The list of search engines to be used for web search"),
-                                     MIDORI_TYPE_WEB_LIST,
+                                     KATZE_TYPE_ARRAY,
                                      G_PARAM_READWRITE));
 }
 
@@ -1685,7 +1686,7 @@ midori_browser_menu_trash_item_activate_cb (GtkWidget*     menuitem,
                                              "KatzeXbelItem");
     gint n = midori_browser_add_xbel_item (browser, item);
     midori_browser_set_current_page (browser, n);
-    midori_web_list_remove_item (browser->trash, item);
+    katze_array_remove_item (browser->trash, item);
     _midori_browser_update_actions (browser);
 }
 
@@ -1694,12 +1695,12 @@ midori_browser_menu_trash_activate_cb (GtkWidget*     widget,
                                        MidoriBrowser* browser)
 {
     GtkWidget* menu = gtk_menu_new ();
-    guint n = midori_web_list_get_length (browser->trash);
+    guint n = katze_array_get_length (browser->trash);
     GtkWidget* menuitem;
     guint i;
     for (i = 0; i < n; i++)
     {
-        KatzeXbelItem* item = midori_web_list_get_nth_item (browser->trash, i);
+        KatzeXbelItem* item = katze_array_get_nth_item (browser->trash, i);
         const gchar* title = katze_xbel_item_get_title (item);
         const gchar* uri = katze_xbel_bookmark_get_href (item);
         menuitem = gtk_image_menu_item_new_with_label (title ? title : uri);
@@ -2048,7 +2049,7 @@ _action_location_secondary_icon_released (GtkAction*     action,
                                           MidoriBrowser* browser)
 {
     MidoriWebView* web_view;
-    MidoriWebList* news_feeds;
+    KatzeArray* news_feeds;
     GtkWidget* menu;
     guint n, i;
     GjsValue* feed;
@@ -2060,13 +2061,13 @@ _action_location_secondary_icon_released (GtkAction*     action,
     if (web_view)
     {
         news_feeds = midori_web_view_get_news_feeds (web_view);
-        n = news_feeds ? midori_web_list_get_length (news_feeds) : 0;
+        n = news_feeds ? katze_array_get_length (news_feeds) : 0;
         if (n)
         {
             menu = gtk_menu_new ();
             for (i = 0; i < n; i++)
             {
-                if (!(feed = midori_web_list_get_nth_item (news_feeds, i)))
+                if (!(feed = katze_array_get_nth_item (news_feeds, i)))
                     continue;
 
                 uri = gjs_value_get_attribute_string (feed, "href");
@@ -2655,11 +2656,11 @@ _action_undo_tab_close_activate (GtkAction*     action,
     guint n;
 
     /* Reopen the most recent trash item */
-    last = midori_web_list_get_length (browser->trash) - 1;
-    item = midori_web_list_get_nth_item (browser->trash, last);
+    last = katze_array_get_length (browser->trash) - 1;
+    item = katze_array_get_nth_item (browser->trash, last);
     n = midori_browser_add_xbel_item (browser, item);
     midori_browser_set_current_page (browser, n);
-    midori_web_list_remove_item (browser->trash, item);
+    katze_array_remove_item (browser->trash, item);
     _midori_browser_update_actions (browser);
 }
 
@@ -2667,7 +2668,7 @@ static void
 _action_trash_empty_activate (GtkAction*     action,
                               MidoriBrowser* browser)
 {
-    midori_web_list_clear (browser->trash);
+    katze_array_clear (browser->trash);
     _midori_browser_update_actions (browser);
 }
 
@@ -3099,7 +3100,7 @@ static void
 midori_browser_search_activate_cb (GtkWidget*     widget,
                                    MidoriBrowser* browser)
 {
-    MidoriWebList* search_engines;
+    KatzeArray* search_engines;
     const gchar* keywords;
     guint last_web_search;
     KatzeItem* item;
@@ -3110,7 +3111,7 @@ midori_browser_search_activate_cb (GtkWidget*     widget,
     search_engines = browser->search_engines;
     keywords = gtk_entry_get_text (GTK_ENTRY (widget));
     g_object_get (browser->settings, "last-web-search", &last_web_search, NULL);
-    item = midori_web_list_get_nth_item (search_engines, last_web_search);
+    item = katze_array_get_nth_item (search_engines, last_web_search);
     if (item)
     {
         location_entry_search = NULL;
@@ -3154,7 +3155,7 @@ midori_browser_search_notify_current_item_cb (GObject*       gobject,
     search_entry = MIDORI_SEARCH_ENTRY (browser->search);
     item = midori_search_entry_get_current_item (search_entry);
     if (item)
-        index = midori_web_list_get_item_index (browser->search_engines, item);
+        index = katze_array_get_item_index (browser->search_engines, item);
     else
         index = 0;
 
@@ -3273,12 +3274,12 @@ midori_browser_init (MidoriBrowser* browser)
     g_object_ref (browser->popup_bookmark);
     browser->menu_tools = gtk_menu_item_get_submenu (GTK_MENU_ITEM (
         gtk_ui_manager_get_widget (ui_manager, "/menubar/Tools")));
-    menuitem = gtk_separator_menu_item_new();
+    menuitem = gtk_separator_menu_item_new ();
     gtk_widget_show (menuitem);
     gtk_menu_shell_append (GTK_MENU_SHELL (browser->menu_tools), menuitem);
     browser->menu_window = gtk_menu_item_get_submenu (GTK_MENU_ITEM (
         gtk_ui_manager_get_widget (ui_manager, "/menubar/Window")));
-    menuitem = gtk_separator_menu_item_new();
+    menuitem = gtk_separator_menu_item_new ();
     gtk_widget_show (menuitem);
     gtk_menu_shell_append (GTK_MENU_SHELL (browser->menu_window), menuitem);
     gtk_widget_show (browser->menubar);
@@ -3734,8 +3735,8 @@ _midori_browser_update_settings (MidoriBrowser* browser)
 
     if (browser->search_engines)
     {
-        item = midori_web_list_get_nth_item (browser->search_engines,
-                                             last_web_search);
+        item = katze_array_get_nth_item (browser->search_engines,
+                                         last_web_search);
         if (item)
             midori_search_entry_set_current_item (
                 MIDORI_SEARCH_ENTRY (browser->search), item);
@@ -3872,8 +3873,8 @@ midori_browser_set_property (GObject*      object,
         {
             g_object_get (browser->settings, "last-web-search",
                           &last_web_search, NULL);
-            item = midori_web_list_get_nth_item (browser->search_engines,
-                                                 last_web_search);
+            item = katze_array_get_nth_item (browser->search_engines,
+                                             last_web_search);
             if (item)
                 g_object_set (browser->search, "current-item", item, NULL);
         }
index 413081fd150680b6d977ab3012fca8382f9e250a..790dbdb9590bde750ed4b5bf91da5317e97a877d 100644 (file)
@@ -20,7 +20,7 @@ struct _MidoriSearchEntry
 {
     GtkIconEntry parent_instance;
 
-    MidoriWebList* search_engines;
+    KatzeArray* search_engines;
     KatzeItem* current_item;
 };
 
@@ -64,7 +64,7 @@ midori_search_entry_class_init (MidoriSearchEntryClass* class)
                                      "search-engines",
                                      _("Search Engines"),
                                      _("The list of search engines"),
-                                     MIDORI_TYPE_WEB_LIST,
+                                     KATZE_TYPE_ARRAY,
                                      G_PARAM_READWRITE));
 
     g_object_class_install_property (gobject_class,
@@ -115,7 +115,7 @@ midori_search_entry_icon_released_cb (GtkWidget*            widget,
                                       gint                  button)
 {
     MidoriSearchEntry* search_entry;
-    MidoriWebList* search_engines;
+    KatzeArray* search_engines;
     GtkWidget* menu;
     guint n, i;
     GtkWidget* menuitem;
@@ -126,12 +126,12 @@ midori_search_entry_icon_released_cb (GtkWidget*            widget,
     search_entry = MIDORI_SEARCH_ENTRY (widget);
     search_engines = search_entry->search_engines;
     menu = gtk_menu_new ();
-    n = midori_web_list_get_length (search_engines);
+    n = katze_array_get_length (search_engines);
     if (n)
     {
         for (i = 0; i < n; i++)
         {
-            item = midori_web_list_get_nth_item (search_engines, i);
+            item = katze_array_get_nth_item (search_engines, i);
             menuitem = gtk_image_menu_item_new_with_label (
                 katze_item_get_name (item));
             pixbuf = sokoke_web_icon (katze_item_get_icon (item),
@@ -175,9 +175,9 @@ _midori_search_entry_move_index (MidoriSearchEntry* search_entry,
     gint i;
     KatzeItem* item;
 
-    i = midori_web_list_get_item_index (search_entry->search_engines,
-                                        search_entry->current_item);
-    item = midori_web_list_get_nth_item (search_entry->search_engines, i + n);
+    i = katze_array_get_item_index (search_entry->search_engines,
+                                    search_entry->current_item);
+    item = katze_array_get_nth_item (search_entry->search_engines, i + n);
     if (item)
         midori_search_entry_set_current_item (search_entry, item);
 }
@@ -216,8 +216,8 @@ midori_search_entry_scroll_event_cb (MidoriSearchEntry* search_entry,
 }
 
 static void
-midori_search_entry_engines_add_item_cb (MidoriWebList*     web_list,
-                                         KatzeItem*     item,
+midori_search_entry_engines_add_item_cb (KatzeArray*        list,
+                                         KatzeItem*         item,
                                          MidoriSearchEntry* search_entry)
 {
     if (!search_entry->current_item)
@@ -225,7 +225,7 @@ midori_search_entry_engines_add_item_cb (MidoriWebList*     web_list,
 }
 
 static void
-midori_search_entry_engines_remove_item_cb (MidoriWebList*     web_list,
+midori_search_entry_engines_remove_item_cb (KatzeArray*        list,
                                             KatzeItem*         item,
                                             MidoriSearchEntry* search_entry)
 {
@@ -233,7 +233,7 @@ midori_search_entry_engines_remove_item_cb (MidoriWebList*     web_list,
 
     if (search_entry->current_item == item)
     {
-        found_item = midori_web_list_get_nth_item (web_list, 0);
+        found_item = katze_array_get_nth_item (list, 0);
         if (found_item)
             midori_search_entry_set_current_item (search_entry, found_item);
         else
@@ -251,7 +251,7 @@ midori_search_entry_engines_remove_item_cb (MidoriWebList*     web_list,
 static void
 midori_search_entry_init (MidoriSearchEntry* search_entry)
 {
-    search_entry->search_engines = midori_web_list_new ();
+    search_entry->search_engines = katze_array_new (KATZE_TYPE_ITEM);
     search_entry->current_item = NULL;
 
     gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (search_entry),
@@ -357,7 +357,7 @@ midori_search_entry_new (void)
  *
  * Return value: the list of search engines
  **/
-MidoriWebList*
+KatzeArray*
 midori_search_entry_get_search_engines (MidoriSearchEntry* search_entry)
 {
     g_return_val_if_fail (MIDORI_IS_SEARCH_ENTRY (search_entry), NULL);
@@ -374,9 +374,10 @@ midori_search_entry_get_search_engines (MidoriSearchEntry* search_entry)
  **/
 void
 midori_search_entry_set_search_engines (MidoriSearchEntry* search_entry,
-                                        MidoriWebList*     search_engines)
+                                        KatzeArray*        search_engines)
 {
     g_return_if_fail (MIDORI_IS_SEARCH_ENTRY (search_entry));
+    g_return_if_fail (katze_array_is_a (search_engines, KATZE_TYPE_ITEM));
 
     g_object_ref (search_engines);
     katze_object_assign (search_entry->search_engines, search_engines);
@@ -629,7 +630,7 @@ midori_search_entry_get_editor (GtkWidget* treeview,
 
         search_entry = g_object_get_data (G_OBJECT (treeview), "search-entry");
         if (new_engine)
-            midori_web_list_add_item (search_entry->search_engines, item);
+            katze_array_add_item (search_entry->search_engines, item);
     }
     gtk_widget_destroy (dialog);
 }
@@ -666,7 +667,7 @@ midori_search_entry_dialog_remove_cb (GtkWidget* widget,
     GtkTreeModel* liststore;
     GtkTreeIter iter;
     KatzeItem* item;
-    MidoriWebList* search_engines;
+    KatzeArray* search_engines;
 
     search_entry = g_object_get_data (G_OBJECT (treeview), "search-entry");
     search_engines = search_entry->search_engines;
@@ -674,7 +675,7 @@ midori_search_entry_dialog_remove_cb (GtkWidget* widget,
     if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
     {
         gtk_tree_model_get (liststore, &iter, 0, &item, -1);
-        midori_web_list_remove_item (search_engines, item);
+        katze_array_remove_item (search_engines, item);
         g_object_unref (item);
         /* FIXME: we want to allow undo of some kind */
     }
@@ -698,9 +699,9 @@ midori_search_entry_treeview_selection_cb (GtkTreeSelection* selection,
 }
 
 static void
-midori_search_entry_dialog_engines_add_item_cb (MidoriWebList* web_list,
-                                                KatzeItem*     item,
-                                                GtkWidget*     treeview)
+midori_search_entry_dialog_engines_add_item_cb (KatzeArray* list,
+                                                KatzeItem*  item,
+                                                GtkWidget*  treeview)
 {
     GtkTreeModel* liststore;
     GtkTreeIter iter;
@@ -711,9 +712,9 @@ midori_search_entry_dialog_engines_add_item_cb (MidoriWebList* web_list,
 }
 
 static void
-midori_search_entry_dialog_engines_remove_item_cb (MidoriWebList* web_list,
-                                                   KatzeItem*     item,
-                                                   GtkWidget*     treeview)
+midori_search_entry_dialog_engines_remove_item_cb (KatzeArray* list,
+                                                   KatzeItem*  item,
+                                                   GtkWidget*  treeview)
 {
     GtkTreeModel* liststore;
     GtkTreeIter iter;
@@ -838,10 +839,10 @@ midori_search_entry_get_dialog (MidoriSearchEntry* search_entry)
     gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
                                          GTK_SHADOW_IN);
     gtk_box_pack_start (GTK_BOX (hbox), scrolled, TRUE, TRUE, 5);
-    n = midori_web_list_get_length (search_entry->search_engines);
+    n = katze_array_get_length (search_entry->search_engines);
     for (i = 0; i < n; i++)
     {
-        item = midori_web_list_get_nth_item (search_entry->search_engines, i);
+        item = katze_array_get_nth_item (search_entry->search_engines, i);
         gtk_list_store_insert_with_values (GTK_LIST_STORE (liststore),
                                            NULL, i, 0, item, -1);
     }
index 30d33ae630ff95bbbf6b01dbef6dba003796170d..176f34d241ba84e102cb85d46781cbf384c38c32 100644 (file)
@@ -47,12 +47,12 @@ midori_search_entry_get_type               (void);
 GtkWidget*
 midori_search_entry_new                    (void);
 
-MidoriWebList*
+KatzeArray*
 midori_search_entry_get_search_engines     (MidoriSearchEntry*  search_entry);
 
 void
 midori_search_entry_set_search_engines     (MidoriSearchEntry*  search_entry,
-                                            MidoriWebList*      name);
+                                            KatzeArray*         name);
 
 KatzeItem*
 midori_search_entry_get_current_item       (MidoriSearchEntry*  search_entry);
index e85f052c2cc26796680932e45c2327ac727948ff..d28a83f062e3037a52e9257b1a6b3e361a26101c 100644 (file)
@@ -42,7 +42,7 @@ struct _MidoriWebView
     MidoriLoadStatus load_status;
     gchar* statusbar_text;
     gchar* link_uri;
-    MidoriWebList* news_feeds;
+    KatzeArray* news_feeds;
 
     MidoriWebSettings* settings;
 
@@ -487,7 +487,7 @@ gjs_value_links_foreach_cb (GjsValue*      link,
                 || !strcmp (type, "application/x.atom+xml")
                 || !strcmp (type, "application/atom+xml"))
             {
-                midori_web_list_add_item (web_view->news_feeds, link);
+                katze_array_add_item (web_view->news_feeds, link);
                 g_signal_emit (web_view, signals[NEWS_FEED_READY], 0,
                     gjs_value_get_attribute_string (link, "href"), type,
                     gjs_value_has_attribute (link, "title")
@@ -534,7 +534,7 @@ webkit_web_frame_load_done (WebKitWebFrame* web_frame,
     value = gjs_value_new (webkit_web_frame_get_global_context (web_frame), NULL);
     document = gjs_value_get_by_name (value, "document");
     links = gjs_value_get_elements_by_tag_name (document, "link");
-    midori_web_list_clear (web_view->news_feeds);
+    katze_array_clear (web_view->news_feeds);
     gjs_value_foreach (links, (GjsCallback)gjs_value_links_foreach_cb, web_view);
     g_object_unref (links);
     g_object_unref (document);
@@ -760,7 +760,7 @@ midori_web_view_init (MidoriWebView* web_view)
         GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
     web_view->progress = 0.0;
     web_view->load_status = MIDORI_LOAD_FINISHED;
-    web_view->news_feeds = midori_web_list_new ();
+    web_view->news_feeds = katze_array_new (GJS_TYPE_VALUE);
 
     web_view->settings = midori_web_settings_new ();
     g_object_set (web_view, "WebKitWebView::settings", web_view->settings, NULL);
@@ -1168,14 +1168,14 @@ midori_web_view_get_link_uri (MidoriWebView* web_view)
  * Retrieves a list of news feeds for the current page
  * or %NULL if there are no feeds at all.
  *
- * Return value: a #MidoriWebList, or %NULL
+ * Return value: a #KatzeArray, or %NULL
  **/
-MidoriWebList*
+KatzeArray*
 midori_web_view_get_news_feeds (MidoriWebView* web_view)
 {
     g_return_val_if_fail (MIDORI_IS_WEB_VIEW (web_view), NULL);
 
-    if (!midori_web_list_is_empty (web_view->news_feeds))
+    if (!katze_array_is_empty (web_view->news_feeds))
         return web_view->news_feeds;
     return NULL;
 }
index 76571c72de72752f498c55056c6ea9511ba9ce88..8773c1e4c0ef037a2c7733e04f67833127705c91 100644 (file)
@@ -114,7 +114,7 @@ midori_web_view_get_display_title      (MidoriWebView*     web_view);
 const gchar*
 midori_web_view_get_link_uri           (MidoriWebView*     web_view);
 
-MidoriWebList*
+KatzeArray*
 midori_web_view_get_news_feeds         (MidoriWebView*     web_view);
 
 gboolean
index 60ee1476f50510ca51356b764cca5986d53d7bea..58af4fd93d27a6061c78368fbc4571cf59109961 100644 (file)
@@ -80,8 +80,8 @@ sokoke_spawn_program (const gchar* command,
 }
 
 gchar*
-sokoke_magic_uri (const gchar*   uri,
-                  MidoriWebList* search_engines)
+sokoke_magic_uri (const gchar* uri,
+                  KatzeArray*  search_engines)
 {
     gchar* current_dir;
     gchar* result;
@@ -92,7 +92,7 @@ sokoke_magic_uri (const gchar*   uri,
 
     g_return_val_if_fail (uri, NULL);
     if (search_engines)
-        g_return_val_if_fail (MIDORI_IS_WEB_LIST (search_engines), NULL);
+        g_return_val_if_fail (katze_array_is_a (search_engines, KATZE_TYPE_ITEM), NULL);
 
     /* Add file:// if we have a local path */
     if (g_path_is_absolute (uri))
@@ -122,7 +122,7 @@ sokoke_magic_uri (const gchar*   uri,
         parts = g_strsplit (uri, " ", 2);
         if (parts[0] && parts[1])
         {
-            item = midori_web_list_find_token (search_engines, parts[0]);
+            item = katze_array_find_token (search_engines, parts[0]);
             if (item)
                 search_uri = katze_item_get_uri (item);
         }
index 873e3704254fd8df36d3acba784070d99a2199d5..a74c80ce170dfc10aae4cbeafca14f312773d5f7 100644 (file)
@@ -25,7 +25,7 @@ sokoke_spawn_program                (const gchar* command,
 
 gchar*
 sokoke_magic_uri                    (const gchar*    uri,
-                                     MidoriWebList*  search_engines);
+                                     KatzeArray*     search_engines);
 
 void
 sokoke_entry_setup_completion       (GtkEntry*       entry);
index 4f59301ed5b650e3bc1a57ab3f8ebe9246169e1d..e8ee9570941adf8b786c3b56f97fb9d588324880 100644 (file)
@@ -16,5 +16,6 @@ midori/gjs.c
 katze/katze-throbber.c
 katze/katze-utils.c
 katze/katze-item.c
-katze/katze-weblist.c
+katze/katze-list.c
+katze/katze-array.c
 katze/katze-xbel.c