Permalink
Browse files

Add TreeModal

  • Loading branch information...
1 parent ccffc3b commit 06c8611f94c9e41ecbf0f2d4323fae468a76186e @zcbenz committed Oct 19, 2011
Showing with 79 additions and 2 deletions.
  1. +4 −0 src/impl_glue_gtk.h
  2. +4 −2 src/node_gui.cc
  3. +56 −0 src/node_gui_tree_model.cc
  4. +15 −0 src/node_gui_tree_model.h
View
@@ -30,6 +30,10 @@ inline v8::Handle<v8::Value> glue (unsigned int i) {
return v8::Integer::NewFromUnsigned (i);
}
+inline v8::Handle<v8::Value> glue (long unsigned i) {
+ return v8::Integer::NewFromUnsigned (i);
+}
+
inline v8::Handle<v8::Value> glue (char *i) {
g_free (i);
return v8::String::New (i);
View
@@ -3,9 +3,10 @@
#include "node_gui_type.h"
#include "node_gui_clipboard.h"
#include "node_gui_object.h"
+#include "node_gui_tree_model.h"
#include "node_gui_tree_path.h"
-#include "node_gui_text_iter.h"
#include "node_gui_tree_iter.h"
+#include "node_gui_text_iter.h"
#include "node_gui_text_buffer.h"
#include "node_gui_list_store.h"
#include "node_gui_widget.h"
@@ -42,9 +43,10 @@ void Init (Handle<v8::Object> target) {
clip::Global::Init (target);
clip::Type::Init (target);
clip::Object::Init (target);
+ clip::TreeModel::Init (target);
clip::TreePath::Init (target);
- clip::TextIter::Init (target);
clip::TreeIter::Init (target);
+ clip::TextIter::Init (target);
clip::TextBuffer::Init (target);
clip::ListStore::Init (target);
clip::Clipboard::Init (target);
@@ -0,0 +1,56 @@
+#include "node_gui_tree_model.h"
+
+namespace clip {
+Persistent<FunctionTemplate> TreeModel::constructor_template;
+
+void TreeModel::Init (Handle<v8::Object> target) {
+ ATTACH_CONSTRUCTOR ("TreeModel", TreeModel, (Constructor<TreeModel>));
+
+ DEFINE_NODE_METHOD ("getValue", GetValue);
+
+ GETTER_METHOD (TreeModel, "getNColumns", gtk_tree_model_get_n_columns, gint);
+
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "getColumnType" , (GetterMethod<GType , gint , GtkTreeModel , gtk_tree_model_get_column_type> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "getIter" , (GetterMethod<gboolean , GtkTreeIter * , GtkTreePath * , GtkTreeModel , gtk_tree_model_get_iter> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "getIterFromString" , (GetterMethod<gboolean , GtkTreeIter * , const gchar * , GtkTreeModel , gtk_tree_model_get_iter_from_string> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "getIterFirst" , (GetterMethod<gboolean , GtkTreeIter * , GtkTreeModel , gtk_tree_model_get_iter_first> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "getPath" , (GetterMethod<GtkTreePath * , GtkTreeIter * , GtkTreeModel , gtk_tree_model_get_path> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "iterNext" , (GetterMethod<gboolean , GtkTreeIter * , GtkTreeModel , gtk_tree_model_iter_next> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "iterChildren" , (GetterMethod<gboolean , GtkTreeIter * , GtkTreeIter * , GtkTreeModel , gtk_tree_model_iter_children> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "hasChild" , (GetterMethod<gboolean , GtkTreeIter * , GtkTreeModel , gtk_tree_model_iter_has_child> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "nChildren" , (GetterMethod<gint , GtkTreeIter * , GtkTreeModel , gtk_tree_model_iter_n_children> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "iterParent" , (GetterMethod<gboolean , GtkTreeIter * , GtkTreeIter * , GtkTreeModel , gtk_tree_model_iter_parent> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "getStringFromIter" , (GetterMethod<gchar * , GtkTreeIter * , GtkTreeModel , gtk_tree_model_get_string_from_iter> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "rowChanged" , (SetterMethod<GtkTreePath * , GtkTreeIter * , GtkTreeModel , gtk_tree_model_row_changed> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "rowInserted" , (SetterMethod<GtkTreePath * , GtkTreeIter * , GtkTreeModel , gtk_tree_model_row_inserted> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "rowHasChildToggled" , (SetterMethod<GtkTreePath * , GtkTreeIter * , GtkTreeModel , gtk_tree_model_row_has_child_toggled> )) ;
+ NODE_SET_PROTOTYPE_METHOD (constructor_template , "rowDeleted" , (SetterMethod<GtkTreePath * , GtkTreeModel , gtk_tree_model_row_deleted> )) ;
+
+ END_CONSTRUCTOR ();
+}
+
+Handle<Value> TreeModel::GetValue (const Arguments& args) {
+ HandleScope scope;
+
+ if (args.Length () != 2)
+ return THROW_BAD_ARGS;
+
+ GValue value = { 0 };
+
+ GtkTreeModel *obj = glue<GtkTreeModel> (args.This ());
+ GtkTreeIter *iter = static_cast<GtkTreeIter *> (
+ Local<v8::Object>::Cast (args[0])->GetPointerFromInternalField(0));
+ int column = args[1]->Int32Value ();
+
+ gdk_threads_enter ();
+ gtk_tree_model_get_value (obj, iter, column, &value);
+ gdk_threads_leave ();
+
+ Handle<Value> result = glue (&value);
+
+ g_value_unset (&value);
+
+ return scope.Close (result);
+}
+} /* clip */
+
@@ -0,0 +1,15 @@
+#ifndef NODE_GUI_TREE_MODEL_H
+#define NODE_GUI_TREE_MODEL_H
+
+#include "node_gui_object.h"
+
+namespace clip {
+class TreeModel: public Object {
+DECLARE_NODE_OBJECT (TreeModel);
+
+protected:
+ DEFINE_CPP_METHOD (GetValue);
+};
+} /* clip */
+
+#endif /* end of NODE_GUI_TREE_MODEL_H */

0 comments on commit 06c8611

Please sign in to comment.