Commit 74cd6de4 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Hide buttons when appropriate

Hide the close button if the window is not deletable, hide the
maximize button if the window is not resizable, and hide all
buttons if the window is a dialog.
parent ca849344
......@@ -437,6 +437,7 @@ static void gtk_window_unrealize_icon (GtkWindow *window);
static void resize_grip_create_window (GtkWindow *window);
static void resize_grip_destroy_window (GtkWindow *window);
static void update_grip_visibility (GtkWindow *window);
static void update_window_buttons (GtkWindow *window);
static void gtk_window_notify_keys_changed (GtkWindow *window);
static GtkKeyHash *gtk_window_get_key_hash (GtkWindow *window);
......@@ -2900,6 +2901,8 @@ gtk_window_set_type_hint (GtkWindow *window,
priv->reset_type_hint = TRUE;
priv->gdk_type_hint = hint;
update_window_buttons (window);
}
/**
......@@ -3480,6 +3483,8 @@ gtk_window_set_deletable (GtkWindow *window,
GDK_FUNC_ALL | GDK_FUNC_CLOSE);
}
update_window_buttons (window);
g_object_notify (G_OBJECT (window), "deletable");
}
......@@ -4853,6 +4858,51 @@ get_default_title (void)
return title;
}
static void
update_window_buttons (GtkWindow *window)
{
GtkWindowPrivate *priv = window->priv;
if (priv->client_decorated)
{
if (priv->title_box != NULL)
gtk_widget_show (priv->title_box);
if (priv->title_min_button != NULL)
{
if (priv->gdk_type_hint == GDK_WINDOW_TYPE_HINT_NORMAL)
gtk_widget_show (priv->title_min_button);
else
gtk_widget_hide (priv->title_min_button);
}
if (priv->title_max_button != NULL)
{
if (priv->resizable &&
priv->gdk_type_hint == GDK_WINDOW_TYPE_HINT_NORMAL)
gtk_widget_show (priv->title_max_button);
else
gtk_widget_hide (priv->title_max_button);
}
if (priv->title_close_button != NULL)
{
if (priv->deletable &&
priv->gdk_type_hint == GDK_WINDOW_TYPE_HINT_NORMAL)
gtk_widget_show_all (priv->title_close_button);
else
gtk_widget_hide (priv->title_close_button);
}
if (priv->title_label != NULL)
gtk_widget_show (priv->title_label);
}
else
{
if (priv->title_box != NULL)
gtk_widget_hide (priv->title_box);
}
}
static void
create_decoration (GtkWidget *widget)
......@@ -4929,6 +4979,8 @@ create_decoration (GtkWidget *widget)
G_CALLBACK (gtk_window_title_min_clicked), window);
gtk_widget_show_all (priv->title_box);
update_window_buttons (window);
}
}
......@@ -8765,6 +8817,7 @@ gtk_window_set_resizable (GtkWindow *window,
priv->resizable = resizable;
update_grip_visibility (window);
update_window_buttons (window);
gtk_widget_queue_resize_no_redraw (GTK_WIDGET (window));
......
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