Re: stock items: how this stuff works ?



Hi Vicent,

On Thu, 2004-04-08 at 12:00, Vincent Torri wrote:
[snip]
And i am looking
for it when i only have the id of the icon.

Here you've got some examples to create ...

* A Menu item:

GtkWidget *menu_undo;
menu_undo = gtk_image_menu_item_new_from_stock ("gtk-undo",
accel_group);

* A Toolbar button:

GtkWidget *button_new;
button_new = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
                        "gtk-new", _("New"), NULL, NULL, NULL,-1);

* An Image for dialog:

GtkWidget *image;
image = gtk_image_new_from_stock ("gtk-dialog-warning",
GTK_ICON_SIZE_DIALOG);

* A button:

GtkWidget *okbutton;
okbutton = gtk_button_new_from_stock ("gtk-ok");

* A button with stock image and custom label:

GtkWidget*
create_custom_button_from_stock(gchar* label_text,gchar *stock_id)
{
  GtkWidget* button;
  GtkWidget* image;
  GtkWidget* box;
  GtkWidget* label;

  button = gtk_button_new();
  box = gtk_hbox_new(FALSE,0);

  image = gtk_image_new_from_stock(stock_id,GTK_ICON_SIZE_BUTTON);
  label = gtk_label_new(label_text);

  gtk_box_pack_start((GtkBox*)box,image,FALSE,FALSE,0);
  gtk_box_pack_end  ((GtkBox*)box,label,FALSE,FALSE,0);
  gtk_widget_show(label);
  gtk_widget_show(image);
  gtk_widget_show(box);
  gtk_container_add(GTK_CONTAINER(button),box);

  return button;
}



Hope this helps.
-- 
Iago Rubio   
- Home page    * http://www.iagorubio.com 
- Last project * http://cssed.sourceforge.net         
- GPG Keyserv  * pgp.rediris.es id=0x909BD4DD

Attachment: signature.asc
Description: This is a digitally signed message part



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