Re: Delayed events



On Wed, Nov 26, 2008 at 8:03 AM, Nicola Fontana <ntd entidi it> wrote:
On Tue, 25 Nov 2008 21:26:54 -0800
"Roy G. Biv" <kroylar gmail com> wrote:

Hello everybody!

I am just learning how to use GTK+ and have run into a problem.  After
having followed Micah Carrick's Glade3 tutorial, I have learned that
using GtkBuilder seems to be the best way to do things.  Therefore the
method that he used in his tutorial is the how I'm doing it too.  On
to my problem...

I have created a window that contains a single combobox widget named
combobox1.  In this combobox I have listed a few different colors.
And in glade I set the a handler named "on_combobox1_changed" for the
"changed" entry under GtkComboBox.

My C program contains this function:

void on_combobox1_changed (GtkComboBox *widget, gpointer user_data);

My guess is you have something weird in your event loop: you
should post the code.

Ciao
--
Nicola

Thank you all for your help.

I tried adding stderr to my printf function but it still seems to be
buffered. Here is the code that I am working with:

#include <gtk/gtk.h>
#include <stdio.h>

void on_combobox1_changed (GtkComboBox *widget, gpointer user_data) {
   printf("on_combobox1_changed event");
//    int hello = GPOINTER_TO_INT(user_data);
//    printf("%d", hello);
//    GtkWidget window = GTK_WIDGET( widget );
   GdkColor color;
//    gdk_color_parse(gtk_combo_box_get_active_text(widget), &color);
   gdk_color_parse("blue", &color);
   gtk_widget_modify_bg (GTK_WIDGET (widget), GTK_STATE_NORMAL, &color);
}

void
on_window_destroy (GtkObject *object, gpointer user_data)
{
   printf("on_window_destroy event");
   gtk_main_quit ();
}

int
main (int argc, char *argv[])
{
//    GtkWidget *combobox1;
   GtkBuilder      *builder;
   GtkWidget       *window;
   GdkColor red;

   gtk_init (&argc, &argv);

   builder = gtk_builder_new ();
   gtk_builder_add_from_file (builder, "testcolor1.xml", NULL);
   window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
   gdk_color_parse ("red", &red);
   gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &red);
   gtk_builder_connect_signals (builder, NULL);
//    GtkComboBox *combobox1 = GTK_COMBO_BOX (builder);
//    g_signal_connect(G_OBJECT(combobox1), "clicked", G_CALLBACK
(on_combobox1_changed), NULL);

   g_object_unref (G_OBJECT (builder));
   gtk_widget_show (window);
//    gtk_widget_modify_bg (window, GTK_STATE_NORMAL, red);

   gtk_main ();

   return 0;
}

-Roy



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