[Glade-users] get/set GTK widget properties.

On Thu, May 16, 2013 at 5:53 PM, dE <de.techno at gmail.com> wrote:
Hello everyone!

I'm using Glade to make the GUI (actually it's made), as a result I don't
have much idea about the coding part (in C) neither there are any tutorials
which focus on the coding part with Glade, most of them being Python based.

How do you change/set the property of a widget? For e.g. a button label, or
read buffer text in an input box?

I've realized that every widget type has a dedicated structure assigned to
it, for e.g. Gtkbutton, or GtkEntry, and each widget has properties, e.g. --


But how do you get or change these properties? The structure of the widget
does not have have these elements, as a result you can't GtkEntry.buffer.

So how do you access these properties?

I've noticed these functions --


That's right, you should use the API provided by a widget class to
set it's properties.

Which may be used to modify the widget properties, but I get --

"(a.out:23415): Gtk-CRITICAL **: gtk_entry_get_text: assertion `GTK_IS_ENTRY
(entry)' failed"



In function --

void test_func(GtkEntry *test)

Then the pointer you gave to gtk_entry_get_text() does not actually
point to a GtkEntry object.

Perhaps it's NULL, or a wild pointer that's only casted as a GtkEntry *.

Where glade is set to run this function and pass "entry2" (in "user data" of
the signals tab) on event GtkButton > released.

Ah, then you have a bad callback signature see this documentation
for the signature of a callback for the GtkButton::released signal:


Notice that you are actually passing the button which emitted the "released"
signal as an entry to gtk_entry_set_text().

Every signal has a different signature, you need to pass the correct type
of callback when connecting to any signal.

If Glade is installed on a system with DevHelp also installed, you should
be able to get the signal documentation directly by clicking the devhelp
icon for a given signal in the signal editor.


If this's how you get/set properties, then of what use are the properties as
listed in --


Those are GObject properties, they can be set for any object with
g_object_set()/g_object_get() or passed to g_object_new(), but
it's recommend to use the actual API to modify objects rather
than g_object_set/get (the g_object_set()/get() apis are rather
for more generic access, i.e. GtkBuilder uses them when
building an interface defined with Glade).

Thankyou for the help, I need this to be fixed quick.
Glade-users maillist  -  Glade-users at lists.ximian.com

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