Need to get the tree view from the model

View: New views
5 Messages — Rating Filter:   Alert me  

Need to get the tree view from the model

by dhkuhl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What is the most direct way to get the tree view from the tree model?  I
don't see a function for doing this.

Also, when I went to the source, GtkTreeModel is defined a follows:
typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */

Why is it called a "Dummy typedef" and why can't I find the structure
for it?

Thanks,

Dave
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Need to get the tree view from the model

by rpoe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The answer to your second question: A dummy typedef means you
can't find the structure for it. :-) The *.h file is merely saying
that the typedef is a shorthand for a given structure. The actual
structure is private, not intended to be seen by users of the *.h
file.

The intent is to force you to go through accessor functions. Those
functions will reside in a source code that contains the actual
definition of the structure. The idea is to prevent users from
directly accessing fields in that structure. Accessor functions
allow the author to force any safety measures or bookkeeping that
may be required. Also, the user needn't worry about the names
of fields in the structure and the author is free to add, delete,
or rename them without affecting the interface.

As for your first question, the reason you can't get "the"
tree view from the model is that models can be attached to
arbitrarily many views, which will all update when the model
is changed.

You will have to provide the linkage yourself. The easiest way
is probably to provide the model as an additional parameter
in your callbacks (notice that most have an argument for
"user data".

                        Randy


dhk wrote:

> What is the most direct way to get the tree view from the tree model?  I
> don't see a function for doing this.
>
> Also, when I went to the source, GtkTreeModel is defined a follows:
> typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */
>
> Why is it called a "Dummy typedef" and why can't I find the structure
> for it?
>
> Thanks,
>
> Dave

--
Randall Poe (randall.c.poe@...)
Senior Member Engineering Staff
Lockheed Martin Advanced Technology Laboratory
Sixth Floor, 3 Executive Campus
Cherry Hill, NJ 08002

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Need to get the tree view from the model

by Emmanuele Bassi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2008-09-17 at 13:48 +0000, dhk wrote:
> What is the most direct way to get the tree view from the tree model?  I
> don't see a function for doing this.

it wouldn't make any sense.

a model can be used as the data source for many TreeView widgets.

> Also, when I went to the source, GtkTreeModel is defined a follows:
> typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */
>
> Why is it called a "Dummy typedef" and why can't I find the structure
> for it?

there is no data structure: GtkTreeModel is an interface. the dummy
typedef is there just for type casting purposes.

ciao,
 Emmanuele.

--
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Need to get the tree view from the model

by dhkuhl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Emmanuele Bassi wrote:

> On Wed, 2008-09-17 at 13:48 +0000, dhk wrote:
>> What is the most direct way to get the tree view from the tree model?  I
>> don't see a function for doing this.
>
> it wouldn't make any sense.
>
> a model can be used as the data source for many TreeView widgets.
>
>> Also, when I went to the source, GtkTreeModel is defined a follows:
>> typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */
>>
>> Why is it called a "Dummy typedef" and why can't I find the structure
>> for it?
>
> there is no data structure: GtkTreeModel is an interface. the dummy
> typedef is there just for type casting purposes.
>
> ciao,
>  Emmanuele.
>
I have different treeviews that use the same model, each on a notebook
tabs.  Whenever a row is added I call gtk_tree_model_foreach(), which
passes in the model, to get the highest line number (user_data is used
to pass back the number).  My GtkTreeModelForeachFunc function uses a
static variable to keep track of the highest number.  The problem is if
the user switches tabs I need to reset the static variable since the
treview changed.

What I think I'll do is after the gtk_tree_model_foreach() call when I
get my line number I'll call my GtkTreeModelForeachFunc with NULLs which
  will reset my static variable.  That should be acceptable.

Thanks all,
Dave




_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Need to get the tree view from the model

by rpoe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

dhk wrote:

> > Emmanuele Bassi wrote:
>> >> On Wed, 2008-09-17 at 13:48 +0000, dhk wrote:
>>> >>> What is the most direct way to get the tree view from the tree
>>> >>> model?  I don't see a function for doing this.
>> >>
>> >> it wouldn't make any sense.
>> >>
>> >> a model can be used as the data source for many TreeView widgets.
>> >>
>>> >>> Also, when I went to the source, GtkTreeModel is defined a follows:
>>> >>> typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */
>>> >>>
>>> >>> Why is it called a "Dummy typedef" and why can't I find the
structure

>>> >>> for it?
>> >>
>> >> there is no data structure: GtkTreeModel is an interface. the dummy
>> >> typedef is there just for type casting purposes.
>> >>
>> >> ciao,
>> >>  Emmanuele.
>> >>
> > I have different treeviews that use the same model, each on a notebook
> > tabs.  Whenever a row is added I call gtk_tree_model_foreach(), which
> > passes in the model, to get the highest line number (user_data is used
> > to pass back the number).  My GtkTreeModelForeachFunc function uses a
> > static variable to keep track of the highest number.  The problem is if
> > the user switches tabs I need to reset the static variable since the
> > treview changed.

This doesn't sound like a very good design, since as you notice
this function can be called by any of the views, in no
predictable order.

If this highest line number is something the tree view needs to
keep track of, then perhaps code associated with the tree
view, not the tree model needs to keep track of it. For
instance, keep a structure like

struct mystruct {
   GtkTreeModel *model;
   int highest_row;
}

and pass a pointer to that to your function instead.


--
Randall Poe (randall.c.poe@...)
Senior Member Engineering Staff
Lockheed Martin Advanced Technology Laboratory
Sixth Floor, 3 Executive Campus
Cherry Hill, NJ 08002
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
LightInTheBox - Buy quality products at wholesale price!