Re: Insensitive pixmaps



On Sun, 20 Sep 1998, Lionel ULMER wrote:

> >   Can't you just use gtk_pixmap_set() to switch the GtkPixmap between the
> > two images you want for sensitive and insensitive? 
> 
> Well, it is what I am doing... But it is really a "hack" (each time I
> do a gtk_widget_set_sensitive, I need to call a special function that
> changes the pixmap).
> 
> And changing the Pixmap code would mean that all the code using
> GtkPixmaps (as toolbar for example) would not have to be changed to
> have the "new" sensitive code.

if a widget changes it's state (i.e. sentsitivity) the GtkWidget::state_changed
signal is emitted, so you only need to:

gtk_signal_connect (GTK_OBJECT (pixmap),
                    "state_changed",
                    GTK_SIGNAL_FUNC (pixmap_state_changed),
                    NULL);
static void
pixmap_state_changed (GtkWidget      *widget,
                      GtkStateType    previous_state,
                      gpointer        user_data)
{
  GtkPixmap *pixmap;
  
  pixmap = GTK_PIXMAP (widget);

  switch (GTK_WIDGET_STATE (pixmap))
  {
  case GTK_STATE_NORMAL:
    gtk_pixmap_set (pixmap, normal_pixmap, normal_mask);
    break;
  case GTK_STATE_INSENSITIVE:
    gtk_pixmap_set (pixmap, insensitive_pixmap, insensitive_mask);
    break;
  case GTK_STATE_ACTIVE:
  case GTK_STATE_PRELIGHT:
  case GTK_STATE_SELECTED:
    /* we want to ignore these? */
    break;
  }
}
                      

> 
> -- 
>   Lionel ULMER  -  bbrox@mygale.org - http://www.mygale.org/~bbrox/
> 

---
ciaoTJ



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