[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. --

https://developer.gnome.org/gtk3/3.2/GtkButton.html#GtkButton.properties

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 --

gtk_button_get_label
gtk_button_set_use_stock
gtk_button_set_image
...

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"

on

gtk_entry_get_text(test);

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:

https://developer.gnome.org/gtk3/unstable/GtkButton.html#GtkButton-released

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.

Cheers,
    -Tristan


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

https://developer.gnome.org/gtk3/3.2/GtkButton.html#GtkButton.properties


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
http://lists.ximian.com/mailman/listinfo/glade-users




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