Re: xpm in place of button...

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

 



On Mon, 2003-06-02 at 12:02, Hari Prasad Nadig wrote:
> GtkWidget *pixmap, *fixed;
> GdkPixmap *ic_pixmap;
> GdkBitmap *mask;  
> GtkStyle *style; 
> GdkGC *gc;
> 
>    style = gtk_widget_get_default_style();    
>    gc = style->black_gc;  
>    ic_pixmap = gdk_pixmap_create_from_xpm_d( window->window, &mask,&style->bg[GTK_STATE_NORMAL],ic_xpm );
> 
> 
>    pixmap = gtk_pixmap_new( ic_pixmap, mask );
> 
>    fixed = gtk_fixed_new();   
>    gtk_widget_set_usize( fixed, 80, 105 );  
>    gtk_fixed_put( GTK_FIXED(fixed), pixmap, 0, 0 ); 
>  
>    gtk_table_attach_defaults (GTK_TABLE(*table_ics),fixed, 8, 10, 5, 8);   
> 
>    gtk_widget_show( pixmap);  
>    gtk_widget_show( fixed );
> 
> 
> This is my code. It generates a transparent image alright. But what do I do to give it a functionality of button?

You could connect a function to the "button-release-event" signal of
pixmap, which it inherits from GtkWidget.

gboolean button_release_cb (GtkWidget *widget,
                            GdkEventButton *event, 
                            gpointer user_data);
...
g_signal_connect (G_OBJECT (pixmap),
                  "button-release-event",
                  G_CALLBACK (button_release_cb),
                  NULL);
...


Alternatively, you could probably manage to pack the pixmap into a
button, and then set the properties of that button to make it not add
spacing, relief, or anything else.  The properties "border-width" and
"relief" come to mind, though you might need more.

In the end, the button approach is probably better, because you'll
actually get a "clicked" signal, rather than having to figure out in
your code whether or not a button release is a click.  And you'll get
keyboard navigation.

Or, of course, you could always just not make such an interface. 
They're basically always sub-optimal from any viewpoint other than
eye-candy.

--
Shaun




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux