Re: Nonstandard Check Button
- From: Carsten Burstedde <c burstedde de>
- To: Paul Pogonyshev <pogonyshev gmx net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Nonstandard Check Button
- Date: Mon, 17 Jan 2005 20:04:39 +0100
So, any callback will be called after the class handler of the signal.  Then
you should subclass GtkCheckButton, override the `clicked' handler and not
call the handler of the parent class.
Thanks, I got it working.  Code below.  There are two ugly things about
that:
1. toggle_button_set_active stops working, due to the way toggle button
uses the clicked signal internally.
2. If I want to have toggle button and check button with this
functionality, I must derive two separate new widgets, although the code
is the same.  So should this be really inside toggle button? But there
is probably no hope for adding a property for this in the official API.
Thanks anyway!
Carsten
static void
foo_gtk_check_button_class_init (FooGtkCheckButtonClass *class)
{
  GtkButtonClass   *button_class;
  
  button_class = (GtkButtonClass*) class;
  parent_class = g_type_class_peek_parent (class);
  
  button_class->clicked = NULL;
}
void
foo_gtk_check_button_set_active (FooGtkCheckButton *button,
                                 gboolean is_active)
{
  g_return_if_fail (FOO_GTK_IS_CHECK_BUTTON (button));
 
  is_active = is_active != FALSE;
   
  if (GTK_TOGGLE_BUTTON (button)->active != is_active)
    {
      if (GTK_BUTTON_CLASS (parent_class)->clicked)
        {
          GTK_BUTTON_CLASS (parent_class)->clicked
                            (GTK_BUTTON (button));
        }
    }
}
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]