Commit 328f221b authored by Matthias Clasen's avatar Matthias Clasen

csd: Improve window button handling

Group the buttons on each side in a box, and give them different
style classes, so themes can differentiate (this is partially a
workaround for limitations in our css selectors). The boxes also
let us add a margin below the buttons, without affecting the
allocation of the buttons themselves.
parent 534a7a93
......@@ -5046,11 +5046,13 @@ update_window_buttons (GtkWindow *window)
{
GtkWindowPrivate *priv = window->priv;
gboolean maximized;
GtkTextDirection direction;
if (priv->title_box == NULL)
return;
maximized = gtk_window_get_maximized (window);
direction = gtk_widget_get_direction (GTK_WIDGET (window));
if (priv->fullscreen ||
(maximized && priv->hide_titlebar_when_maximized))
......@@ -5107,9 +5109,24 @@ update_window_buttons (GtkWindow *window)
{
for (i = 0; i < 2; i++)
{
GtkWidget *box;
if (tokens[i] == NULL)
continue;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show (box);
gtk_widget_set_margin_bottom (box, 6);
if ((direction == GTK_TEXT_DIR_LTR && i == 0) ||
(direction == GTK_TEXT_DIR_RTL && i == 1))
gtk_style_context_add_class (gtk_widget_get_style_context (box), "left");
else
gtk_style_context_add_class (gtk_widget_get_style_context (box), "right");
if (i == 0)
gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->title_box), box);
else
gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->title_box), box);
t = g_strsplit (tokens[i], ",", -1);
for (j = 0; t[j]; j++)
{
......@@ -5181,12 +5198,7 @@ update_window_buttons (GtkWindow *window)
}
if (button)
{
if (i == 0)
gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->title_box), button);
else
gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->title_box), button);
}
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
}
g_strfreev (t);
}
......
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