Commit c73b48f2 authored by Matthias Clasen's avatar Matthias Clasen

Add a gtk_window_close function

This is useful when adding close buttons in custom titlebars.
parent 860197a7
......@@ -5560,6 +5560,7 @@ gtk_window_get_default_widget
gtk_window_set_default
gtk_window_present
gtk_window_present_with_time
gtk_window_close
gtk_window_iconify
gtk_window_deiconify
gtk_window_stick
......
......@@ -1235,7 +1235,7 @@ gtk_window_title_max_clicked (GtkWidget *widget, gpointer data)
static gboolean
send_delete_event (gpointer data)
{
GtkWidget *window = GTK_WIDGET (data);
GtkWidget *window = data;
GdkEvent *event;
event = gdk_event_new (GDK_DELETE);
......@@ -1249,10 +1249,25 @@ send_delete_event (gpointer data)
return G_SOURCE_REMOVE;
}
static void
gtk_window_title_close_clicked (GtkWidget *button, gpointer data)
/**
* gtk_window_close:
* @window: a #GtkWindow
*
* Requests that the window is closed, similar to what happens
* when a window manager close button is clicked.
*
* This function can be used with close buttons in custom
* titlebars.
*
* Since: 3.10
*/
void
gtk_window_close (GtkWindow *window)
{
gdk_threads_add_idle (send_delete_event, data);
if (!gtk_widget_get_realized (GTK_WIDGET (window)))
return;
gdk_threads_add_idle (send_delete_event, window);
}
static void
......@@ -5157,7 +5172,7 @@ update_window_buttons (GtkWindow *window)
gtk_widget_set_can_focus (button, FALSE);
gtk_widget_show_all (button);
g_signal_connect (button, "clicked",
G_CALLBACK (gtk_window_title_close_clicked), window);
G_CALLBACK (gtk_window_close), window);
priv->title_close_button = button;
}
......
......@@ -348,6 +348,8 @@ GDK_AVAILABLE_IN_ALL
void gtk_window_fullscreen (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
void gtk_window_unfullscreen (GtkWindow *window);
GDK_AVAILABLE_IN_3_10
void gtk_window_close (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
void gtk_window_set_keep_above (GtkWindow *window, gboolean setting);
GDK_AVAILABLE_IN_ALL
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment