static void st_bin_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StBinPrivate *priv = ST_BIN (self)->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); st_theme_node_adjust_for_height (theme_node, &for_height); if (priv->child == NULL) { if (min_width_p) *min_width_p = 0; if (natural_width_p) *natural_width_p = 0; } else { _st_actor_get_preferred_width (priv->child, for_height, priv->y_fill, min_width_p, natural_width_p); } st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void shell_slicer_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { ClutterActor *child = st_bin_get_child (ST_BIN (self)); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); st_theme_node_adjust_for_height (theme_node, &for_height); if (min_width_p) *min_width_p = 0; if (child == NULL) { if (natural_width_p) *natural_width_p = 0; } else { _st_actor_get_preferred_width (child, for_height, FALSE, NULL, natural_width_p); } st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_scroll_bar_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StScrollBar *bar = ST_SCROLL_BAR (self); StScrollBarPrivate *priv = bar->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); st_theme_node_adjust_for_height (theme_node, &for_height); if (min_width_p) *min_width_p = 0; if (natural_width_p) *natural_width_p = 0; if (priv->vertical) { gfloat tmin_width_p, tnatural_width_p; #define ADJUST_WIDTH_IF_LARGER(actor) \ _st_actor_get_preferred_width (actor, for_height, TRUE, \ &tmin_width_p, &tnatural_width_p); \ if (min_width_p && tmin_width_p > *min_width_p) \ *min_width_p = tmin_width_p; \ if (natural_width_p && tnatural_width_p > *natural_width_p) \ *natural_width_p = tnatural_width_p; ADJUST_WIDTH_IF_LARGER (priv->bw_stepper); ADJUST_WIDTH_IF_LARGER (priv->fw_stepper); ADJUST_WIDTH_IF_LARGER (priv->trough); ADJUST_WIDTH_IF_LARGER (priv->handle); #undef ADJUST_WIDTH_IF_LARGER } else { gfloat tmin_width_p, tnatural_width_p; #define ADD_TO_WIDTH(actor) \ _st_actor_get_preferred_width (actor, for_height, TRUE, \ &tmin_width_p, &tnatural_width_p); \ if (min_width_p) \ *min_width_p += tmin_width_p; \ if (natural_width_p ) \ *natural_width_p += tnatural_width_p; ADD_TO_WIDTH (priv->bw_stepper); ADD_TO_WIDTH (priv->fw_stepper); ADD_TO_WIDTH (priv->trough); ADD_TO_WIDTH (priv->handle); #undef ADD_TO_WIDTH } st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_scroll_view_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gfloat min_width = 0, natural_width; gfloat child_min_width, child_natural_width; if (!priv->child) return; st_theme_node_adjust_for_height (theme_node, &for_height); clutter_actor_get_preferred_width (priv->child, -1, &child_min_width, &child_natural_width); natural_width = child_natural_width; switch (priv->hscrollbar_policy) { case GTK_POLICY_NEVER: min_width = child_min_width; break; case GTK_POLICY_ALWAYS: case GTK_POLICY_AUTOMATIC: case GTK_POLICY_EXTERNAL: /* Should theoretically use the min width of the hscrollbar, * but that's not cleanly defined at the moment */ min_width = 0; break; default: g_warn_if_reached(); break; } if (priv->vscrollbar_policy != GTK_POLICY_NEVER) { float sb_width = get_scrollbar_width (ST_SCROLL_VIEW (actor), for_height); min_width += sb_width; natural_width += sb_width; } if (min_width_p) *min_width_p = min_width; if (natural_width_p) *natural_width_p = natural_width; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void sagarmatha_stack_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { SagarmathaStack *stack = SAGARMATHA_STACK (actor); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gboolean first = TRUE; float min = 0, natural = 0; GList *iter; GList *children; st_theme_node_adjust_for_height (theme_node, &for_height); children = st_container_get_children_list (ST_CONTAINER (stack)); for (iter = children; iter; iter = iter->next) { ClutterActor *child = iter->data; float child_min, child_natural; clutter_actor_get_preferred_width (child, for_height, &child_min, &child_natural); if (first) { first = FALSE; min = child_min; natural = child_natural; } else { if (child_min > min) min = child_min; if (child_natural > natural) natural = child_natural; } } if (min_width_p) *min_width_p = min; if (natural_width_p) *natural_width_p = natural; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void shell_stack_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gboolean first = TRUE; float min = 0, natural = 0; ClutterActor *child; st_theme_node_adjust_for_height (theme_node, &for_height); for (child = clutter_actor_get_first_child (actor); child != NULL; child = clutter_actor_get_next_sibling (child)) { float child_min, child_natural; clutter_actor_get_preferred_width (child, for_height, &child_min, &child_natural); if (first) { first = FALSE; min = child_min; natural = child_natural; } else { if (child_min > min) min = child_min; if (child_natural > natural) natural = child_natural; } } if (min_width_p) *min_width_p = min; if (natural_width_p) *natural_width_p = natural; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_box_layout_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); st_theme_node_adjust_for_height (theme_node, &for_height); get_content_preferred_width (ST_BOX_LAYOUT (actor), for_height, min_width_p, natural_width_p); st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_entry_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StEntryPrivate *priv = ST_ENTRY_PRIV (actor); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gfloat icon_w; st_theme_node_adjust_for_height (theme_node, &for_height); clutter_actor_get_preferred_width (priv->entry, for_height, min_width_p, natural_width_p); if (priv->primary_icon) { clutter_actor_get_preferred_width (priv->primary_icon, -1, NULL, &icon_w); if (min_width_p) *min_width_p += icon_w + priv->spacing; if (natural_width_p) *natural_width_p += icon_w + priv->spacing; } if (priv->secondary_icon) { clutter_actor_get_preferred_width (priv->secondary_icon, -1, NULL, &icon_w); if (min_width_p) *min_width_p += icon_w + priv->spacing; if (natural_width_p) *natural_width_p += icon_w + priv->spacing; } st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void cinnamon_generic_container_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { CinnamonGenericContainerAllocation *alloc = g_slice_new0 (CinnamonGenericContainerAllocation); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); st_theme_node_adjust_for_height (theme_node, &for_height); alloc->_refcount = 1; g_signal_emit (G_OBJECT (actor), cinnamon_generic_container_signals[GET_PREFERRED_WIDTH], 0, for_height, alloc); if (min_width_p) *min_width_p = alloc->min_size; if (natural_width_p) *natural_width_p = alloc->natural_size; cinnamon_generic_container_allocation_unref (alloc); st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_scroll_bar_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StScrollBar *bar = ST_SCROLL_BAR (self); StScrollBarPrivate *priv = bar->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); gfloat trough_min_width, trough_natural_width; gfloat handle_min_width, handle_natural_width; st_theme_node_adjust_for_height (theme_node, &for_height); _st_actor_get_preferred_width (priv->trough, for_height, TRUE, &trough_min_width, &trough_natural_width); _st_actor_get_preferred_width (priv->handle, for_height, TRUE, &handle_min_width, &handle_natural_width); if (priv->vertical) { if (min_width_p) *min_width_p = MAX (trough_min_width, handle_min_width); if (natural_width_p) *natural_width_p = MAX (trough_natural_width, handle_natural_width); } else { if (min_width_p) *min_width_p = trough_min_width + handle_min_width; if (natural_width_p) *natural_width_p = trough_natural_width + handle_natural_width; } st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_scroll_view_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gboolean account_for_vscrollbar = FALSE; gfloat min_width = 0, natural_width; gfloat child_min_width, child_natural_width; if (!priv->child) return; st_theme_node_adjust_for_height (theme_node, &for_height); clutter_actor_get_preferred_width (priv->child, -1, &child_min_width, &child_natural_width); natural_width = child_natural_width; switch (priv->hscrollbar_policy) { case GTK_POLICY_NEVER: min_width = child_min_width; break; case GTK_POLICY_ALWAYS: case GTK_POLICY_AUTOMATIC: /* Should theoretically use the min width of the hscrollbar, * but that's not cleanly defined at the moment */ min_width = 0; break; } switch (priv->vscrollbar_policy) { case GTK_POLICY_NEVER: account_for_vscrollbar = FALSE; break; case GTK_POLICY_ALWAYS: account_for_vscrollbar = !priv->overlay_scrollbars; break; case GTK_POLICY_AUTOMATIC: /* For automatic scrollbars, we always request space for the vertical * scrollbar; we won't know whether we actually need one until our * height is assigned in allocate(). */ account_for_vscrollbar = !priv->overlay_scrollbars; break; } if (account_for_vscrollbar) { float sb_width = get_scrollbar_width (ST_SCROLL_VIEW (actor), for_height); min_width += sb_width; natural_width += sb_width; } if (min_width_p) *min_width_p = min_width; if (natural_width_p) *natural_width_p = natural_width; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }