GPtrArray

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

 



Hi list,

I do a simples struct:

typedef struct
{
    GtkWidget *window;
    GtkWidget *drawingArea;
    GPtrArray *parray;
    gint a;
} GtkDesenho;

In main():

    GtkDesenho *desenho;

    desenho = g_slice_new(GtkDesenho);
    desenho->window     = glade_xml_get_widget(xml, "window2");
    desenho->drawingArea= glade_xml_get_widget(xml, "drawing_area");


  gtk_window_set_title(GTK_WINDOW(desenho->window), "Drawing Areas");

  gtk_widget_set_size_request(desenho->window, 400, 300);



  /* Create a pointer array to hold image data. Then, add event masks to the new
   * drawing area widget. */
   desenho->parray = g_ptr_array_sized_new(500);
    g_print("\n tamanho do array: %d", desenho->parray->len);
  GTK_WIDGET_SET_FLAGS (desenho->drawingArea, GTK_CAN_FOCUS);

  gtk_widget_add_events (desenho->drawingArea, GDK_BUTTON_PRESS_MASK |

                                              GDK_BUTTON_MOTION_MASK |

                                                   GDK_KEY_PRESS_MASK);







  gtk_container_add (GTK_CONTAINER (desenho->window), desenho->drawingArea);


  // and call the events to the callbacks

    g_signal_connect(G_OBJECT(desenho->drawingArea),
"button_press_event", G_CALLBACK(button_pressed), desenho);
    g_signal_connect(G_OBJECT(desenho->drawingArea),
"motion_notify_event", G_CALLBACK(button_pressed), desenho);
    g_signal_connect(G_OBJECT(desenho->drawingArea), "expose_event",
G_CALLBACK(expose_event), desenho);

//the button6 must clear the drawing area

   g_signal_connect(G_OBJECT(button6), "clicked",
G_CALLBACK(limpaDrawingArea), desenho);

// out of main, here is my g_callback limpaDrawingArea

static gboolean limpaDrawingArea(GtkWidget *a, GdkEventButton *event,
GtkDesenho *desenho)

{

    gdk_window_clear(desenho->drawingArea->window);
    g_ptr_array_remove_range(desenho->parray, 0, desenho->parray->len);

    return FALSE;
}

It must clear my drawing area, or not?

When I press the button6, this messages are showed:

(main:10566): Gdk-CRITICAL **: gdk_window_clear: assertion `window !=
NULL' failed

(main:10566): GLib-CRITICAL **: g_ptr_array_remove_range: assertion
`index_ < array->len' failed

What's happen? The callbacks button_press and expose_event are working
fine, and them use desenho->drawingArea->window, and
desenho->parray->len too, without showing anyone problem!

Thank you!
-- 
Abraço,
Frederico Schardong,
SOLIS - O lado livre da tecnologia
www.solis.coop.br
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux