Re: Deprecated function ed icons on button



Hello,

yes, stock icons are now deprecated in favour of icon names, preferably
symbolic icons (especally if you are building a GNOME component). Creating
image buttons may seem a  bit harder than before.

As you may have already seen, a GtkButton is subclassed from GtkBin, which
means you can pack another widget into it. It can be a GtkLabel, or even a
GtkEntry (this sounds crazy), or, in your case, a GtkImage.

Create a GtkImage with gtk_image_new_from_icon_name(), then add it to the
button with gtk_container_add(GTK_CONTAINER(button), image).

And now that you hopefully understand the concept, I'd like to introduce
gtk_button_new_from_icon_name() :) For this, you need GTK 3.10, though, but
it's a shorthand for the above.

Personally, I prefer using Glade/GtkBuilder, although Glade doesn't support
some of the newer widgets, and gives you hard times with other stuff.

Best,
Gergely Polonkai
On 6 Oct 2014 17:03, "arkkimede" <arkkimede gmail com> wrote:

Hi,
I'm starting to learn GTK+ and I'm using beginner tutorial found on GTK web
site.
(I'm working on linux debian testing amd64 with Xfce)
The actual version of GTK is 3.x and the tutorial is related to 2.x
This means that some time there are some deprecated function that have to
be substituted with the new ones.
Some time the task is easy like

gtk_vbox_new(FALSE, 0) ==> gtk_box_new(GTK_ORIENTATION_VERTICAL, 0)

some time not so easy.

One of these case is  gtk_image_menu_item_new_from_stock(GTK_STOK_NEW,NULL)
The new version is
gtk_menu_item_new_with_label or
gtk_menu_item_new_with_mnemonic.

I made the new version, the compiler do not print any message but the final
result is that the icon
disappear.

Googling I found that this is the new philosophy of GTK and to see the
icons I have to made some settings in my environment.

Somewhere I found that I have to put in ~/.config/gtk-3.0/settings.ini
some like
[Settings]
gtk-menu-images=1
gtk-button-images=1

Running the GTK program I do not see any icons!

Could you help me to find a solution, please?

Thanks in Advance
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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