[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-gtk-cvs
Subject:    [php-gtk-cvs] com gtk/php-gtk: Framework for custom tree models.: ext/gtk+/config.m4 =?UTF-8?Q?ext/g
From:       David Soria Parra <dsp () php ! net>
Date:       2006-09-23 19:35:41
Message-ID: php-mail-f64a98c3aa4c51623781ab2c41077ba6735101062 () git ! php ! net
[Download RAW message or body]

Commit:    f6d69ad395e8ca02c2c7a97dd99f1c61f17983e4
Author:    Andrei Zmievski <andrei@php.net>         Sat, 23 Sep 2006 19:35:41 +0000
Parents:   00bf1efa66f9ea30fb37ecb32907a3b27c0d1564
Branches:  master

Link:       http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=f6d69ad395e8ca02c2c7a97dd99f1c61f17983e4

Log:
Framework for custom tree models.

Changed paths:
  M  ext/gtk+/config.m4
  M  ext/gtk+/php_gtk+.c
  A  ext/gtk+/phpg_custom_tree_model.c
  A  ext/gtk+/phpg_custom_tree_model.h


["diff_f6d69ad395e8ca02c2c7a97dd99f1c61f17983e4.txt" (text/plain)]

f6d69ad395e8ca02c2c7a97dd99f1c61f17983e4
diff --git a/ext/gtk+/config.m4 b/ext/gtk+/config.m4
index babcfdc..8ec534d 100644
--- a/ext/gtk+/config.m4
+++ b/ext/gtk+/config.m4
@@ -28,4 +28,4 @@ PHP_EVAL_LIBLINE($PANGO_LIBS, PHP_GTK2_SHARED_LIBADD)
 
 PHP_SUBST(PHP_GTK2_SHARED_LIBADD)
 
-PHP_GTK_EXTENSION([gtk+], no, [php_gtk+.c], [gen_atk.c gen_pango.c gen_gdk.c \
gen_gtk.c php_gdk.c php_gtk+_types.c]) +PHP_GTK_EXTENSION([gtk+], no, [php_gtk+.c], \
[gen_atk.c gen_pango.c gen_gdk.c gen_gtk.c php_gdk.c php_gtk+_types.c \
                phpg_custom_tree_model.c])
diff --git a/ext/gtk+/php_gtk+.c b/ext/gtk+/php_gtk+.c
index e4a47bb..c2eddf5 100644
--- a/ext/gtk+/php_gtk+.c
+++ b/ext/gtk+/php_gtk+.c
@@ -1,7 +1,7 @@
 /*
  * PHP-GTK - The PHP language bindings for GTK+
  *
- * Copyright (C) 2001,2002 Andrei Zmievski <andrei@php.net>
+ * Copyright (C) 2001-2006 Andrei Zmievski <andrei@php.net>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/ext/gtk+/phpg_custom_tree_model.c b/ext/gtk+/phpg_custom_tree_model.c
new file mode 100644
index 0000000..f983f6b
--- /dev/null
+++ b/ext/gtk+/phpg_custom_tree_model.c
@@ -0,0 +1,126 @@
+/*
+ * PHP-GTK - The PHP language bindings for GTK+
+ *
+ * Copyright (C) 2001-2006 Andrei Zmievski <andrei@php.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 2.1 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+ 
+/* $Id$: */
+
+#include "php_gtk.h"
+
+#if HAVE_PHP_GTK
+
+#include "phpg_custom_tree_model.h"
+
+static void phpg_custom_tree_model_class_init(PhpGtkCustomTreeModelClass *klass);
+static void phpg_custom_tree_model_init(PhpGtkCustomTreeModel *self);
+static void phpg_custom_tree_model_iface_init(GtkTreeModelIface *iface);
+
+GType
+phpg_custom_tree_model_get_type(void)
+{   
+    static GType object_type = 0;
+
+    if (!object_type) {
+    static const GTypeInfo object_info = {
+        sizeof(PhpGtkCustomTreeModelClass),
+        (GBaseInitFunc) NULL,
+        (GBaseFinalizeFunc) NULL,
+        (GClassInitFunc) phpg_custom_tree_model_class_init,
+        NULL, /* class_finalize */
+        NULL, /* class_data */
+        sizeof(PhpGtkCustomTreeModel),
+        0, /* n_preallocs */
+        (GInstanceInitFunc) phpg_custom_tree_model_init,
+    };
+    static const GInterfaceInfo tree_model_info = {
+        (GInterfaceInitFunc) phpg_custom_tree_model_iface_init,
+        NULL,
+        NULL,
+    };
+
+    object_type = g_type_register_static(G_TYPE_OBJECT,
+                         "PhpGtkCustomTreeModel",
+                         &object_info, 0);
+    g_type_add_interface_static(object_type,
+                    GTK_TYPE_TREE_MODEL,
+                    &tree_model_info);
+    }
+    return object_type;
+}
+
+static guint phpg_custom_tree_model_get_flags(GtkTreeModel *tree_model);
+static gint phpg_custom_tree_model_get_n_columns(GtkTreeModel *tree_model);
+static GType phpg_custom_tree_model_get_column_type(GtkTreeModel *tree_model, gint \
index); +static gboolean phpg_custom_tree_model_get_iter(GtkTreeModel *tree_model,
+												GtkTreeIter *iter,
+												GtkTreePath *path);
+static GtkTreePath *phpg_custom_tree_model_get_path(GtkTreeModel *tree_model,
+													GtkTreeIter *iter);
+static void phpg_custom_tree_model_get_value(GtkTreeModel*tree_model,
+											 GtkTreeIter *iter,
+											 gint column, GValue *value);
+static gboolean phpg_custom_tree_model_iter_next(GtkTreeModel *tree_model,
+												 GtkTreeIter *iter);
+static gboolean phpg_custom_tree_model_iter_children(GtkTreeModel *tree_model,
+													 GtkTreeIter *iter,
+													 GtkTreeIter *parent);
+static gboolean phpg_custom_tree_model_iter_has_child(GtkTreeModel *tree_model,
+													  GtkTreeIter *iter);
+static gint phpg_custom_tree_model_iter_n_children(GtkTreeModel *tree_model,
+												   GtkTreeIter *iter);
+static gboolean phpg_custom_tree_model_iter_nth_child(GtkTreeModel *tree_model,
+													  GtkTreeIter  *iter,
+													  GtkTreeIter  *parent,
+													  gint n);
+static gboolean phpg_custom_tree_model_iter_parent(GtkTreeModel *tree_model,
+												   GtkTreeIter *iter,
+												   GtkTreeIter *child);
+static void phpg_custom_tree_model_unref_node(GtkTreeModel *tree_model,
+											  GtkTreeIter *iter);
+static void phpg_custom_tree_model_ref_node(GtkTreeModel *tree_model,
+											GtkTreeIter *iter);
+
+static void
+phpg_custom_tree_model_iface_init(GtkTreeModelIface *iface)
+{ 
+  iface->get_flags = phpg_custom_tree_model_get_flags;
+  iface->get_n_columns = phpg_custom_tree_model_get_n_columns;
+  iface->get_column_type = phpg_custom_tree_model_get_column_type;
+  iface->get_iter = phpg_custom_tree_model_get_iter;
+  iface->get_path = phpg_custom_tree_model_get_path;
+  iface->get_value = phpg_custom_tree_model_get_value;
+  iface->iter_next = phpg_custom_tree_model_iter_next;
+  iface->iter_children = phpg_custom_tree_model_iter_children;
+  iface->iter_has_child = phpg_custom_tree_model_iter_has_child;
+  iface->iter_n_children = phpg_custom_tree_model_iter_n_children;
+  iface->iter_nth_child = phpg_custom_tree_model_iter_nth_child;
+  iface->iter_parent = phpg_custom_tree_model_iter_parent;
+  iface->ref_node = phpg_custom_tree_model_ref_node;
+  iface->unref_node = phpg_custom_tree_model_unref_node;
+}
+
+static void
+phpg_custom_tree_model_init(PhpGtkCustomTreeModel *self)
+{
+	do {
+		self->stamp = g_random_int();
+	} while (self->stamp == 0);
+}
+
+
+#endif
diff --git a/ext/gtk+/phpg_custom_tree_model.h b/ext/gtk+/phpg_custom_tree_model.h
new file mode 100644
index 0000000..fdb5eb3
--- /dev/null
+++ b/ext/gtk+/phpg_custom_tree_model.h
@@ -0,0 +1,49 @@
+/*
+ * PHP-GTK - The PHP language bindings for GTK+
+ *
+ * Copyright (C) 2001-2006 Andrei Zmievski <andrei@php.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 2.1 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+ 
+/* $Id$: */
+
+#include <gtk/gtktreemodel.h>
+
+#define PHPG_TYPE_CUSTOM_TREE_MODEL            (pygtk_custom_tree_model_get_type())
+#define PHPG_CUSTOM_TREE_MODEL(object)         (G_TYPE_CHECK_INSTANCE_CAST((object), \
PHPG_TYPE_CUSTOM_TREE_MODEL, PhpGtkCustomTreeModel)) +#define \
PHPG_CUSTOM_TREE_MODEL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), \
PHPG_TYPE_CUSTOM_TREE_MODEL, PhpGtkCustomTreeModelClass)) +#define \
PHPG_IS_CUSTOM_TREE_MODEL(object)      (G_TYPE_CHECK_INSTANCE_TYPE((object), \
PHPG_TYPE_CUSTOM_TREE_MODEL)) +#define PHPG_IS_CUSTOM_TREE_MODEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), PHPG_TYPE_CUSTOM_TREE_MODEL)) +#define \
PHPG_CUSTOM_TREE_MODEL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), \
PHPG_TYPE_CUSTOM_TREE_MODEL, PhpGtkCustomTreeModelClass)) +
+typedef struct _PhpGtkCustomTreeModel PhpGtkCustomTreeModel;
+typedef struct _PhpGtkCustomTreeModelClass PhpGtkCustomTreeModelClass;
+
+struct _PhpGtkCustomTreeModel {
+    GObject parent_instance;
+
+    gint stamp;
+};
+
+struct _PhpGtkCustomTreeModelClass {
+    GObjectClass parent_class;
+};
+
+GType                   phpg_custom_tree_model_get_type (void);
+PhpGtkCustomTreeModel * phpg_custom_tree_model_new      (void);
+void                    \
phpg_custom_tree_model_invalidate_iters(PhpGtkCustomTreeModel *); +gboolean           \
phpg_custom_tree_model_iter_is_valid(PhpGtkCustomTreeModel *, GtkTreeIter *); +



-- 
PHP-GTK CVS Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic