Re: gtk+ using a button to update a graph on main window
Re: gtk+ using a button to update a graph on main window
- Subject: Re: gtk+ using a button to update a graph on main window
- From: George Peter Staplin <email@hidden>
- Date: Fri, 24 Oct 2008 11:13:10 -0600
Quoted "S. Aguinaga" <email@hidden>:
I'm having trouble the callback code on a button, to update the
graph on my main window.
Maybe I'm using the wrong syntax, but I hope some of you will be ale
to shed light on this
issue:
I suspect one of the lists here: http://www.gtk.org/mailing-lists.html
might be more helpful, but I will attempt to help anyway.
in the callbacks.c file (after generating it from glade3) I have
the following code at the bottom, and the next section is the error
msg I get:
________________________________
SynchioButton I was clicked!
(harp_app_0:5279): GLib-GObject-WARNING **: invalid cast from
`GtkDataboxLines' to `GtkDatabox'
** (harp_app_0:5279): CRITICAL **: gtk_databox_graph_add: assertion
`GTK_IS_DATABOX (box)' failed
(harp_app_0:5279): GLib-GObject-WARNING **: invalid cast from
`GtkDataboxLines' to `GtkDatabox'
** (harp_app_0:5279): CRITICAL **: gtk_databox_calculate_extrema:
assertion `GTK_IS_DATABOX (box)' failed
(harp_app_0:5279): Gtk-CRITICAL **: gtk_widget_show: assertion
`GTK_IS_WIDGET (widget)' failed
________________________________
in my main file (interface.c) I have the following way of connecting
the button to the callback:
/* SYNCH IO BUTTON CALLBACK */
g_signal_connect (G_OBJECT (synchioButton), "clicked", G_CALLBACK
(button_clicked),
(gpointer) window1);
:: any help will be greatly appreciated
________________________________
void
button_clicked(GtkButton *synchioButton,
GtkWindow *window1)
{
//GtkWidget *dialog, *label, *image, *hbox;
GtkWidget*plotbox;
GtkWidget*gtk_databox_new (void);
The code above is rather odd. Why are you declaring the
gtk_databox_new() function? That should be in gtkdatabox.h; which you
should #include.
GtkDataboxGraph*graph;
GdkColor color;
gfloat *X, *Y;
gint i;
g_print("SynchioButton I was clicked!\n");
X = g_new0 (gfloat, POINTS); // WILL PROBABLY HAVE TO GET RID OF THIS
Y = g_new0 (gfloat, POINTS);
for (i = 1 ; i < POINTS + 1; i ++) { X [i] = i; Y [i] = log10 (i); }
color.red = 15535;
color.green = 15535;
color.blue = 15535;
graph = gtk_databox_lines_new (POINTS, X, Y, &color, 1);
gtk_databox_graph_add (GTK_DATABOX (plotbox), graph);
In the code I see you haven't created a plotbox object. You're using
an uninitialized plotbox object pointer.
gtk_databox_auto_rescale (GTK_DATABOX (plotbox), 0.05);
The same issue here, as above.
gtk_widget_show (plotbox);
}
The Gtk+ tutorials or a good book would probably help you. I also
suggest studying the GObject documentation.
George
--
http://people.freedesktop.org/~gstaplin/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden