static void
pnl_dock_revealer_get_child_preferred_height (PnlDockRevealer *self,
                                              gint            *min_height,
                                              gint            *nat_height)
{
  PnlDockRevealerPrivate *priv = pnl_dock_revealer_get_instance_private (self);
  GtkWidget *child;

  g_assert (PNL_IS_DOCK_REVEALER (self));
  g_assert (min_height != NULL);
  g_assert (nat_height != NULL);

  *min_height = 0;
  *nat_height = 0;

  if (NULL == (child = gtk_bin_get_child (GTK_BIN (self))))
    return;

  if (!gtk_widget_get_child_visible (child) || !gtk_widget_get_visible (child))
    return;

  gtk_widget_get_preferred_height (child, min_height, nat_height);

  if (IS_VERTICAL (priv->transition_type) && priv->position_set)
    {
      if (priv->position > *min_height)
        *nat_height = priv->position;
      else
        *nat_height = *min_height;
    }
}
Exemple #2
0
static gboolean
gnm_notebook_button_press (GtkWidget      *widget,
			   GdkEventButton *event)
{
	GnmNotebook *nb = GNM_NOTEBOOK (widget);
	unsigned ui;

	for (ui = 0; /* Nothing */; ui++) {
		GtkWidget *child = gnm_notebook_get_nth_label (nb, ui);
		GtkAllocation child_allocation;

		if (!child)
			break;

		if (!gtk_widget_get_child_visible (child))
			continue;

		gtk_widget_get_allocation (child, &child_allocation);

		if (event->x >= child_allocation.x &&
		    event->x <  child_allocation.x + child_allocation.width &&
		    event->y >= child_allocation.y &&
		    event->y <  child_allocation.y + child_allocation.height) {
			if (0)
				g_printerr ("Button %d pressed\n", ui);
			if (gtk_widget_event (child, (GdkEvent*)event))
				return TRUE;
			else
				break;
		}
	}

	return GTK_WIDGET_CLASS(gnm_notebook_parent_class)
		->button_press_event (widget, event);
}
static void
pnl_dock_revealer_size_allocate (GtkWidget     *widget,
                                 GtkAllocation *allocation)
{
  PnlDockRevealer *self = (PnlDockRevealer *)widget;
  PnlDockRevealerPrivate *priv = pnl_dock_revealer_get_instance_private (self);
  GtkAllocation child_allocation;
  GtkRequisition min_req;
  GtkRequisition nat_req;
  GtkWidget *child;

  g_assert (PNL_IS_DOCK_REVEALER (self));

  gtk_widget_set_allocation (widget, allocation);

  if (gtk_widget_get_realized (GTK_WIDGET (self)))
    gdk_window_move_resize (priv->window,
                            allocation->x,
                            allocation->y,
                            allocation->width,
                            allocation->height);

  if (NULL == (child = gtk_bin_get_child (GTK_BIN (self))))
    return;

  if (!gtk_widget_get_child_visible (child))
    return;

  child_allocation.x = 0;
  child_allocation.y = 0;
  child_allocation.width = allocation->width;
  child_allocation.height = allocation->height;

  if (IS_HORIZONTAL (priv->transition_type))
    {
      pnl_dock_revealer_get_child_preferred_width (self, &min_req.width, &nat_req.width);
      child_allocation.width = nat_req.width;

      if (priv->transition_type == PNL_DOCK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
        child_allocation.x = allocation->width - child_allocation.width;
    }
  else if (IS_VERTICAL (priv->transition_type))
    {
      pnl_dock_revealer_get_child_preferred_height (self, &min_req.height, &nat_req.height);
      child_allocation.height = nat_req.height;

      if (priv->transition_type == PNL_DOCK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN)
        child_allocation.y = allocation->height - child_allocation.height;
    }

  gtk_widget_size_allocate (child, &child_allocation);
}
static void union_with_clip (GtkWidget *widget,
                 gpointer   clip)
{
    GtkAllocation widget_clip;

    if (!gtk_widget_is_visible (widget) ||
            !gtk_widget_get_child_visible (widget))
        return;

    gtk_widget_get_clip (widget, &widget_clip);

    gdk_rectangle_union (&widget_clip, clip, clip);
}
Exemple #5
0
static void
gstyle_slidein_map (GtkWidget *widget)
{
  GstyleSlidein *self = (GstyleSlidein *)widget;

  g_assert (GSTYLE_IS_SLIDEIN (self));

  GTK_WIDGET_CLASS (gstyle_slidein_parent_class)->map (widget);

  if (self->overlay_child != NULL &&
      self->overlay_window != NULL &&
      gtk_widget_get_visible (self->overlay_child) &&
      gtk_widget_get_child_visible (self->overlay_child))
    {
       gdk_window_show (self->overlay_window);
       g_signal_connect_swapped (self, "button-press-event",
                                 G_CALLBACK(event_window_button_press_event_cb),
                                 self);
    }
}
static void
select_first_contact (EmpathyRosterView *self)
{
  GList *children, *l;

  children = gtk_container_get_children (GTK_CONTAINER (self));
  for (l = children; l != NULL; l = g_list_next (l))
    {
      GtkWidget *child = l->data;

      if (!gtk_widget_get_child_visible (child))
        continue;

      if (!EMPATHY_IS_ROSTER_CONTACT (child))
        continue;

      gtk_list_box_select_row (GTK_LIST_BOX (self), GTK_LIST_BOX_ROW (child));
      break;
    }

  g_list_free (children);
}
Exemple #7
0
static void
gb_slider_map (GtkWidget *widget)
{
  GbSlider *self = (GbSlider *)widget;
  GbSliderPrivate *priv = gb_slider_get_instance_private (self);
  gsize i;

  g_assert (GB_IS_SLIDER (self));

  GTK_WIDGET_CLASS (gb_slider_parent_class)->map (widget);

  for (i = 0; i < priv->children->len; i++)
    {
      GbSliderChild *child;

      child = g_ptr_array_index (priv->children, i);

      if ((child->window != NULL) &&
          gtk_widget_get_visible (child->widget) &&
          gtk_widget_get_child_visible (child->widget))
        gdk_window_show (child->window);
    }
}
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");
}
Exemple #9
0
void
clearlooks_get_notebook_tab_position (GtkWidget *widget,
                                      gboolean  *start,
                                      gboolean  *end)
{
	/* default value */
	*start = TRUE;
	*end = FALSE;

	if (GE_IS_NOTEBOOK (widget)) {
		gboolean found_tabs = FALSE;
		gint i, n_pages;
		GtkNotebook *notebook = GTK_NOTEBOOK (widget);

		/* got a notebook, so walk over all the tabs and decide based
		 * on that ...
		 * It works like this:
		 *   - If there is any visible tab that is expanded, set both.
		 *   - Set start/end if there is any visible tab that is at
		 *     the start/end.
		 *   - If one has the child_visibility set to false, arrows
		 *     are present; so none
		 * The heuristic falls over if there is a notebook that just
		 * happens to fill up all the available space. ie. All tabs
		 * are left aligned, but it does not require scrolling.
		 * (a more complex heuristic could calculate the tabs width
		 * and add them all up) */

		n_pages = gtk_notebook_get_n_pages (notebook);
		for (i = 0; i < n_pages; i++) {
			GtkWidget *tab_child;
			GtkWidget *tab_label;
			gboolean expand;
			GtkPackType pack_type;
						
			tab_child = gtk_notebook_get_nth_page (notebook, i);

			/* Skip invisible tabs */
			tab_label = gtk_notebook_get_tab_label (notebook, tab_child);
			if (!tab_label || !GTK_WIDGET_VISIBLE (tab_label))
				continue;
			/* This is the same what the notebook does internally. */
			if (tab_label && !gtk_widget_get_child_visible (tab_label)) {
				/* One child is hidden because scroll arrows are present.
				 * So both corners are rounded. */
				*start = FALSE;
				*end = FALSE;
				return;
			}

			gtk_notebook_query_tab_label_packing (notebook, tab_child,
			                                      &expand,
			                                      NULL, /* don't need fill */
			                                      &pack_type);

			if (!found_tabs) {
				found_tabs = TRUE;
				*start = FALSE;
				*end = FALSE;
			}

			if (expand) {
				*start = TRUE;
				*end = TRUE;
			} else if (pack_type == GTK_PACK_START) {
				*start = TRUE;
			} else {
				*end = TRUE;
			}
		}
	}
}
Exemple #10
0
static VALUE
rg_child_visible_p(VALUE self)
{
    return CBOOL2RVAL(gtk_widget_get_child_visible(_SELF(self)));
}