| View previous topic :: View next topic |
| Author |
Message |
beidlerj
Joined: 10 Feb 2006 Posts: 55 Location: Oregon, USA
|
Posted: Wed Feb 15, 2006 2:56 am Post subject: Stock buttons with images? |
|
|
How does one get a button with the nice stock image already applied to it? If I use:
| Code: | | $okButton = new GtkButton('gtk-ok'); |
I get a button with OK on it, but no image. If I try to use the GtkButton::new_from_stock() constructor, I get parse errors. What's the correct way, or does WinXP Pro just not like putting icons on buttons? Also, where does one find a list of the constants?
Thanks. |
|
| Back to top |
|
 |
ron_t
Joined: 11 Dec 2005 Posts: 78 Location: Gatineau, Quebec
|
Posted: Wed Feb 15, 2006 3:29 am Post subject: Re: Stock buttons with images? |
|
|
| beidlerj wrote: | How does one get a button with the nice stock image already applied to it? If I use:
| Code: | | $okButton = new GtkButton('gtk-ok'); |
I get a button with OK on it, but no image. If I try to use the GtkButton::new_from_stock() constructor, I get parse errors. What's the correct way, or does WinXP Pro just not like putting icons on buttons? Also, where does one find a list of the constants?
Thanks. |
I'm assuming you're talking about toolbar buttons...
And that you know you can get the whole set of stock icons in the documentation package Christian puts together and makes available at: php-gtk2.de/manual/ (You'll find them in \images\reference\gtk\stock_icons).
If you visit my blog at:
http://www.writingup.com/blog/phpgtk2
and look for Lesson 0016 A Simple Toolbar, you'll find a short explanation of one way to use stock buttons. I can't say whether or not it's the accepted way, but it works.
Just remember to change the paths to the icon files in the code sample to match where you keep your icons.
Take care.
-Ron T. |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Wed Feb 15, 2006 8:47 am Post subject: Re: Stock buttons with images? |
|
|
| beidlerj wrote: | I get a button with OK on it, but no image.
does WinXP Pro just not like putting icons on buttons? |
The gtk theme for windows doesn't show the images.
You can make them visible by deactivating the wimp-theme that gnope did install automatically (that is to make php-gtk2 apps look as integrated as possible): There is a .gtkrc-2.0 file somewhere in the gnope installation directory (probably in some gtk subdir). Rename it to something different, and restart your application.
The constants are in the manual under "Gtk Enums":
http://php-gtk2.de/manual/en/html/gtk/gtk.enum.stockitems.html |
|
| Back to top |
|
 |
beidlerj
Joined: 10 Feb 2006 Posts: 55 Location: Oregon, USA
|
Posted: Wed Feb 15, 2006 6:29 pm Post subject: Re: Stock buttons with images? |
|
|
| cweiske wrote: |
The gtk theme for windows doesn't show the images.
You can make them visible by deactivating the wimp-theme that gnope did install automatically (that is to make php-gtk2 apps look as integrated as possible) |
Ah, so I was doing it right! It works now. Thanks, Christian! Now I just have to decide if I liked the WIMP look better or not.
BTW, the exact filepath is "C:\PHP-Gtk2\etc\gtk-2.0\gtkrc", for those who wish to do the same.
Ron - Your blog rocks, but sometimes I can't access www.writingup.com in the late afternoons (GMT - 8 here...) around 4pm. Do you know if they do server updates every day that interfere with access? |
|
| Back to top |
|
 |
beidlerj
Joined: 10 Feb 2006 Posts: 55 Location: Oregon, USA
|
Posted: Tue Feb 21, 2006 9:31 pm Post subject: |
|
|
Is it possible to use the stock icons on a button and have a different label?
Example: I set up a GtkDialog, and passed the constructor 4 buttons: "gtk-apply", "gtk-media-stop", "gtk-cancel", and "gtk-ok". My dialog is meant for showing a list of GtkCheckBoxes, allowing the user to select/clear entries before processing. The OK and Cancel buttons for the dialog are standard, but the other two are meant to be connected to "select all" or "clear all" functions for the checkboxes. I chose those two particular stock buttons because their icons (the little green check mark or the blank box) conveyed the idea of checking or unchecking all the checkboxes. The only problem is, with stock buttons, you get the stock label as well. I thought I could override the label on the buttons using the GtkButton function set_label(). That works, but then you lose the stock icon and have only the text displayed on the label. How can I use my own label but a stock icon on the button? I also tried the set_image() function, but that expects an image file (*.jpg, *.gif, etc.).
Thanks again,
Jeff |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Tue Feb 21, 2006 10:04 pm Post subject: |
|
|
| beidlerj wrote: | | Is it possible to use the stock icons on a button and have a different label? |
| Code: | $btn = new GtkButton('my text');
$btn->set_image(GtkImage::new_from_stock(Gtk::STOCK_OK, Gtk::ICON_SIZE_LARGE_TOOLBAR)); |
|
|
| Back to top |
|
 |
beidlerj
Joined: 10 Feb 2006 Posts: 55 Location: Oregon, USA
|
Posted: Tue Feb 21, 2006 11:51 pm Post subject: |
|
|
Awesome!
Danke schoehen, Christian!  |
|
| Back to top |
|
 |
tulpe
Joined: 06 Sep 2006 Posts: 7
|
Posted: Fri Sep 29, 2006 3:21 pm Post subject: |
|
|
| You can have the stock icons with the wimp theme by setting the value "gtk-button-images" in etc\gtk-2.0\gtkrc from 0 to 1. |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Nov 29, 2006 5:30 pm Post subject: |
|
|
The gtk theme for windows doesn't show the images.
You can make them visible by deactivating the wimp-theme that gnope did install automatically (that is to make php-gtk2 apps look as integrated as possible): There is a .gtkrc-2.0 file somewhere in the gnope installation directory (probably in some gtk subdir). Rename it to something different, and restart your application.
 |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Nov 29, 2006 5:30 pm Post subject: |
|
|
The gtk theme for windows doesn't show the images.
You can make them visible by deactivating the wimp-theme that gnope did install automatically (that is to make php-gtk2 apps look as integrated as possible): There is a .gtkrc-2.0 file somewhere in the gnope installation directory (probably in some gtk subdir). Rename it to something different, and restart your application.
 |
|
| Back to top |
|
 |
|