static void _handle_update_child_visible (GtkTextHandle *handle, GtkTextHandlePosition pos) { HandleWindow *handle_window; GtkTextHandlePrivate *priv; cairo_rectangle_int_t rect; GtkAllocation allocation; GtkWidget *parent; priv = handle->priv; handle_window = &priv->windows[pos]; if (!priv->parent_scrollable) { gtk_widget_set_child_visible (handle_window->widget, TRUE); return; } parent = gtk_widget_get_parent (GTK_WIDGET (priv->parent_scrollable)); rect = handle_window->pointing_to; gtk_widget_translate_coordinates (priv->parent, parent, rect.x, rect.y, &rect.x, &rect.y); gtk_widget_get_allocation (GTK_WIDGET (parent), &allocation); if (rect.x < 0 || rect.x + rect.width > allocation.width || rect.y < 0 || rect.y + rect.height > allocation.height) gtk_widget_set_child_visible (handle_window->widget, FALSE); else gtk_widget_set_child_visible (handle_window->widget, TRUE); }
static void hd_status_area_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { HDStatusAreaBoxPrivate *priv; guint border_width; GtkAllocation child_allocation = {0, 0, 0, 0}; guint visible_children = 0; GList *c; priv = HD_STATUS_AREA_BOX (widget)->priv; border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); /* chain up */ GTK_WIDGET_CLASS (hd_status_area_box_parent_class)->size_allocate (widget, allocation); child_allocation.height = ITEM_HEIGHT; /* Place the first eight visible children */ for (c = priv->children; c && visible_children < priv->max_visible_children; c = c->next) { HDStatusAreaBoxChild *info = c->data; GtkRequisition child_requisition; /* ignore hidden widgets */ if (!gtk_widget_is_visible (info->widget)) continue; /* there are some widgets which need a size request */ gtk_widget_get_preferred_size (info->widget, &child_requisition, NULL); child_allocation.x = allocation->x + border_width + PADDING_LEFT + (visible_children / 2) * (ITEM_WIDTH + SPACING); child_allocation.y = allocation->y + border_width + (visible_children % 2 * (ITEM_HEIGHT + SPACING)); child_allocation.width = ITEM_WIDTH; child_allocation.height = ITEM_HEIGHT; gtk_widget_size_allocate (info->widget, &child_allocation); gtk_widget_set_child_visible (info->widget, TRUE); visible_children++; } /* Hide the other children */ for (; c; c = c->next) { HDStatusAreaBoxChild *info = c->data; gtk_widget_set_child_visible (info->widget, FALSE); } }
static void set_visible_child (GdStack *stack, GdStackChildInfo *child_info) { GdStackPrivate *priv = stack->priv; GdStackChildInfo *info; GtkWidget *widget = GTK_WIDGET (stack); GList *l; /* If none, pick first visible */ if (child_info == NULL) { for (l = priv->children; l != NULL; l = l->next) { info = l->data; if (gtk_widget_get_visible (info->widget)) { child_info = info; break; } } } if (child_info == priv->visible_child) return; if (priv->last_visible_child) gtk_widget_set_child_visible (priv->last_visible_child->widget, FALSE); priv->last_visible_child = NULL; if (priv->last_visible_surface != NULL) cairo_surface_destroy (priv->last_visible_surface); priv->last_visible_surface = NULL; if (priv->visible_child && priv->visible_child->widget) { if (gtk_widget_is_visible (widget)) priv->last_visible_child = priv->visible_child; else gtk_widget_set_child_visible (priv->visible_child->widget, FALSE); } priv->visible_child = child_info; if (child_info) gtk_widget_set_child_visible (child_info->widget, TRUE); gtk_widget_queue_resize (GTK_WIDGET (stack)); gtk_widget_queue_draw (GTK_WIDGET (stack)); g_object_notify (G_OBJECT (stack), "visible-child"); g_object_notify (G_OBJECT (stack), "visible-child-name"); gd_stack_start_transition (stack); }
static void stack_child_visibility_notify_cb (GObject *obj, GParamSpec *pspec, gpointer user_data) { GdStack *stack = GD_STACK (user_data); GdStackPrivate *priv = stack->priv; GtkWidget *child = GTK_WIDGET (obj); GdStackChildInfo *child_info; child_info = find_child_info_for_widget (stack, child); if (priv->visible_child == NULL && gtk_widget_get_visible (child)) set_visible_child (stack, child_info); else if (priv->visible_child == child_info && !gtk_widget_get_visible (child)) set_visible_child (stack, NULL); if (child_info == priv->last_visible_child) { gtk_widget_set_child_visible (priv->last_visible_child->widget, FALSE); priv->last_visible_child = NULL; } }
static void pnl_dock_revealer_animation_done (gpointer user_data) { g_autoptr(PnlDockRevealer) self = user_data; PnlDockRevealerPrivate *priv = pnl_dock_revealer_get_instance_private (self); g_assert (PNL_DOCK_REVEALER (self)); if (priv->adjustment != NULL) { gboolean child_revealed; child_revealed = (gtk_adjustment_get_value (priv->adjustment) == 1.0); if (priv->child_revealed != child_revealed) { GtkWidget *child = gtk_bin_get_child (GTK_BIN (self)); priv->child_revealed = child_revealed; gtk_widget_set_child_visible (GTK_WIDGET (child), gtk_adjustment_get_value (priv->adjustment) != 0.0); g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CHILD_REVEALED]); } gtk_widget_queue_resize (GTK_WIDGET (self)); } }
static void gtk_search_bar_init (GtkSearchBar *bar) { GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); GtkStyleContext *context; gtk_widget_init_template (GTK_WIDGET (bar)); /* We use child-visible to avoid the unexpanded revealer * peaking out by 1 pixel */ gtk_widget_set_child_visible (priv->revealer, FALSE); g_signal_connect (priv->revealer, "notify::reveal-child", G_CALLBACK (reveal_child_changed_cb), bar); g_signal_connect (priv->revealer, "notify::child-revealed", G_CALLBACK (child_revealed_changed_cb), bar); gtk_widget_set_no_show_all (priv->close_button, TRUE); g_signal_connect (priv->close_button, "clicked", G_CALLBACK (close_button_clicked_cb), bar); context = gtk_widget_get_style_context (GTK_WIDGET (bar)); gtk_style_context_add_class (context, "search-bar"); gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL); };
static void delete_button_clicked_cb (GtkButton *source, gpointer user_data) { CbComposeImages *self = user_data; const guint n_images = self->images->len; Image *image = NULL; guint i; /* If the button really gets clicked in the split second the * delete animation is running, just ignore it */ if (cb_animation_is_running (&self->delete_animation)) return; /* Find the image by button... */ for (i = 0; i < n_images; i ++) { Image *img = &g_array_index (self->images, Image, i); if (img->delete_button == (GtkWidget *)source) { image = img; break; } } g_assert (image != NULL); /* Hide non-image widgets during delete transtion */ gtk_widget_set_child_visible (image->delete_button, FALSE); gtk_widget_hide (image->progressbar); image->deleted = TRUE; cb_animation_start (&self->delete_animation, image); }
static void reveal_child_changed_cb (GObject *object, GParamSpec *pspec, GtkSearchBar *bar) { GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); gboolean reveal_child; g_object_get (object, "reveal-child", &reveal_child, NULL); if (reveal_child) gtk_widget_set_child_visible (priv->revealer, TRUE); if (reveal_child == priv->reveal_child) return; priv->reveal_child = reveal_child; if (priv->entry) { if (reveal_child) _gtk_entry_grab_focus (GTK_ENTRY (priv->entry), FALSE); else gtk_entry_set_text (GTK_ENTRY (priv->entry), ""); } g_object_notify (G_OBJECT (bar), "search-mode-enabled"); }
static void gd_stack_add (GtkContainer *container, GtkWidget *child) { GdStack *stack = GD_STACK (container); GdStackPrivate *priv = stack->priv; GdStackChildInfo *child_info; g_return_if_fail (child != NULL); child_info = g_slice_new (GdStackChildInfo); child_info->widget = child; child_info->name = NULL; child_info->title = NULL; child_info->symbolic_icon_name = NULL; priv->children = g_list_append (priv->children, child_info); gtk_widget_set_parent_window (child, priv->bin_window); gtk_widget_set_parent (child, GTK_WIDGET (stack)); g_signal_connect (child, "notify::visible", G_CALLBACK (stack_child_visibility_notify_cb), stack); gtk_widget_child_notify (child, "position"); if (priv->visible_child == NULL && gtk_widget_get_visible (child)) set_visible_child (stack, child_info); else gtk_widget_set_child_visible (child, FALSE); if (priv->homogeneous || priv->visible_child == child_info) gtk_widget_queue_resize (GTK_WIDGET (stack)); }
static void gtk_expander_add (GtkContainer *container, GtkWidget *widget) { GTK_CONTAINER_CLASS (gtk_expander_parent_class)->add (container, widget); gtk_widget_set_child_visible (widget, GTK_EXPANDER (container)->priv->expanded); gtk_widget_queue_resize (GTK_WIDGET (container)); }
/* src_offset and dst_offset need to be in [0.0, 1.0] range */ static gboolean animate (GstyleSlidein *self, gdouble target_offset) { GtkWidget *child; g_assert (GSTYLE_IS_SLIDEIN (self)); g_assert (0.0 <= target_offset && target_offset <= 1.0); child = gtk_bin_get_child (GTK_BIN (self)); if (child == NULL || self->overlay_child == NULL) return FALSE; animate_stop (self); if (!self->duration_set) self->duration = gstyle_animation_check_enable_animation () ? compute_duration (self) : 0; self->src_offset = self->offset; self->dst_offset = target_offset; gtk_widget_set_child_visible (child, TRUE); if (self->src_offset == self->dst_offset) return FALSE; if (self->src_offset < self->dst_offset) { self->is_opening = TRUE; g_signal_emit (self, signals [OPENING], 0); } else { self->is_closing = TRUE; g_signal_emit (self, signals [CLOSING], 0); } if (self->duration == 0) { self->offset = target_offset; animation_done_cb (self); gtk_widget_queue_resize (GTK_WIDGET (self)); } else if (!self->animation_handler_id) { self->animation_starttime = g_get_monotonic_time(); self->animation_handler_id = gtk_widget_add_tick_callback (GTK_WIDGET (self), animation_tick_cb, self, NULL); } return TRUE; }
static void child_revealed_changed_cb (GObject *object, GParamSpec *pspec, GtkSearchBar *bar) { GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); gboolean val; g_object_get (object, "child-revealed", &val, NULL); if (!val) gtk_widget_set_child_visible (priv->revealer, FALSE); }
static void gtk_places_view_row_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GtkPlacesViewRow *self = GTK_PLACES_VIEW_ROW (object); switch (prop_id) { case PROP_ICON: gtk_image_set_from_gicon (self->icon_image, g_value_get_object (value), GTK_ICON_SIZE_LARGE_TOOLBAR); break; case PROP_NAME: gtk_label_set_label (self->name_label, g_value_get_string (value)); break; case PROP_PATH: gtk_label_set_label (self->path_label, g_value_get_string (value)); break; case PROP_VOLUME: g_set_object (&self->volume, g_value_get_object (value)); break; case PROP_MOUNT: g_set_object (&self->mount, g_value_get_object (value)); /* * When we hide the eject button, no size is allocated for it. Since * we want to have alignment between rows, it needs an empty space * when the eject button is not available. So, call then * gtk_widget_set_child_visible(), which makes the button allocate the * size but it stays hidden when needed. */ gtk_widget_set_child_visible (GTK_WIDGET (self->eject_button), self->mount != NULL); break; case PROP_FILE: g_set_object (&self->file, g_value_get_object (value)); break; case PROP_IS_NETWORK: gtk_places_view_row_set_is_network (self, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } }
void on_modular_scale_show (GtkWidget *widget, gpointer user_data) { GtkWidget *language = lookup_widget( GTK_WIDGET( widget ), "language" ); GtkWidget *sleep = lookup_widget( GTK_WIDGET( widget ), "sleep" ); #ifdef LANGUAGE gtk_widget_set_child_visible( GTK_WIDGET( language ), TRUE ); #else gtk_widget_set_child_visible( GTK_WIDGET( language ), FALSE ); #endif #ifdef SLEEP gtk_widget_set_child_visible( GTK_WIDGET( sleep ), TRUE ); #else gtk_widget_set_child_visible( GTK_WIDGET( sleep ), FALSE ); #endif }
static void pnl_dock_revealer_add (GtkContainer *container, GtkWidget *widget) { PnlDockRevealer *self = (PnlDockRevealer *)container; PnlDockRevealerPrivate *priv = pnl_dock_revealer_get_instance_private (self); g_assert (PNL_IS_DOCK_REVEALER (self)); g_assert (GTK_IS_WIDGET (widget)); GTK_CONTAINER_CLASS (pnl_dock_revealer_parent_class)->add (container, widget); gtk_widget_set_child_visible (widget, priv->reveal_child); }
static void gtk_revealer_real_add (GtkContainer *container, GtkWidget *child) { GtkRevealer *revealer = GTK_REVEALER (container); GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); g_return_if_fail (child != NULL); gtk_widget_set_parent_window (child, priv->bin_window); gtk_widget_set_child_visible (child, priv->current_pos != 0.0); GTK_CONTAINER_CLASS (gtk_revealer_parent_class)->add (container, child); }
void pnl_dock_revealer_set_reveal_child (PnlDockRevealer *self, gboolean reveal_child) { PnlDockRevealerPrivate *priv = pnl_dock_revealer_get_instance_private (self); g_return_if_fail (PNL_IS_DOCK_REVEALER (self)); reveal_child = !!reveal_child; if (reveal_child != priv->reveal_child) { PnlAnimation *animation; GtkWidget *child; priv->reveal_child = reveal_child; child = gtk_bin_get_child (GTK_BIN (self)); if (child != NULL) { guint duration; if (priv->animation != NULL) { pnl_animation_stop (priv->animation); pnl_clear_weak_pointer (&priv->animation); } gtk_widget_set_child_visible (child, TRUE); duration = pnl_dock_revealer_calculate_duration (self); animation = pnl_object_animate_full (priv->adjustment, PNL_ANIMATION_EASE_IN_OUT_CUBIC, duration, gtk_widget_get_frame_clock (GTK_WIDGET (self)), pnl_dock_revealer_animation_done, g_object_ref (self), "value", reveal_child ? 1.0 : 0.0, NULL); pnl_set_weak_pointer (&priv->animation, animation); } g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_REVEAL_CHILD]); } }
static gboolean gtk_expander_animation_timeout (GtkExpander *expander) { GtkExpanderPrivate *priv = expander->priv; GdkRectangle area; gboolean finish = FALSE; if (gtk_widget_get_realized (GTK_WIDGET (expander))) { get_expander_bounds (expander, &area); gdk_window_invalidate_rect (GTK_WIDGET (expander)->window, &area, TRUE); } if (priv->expanded) { if (priv->expander_style == GTK_EXPANDER_COLLAPSED) { priv->expander_style = GTK_EXPANDER_SEMI_EXPANDED; } else { priv->expander_style = GTK_EXPANDER_EXPANDED; finish = TRUE; } } else { if (priv->expander_style == GTK_EXPANDER_EXPANDED) { priv->expander_style = GTK_EXPANDER_SEMI_COLLAPSED; } else { priv->expander_style = GTK_EXPANDER_COLLAPSED; finish = TRUE; } } if (finish) { priv->animation_timeout = 0; if (GTK_BIN (expander)->child) gtk_widget_set_child_visible (GTK_BIN (expander)->child, priv->expanded); gtk_widget_queue_resize (GTK_WIDGET (expander)); } return !finish; }
static gboolean gd_stack_set_transition_position (GdStack *stack, gdouble pos) { GdStackPrivate *priv = stack->priv; gboolean done; priv->transition_pos = pos; gtk_widget_queue_draw (GTK_WIDGET (stack)); if (priv->bin_window != NULL && (priv->transition_type == GD_STACK_TRANSITION_TYPE_SLIDE_LEFT || priv->transition_type == GD_STACK_TRANSITION_TYPE_SLIDE_RIGHT)) { GtkAllocation allocation; gtk_widget_get_allocation (GTK_WIDGET (stack), &allocation); gdk_window_move (priv->bin_window, get_bin_window_x (stack, &allocation), 0); } done = pos >= 1.0; if (done || priv->last_visible_surface != NULL) { if (priv->last_visible_child) { gtk_widget_set_child_visible (priv->last_visible_child->widget, FALSE); priv->last_visible_child = NULL; } } if (done) { if (priv->last_visible_surface != NULL) { cairo_surface_destroy (priv->last_visible_surface); priv->last_visible_surface = NULL; } gtk_widget_queue_resize (GTK_WIDGET (stack)); } return done; }
/** * gtk_expander_set_expanded: * @expander: a #GtkExpander * @expanded: whether the child widget is revealed * * Sets the state of the expander. Set to %TRUE, if you want * the child widget to be revealed, and %FALSE if you want the * child widget to be hidden. * * Since: 2.4 **/ void gtk_expander_set_expanded (GtkExpander *expander, gboolean expanded) { GtkExpanderPrivate *priv; g_return_if_fail (GTK_IS_EXPANDER (expander)); priv = expander->priv; expanded = expanded != FALSE; if (priv->expanded != expanded) { GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (expander)); gboolean enable_animations; priv->expanded = expanded; g_object_get (settings, "gtk-enable-animations", &enable_animations, NULL); if (enable_animations && gtk_widget_get_realized (GTK_WIDGET (expander))) { gtk_expander_start_animation (expander); } else { priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED; if (GTK_BIN (expander)->child) { gtk_widget_set_child_visible (GTK_BIN (expander)->child, priv->expanded); gtk_widget_queue_resize (GTK_WIDGET (expander)); } } g_object_notify (G_OBJECT (expander), "expanded"); } }
static void gtk_revealer_set_position (GtkRevealer *revealer, gdouble pos) { GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); gboolean new_visible; GtkWidget *child; GtkRevealerTransitionType transition; priv->current_pos = pos; /* We check target_pos here too, because we want to ensure we set * child_visible immediately when starting a reveal operation * otherwise the child widgets will not be properly realized * after the reveal returns. */ new_visible = priv->current_pos != 0.0 || priv->target_pos != 0.0; child = gtk_bin_get_child (GTK_BIN (revealer)); if (child != NULL && new_visible != gtk_widget_get_child_visible (child)) gtk_widget_set_child_visible (child, new_visible); transition = effective_transition (revealer); if (transition == GTK_REVEALER_TRANSITION_TYPE_CROSSFADE) { gtk_widget_set_opacity (GTK_WIDGET (revealer), priv->current_pos); gtk_widget_queue_draw (GTK_WIDGET (revealer)); } else { gtk_widget_queue_resize (GTK_WIDGET (revealer)); } if (priv->current_pos == priv->target_pos) g_object_notify (G_OBJECT (revealer), "child-revealed"); }
static void matenu_menu_bar_real_size_allocate (GtkWidget* base, GdkRectangle* a) { MatenuMenuBar * self; gboolean need_reset_bg_pixmap; gint delta_x; gint delta_y; gboolean _tmp0_ = FALSE; gboolean _tmp1_ = FALSE; gboolean _tmp2_ = FALSE; GdkRectangle _tmp3_ = {0}; GdkRectangle oa; GtkRequisition or = {0}; self = (MatenuMenuBar*) base; need_reset_bg_pixmap = FALSE; delta_x = (*a).x - ((GtkWidget*) self)->allocation.x; delta_y = (*a).y - ((GtkWidget*) self)->allocation.y; if (delta_x != 0) { _tmp2_ = TRUE; } else { _tmp2_ = delta_y != 0; } if (_tmp2_) { _tmp1_ = TRUE; } else { _tmp1_ = (*a).width != ((GtkWidget*) self)->allocation.width; } if (_tmp1_) { _tmp0_ = TRUE; } else { _tmp0_ = (*a).height != ((GtkWidget*) self)->allocation.height; } if (_tmp0_) { need_reset_bg_pixmap = TRUE; } matenu_menu_bar_get_background (self)->offset_x = matenu_menu_bar_get_background (self)->offset_x + delta_x; matenu_menu_bar_get_background (self)->offset_y = matenu_menu_bar_get_background (self)->offset_y + delta_y; GTK_WIDGET_CLASS (matenu_menu_bar_parent_class)->size_allocate ((GtkWidget*) GTK_MENU_BAR (self), a); oa = (_tmp3_.x = 0, _tmp3_.y = 0, _tmp3_.width = 0, _tmp3_.height = 0, _tmp3_); gtk_widget_get_child_requisition ((GtkWidget*) self->priv->_overflown_arrow, &or); switch (gtk_menu_bar_get_pack_direction ((GtkMenuBar*) self)) { case GTK_PACK_DIRECTION_TTB: { oa.height = or.height; oa.width = (*a).width; oa.x = 0; oa.y = (*a).height - oa.height; break; } case GTK_PACK_DIRECTION_BTT: { oa.height = or.height; oa.width = (*a).width; oa.x = 0; oa.y = 0; break; } case GTK_PACK_DIRECTION_RTL: { oa.height = (*a).height; oa.width = or.width; oa.x = 0; oa.y = 0; break; } default: { oa.width = or.width; oa.height = (*a).height; oa.x = (*a).width - oa.width; oa.y = 0; break; } } gtk_widget_size_allocate ((GtkWidget*) self->priv->_overflown_arrow, &oa); if (matenu_menu_bar_get_overflown (self)) { gtk_widget_set_child_visible ((GtkWidget*) self->priv->_overflown_arrow, TRUE); { gint i; i = 0; { gboolean _tmp4_; _tmp4_ = TRUE; while (TRUE) { MatenuItem* item; MatenuItem* _tmp5_; GtkWidget* child; if (!_tmp4_) { i++; } _tmp4_ = FALSE; if (!(i < matenu_shell_get_length ((MatenuShell*) self))) { break; } item = matenu_shell_get_item ((MatenuShell*) self, i); child = _g_object_ref0 ((_tmp5_ = item, GTK_IS_WIDGET (_tmp5_) ? ((GtkWidget*) _tmp5_) : NULL)); gtk_widget_set_child_visible (child, !matenu_menu_bar_child_need_overflown_arrow (self, child)); _g_object_unref0 (child); _g_object_unref0 (item); } } } } else { gtk_widget_set_child_visible ((GtkWidget*) self->priv->_overflown_arrow, FALSE); { gint i; i = 0; { gboolean _tmp6_; _tmp6_ = TRUE; while (TRUE) { MatenuItem* item; MatenuItem* _tmp7_; GtkWidget* child; if (!_tmp6_) { i++; } _tmp6_ = FALSE; if (!(i < matenu_shell_get_length ((MatenuShell*) self))) { break; } item = matenu_shell_get_item ((MatenuShell*) self, i); child = _g_object_ref0 ((_tmp7_ = item, GTK_IS_WIDGET (_tmp7_) ? ((GtkWidget*) _tmp7_) : NULL)); gtk_widget_set_child_visible (child, TRUE); _g_object_unref0 (child); _g_object_unref0 (item); } } } } if (need_reset_bg_pixmap) { matenu_menu_bar_reset_bg_pixmap (self); } }
static VALUE rg_set_child_visible(VALUE self, VALUE is_visible) { gtk_widget_set_child_visible(_SELF(self), RVAL2CBOOL(is_visible)); return self; }