Redo patch in efae64b
(Set vertical/horizontal class...)
Add a _gtk_orientable_set_style_classes() function so all orientation changes to style happen in a single place.
This commit is contained in:
@ -1049,25 +1049,6 @@ gtk_cell_area_box_dispose (GObject *object)
|
|||||||
G_OBJECT_CLASS (gtk_cell_area_box_parent_class)->dispose (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
|
static void
|
||||||
gtk_cell_area_box_set_property (GObject *object,
|
gtk_cell_area_box_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -1083,7 +1064,6 @@ gtk_cell_area_box_set_property (GObject *object,
|
|||||||
|
|
||||||
/* Notify that size needs to be requested again */
|
/* Notify that size needs to be requested again */
|
||||||
reset_contexts (box);
|
reset_contexts (box);
|
||||||
reset_orientation_style (box);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PROP_SPACING:
|
case PROP_SPACING:
|
||||||
|
@ -414,25 +414,6 @@ 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
|
static void
|
||||||
gtk_cell_view_set_property (GObject *object,
|
gtk_cell_view_set_property (GObject *object,
|
||||||
guint param_id,
|
guint param_id,
|
||||||
@ -450,7 +431,7 @@ gtk_cell_view_set_property (GObject *object,
|
|||||||
if (view->priv->context)
|
if (view->priv->context)
|
||||||
gtk_cell_area_context_reset (view->priv->context);
|
gtk_cell_area_context_reset (view->priv->context);
|
||||||
|
|
||||||
reset_orientation_style (view);
|
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
|
||||||
break;
|
break;
|
||||||
case PROP_BACKGROUND:
|
case PROP_BACKGROUND:
|
||||||
{
|
{
|
||||||
|
@ -187,23 +187,11 @@ gtk_grid_set_orientation (GtkGrid *grid,
|
|||||||
GtkOrientation orientation)
|
GtkOrientation orientation)
|
||||||
{
|
{
|
||||||
GtkGridPrivate *priv = grid->priv;
|
GtkGridPrivate *priv = grid->priv;
|
||||||
GtkStyleContext *context;
|
|
||||||
|
|
||||||
if (priv->orientation != orientation)
|
if (priv->orientation != orientation)
|
||||||
{
|
{
|
||||||
priv->orientation = orientation;
|
priv->orientation = orientation;
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (grid));
|
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (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");
|
g_object_notify (G_OBJECT (grid), "orientation");
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,6 @@ void
|
|||||||
gtk_orientable_set_orientation (GtkOrientable *orientable,
|
gtk_orientable_set_orientation (GtkOrientable *orientable,
|
||||||
GtkOrientation orientation)
|
GtkOrientation orientation)
|
||||||
{
|
{
|
||||||
GtkStyleContext *context;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
|
g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
|
||||||
|
|
||||||
g_object_set (orientable,
|
g_object_set (orientable,
|
||||||
@ -89,20 +87,7 @@ gtk_orientable_set_orientation (GtkOrientable *orientable,
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (GTK_IS_WIDGET (orientable))
|
if (GTK_IS_WIDGET (orientable))
|
||||||
{
|
_gtk_orientable_set_style_classes (orientable);
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (orientable));
|
|
||||||
|
|
||||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,3 +114,27 @@ gtk_orientable_get_orientation (GtkOrientable *orientable)
|
|||||||
|
|
||||||
return orientation;
|
return orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gtk_orientable_set_style_classes (GtkOrientable *orientable)
|
||||||
|
{
|
||||||
|
GtkStyleContext *context;
|
||||||
|
GtkOrientation orientation;
|
||||||
|
|
||||||
|
g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
|
||||||
|
g_return_if_fail (GTK_IS_WIDGET (orientable));
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (GTK_WIDGET (orientable));
|
||||||
|
orientation = gtk_orientable_get_orientation (orientable);
|
||||||
|
|
||||||
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -55,6 +55,9 @@ void gtk_orientable_set_orientation (GtkOrientable *orientable,
|
|||||||
GtkOrientation orientation);
|
GtkOrientation orientation);
|
||||||
GtkOrientation gtk_orientable_get_orientation (GtkOrientable *orientable);
|
GtkOrientation gtk_orientable_get_orientation (GtkOrientable *orientable);
|
||||||
|
|
||||||
|
/* Private */
|
||||||
|
void _gtk_orientable_set_style_classes (GtkOrientable *orientable);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_ORIENTABLE_H__ */
|
#endif /* __GTK_ORIENTABLE_H__ */
|
||||||
|
@ -1204,23 +1204,11 @@ gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
|
|||||||
GtkOrientation orientation)
|
GtkOrientation orientation)
|
||||||
{
|
{
|
||||||
GtkProgressBarPrivate *priv = pbar->priv;
|
GtkProgressBarPrivate *priv = pbar->priv;
|
||||||
GtkStyleContext *context;
|
|
||||||
|
|
||||||
if (priv->orientation != orientation)
|
if (priv->orientation != orientation)
|
||||||
{
|
{
|
||||||
priv->orientation = orientation;
|
priv->orientation = orientation;
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (pbar));
|
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (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)))
|
if (gtk_widget_is_drawable (GTK_WIDGET (pbar)))
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (pbar));
|
gtk_widget_queue_resize (GTK_WIDGET (pbar));
|
||||||
|
@ -112,25 +112,6 @@ gtk_separator_init (GtkSeparator *separator)
|
|||||||
private->orientation = GTK_ORIENTATION_HORIZONTAL;
|
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
|
static void
|
||||||
gtk_separator_set_property (GObject *object,
|
gtk_separator_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -144,7 +125,7 @@ gtk_separator_set_property (GObject *object,
|
|||||||
{
|
{
|
||||||
case PROP_ORIENTATION:
|
case PROP_ORIENTATION:
|
||||||
private->orientation = g_value_get_enum (value);
|
private->orientation = g_value_get_enum (value);
|
||||||
reset_orientation_style (separator);
|
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -233,25 +233,6 @@ gtk_tool_palette_reconfigured (GtkToolPalette *palette)
|
|||||||
gtk_widget_queue_resize_no_redraw (GTK_WIDGET (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
|
static void
|
||||||
gtk_tool_palette_set_property (GObject *object,
|
gtk_tool_palette_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -282,7 +263,7 @@ gtk_tool_palette_set_property (GObject *object,
|
|||||||
if ((guint) g_value_get_enum (value) != palette->priv->orientation)
|
if ((guint) g_value_get_enum (value) != palette->priv->orientation)
|
||||||
{
|
{
|
||||||
palette->priv->orientation = g_value_get_enum (value);
|
palette->priv->orientation = g_value_get_enum (value);
|
||||||
reset_orientation_style (palette);
|
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (palette));
|
||||||
gtk_tool_palette_reconfigured (palette);
|
gtk_tool_palette_reconfigured (palette);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user