Re: How to make...
- From: Gus Koppel <gtk spamkiller bytechase cx>
- To: gtk-app-devel-list gnome org
- Subject: Re: How to make...
- Date: Wed, 21 Apr 2004 23:28:18 +0200
Eric Lemings wrote:
I'm trying to make a horizontal group of four buttons that each
contain only a stock icon (no label) and are packed just wide enough
to show the icon.
What would the code look like?
There are two approaches to this design. One uses a GtkHButtonBox as a
container, the other one uses a GtkHBox as a container. Using
GtkHButtonBox has two drawbacks, however:
1. until most recent GTK+ versions the buttons are all of same width
2. buttons seem to get wider than required by the icons
The alternative uses just a GtkHBox and can be coded like this:
my_hbox = gtk_hbox_new (FALSE, 0);
gtk_widget_show (my_hbox);
gtk_box_pack_start (GTK_BOX (vbox2), my_hbox, FALSE, FALSE, 0);
button1 = gtk_button_new ();
gtk_widget_show (button1);
gtk_box_pack_start (GTK_BOX (my_hbox), button1, FALSE, FALSE, 0);
image1 = gtk_image_new_from_stock ("gtk-dialog-info",
GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image1);
gtk_container_add (GTK_CONTAINER (button1), image1);
button2 = gtk_button_new ();
gtk_widget_show (button2);
gtk_box_pack_start (GTK_BOX (my_hbox), button2, FALSE, FALSE, 0);
image2 = gtk_image_new_from_stock ("gtk-dialog-info",
GTK_ICON_SIZE_DIALOG);
gtk_widget_show (image2);
gtk_container_add (GTK_CONTAINER (button2), image2);
[...]
Put the GtkHBox inside whatever container you want to have it in, i.e. a
GtkVBox inside a GtkWindow. All of the above widgets need to be declared
as well, i.e.
GtkWidget *my_hbox;
Note however, that offering buttons with icons *only* (no labels at all)
is considered user-unfriendly design by many people.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]