libseed-list seed && GtkTreeSelection
- From: tsr <tsr offentlig tsr se>
- To: libseed-list gnome org
- Subject: libseed-list seed && GtkTreeSelection
- Date: Tue, 25 May 2010 17:20:29 +0200
Hi,
First off, I don't know much of JS or Gtk but still I'm trying to use
seed to create a basic desktop editor.
(I've chosen this combination cause I hope to eventually be able to
replicate it for the web later on and using JS for the logic in both
places might save me some coding - that is the idea anyway)
Anyhow, I've managed to set up a GtkTreeView that recursively displays
the files and folders from a given folder. I have also managed to catch
the event of one row being selected. Now I have trouble using that
select-event to show the contents of the file (/folder) in a separate
panel.
Below is my code (I've built the interface with glade, so I think you
should be able to follow my intentions without a full glade file)
The problem is dealing with the
Gtk.TreeSelection.get_selected()-function (see the show_file-function
below). I don't understand what the first argument should be, I've tried
almost any combination of things but I (almost) always get:
(seed:17195): GLib-GObject-CRITICAL **: g_object_get_qdata: assertion
`G_IS_OBJECT (object)' failed
Fallo de segmentación (in english: ~ segmentation fault)
I've installed seed from the ubuntu-repos and they show version 2.28
(haven't dist-upgraded from Jaunty)
If you need any more info to be able to help me I am ofc willing to give
that.
Oh, while I'm here, is there any generic way of getting information out
of seed_struct-object? It would help me to debug things and keep moving
slowly forward).
I am not on the list, so please cc me (but I will check the archives so
you don't have to).
/Tomas
-- code ----------
#!/usr/bin/env seed
var Gtk = imports.gi.Gtk;
var GtkBuilder = imports.gtkbuilder;
var Gio = imports.gi.Gio;
function populate_tree(tree, tree_piter, file) {
var tree_iter = new Gtk.TreeIter();
var file_iter = file.enumerate_children("standard::*");
while (finfo = file_iter.next_file()) {
tree.append(tree_iter, tree_piter);
tree.set_value(tree_iter, 0, finfo.get_display_name(), "/fake", 0);
if (finfo.get_content_type() == "inode/directory") {
populate_tree(tree, tree_iter, file.get_child(finfo.get_name()));
}
}
}
function show_file() {
iter = new Gtk.TreeIter();
/* This is the problematic part */
tree_selection.get_selected(tree_view, iter);
/* What should I do here? */
}
Gtk.init(Seed.argv);
builder = new Gtk.Builder();
builder.add_from_file("basic_gui.glade");
window = builder.get_object("window1");
window.signal.hide.connect(Gtk.main_quit);
tree = builder.get_object("treestore1");
tree_view = builder.get_object("treeview1");
tree_selection = tree_view.get_selection();
tree_selection.signal.changed.connect(show_file);
basedir = Gio.file_new_for_path("./files");
populate_tree(tree, null, basedir);
window.show_all();
Gtk.main();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]