]> spindle.queued.net Git - midori/commitdiff
Add the boilerplate for MidoriBookmarkStore
authorChristian Dywan <christian@twotoasts.de>
Tue, 9 Jun 2009 00:59:29 +0000 (02:59 +0200)
committerChristian Dywan <christian@twotoasts.de>
Tue, 9 Jun 2009 00:59:29 +0000 (02:59 +0200)
panels/midori-bookmark-store.c [new file with mode: 0644]
panels/midori-bookmark-store.h [new file with mode: 0644]
panels/midori-bookmarks.c

diff --git a/panels/midori-bookmark-store.c b/panels/midori-bookmark-store.c
new file mode 100644 (file)
index 0000000..da40177
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ Copyright (C) 2009 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 "midori-bookmark-store.h"
+
+struct _MidoriBookmarkStore
+{
+    GtkTreeStore parent_instance;
+};
+
+struct _MidoriBookmarkStoreClass
+{
+    GtkTreeStoreClass parent_class;
+};
+
+static void
+midori_bookmark_store_drag_source_iface_init (GtkTreeDragSourceIface* iface);
+
+static void
+midori_bookmark_store_drag_dest_iface_init (GtkTreeDragDestIface* iface);
+
+G_DEFINE_TYPE_WITH_CODE (MidoriBookmarkStore, midori_bookmark_store, GTK_TYPE_TREE_STORE,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE,
+                                                midori_bookmark_store_drag_source_iface_init)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_DEST,
+                                                midori_bookmark_store_drag_dest_iface_init));
+
+static void
+midori_bookmark_store_finalize (GObject* object);
+
+static void
+midori_bookmark_store_class_init (MidoriBookmarkStoreClass* class)
+{
+    GObjectClass* gobject_class;
+
+    gobject_class = G_OBJECT_CLASS (class);
+    gobject_class->finalize = midori_bookmark_store_finalize;
+}
+
+static void
+midori_bookmark_store_init (MidoriBookmarkStore* bookmark_store)
+{
+    /* Nothing to do */
+}
+
+static void
+midori_bookmark_store_finalize (GObject* object)
+{
+    MidoriBookmarkStore* bookmark_store = MIDORI_BOOKMARK_STORE (object);
+
+    /* Nothing to do */
+}
+
+static void
+midori_bookmark_store_drag_source_iface_init (GtkTreeDragSourceIface* iface)
+{
+  /*iface->row_draggable = real_gtk_tree_store_row_draggable;
+  iface->drag_data_delete = gtk_tree_store_drag_data_delete;
+  iface->drag_data_get = gtk_tree_store_drag_data_get;*/
+}
+
+static void
+midori_bookmark_store_drag_dest_iface_init (GtkTreeDragDestIface* iface)
+{
+  /*iface->drag_data_received = gtk_tree_store_drag_data_received;
+  iface->row_drop_possible = gtk_tree_store_row_drop_possible;*/
+}
+
+/**
+ * midori_bookmark_store_new:
+ *
+ * Creates a new empty bookmark_store.
+ *
+ * Return value: a new #MidoriBookmarkStore
+ *
+ * Since: 0.1.8
+ **/
+GtkTreeStore*
+midori_bookmark_store_new (gint n_columns,
+                           ...)
+{
+    GtkTreeStore* treestore;
+    va_list args;
+    gint i;
+    GType* types;
+
+    g_return_val_if_fail (n_columns > 0, NULL);
+
+    treestore = g_object_new (GTK_TYPE_TREE_STORE, NULL);
+
+    va_start (args, n_columns);
+
+    types = g_new (gint, n_columns);
+    for (i = 0; i < n_columns; i++)
+    {
+        GType type = va_arg (args, GType);
+        types[i] = type;
+    }
+    va_end (args);
+
+    gtk_tree_store_set_column_types (treestore, i, types);
+
+    return treestore;
+}
diff --git a/panels/midori-bookmark-store.h b/panels/midori-bookmark-store.h
new file mode 100644 (file)
index 0000000..ee6a3d5
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2009 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_BOOKMARK_STORE_H__
+#define __MIDORI_BOOKMARK_STORE_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define MIDORI_TYPE_BOOKMARK_STORE \
+    (midori_bookmark_store_get_type ())
+#define MIDORI_BOOKMARK_STORE(obj) \
+    (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_BOOKMARK_STORE, MidoriBookmarkStore))
+#define MIDORI_BOOKMARK_STORE_CLASS(klass) \
+    (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_BOOKMARK_STORE, MidoriBookmarkStoreClass))
+#define MIDORI_IS_BOOKMARK_STORE(obj) \
+    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_BOOKMARK_STORE))
+#define MIDORI_IS_BOOKMARK_STORE_CLASS(klass) \
+    (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_BOOKMARK_STORE))
+#define MIDORI_BOOKMARK_STORE_GET_CLASS(obj) \
+    (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_BOOKMARK_STORE, MidoriBookmarkStoreClass))
+
+typedef struct _MidoriBookmarkStore                MidoriBookmarkStore;
+typedef struct _MidoriBookmarkStoreClass           MidoriBookmarkStoreClass;
+
+GType
+midori_bookmark_store_get_type               (void);
+
+GtkTreeStore*
+midori_bookmark_store_new                    (gint n_columns,
+                                              ...);
+
+G_END_DECLS
+
+#endif /* __MIDORI_BOOKMARK_STORE_H__ */
index 123b0ea8d238886aaa4e32d89e4660f80ec6f645..cafadfba33e162c99cba12ea73e5c2c68cd5e73c 100644 (file)
@@ -894,7 +894,7 @@ midori_bookmarks_init (MidoriBookmarks* bookmarks)
     bookmarks->net = katze_net_new ();
 
     /* Create the treeview */
-    model = gtk_tree_store_new (1, KATZE_TYPE_ITEM);
+    model = midori_bookmark_store_new (1, KATZE_TYPE_ITEM);
     treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
     column = gtk_tree_view_column_new ();