[gtk+] csd: Improve window button handling



commit 328f221b5c0523ea7eb6d4b58047f67c849e3588
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 29 18:18:35 2013 -0400

    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.

 gtk/gtkwindow.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index b7cb9da..eb2a12f 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -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);
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]