gtk_widget_shape_combine_mask() question



I try to understand how to use with  gtk_widget_shape_combine_mask()
function, i want to give a shape to my eventbox, i don't know if it
possible? or it possible only for windows? I based on wheelbarrow.c
from http://www.silab.dsi.unimi.it/manual/GTK+%20Tutorial/sec-pixmaps.html.
 Somebody can to help me ?

Here is my code +attached file:

#include <gtk/gtk.h>
#include <string.h>
#include <ctype.h>
int main (int argc, char *argv[])
{
	gtk_init (&argc, &argv);
	GtkWidget *window, *fixed;
	GdkColor color;
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size(GTK_WINDOW(window), 800, 450);
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_container_set_border_width(GTK_CONTAINER(window), 10);
	fixed=gtk_fixed_new();
	gtk_container_add(GTK_CONTAINER(window), fixed);
	GtkWidget *eventbox;
	eventbox=gtk_event_box_new();
	//gtk_widget_set_app_paintable(eventbox, TRUE);
	gtk_widget_set_size_request(eventbox, 20, 25);

//gdk_color_parse("#5BA84A", &color);
//gtk_widget_modify_bg (eventbox, GTK_STATE_NORMAL, &color);
	gtk_fixed_put(GTK_FIXED(fixed), eventbox, 10, 10);
// style = gtk_widget_get_default_style();
#include "krug.xpm"

GdkPixmap *gdk_pixmap;
    GdkBitmap *mask;
    GtkStyle *style;
GtkWidget *pixmap;

style = gtk_widget_get_default_style();
gdk_pixmap = gdk_pixmap_create_from_xpm_d(eventbox->window, &mask,
&style->bg[GTK_STATE_NORMAL], krug );
    pixmap = gtk_pixmap_new( gdk_pixmap, mask );
    gtk_widget_show( pixmap );
gtk_container_add(GTK_CONTAINER(eventbox), pixmap);
gtk_widget_shape_combine_mask( eventbox, mask, 0, 0 );
	
	gtk_widget_show(fixed);
	gtk_widget_show(eventbox);
gtk_widget_show(window);
	gtk_main ();
	return 0;
}



The compillation is ok, but it failed on running, the errors that i have is  :

(wheelbarrow:32756): Gdk-CRITICAL **:
gdk_pixmap_colormap_create_from_xpm_d: assertion `drawable != NULL ||
colormap != NULL' failed

(wheelbarrow:32756): Gtk-CRITICAL **: gtk_pixmap_new: assertion `val
!= NULL' failed

(wheelbarrow:32756): Gtk-CRITICAL **: gtk_widget_show: assertion
`GTK_IS_WIDGET (widget)' failed

(wheelbarrow:32756): Gtk-CRITICAL **: gtk_container_add: assertion
`GTK_IS_WIDGET (widget)' failed
Segmentation fault

What's wrong here?

Attachment: krug.xpm
Description: X pixmap



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