Custom widget headache



Hello folks,

I'm trying to build a custom widget, following the route that is outlined for the "GtkDial" widget in the GTK+ tutorial. I'm already stuck at the very beginning -- type registration. My widget is called "cw_area", and I followed the usual naming conventions which will be helpful in the following.

Below I have included a bit of the output I get when I start the program. The lines starting with <<< and >>> are debugging markers that I use to keep track of what is actually going on.

-------------------------

Entering cw_area_new: cw_area.c (121)
Entering cw_area_get_type: cw_area.c (52)
<<< Exiting cw_area_get_type: cw_area.c (67)
Entering cw_area_class_init: cw_area.c (75)
<<< Exiting cw_area_class_init: cw_area.c (90)
Entering cw_area_init: cw_area.c (96)
<<< Exiting cw_area_init: cw_area.c (99)

(ctops-gui:4398): GLib-GObject-CRITICAL **: g_object_notify_queue_thaw: assertion `object->ref_count > 0' failed

(ctops-gui:4398): GLib-GObject-CRITICAL **: g_object_notify_queue_thaw: assertion `nqueue->freeze_count > 0' failed

<<< Exiting cw_area_new: cw_area.c (124)

------------------------

The GLib-GObject-CRITICAL warnings actually happen at some point inside gtk_type_new(), and I've no idea what they mean. Since all the type system knows about my widgets at this point is the stuff passed into gtk_type_unique() in my function cw_area_get_type(), some of that information must be erroneous but I don't know which.

Below I put some of my C code that I hope is relevant to the solution of this problem. It's just the class definition and the four functions that get called during the sequence shown above.

Thanks,
--Daniel

------------------------

#define ENTER g_printerr(">>> Entering %s: %s (%d)\n", __FUNCTION__, __FILE__, __LINE__); #define EXIT g_printerr("<<< Exiting %s: %s (%d)\n", __FUNCTION__, __FILE__, __LINE__);

struct CwArea_t {
        GtkWidget widget;

        guint policy:2;
        guint8 button;
        guint32 timer;

        gdouble max_width, max_height;
        gdouble dim[5];
        double sina, cosa;
        guint window_width, window_height;
        double xscale, yscale, xoffset, yoffset;
        GtkAdjustment *adj[5];
};

struct CwAreaClass_t {
        GtkWidgetClass parent_class;
};

GtkType cw_area_get_type()
{
        static GtkType area_type = 0;

ENTER
        if (!area_type) {
                static const GtkTypeInfo area_info = {
                        "CwArea",
                        sizeof (CwArea),
                        sizeof (CwAreaClass),
                        (GtkClassInitFunc) cw_area_class_init,
                        (GtkObjectInitFunc) cw_area_init,
                        /* reserved_1 */ NULL,
                        /* reserved_1 */ NULL,
                        (GtkClassInitFunc) NULL
                };

                area_type = gtk_type_unique(GTK_TYPE_WIDGET, &area_info);
        }
EXIT
        return area_type;
}

static void cw_area_class_init(CwAreaClass * class)
{
        GtkObjectClass *object_class;
        GtkWidgetClass *widget_class;
ENTER
        object_class = (GtkObjectClass *) class;
        widget_class = (GtkWidgetClass *) class;

        parent_class = gtk_type_class(gtk_widget_get_type());

        object_class->destroy = cw_area_destroy;

        widget_class->realize = cw_area_realize;
        widget_class->expose_event = cw_area_expose;
        widget_class->size_request = cw_area_size_request;
        widget_class->size_allocate = cw_area_size_allocate;
        widget_class->button_press_event = cw_area_button_press;
        widget_class->button_release_event = cw_area_button_release;
        widget_class->motion_notify_event = cw_area_motion_notify;
EXIT
}

static void cw_area_init(CwArea *area)
{
        static CwArea area_null;
ENTER
        *area = area_null;
        area->policy = GTK_UPDATE_CONTINUOUS;
EXIT
}

GtkWidget *cw_area_new(void) {
        CwArea *area;
        GtkType t;

ENTER
        area = gtk_type_new(cw_area_get_type());
EXIT
        return GTK_WIDGET(area);
}




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