Re: Gtk::TreeView



Vladimir,

I've attached two files. They're both essentially the same thing that
you pasted, but changed a bit to make them compile without the rest of
your code.

Try compiling and running them and let me know if they produce the
errors you're getting with your code.

better.cc is the same program implemented slightly differently using
stack allocation and inheritance. Both being 'Good Things (TM)' in
this case.

Paul

On 12/18/06, Vladimir Đokić <v djokic gmail com> wrote:
Hi all,

Here's the code snip (from various files):

int main(int argc, char* argv[])
{
    Gtk::Main kit(argc, argv);

    u1::Editor* editor = new u1::Editor();
    editor->Init();

    Gtk::Main::run(editor->GetWindow());

    delete editor;

    return 0;
}

class Editor
{
public:
    Editor()
        : mWindow(NULL)
    { /* void */ }

    ~Editor()
    { delete mWindow; }

     void Init()
    {
       ...

        Glib::RefPtr<Gnome::Glade::Xml> xml =
Gnome::Glade::Xml::create("Ui/u1Editor.glade");
        xml->get_widget("u1Window", mWindow);

        ...
        Gtk::TreeView* tree_view = NULL;
        xml->get_widget("u1TreeView", tree_view);

        mTreeModel = Gtk::TreeStore::create(mTreeColumns);
        tree_view->set_model(mTreeModel);

        Gtk::TreeModel::Row row = *(mTreeModel->append());
        row[mTreeColumns.mNodeName] = "Root";

        tree_view.append_column("Nodes",
mTreeColumns.mNodeName );
    }

private:
    void OnQuit() // <-- executed from menu bar
    {
        Gtk::Main::quit();
    }

    class TreeColumns : public Gtk::TreeModel::ColumnRecord
    {
     public:

    ModelColumns()
    { add(mNodeName); }

        Gtk::TreeModelColumn<Glib::ustring> mNodeName;
    };

    TreeColumn mTreeColumns;
    Glib::RefPtr<Gtk::TreeStore> mTreeModel;

    Gtk::Window*   mWindow;

};



Hope this will make more sense,

Vladimir.


