summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Watson <mattdangerw@gmail.com>2013-08-30 12:43:01 -0700
committerMatt Watson <mattdangerw@gmail.com>2013-08-30 17:43:10 -0700
commit20e6a38f94cb02c94d9091b104ad390d0d995279 (patch)
treef8f69664d41ab4c90ae349de286f9c96f6f94b69
parent50629bb649ac1fd9fff1486b2c32b55b9268e2f7 (diff)
Emit delete-event on x button click
This gives the apps a chance to intercept the delete event and prompt the user before closing the app. We synthesize the delete-event in eos-window and connect a default handler which destroys the window [endlessm/eos-sdk#284]
-rw-r--r--endless/eoswindow.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/endless/eoswindow.c b/endless/eoswindow.c
index 37216f3..366ad36 100644
--- a/endless/eoswindow.c
+++ b/endless/eoswindow.c
@@ -516,6 +516,15 @@ eos_window_forall (GtkContainer *container,
callback_data);
}
+/* Our default delete event handler destroys the window. */
+static gboolean
+eos_window_default_delete (GtkWidget* window,
+ gpointer user_data)
+{
+ gtk_widget_destroy (GTK_WIDGET (window));
+ return FALSE;
+}
+
static void
eos_window_class_init (EosWindowClass *klass)
{
@@ -537,6 +546,7 @@ eos_window_class_init (EosWindowClass *klass)
widget_class->unmap = eos_window_unmap;
widget_class->show = eos_window_show;
container_class->forall = eos_window_forall;
+ widget_class->delete_event = eos_window_default_delete;
/**
* EosWindow:application:
@@ -581,7 +591,10 @@ on_close_clicked_cb (GtkWidget* top_bar,
{
if (user_data != NULL)
{
- gtk_widget_destroy (GTK_WIDGET (user_data));
+ // We don't actually care about the return value, the default "delete-event" handler
+ // will take care of closing windows for us
+ gboolean dummy = FALSE;
+ g_signal_emit_by_name (G_OBJECT (user_data), "delete-event", NULL, &dummy);
}
}