Using custom stock item



Hello,

I'm trying to resolve an issue with custom stock items. I'm able to
create and use them in gtk_image_new_from_stock() function, but
gtk_button_new_from_stock() fails to create button with my item
(instead, ti falls back to displaying stock item's id as a label).

Here is a minimal sample application that demonstrates my problem:
-------------------
#include <gtk/gtk.h>

int main () {
  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *image;
  GtkWidget *button;
  GtkIconFactory *factory;
  GtkIconSource *source;
  GtkIconSet *set;
  gchar id[] = "myapp-new-id";

  gtk_init( NULL, NULL );

  window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
  g_signal_connect (G_OBJECT (window), "delete-event",
                    G_CALLBACK (gtk_main_quit), NULL);

  factory = gtk_icon_factory_new();
  source = gtk_icon_source_new();
  set = gtk_icon_set_new();

  gtk_icon_factory_add_default( factory );

  gtk_icon_source_set_filename( source, "C:/devel/code/test.png" );
  gtk_icon_set_add_source( set, source );
  gtk_icon_factory_add( factory, id, set );

  vbox = gtk_vbox_new( FALSE, 5 );
  gtk_container_add( GTK_CONTAINER( window ), vbox );

  image = gtk_image_new_from_stock( id, GTK_ICON_SIZE_DIALOG );
  gtk_box_pack_start( GTK_BOX( vbox ), image, TRUE, TRUE, 0 );

  button = gtk_button_new_from_stock( id );
  gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 );

  gtk_widget_show_all( window );
  gtk_main();
  return( 0 );
}
-------------------

Is there anything that I missing here?

-- 
Tadej Borovšak
00386 (0)40 613 131
tadeboro gmail com
tadej borovsak gmail com


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