On 12/18/06, Vladimir Đokić <v djokic gmail com > wrote:
> Hi all,
>
> Unfortunately, since I'm using binary distribution of gtkmm, I'm unable to
step into destruction of Gtk::Window. I've just noticed that I'm using
Multithreaded Debug DLL (and don't know how gtkmm on windows was built), so
I'll try changing these values... I'll post code later, when I get home
(thought the code follows documentation and examples).
>
>
>
> Thanks,
>
> Vladimir.
>
>
> On 12/18/06, Paul Davis < pjdavis engineering uiowa edu> wrote:
> > Vladimir,
> >
> > Could you paste the tree view code you're using.
> >
> > And what is the heap message?  I don't know much about Visual Studio,
> > so if this is some standard error I can only assume its the equivalent
> > of a segfault.
> >
> > Does Visual Studio have a debugger so you can see which line is
> > causing this error?
> >
> > Paul
> >
> > On 12/18/06, Vladimir Đokić < v djokic gmail com> wrote:
> > > Hi all,
> > >
> > > I'm loading everything but the treemodel from the .glade file using
> > > libglademm. For the creation of model and model data columns I'm using
> > > example code from the gtkmm book. The window pointer I'm getting is
valid
> > > (points to Gtk::Window data) as well as the treeview pointer (but I'm
only
> > > deleting window, since all other widgets are managed and will be
deleted as
> > > children of window). I also noticed that nodes are showing some bad
> > > behavior: Only last node is shown as root (top), and the when I click
to
> > > expand the node, nothing shows (empty). The binaries of gtkmm are from
> > > http://www.pcpm.ucl.ac.be/~gustin/win32_ports/. I've
double
> > > checked the code. When the deletion of window occurs the heap error
message
> > > is issued by the visual studio. In the end, I can cook up small
example of
> > > this - if needed.
> > >
> > > Thanks,
> > >
> > > Vladimir.
> > >
> > > On 12/18/06, Paul Davis < pjdavis engineering uiowa edu> wrote:
> > > > Vladimir,
> > > >
> > > > Could you be a tad bit more specific on the problem you're having?
> > > >
> > > > Paul
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > >
> > > "There's no room for ideals in this mechanical place. There has to be
> > > passion. "
> > > _______________________________________________
> > > gtkmm-list mailing list
> > > gtkmm-list gnome org
> > > http://mail.gnome.org/mailman/listinfo/gtkmm-list
> > >
> > >
> > >
> >
>
>
>
> --
>
> "There's no room for ideals in this mechanical place. There has to be
passion. "



--

"There's no room for ideals in this mechanical place. There has to be
passion. "
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



/*
 * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *
 * Author:    Paul Davis pjdavis engineering uiowa edu
 * Copyright: University of Iowa 2006
 *
 * Filename:  test.cc
 * Created:   2006-Dec-18 02:50:36 PM
 * Modified:  2006-Dec-18 03:00:44 PM
*/

#include <gtkmm.h>

class Editor
{
	public:
	    Editor()
		{
		}

		~Editor()
		{
			delete mWindow;
		}

		void
		Init()
    	{
			mWindow = new Gtk::Window() ;

        	Gtk::TreeView* tree_view = Gtk::manage( new Gtk::TreeView() ) ;
			mWindow->add( *tree_view ) ;

        	mTreeModel = Gtk::TreeStore::create(mTreeColumns);
        	tree_view->set_model(mTreeModel);

        	Gtk::TreeModel::Row row = *(mTreeModel->append());
        	row[mTreeColumns.mNodeName] = "Root";

        	tree_view->append_column("Nodes", mTreeColumns.mNodeName );

			mWindow->show_all_children() ;
    	}

		Gtk::Window*
		GetWindow() { return mWindow ; }

	private:
	    void OnQuit() // <-- executed from menu bar
	    {
	        Gtk::Main::quit();
	    }

    	class TreeColumns : public Gtk::TreeModel::ColumnRecord
    	{
    		public:

    			TreeColumns()
    			{
					add(mNodeName);
				}

        		Gtk::TreeModelColumn<Glib::ustring> mNodeName;
    	} ;

    	TreeColumns mTreeColumns;
    	Glib::RefPtr<Gtk::TreeStore> mTreeModel;

    	Gtk::Window*   mWindow;   
};


int
main(int argc, char* argv[])
{
    Gtk::Main kit(argc, argv);

    Editor* editor = new Editor();
    editor->Init() ;

    Gtk::Main::run( *( editor->GetWindow() ) );

    delete editor;

    return 0;
}

/*
 * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *
 * Author:    Paul Davis pjdavis engineering uiowa edu
 * Copyright: University of Iowa 2006
 *
 * Filename:  good.cc
 * Created:   2006-Dec-18 02:50:36 PM
 * Modified:  2006-Dec-18 03:12:13 PM
*/

#include <gtkmm.h>

class Editor : public Gtk::Window
{
	public:
	    Editor()
		{
        	Gtk::TreeView* tree_view = Gtk::manage( new Gtk::TreeView() ) ;
			add( *tree_view ) ;

        	mTreeModel = Gtk::TreeStore::create(mTreeColumns);
        	tree_view->set_model(mTreeModel);

        	Gtk::TreeModel::Row row = *(mTreeModel->append());
        	row[mTreeColumns.mNodeName] = "Root";

        	tree_view->append_column("Nodes", mTreeColumns.mNodeName );

			show_all_children() ;
    	}

	private:
    	class TreeColumns : public Gtk::TreeModel::ColumnRecord
    	{
    		public:

    			TreeColumns()
    			{
					add(mNodeName);
				}

        		Gtk::TreeModelColumn<Glib::ustring> mNodeName;
    	} ;

    	TreeColumns mTreeColumns;
    	Glib::RefPtr<Gtk::TreeStore> mTreeModel;
} ;

int
main(int argc, char* argv[])
{
	Gtk::Main kit(argc, argv);

	Editor e ;
	Gtk::Main::run( e );

	return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]