drawing area and events win32
- From: "jaykumar" <jaykumar mettatechnology com>
- To: <gtk-app-devel-list gnome org>
- Subject: drawing area and events win32
- Date: Tue, 16 Aug 2005 16:40:54 +0530
Hi,
I am new to gtk development, currently I have used gtk -win32 version
2.6.7 for creating a video player.
the ui consists of few buttons ( in vbox1) and and a drawing area ( in
vbox2); and both boxes are packed in Hbox which is loaded in mainwindow.
problem statement:
I had used expose event to display content of RGB buffer on drawing
area (darea), this event is emitted explicitly by a timer (according to
framerate) when completed rgb buffer loading.
video playes smooth and continuous until I press any of the buttons
which are in other part of GUI ( vbox1) leads to player crash with
following message from MS Windows:
>>>>>>>>>>>>>>>>>>
Gdk-ERROR **: file gdkgc-win32.c: line912 (gdk_win32_hdc_get):
assertion failed (win32_gc->hdc == NULL)
aborting...... [ok]
followed by
Runtime error!
program : ......myprog.exe
this program has requested Runtime to terminate it in a unusual way
.......:-D
>>>>>>>>>>>>>>>>>>>windows as usual>>>>>>>>>
when video is paused or not being played ( more better I can say no
expose events generated, say @30 fps).
i had added fake handler for this unused events, but it had just
decreased rate of crash from per video played to 2/5 th. :-(
I dont know if my code is a broken GTk program or i had missed few lines.
if some one can suggest clues
following is my code snippet:
---------------------------------------------------------------------
-------------------timer-------------
void CALLBACK onDisplayframe(int arg, BOOL TimerOrWaitFired)
{
g_signal_emit_by_name(GTK_OBJECT(darea),"expose_event", 0 );
}
-----------main program---------------
int main(int argc,char *argv[])
{
GtkWidget *play_button, *pause_button, *stop_button, *quit_button,
*open_button, *step_button, *text;
GtkWidget *vbox1_fixed, *hbox, *vbox1, *vbox2;
mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (mainwindow), "destroy",G_CALLBACK (destroy),
NULL);
g_signal_connect_swapped (G_OBJECT (mainwindow), "delete_event",G_CALLBACK
(delete_event), NULL);
..........
darea = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(vbox1), darea);
gtk_drawing_area_size((GtkDrawingArea *)darea,890,590);
gtk_signal_connect(GTK_OBJECT (darea), "expose-event",GTK_SIGNAL_FUNC
(on_darea_expose), NULL);
gtk_widget_set_events (darea, GDK_EXPOSURE_MASK |GDK_LEAVE_NOTIFY_MASK
|GDK_BUTTON_PRESS_MASK);
open_button = gtk_button_new_with_label ("Open");
//g_signal_connect (G_OBJECT (open_button), "clicked",G_CALLBACK
(file_dialog), NULL);
g_signal_connect (G_OBJECT (open_button), "focus_in_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (open_button), "focus_out_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (open_button), "leave_notify_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (open_button), "button_release_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (open_button), "button_press_event",G_CALLBACK
(file_dialog), NULL);
gtk_widget_set_size_request (open_button, 100, 30);
play_button = gtk_button_new_with_label ("Play");
//g_signal_connect (G_OBJECT (play_button), "clicked",G_CALLBACK (OnPlay),
NULL);
g_signal_connect (G_OBJECT (play_button), "focus_in_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (play_button), "focus_out_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (play_button), "leave_notify_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (play_button), "button_release_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (play_button), "button_press_event",G_CALLBACK
(OnPlay), NULL);
gtk_widget_set_size_request (play_button, 100, 30);
repeat_button = gtk_check_button_new_with_label ("Repeat");
gtk_toggle_button_set_active((GtkToggleButton *)repeat_button,TRUE);
g_signal_connect (G_OBJECT (repeat_button), "clicked",G_CALLBACK
(OnRepeat),NULL);
g_signal_connect (G_OBJECT (repeat_button), "focus_in_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (repeat_button), "focus_out_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (repeat_button), "leave_notify_event",G_CALLBACK
(default_func), NULL);
gtk_widget_set_size_request (repeat_button, 100, 20);
pause_button = gtk_button_new_with_label ("Pause");
//g_signal_connect (G_OBJECT (pause_button), "clicked",G_CALLBACK (OnPause),
NULL);
g_signal_connect (G_OBJECT (pause_button), "focus_in_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (pause_button), "focus_out_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (pause_button), "leave_notify_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (pause_button), "button_release_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (pause_button), "button_press_event",G_CALLBACK
(OnPause), NULL);
gtk_widget_set_size_request (pause_button, 100, 30);
stop_button = gtk_button_new_with_label ("Stop");
//g_signal_connect (G_OBJECT (stop_button), "clicked",G_CALLBACK (OnStop),
NULL);
g_signal_connect (G_OBJECT (stop_button), "focus_in_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (stop_button), "focus_out_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (stop_button), "leave_notify_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (stop_button), "button_release_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (stop_button), "button_press_event",G_CALLBACK
(OnStop), NULL);
gtk_widget_set_size_request (stop_button, 100, 30);
quit_button = gtk_button_new_with_label ("Quit");
g_signal_connect (G_OBJECT (quit_button), "clicked",G_CALLBACK
(OnExit),NULL);
g_signal_connect_swapped (G_OBJECT (quit_button), "clicked",G_CALLBACK
(gtk_widget_destroy),G_OBJECT (mainwindow));
g_signal_connect (G_OBJECT (quit_button), "focus_in_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (quit_button), "focus_out_event",G_CALLBACK
(default_func), NULL);
g_signal_connect (G_OBJECT (quit_button), "leave_notify_event",G_CALLBACK
(default_func), NULL);
gtk_widget_set_size_request (quit_button, 100, 30);
gtk_widget_show (open_button);
gtk_widget_show (play_button);
gtk_widget_show (repeat_button);
gtk_widget_show (pause_button);
gtk_widget_show (step_button);
gtk_widget_show (stop_button);
gtk_widget_show (quit_button);
gtk_widget_show (vbox1_fixed);
gtk_box_pack_start(GTK_BOX(hbox), vbox1, FALSE, FALSE, 0);
gtk_widget_show(vbox1);
gtk_box_pack_end(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0);
gtk_widget_show(vbox2);
gtk_container_add(GTK_CONTAINER(mainwindow), hbox);
gtk_widget_show(hbox);
gtk_widget_show(mainwindow);
gtk_main();
return 0;
}
------------------expose event handler------------
gboolean on_darea_expose (GtkWidget *widget, GdkEventExpose *event, gpointer
user_data)
{
gdk_draw_rgb_image(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],0,
0, mvsheader.colCount,mvsheader.rowCount,GDK_RGB_DITHER_MAX,
myrgbbuff_gfx.rgbbuffer, mvsheader.colCount * 3);
return TRUE;
}
------------------fake handler-------------------
BOOL default_func(void)
{
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]