From 0eacb2babbab14c5318e883963073b32079a9aff Mon Sep 17 00:00:00 2001 From: Maksym Veremeyenko Date: Wed, 22 Jun 2011 16:15:36 +0300 Subject: [PATCH] make exit procedure correct --- src/main.c | 1 - src/omnplay.cpp | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 94edc7a..41d770f 100644 --- a/src/main.c +++ b/src/main.c @@ -82,7 +82,6 @@ int main(int argc, char **argv) gdk_threads_enter(); omnplay_init(app); gtk_main (); - omnplay_release(app); gdk_threads_leave(); }; diff --git a/src/omnplay.cpp b/src/omnplay.cpp index 2912ecd..d460135 100644 --- a/src/omnplay.cpp +++ b/src/omnplay.cpp @@ -84,8 +84,19 @@ int omnplay_get_content(omnplay_instance_t* app, playlist_item_t *items, int lim static gboolean on_main_window_delete_event( GtkWidget *widget, GdkEvent *event, gpointer user_data ) { - gtk_exit(0); - return TRUE; + g_print ("delete event occurred [start]\n"); + gdk_threads_leave(); + omnplay_release((omnplay_instance_t*)user_data); + gdk_threads_enter(); + g_print ("delete event occurred [finish]\n"); + + return FALSE; +} + +static void on_main_window_destroy( GtkWidget *widget, gpointer user_data ) +{ + g_print ("destroy occurred\n"); + gtk_main_quit(); } omnplay_instance_t* omnplay_create(int argc, char** argv) @@ -994,9 +1005,12 @@ void omnplay_init(omnplay_instance_t* app) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - gtk_signal_connect( GTK_OBJECT( app->window ), "destroy", + gtk_signal_connect( GTK_OBJECT( app->window ), "delete-event", GTK_SIGNAL_FUNC(on_main_window_delete_event), app); + gtk_signal_connect( GTK_OBJECT( app->window ), "destroy", + GTK_SIGNAL_FUNC(on_main_window_destroy), app); + gtk_widget_add_events(app->playlist_grid, GDK_BUTTON_PRESS_MASK); gtk_signal_connect(GTK_OBJECT(app->playlist_grid), "key-press-event", GTK_SIGNAL_FUNC(on_playlist_grid_key), app); -- 1.7.4.4