How to shape a button



Hi all,
       I would like to make a shaped button, but when I use the
gtk_widget_shape_combine_mask(button, mask, 0, 0).
      The follow item is my source code.
      It can be passed build all step and no exception to run , but still
can't shaped the button as the shape.
      According your suggestion, I write  a test code and send to you.
      I used the follow envionment for development.
      OS : RedHat Linux 9.0
      IDE: Anjuta 1.2.2
      GTK+: GTK 2.0
      Can you give me any suggestion, thanks !

Chris.Wu


gboolean
configure_event             (GtkWidget       *widget,
                                        gpointer         user_data)
{
  //GtkWidget *pmap;
  GdkPixmap *PixMap;
  GdkBitmap *ImgLogo;
  GdkColor  Col={0};

  PixMap=gdk_pixmap_create_from_xpm(widget->window, &ImgLogo, &Col,
"circle.xpm");

  gdk_window_shape_combine_mask(GDK_WINDOW(widget->window), ImgLogo, 100,
100);
  gtk_window_set_decorated(GTK_WINDOW(widget), FALSE);
  //pmap = gtk_pixmap_new( PixMap, ImgLogo );
  //gtk_container_add (GTK_CONTAINER (widget), pmap);
  return TRUE;
}


GtkWidget*
create_window1 (void)
{
  GtkWidget *window1;
  GtkWidget *BtnLogo;
  window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  BtnLogo = gtk_button_new_with_label("H");
  g_signal_connect (G_OBJECT(BtnLogo), "configure_event",
                    G_CALLBACK (configure_event),
                    NULL);
  g_signal_connect (G_OBJECT(window1),"destroy",
G_CALLBACK(gtk_main_quit),NULL);
  gtk_container_add (GTK_CONTAINER (window1), BtnLogo);

  return window1;
}


int main (int argc, char *argv[])
{
  GtkWidget *window1;

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  gtk_set_locale ();
  gtk_init (&argc, &argv);

  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");

  /*
   * The following code was added by Glade to create one of each component
   * (except popup menus), just so that you see something after building
   * the project. Delete any components that you don't want shown initially.
   */
  window1 = create_window1 ();
  gtk_widget_show_all(window1);

  gtk_main ();
  return 0;
}



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