]> Pileus Git - ~andy/gtk/commitdiff
Set vertical/horizontal class on all widgets overriding GtkOrientable::orientation
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 12 Jan 2011 21:28:43 +0000 (22:28 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 12 Jan 2011 21:28:43 +0000 (22:28 +0100)
This is so g_object_set() on that property leaves widgets' style in
a meaningful state. Fully fixes bugĀ 639157.

gtk/gtkcellareabox.c
gtk/gtkcellview.c
gtk/gtkgrid.c
gtk/gtkprogressbar.c
gtk/gtkseparator.c
gtk/gtktoolpalette.c

index cc9e8f2983ddb016a26e55456af00f4d4671cc64..ea3a3c8a8d24db2f917d623b822e2fca6bada8a5 100644 (file)
@@ -1049,6 +1049,25 @@ gtk_cell_area_box_dispose (GObject *object)
   G_OBJECT_CLASS (gtk_cell_area_box_parent_class)->dispose (object);
 }
 
+static void
+reset_orientation_style (GtkCellAreaBox *box)
+{
+  GtkStyleContext *context;
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (box));
+
+  if (box->priv->orientation == GTK_ORIENTATION_VERTICAL)
+    {
+      gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+    }
+  else
+    {
+      gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+    }
+}
+
 static void
 gtk_cell_area_box_set_property (GObject       *object,
                                 guint          prop_id,
@@ -1064,6 +1083,8 @@ gtk_cell_area_box_set_property (GObject       *object,
 
       /* Notify that size needs to be requested again */
       reset_contexts (box);
+      reset_orientation_style (box);
+
       break;
     case PROP_SPACING:
       gtk_cell_area_box_set_spacing (box, g_value_get_int (value));
index 168bf04eae1840fd59df271cd2a03af39484280f..87c56ed8bcdaf51a6054da5532e2cdfc8f8a1224 100644 (file)
@@ -414,6 +414,25 @@ gtk_cell_view_get_property (GObject    *object,
     }
 }
 
+static void
+reset_orientation_style (GtkCellView *view)
+{
+  GtkStyleContext *context;
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (view));
+
+  if (view->priv->orientation == GTK_ORIENTATION_VERTICAL)
+    {
+      gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+    }
+  else
+    {
+      gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+    }
+}
+
 static void
 gtk_cell_view_set_property (GObject      *object,
                             guint         param_id,
@@ -430,6 +449,8 @@ gtk_cell_view_set_property (GObject      *object,
       view->priv->orientation = g_value_get_enum (value);
       if (view->priv->context)
        gtk_cell_area_context_reset (view->priv->context);
+
+      reset_orientation_style (view);
       break;
     case PROP_BACKGROUND:
       {
index 3557c16949bd9027a5fcc39fdffadf4a389b1f22..525f970df69d93952c323787d6670bd448f6d1fe 100644 (file)
@@ -187,10 +187,23 @@ gtk_grid_set_orientation (GtkGrid        *grid,
                           GtkOrientation  orientation)
 {
   GtkGridPrivate *priv = grid->priv;
+  GtkStyleContext *context;
 
   if (priv->orientation != orientation)
     {
       priv->orientation = orientation;
+      context = gtk_widget_get_style_context (GTK_WIDGET (grid));
+
+      if (grid->priv->orientation == GTK_ORIENTATION_VERTICAL)
+        {
+          gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+          gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+        }
+      else
+        {
+          gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+          gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+        }
 
       g_object_notify (G_OBJECT (grid), "orientation");
     }
index 3cc366c6a22506ea0a2007c7f3bd08b2ec5e1039..9c8fd92e703c59f29159faaedb77e13c3160911c 100644 (file)
@@ -1204,10 +1204,23 @@ gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
                                   GtkOrientation  orientation)
 {
   GtkProgressBarPrivate *priv = pbar->priv;
+  GtkStyleContext *context;
 
   if (priv->orientation != orientation)
     {
       priv->orientation = orientation;
+      context = gtk_widget_get_style_context (GTK_WIDGET (pbar));
+
+      if (pbar->priv->orientation == GTK_ORIENTATION_VERTICAL)
+        {
+          gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+          gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+        }
+      else
+        {
+          gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+          gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+        }
 
       if (gtk_widget_is_drawable (GTK_WIDGET (pbar)))
         gtk_widget_queue_resize (GTK_WIDGET (pbar));
index 1de28a1a5861bf8ba750f65a2211c3f8a26251fc..b30292fc5019c9de6dcfe945371665a60ae3c361 100644 (file)
@@ -112,6 +112,25 @@ gtk_separator_init (GtkSeparator *separator)
   private->orientation = GTK_ORIENTATION_HORIZONTAL;
 }
 
+static void
+reset_orientation_style (GtkSeparator *separator)
+{
+  GtkStyleContext *context;
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (separator));
+
+  if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL)
+    {
+      gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+    }
+  else
+    {
+      gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+    }
+}
+
 static void
 gtk_separator_set_property (GObject      *object,
                             guint         prop_id,
@@ -125,6 +144,7 @@ gtk_separator_set_property (GObject      *object,
     {
     case PROP_ORIENTATION:
       private->orientation = g_value_get_enum (value);
+      reset_orientation_style (separator);
       gtk_widget_queue_resize (GTK_WIDGET (object));
       break;
     default:
index e35bf813f89e47a575bedcd5f58d5a0a48105737..491cf9e9afef858e0f6bc72df5a6483540596988 100644 (file)
@@ -233,6 +233,25 @@ gtk_tool_palette_reconfigured (GtkToolPalette *palette)
   gtk_widget_queue_resize_no_redraw (GTK_WIDGET (palette));
 }
 
+static void
+reset_orientation_style (GtkToolPalette *palette)
+{
+  GtkStyleContext *context;
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (palette));
+
+  if (palette->priv->orientation == GTK_ORIENTATION_VERTICAL)
+    {
+      gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+    }
+  else
+    {
+      gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+    }
+}
+
 static void
 gtk_tool_palette_set_property (GObject      *object,
                                guint         prop_id,
@@ -263,6 +282,7 @@ gtk_tool_palette_set_property (GObject      *object,
         if ((guint) g_value_get_enum (value) != palette->priv->orientation)
           {
             palette->priv->orientation = g_value_get_enum (value);
+            reset_orientation_style (palette);
             gtk_tool_palette_reconfigured (palette);
           }
         break;