Re: How to determine the type of a widget?
- From: "Marc K." <marc centrin net id>
- To: gtk-list gnome org
- Subject: Re: How to determine the type of a widget?
- Date: Sun, 28 Nov 2004 01:46:40 +0700
On Sunday 28 November 2004 01:26, you wrote:
> Hi,
>
> "Marc K." <marc centrin net id> writes:
> > Question: how can I determine the type of a widget
> > when all I know is that it is a GtkWidget? i.e. it may
> > be a GtkButton, GtkFrame, etc.
> >
> > I tried to dig into the manual for an easy solution but
> > I cant seem to find any. Or maybe I miss something?
>
> You should make yourself familiar with GObject. You are probably
> looking for G_TYPE_FROM_INSTANCE().
What I want to achieve is to collect some IDs (or something similar)
when I create the internal classes. At this point, I have not created
any instances. So I think I cant use G_TYPE_FROM_INSTANCE.
Class *ButtonClass = ClassNew ("Button", BinClass, ....
klass = get_the_class_of (GtkButton)
id = the_id_of_class (klass)
set_class_id (ButtonClass, id)
...
then later (stupid code but i hope it makes the point)
....
id = get_id_of_this_widget_instance (w)
Class c = get_class_from_id (id)
if (c == ButtonClass)
...
else if (c == FrameClass)
...
etc.
marc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]