[gnome-panel] panel: Add style class for orientation to menubar



commit 884600e579b40210b8ea0f333becc5bffe4ca9f1
Author: Peter Hurley <peter hurleysoftware com>
Date:   Wed Mar 14 12:14:04 2012 -0400

    panel: Add style class for orientation to menubar
    
      Add style class "horizontal" or "vertical" based on the orientation
      of the menubar. This allows themeing to adjust styling for vertical
      panels. An example selector would be:
    
      PanelMenuBar.menubar.vertical {
        background-image: -gtk-gradient (linear, right top, left top,
                                         from (shade (@dark_bg_color, 1.15)),
                                         to (shade (@dark_bg_color, 0.95)));
      }
    
    Signed-off-by: Peter Hurley <peter hurleysoftware com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672070

 gnome-panel/panel-menu-bar-object.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gnome-panel/panel-menu-bar-object.c b/gnome-panel/panel-menu-bar-object.c
index 9752f2a..2d9050d 100644
--- a/gnome-panel/panel-menu-bar-object.c
+++ b/gnome-panel/panel-menu-bar-object.c
@@ -83,6 +83,11 @@ panel_menu_bar_object_init (PanelMenuBarObject *menubar)
         g_object_unref (provider);
 	gtk_style_context_add_class (context, "gnome-panel-menu-bar");
 
+	if (menubar->priv->orientation & PANEL_HORIZONTAL_MASK)
+		gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+	else
+		gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+
 	menubar->priv->panel = NULL;
 }
 
@@ -346,6 +351,8 @@ void
 panel_menu_bar_object_set_orientation (PanelMenuBarObject *menubar,
 				       PanelOrientation    orientation)
 {
+	GtkStyleContext *context;
+
         g_return_if_fail (PANEL_IS_MENU_BAR_OBJECT (menubar));
 
         if (menubar->priv->orientation == orientation)
@@ -353,6 +360,16 @@ panel_menu_bar_object_set_orientation (PanelMenuBarObject *menubar,
 
         menubar->priv->orientation = orientation;
 
+	context = gtk_widget_get_style_context (GTK_WIDGET (menubar));
+	if (orientation & PANEL_HORIZONTAL_MASK) {
+		gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+		gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+	} else {
+		gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+		gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+	}
+	gtk_widget_reset_style (GTK_WIDGET (menubar));
+
         panel_menu_bar_object_update_orientation (menubar);
 
         g_object_notify (G_OBJECT (menubar), "orientation");



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