GtkColorButton tracking color changes



I'm trying to monitor color changes in the GtkColorButton popup. The following code only calls the Color_cb when the user has selected a color (actually it is called twice) and not while the sliders are being dragged.  How can I get notified as the changes are happening?

#include <gtk/gtk.h>
#include <gdk/gdkx.h>
/*
Make with:
 gcc -g -fPIC `pkg-config --cflags gtk+-3.0` -c -o ButtonTest.o ButtonTest.c
 gcc -o ButtonTest -g -fPIC  ButtonTest.o  `pkg-config --libs gtk+-3.0`
*/

void Destroy_cb(  GtkWidget *w, gpointer user_data)
{
  fprintf( stderr, "DESTROY\n" );
  gtk_main_quit( );
  return;
}

void Color_cb( GtkColorButton *w, gpointer user_data)
{
  fprintf( stderr, "Color\n" );
}

int main( int argc, char *argv[], char *envp[] )
{
  GtkWindow      *MainWindow;
  GtkColorButton *Button;

  gtk_init( &argc, &argv );

  MainWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
  g_signal_connect( MainWindow, "destroy",
            G_CALLBACK(Destroy_cb), NULL );

  Button = GTK_COLOR_BUTTON( gtk_color_button_new( ) );
  g_signal_connect( Button, "notify::rgba",
            G_CALLBACK(Color_cb), NULL );
  g_signal_connect( Button, "notify::color",
            G_CALLBACK(Color_cb), NULL );

  gtk_container_add( GTK_CONTAINER(MainWindow), GTK_WIDGET(Button) );

  gtk_widget_show_all( MainWindow );
  gtk_main();
  exit( 0 );
}



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