diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/converter/convgui.c | 2 | ||||
-rw-r--r-- | plugins/gtkui/actionhandlers.c | 3 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.c | 2 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 27 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.h | 3 |
5 files changed, 33 insertions, 4 deletions
diff --git a/plugins/converter/convgui.c b/plugins/converter/convgui.c index 7147f09e..ccb15878 100644 --- a/plugins/converter/convgui.c +++ b/plugins/converter/convgui.c @@ -128,6 +128,7 @@ overwrite_prompt_cb (void *ctx) { static void converter_worker (void *ctx) { + deadbeef->background_job_increment (); converter_ctx_t *conv = ctx; char root[2000] = ""; @@ -243,6 +244,7 @@ converter_worker (void *ctx) { converter_plugin->encoder_preset_free (conv->encoder_preset); converter_plugin->dsp_preset_free (conv->dsp_preset); free (conv); + deadbeef->background_job_decrement (); } int diff --git a/plugins/gtkui/actionhandlers.c b/plugins/gtkui/actionhandlers.c index 1ca56aa0..b7e05f39 100644 --- a/plugins/gtkui/actionhandlers.c +++ b/plugins/gtkui/actionhandlers.c @@ -260,8 +260,7 @@ action_add_folders_handler (struct DB_plugin_action_s *action, int ctx) { gboolean action_quit_handler_cb (void *user_data) { - progress_abort (); - deadbeef->sendmessage (DB_EV_TERMINATE, 0, 0, 0); + gtkui_quit (); return FALSE; } diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 2369ff97..3bb0fe2c 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -495,7 +495,7 @@ on_mainwin_delete_event (GtkWidget *widget, gtk_widget_hide (widget); } else { - deadbeef->sendmessage (DB_EV_TERMINATE, 0, 0, 0); + gtkui_quit (); } return TRUE; } diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 5ac539b6..a982fe2c 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -906,7 +906,7 @@ smclient_quit_cancelled (EggSMClient *client, gpointer user_data) { static void smclient_quit (EggSMClient *client, gpointer user_data) { - deadbeef->sendmessage (DB_EV_TERMINATE, 0, 0, 0); + gtkui_quit (); } static void @@ -1251,6 +1251,31 @@ gtkui_show_info_window (const char *fname, const char *title, GtkWidget **pwindo g_object_unref (buffer); gtk_widget_show (widget); } + +gboolean +gtkui_quit_cb (void *ctx) { + if (deadbeef->have_background_jobs ()) { + GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (mainwin), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, _("The player is currently running backgroud tasks. If you quit now, the tasks will be cancelled or interrupted. Data loss may result")); + gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (mainwin)); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), _("Do you still want to quit?")); + gtk_window_set_title (GTK_WINDOW (dlg), _("Warning")); + + int response = gtk_dialog_run (GTK_DIALOG (dlg)); + gtk_widget_destroy (dlg); + if (response != GTK_RESPONSE_YES) { + return FALSE; + } + } + progress_abort (); + deadbeef->sendmessage (DB_EV_TERMINATE, 0, 0, 0); + return FALSE; +} + +void +gtkui_quit (void) { + gdk_threads_add_idle (gtkui_quit_cb, NULL); +} + static int gtkui_start (void) { fprintf (stderr, "gtkui plugin compiled for gtk version: %d.%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h index 0065bb21..3867cc19 100644 --- a/plugins/gtkui/gtkui.h +++ b/plugins/gtkui/gtkui.h @@ -167,4 +167,7 @@ gtkui_create_pltmenu (int plt_idx); void plt_get_title_wrapper (int plt, char *buffer, int len); +void +gtkui_quit (void); + #endif |