Hi, Mr. Alem Thanks for your help! Chris.Wu -----Original Message----- From: Alem Dain [mailto:[EMAIL PROTECTED] Sent: 2005年5月27日 13:51 To: [EMAIL PROTECTED] Cc: gtk-app-devel-list@gnome.org Subject: Re: How to shape a button Hi; I looked at your code. First thing I noticed was that it didn't come with a circle.xpm file. I replaced it with a stock debian logo, mostly transparent :) Moving on, for some reason, the BtnLogo object is never receiving a configure-event. I even tried gtk_widget_set_events(GDK_ALL_EVENTS_MASK), but to no avail. Since this problem isn't interesting (at the moment) I changed it to "realize" (interface.c:31) and it worked. On a fairly pedantic note: GtkPixmap is deprecated as of 2.0. Use GtkImage instead. Another minor issue was that you were trying to set the button to be decorationless, but it's not a GtkWindow. I fixed this by passing window1 as the user_data parameter to your callback. So then I uncommented the bit about putting the image in the container (make sure you don't have a GtkLabel in there already; use BtnLogo = gtk_button_new() instead), and the final thing: you need to show the image: gtk_widget_show(img); Attached is the new code. Enjoy. -Alem On 5/26/05, Chris Wu <[EMAIL PROTECTED]> wrote: > > Have you got my code? > Any progress? > Chris.Wu > > -----Original Message----- > From: Alem Dain [mailto:[EMAIL PROTECTED] > Sent: 2005年5月26日 14:34 > To: [EMAIL PROTECTED] > Subject: Re: How to shape a button > > > Hi, I'd like to try out your code; can you email the xpm as well? > > -Alem > > > On 5/25/05, Chris Wu <[EMAIL PROTECTED]> wrote: > > 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; > > } > > _______________________________________________ > > gtk-app-devel-list mailing list > > gtk-app-devel-list@gnome.org > > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > > > ____________________________________________________________________________ _ > Scanned by Sanmina-SCI eShield ____________________________________________________________________________ _ > ____________________________________________________________________________ _ Scanned by Sanmina-SCI eShield ____________________________________________________________________________ _ _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list