[Xfce4-commits] <exo:stephan/icon-bar-improvements> Improve alignment of items

Stephan Arts noreply at xfce.org
Mon Jan 30 18:38:01 CET 2012


Updating branch refs/heads/stephan/icon-bar-improvements
         to 7b8cb887373648f3166c4fbf637deda8cd3bc3f1 (commit)
       from ac31b57ec639a7405787bbc89280014e66fe6da7 (commit)

commit 7b8cb887373648f3166c4fbf637deda8cd3bc3f1
Author: Stephan Arts <stephan at xfce.org>
Date:   Mon Jan 30 18:35:02 2012 +0100

    Improve alignment of items

 exo/exo-icon-bar.c |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/exo/exo-icon-bar.c b/exo/exo-icon-bar.c
index 3e885f8..5327f08 100644
--- a/exo/exo-icon-bar.c
+++ b/exo/exo-icon-bar.c
@@ -748,11 +748,15 @@ exo_icon_bar_size_allocate (GtkWidget     *widget,
     {
       icon_bar->priv->width = allocation->width;
       icon_bar->priv->item_width = icon_bar->priv->width;
+      icon_bar->priv->hadjustment->value = 0;
+      gtk_adjustment_value_changed (icon_bar->priv->hadjustment);
     }
   else
     {
       icon_bar->priv->height = allocation->height;
       icon_bar->priv->item_height = icon_bar->priv->height;
+      icon_bar->priv->vadjustment->value = 0;
+      gtk_adjustment_value_changed (icon_bar->priv->vadjustment);
     }
 }
 
@@ -1200,7 +1204,7 @@ exo_icon_bar_paint_item (ExoIconBar     *icon_bar,
       if (G_LIKELY (pixbuf != NULL))
         {
           gdk_draw_pixbuf (icon_bar->priv->bin_window, NULL, pixbuf, 0, 0,
-                           px, py, item->pixbuf_width, item->pixbuf_height,
+                           px-1, py-1, item->pixbuf_width, item->pixbuf_height,
                            GDK_RGB_DITHER_NORMAL, item->pixbuf_width,
                            item->pixbuf_height);
           g_object_unref (pixbuf);
@@ -1301,23 +1305,26 @@ exo_icon_bar_calculate_item_size (ExoIconBar      *icon_bar,
       item->pixbuf_height = 0;
     }
 
-  if (icon_bar->priv->text_column != -1)
+  if (icon_bar->priv->text_column != -1 && icon_bar->priv->show_text == TRUE)
     {
       exo_icon_bar_update_item_text (icon_bar, item);
       pango_layout_get_pixel_size (icon_bar->priv->layout,
                                    &item->layout_width,
                                    &item->layout_height);
+      item->width = MAX (item->layout_width, item->pixbuf_width) + 2 * ICON_TEXT_PADDING
+                  + 2 * (focus_width + focus_pad);
+      item->height = item->layout_height + 2 * (focus_width + focus_pad + ICON_TEXT_PADDING)
+                   + item->pixbuf_height;
     }
   else
     {
       item->layout_width = 0;
       item->layout_height = 0;
+
+      item->width = MAX (item->layout_width, item->pixbuf_width) + 2 * (focus_width + focus_pad);
+      item->height = item->layout_height + 2 * (focus_width + focus_pad ) + item->pixbuf_height;
     }
 
-  item->width = MAX (item->layout_width, item->pixbuf_width) + 2 * ICON_TEXT_PADDING
-              + 2 * (focus_width + focus_pad);
-  item->height = item->layout_height + 2 * (focus_width + focus_pad + ICON_TEXT_PADDING)
-               + item->pixbuf_height;
 
   if (item->width < item->height)
   {
@@ -2063,7 +2070,13 @@ exo_icon_bar_show_active (ExoIconBar *icon_bar)
 
   if (icon_bar->priv->orientation == GTK_ORIENTATION_VERTICAL)
     {
-      gtk_adjustment_set_value (icon_bar->priv->vadjustment, icon_bar->priv->active_item->index * icon_bar->priv->item_height);
+      page_size = gtk_adjustment_get_page_size (icon_bar->priv->vadjustment);
+      value = icon_bar->priv->active_item->index * icon_bar->priv->item_height - ((page_size-icon_bar->priv->item_height)/2);
+
+      if (value > (gtk_adjustment_get_upper (icon_bar->priv->vadjustment)-page_size))
+        value = (gtk_adjustment_get_upper (icon_bar->priv->vadjustment)-page_size);
+
+      gtk_adjustment_set_value (icon_bar->priv->vadjustment, value);
       gtk_adjustment_changed (icon_bar->priv->vadjustment);
       return TRUE;
     }


More information about the Xfce4-commits mailing list