コード例 #1
0
ファイル: test-scrollwin.c プロジェクト: GNOME/gtkimageview
/**
 * test_scrollbars_visibility:
 *
 * The objective of this test is to verify that the scrollbars aren't
 * shown when the image clearly fits inside the allocation and that
 * they are shown when the image clearly does not fit.
 **/
static void
test_scrollbars_visibility ()
{
    printf ("test_scrollbars_visibility\n");
    setup ();

    GtkAllocation alloc = {0, 0, 200, 200};
    gtk_widget_set_allocation (GTK_WIDGET (scroll_win), &alloc);

    fake_realize (GTK_WIDGET (scroll_win));

    gtk_widget_set_allocation (GTK_WIDGET (view), &alloc);
    fake_realize (GTK_WIDGET (view));

    // The 100x100 pixbuf is smaller than the 200x200 allocation, so
    // don't show scrollbars.
    gtk_image_view_set_pixbuf (view, pixbuf, TRUE);

    assert (!gtk_widget_get_visible (scroll_win->hscroll));
    assert (!gtk_widget_get_visible (scroll_win->vscroll));

    // Zoomed width and height is 3 * 100 == 300 which is greater than
    // 200, so the scrollbars should be shown.
    gtk_image_view_set_zoom (view, 3.0);

    assert (gtk_widget_get_visible (scroll_win->hscroll));
    assert (gtk_widget_get_visible (scroll_win->vscroll));
    
    teardown ();
}
コード例 #2
0
static void
rb_vis_widget_size_allocate (GtkWidget *widget,
			     GtkAllocation *allocation)
{
	RBVisWidget *rbvw = RB_VIS_WIDGET (widget);
	gtk_widget_set_allocation (widget, allocation);

	if (!gtk_widget_get_realized (widget))
		return;

	rb_debug ("handling size allocate event ([%d,%d] - [%d,%d])",
		  allocation->x, allocation->y,
		  allocation->width, allocation->height);
	gdk_window_move_resize (gtk_widget_get_window (widget),
				allocation->x, allocation->y,
				allocation->width, allocation->height);

	if (rbvw->width != allocation->width) {
		rbvw->width = allocation->width;
		g_object_notify (G_OBJECT (rbvw), "width");
	}
	if (rbvw->height != allocation->height) {
		rbvw->height = allocation->height;
		g_object_notify (G_OBJECT (rbvw), "height");
	}
}
コード例 #3
0
ファイル: gd-stack.c プロジェクト: Udit93/gnome-music
static void
gd_stack_size_allocate (GtkWidget *widget,
			GtkAllocation *allocation)
{
  GdStack *stack = GD_STACK (widget);
  GdStackPrivate *priv = stack->priv;
  GtkAllocation child_allocation;

  g_return_if_fail (allocation != NULL);

  gtk_widget_set_allocation (widget, allocation);

  child_allocation = *allocation;
  child_allocation.x = 0;
  child_allocation.y = 0;

  if (priv->last_visible_child)
    gtk_widget_size_allocate (priv->last_visible_child->widget, &child_allocation);

  if (priv->visible_child)
    gtk_widget_size_allocate (priv->visible_child->widget, &child_allocation);

   if (gtk_widget_get_realized (widget))
    {
      gdk_window_move_resize (priv->view_window,
                              allocation->x, allocation->y,
                              allocation->width, allocation->height);
      gdk_window_move_resize (priv->bin_window,
                              get_bin_window_x (stack, allocation), 0,
                              allocation->width, allocation->height);
    }
}
コード例 #4
0
ファイル: gimpframe.c プロジェクト: AdamGrzonkowski/gimp-1
static void
gimp_frame_size_allocate (GtkWidget     *widget,
                          GtkAllocation *allocation)
{
  GtkFrame      *frame        = GTK_FRAME (widget);
  GtkWidget     *label_widget = gtk_frame_get_label_widget (frame);
  GtkWidget     *child        = gtk_bin_get_child (GTK_BIN (widget));
  GtkAllocation  child_allocation;

  gtk_widget_set_allocation (widget, allocation);

  gimp_frame_child_allocate (frame, &child_allocation);

  if (child && gtk_widget_get_visible (child))
    gtk_widget_size_allocate (child, &child_allocation);

  if (label_widget && gtk_widget_get_visible (label_widget))
    {
      GtkAllocation   label_allocation;
      GtkRequisition  label_requisition;
      gint            border_width;

      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));

      gtk_widget_get_child_requisition (label_widget, &label_requisition);

      label_allocation.x      = allocation->x + border_width;
      label_allocation.y      = allocation->y + border_width;
      label_allocation.width  = MAX (label_requisition.width,
                                     allocation->width - 2 * border_width);
      label_allocation.height = label_requisition.height;

      gtk_widget_size_allocate (label_widget, &label_allocation);
    }
}
コード例 #5
0
ファイル: gtk2drawing.c プロジェクト: dslab-epfl/warr
static gint
moz_gtk_scrolled_window_paint(GdkDrawable* drawable, GdkRectangle* rect,
                              GdkRectangle* cliprect, GtkWidgetState* state)
{
    GtkStyle* style;
    GtkAllocation allocation;
    GtkWidget* widget;

    ensure_scrolled_window_widget();
    widget = gParts->scrolledWindowWidget;

    gtk_widget_get_allocation(widget, &allocation);
    allocation.x = rect->x;
    allocation.y = rect->y;
    allocation.width = rect->width;
    allocation.height = rect->height;
    gtk_widget_set_allocation(widget, &allocation);

    style = gtk_widget_get_style(widget);
    TSOffsetStyleGCs(style, rect->x - 1, rect->y - 1);
    gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
                     cliprect, gParts->scrolledWindowWidget, "scrolled_window",
                     rect->x, rect->y, rect->width, rect->height);
    return MOZ_GTK_SUCCESS;
}
コード例 #6
0
static void
xfce_panel_image_size_allocate (GtkWidget     *widget,
                                GtkAllocation *allocation)
{
  XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;

  gtk_widget_set_allocation (widget, allocation);

  /* check if the available size changed */
  if ((priv->pixbuf != NULL || priv->source != NULL)
      && allocation->width > 0
      && allocation->height > 0
      && (allocation->width != priv->width
      || allocation->height != priv->height))
    {
      /* store the new size */
      priv->width = allocation->width;
      priv->height = allocation->height;

      /* free cache */
      xfce_panel_image_unref_null (priv->cache);

      if (priv->pixbuf == NULL)
        {
          /* delay icon loading */
          priv->idle_load_id = gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE, xfce_panel_image_load,
                                                          widget, xfce_panel_image_load_destroy);
        }
      else
        {
          /* directly render pixbufs */
          xfce_panel_image_load (widget);
        }
    }
}
コード例 #7
0
ファイル: bubble.c プロジェクト: echoline/gtk-background
static void
gtk_bubble_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
	GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
	GtkAllocation child_allocation;

	gtk_widget_set_allocation (widget, allocation);

	if (child && gtk_widget_get_visible (child))
	{
		child_allocation.x = allocation->x + MIN (25.0,
					allocation->width / 2.0);
		child_allocation.y = allocation->y + MIN (25.0,
					allocation->height / 2.0);
		child_allocation.width = allocation->width - MIN (50.0,
					allocation->width);
		child_allocation.height = allocation->height - MIN (50.0,
					allocation->height);

		gtk_widget_size_allocate (child, &child_allocation);
	}

	GTK_WIDGET_CLASS (gtk_bubble_parent_class)->size_allocate (widget,
				allocation);
}
コード例 #8
0
ファイル: gtkcols.c プロジェクト: FauxFaux/PuTTYTray
static void columns_size_allocate(GtkWidget *widget, GtkAllocation *alloc)
{
  Columns *cols;
  ColumnsChild *child;
  GList *children;
  gint border;

  g_return_if_fail(widget != NULL);
  g_return_if_fail(IS_COLUMNS(widget));
  g_return_if_fail(alloc != NULL);

  cols = COLUMNS(widget);
  gtk_widget_set_allocation(widget, alloc);

  border = gtk_container_get_border_width(GTK_CONTAINER(cols));

  columns_alloc_horiz(cols, alloc->width, columns_gtk2_get_width);
  columns_alloc_vert(cols, alloc->height, columns_gtk2_get_height);

  for (children = cols->children; children && (child = children->data);
       children = children->next) {
    if (child->widget && gtk_widget_get_visible(child->widget)) {
      GtkAllocation call;
      call.x = alloc->x + border + child->x;
      call.y = alloc->y + border + child->y;
      call.width = child->w;
      call.height = child->h;
      gtk_widget_size_allocate(child->widget, &call);
    }
  }
}
コード例 #9
0
static void
gstyle_color_widget_size_allocate (GtkWidget     *widget,
                                   GtkAllocation *allocation)
{
  GstyleColorWidget *self = (GstyleColorWidget *)widget;
  GtkAllocation child_allocation;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));

  gtk_widget_set_allocation (widget, allocation);

  if (self->label && gtk_widget_get_visible (GTK_WIDGET (self->label)))
  {
    child_allocation.x = 0;
    child_allocation.y = 0;
    child_allocation.width = allocation->width;
    child_allocation.height = allocation->height;

    gtk_widget_size_allocate (GTK_WIDGET (self->label), &child_allocation);
  }

  if (gtk_widget_get_realized (widget))
    gdk_window_move_resize (gtk_widget_get_window (widget),
                            allocation->x,
                            allocation->y,
                            allocation->width,
                            allocation->height);
}
コード例 #10
0
static void
gd_tagged_entry_size_allocate (GtkWidget *widget,
                               GtkAllocation *allocation)
{
    GdTaggedEntry *self = GD_TAGGED_ENTRY (widget);
    gint x, y, width, height;
    GdTaggedEntryTag *tag;
    GList *l;

    gtk_widget_set_allocation (widget, allocation);
    GTK_WIDGET_CLASS (gd_tagged_entry_parent_class)->size_allocate (widget, allocation);

    if (gtk_widget_get_realized (widget))
    {
        gd_tagged_entry_tag_panel_get_position (self, &x, &y);

        for (l = self->tags; l != NULL; l = l->next)
        {
            GtkBorder margin;

            tag = l->data;
            gd_tagged_entry_tag_get_size (tag, self, &width, &height);
            gd_tagged_entry_tag_get_margin (tag, self, &margin);
            gdk_window_move_resize (tag->window, x, y + margin.top, width, height);

            x += width;
        }

        gtk_widget_queue_draw (widget);
    }
}
コード例 #11
0
static void
size_allocate (GtkWidget *widget,
    GtkAllocation *allocation)
{
  GtkBin *bin = GTK_BIN (widget);
  GtkAllocation child_allocation;
  GtkWidget *child;

  gtk_widget_set_allocation (widget, allocation);

  child = gtk_bin_get_child (bin);

  if (child && gtk_widget_get_visible (child))
    {
      child_allocation.x = allocation->x +
          gtk_container_get_border_width (GTK_CONTAINER (widget));
      child_allocation.y = allocation->y +
          gtk_container_get_border_width (GTK_CONTAINER (widget));
      child_allocation.width = MAX (allocation->width -
          gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2, 0);
      child_allocation.height = MAX (allocation->height -
          gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2, 0);

      gtk_widget_size_allocate (child, &child_allocation);
    }
}
コード例 #12
0
static void
gimp_ruler_size_allocate (GtkWidget     *widget,
                          GtkAllocation *allocation)
{
  GimpRuler        *ruler = GIMP_RULER (widget);
  GimpRulerPrivate *priv  = GIMP_RULER_GET_PRIVATE (ruler);
  GtkAllocation     widget_allocation;
  gboolean          resized;

  gtk_widget_get_allocation (widget, &widget_allocation);

  resized = (widget_allocation.width  != allocation->width ||
             widget_allocation.height != allocation->height);

  gtk_widget_set_allocation (widget, allocation);

  if (gtk_widget_get_realized (widget))
    {
      gdk_window_move_resize (priv->input_window,
                              allocation->x, allocation->y,
                              allocation->width, allocation->height);

      if (resized)
        gimp_ruler_make_pixmap (ruler);
    }
}
コード例 #13
0
ファイル: gtkcellview.c プロジェクト: BYC/gtk
static void
gtk_cell_view_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
{
  GtkCellView        *cellview = GTK_CELL_VIEW (widget);
  GtkCellViewPrivate *priv = cellview->priv;
  gint                alloc_width, alloc_height;

  gtk_widget_set_allocation (widget, allocation);

  gtk_cell_area_context_get_allocation (priv->context, &alloc_width, &alloc_height);

  /* The first cell view in context is responsible for allocating the context at allocate time 
   * (or the cellview has its own context and is not grouped with any other cell views) 
   *
   * If the cellview is in "fit model" mode, we assume its not in context and needs to
   * allocate every time.
   */
  if (priv->fit_model)
    gtk_cell_area_context_allocate (priv->context, allocation->width, allocation->height);
  else if (alloc_width != allocation->width && priv->orientation == GTK_ORIENTATION_HORIZONTAL)
    gtk_cell_area_context_allocate (priv->context, allocation->width, -1);
  else if (alloc_height != allocation->height && priv->orientation == GTK_ORIENTATION_VERTICAL)
    gtk_cell_area_context_allocate (priv->context, -1, allocation->height);
}
コード例 #14
0
ファイル: ovBox.c プロジェクト: Jactry/virt-viewer
static void
ViewOvBoxSizeAllocate(GtkWidget *widget,         // IN
                      GtkAllocation *allocation) // IN
{
   ViewOvBox *that;
   ViewOvBoxPrivate *priv;
   GtkAllocation under;
   GtkAllocation over;

   gtk_widget_set_allocation (widget, allocation);

   that = VIEW_OV_BOX(widget);
   priv = that->priv;

   ViewOvBoxGetUnderGeometry(that, &under.x, &under.y, &under.width,
                             &under.height);
   ViewOvBoxGetOverGeometry(that, &over.x, &over.y, &over.width, &over.height);

   if (gtk_widget_get_realized(widget)) {
      gdk_window_move_resize(gtk_widget_get_window(widget),
                             allocation->x, allocation->y,
                             allocation->width, allocation->height);
      gdk_window_move_resize(priv->underWin, under.x, under.y, under.width,
                             under.height);
      gdk_window_move_resize(priv->overWin, over.x, over.y, over.width,
                             over.height);
   }

   under.x = 0;
   under.y = 0;
   gtk_widget_size_allocate(priv->under, &under);
   over.x = 0;
   over.y = 0;
   gtk_widget_size_allocate(priv->over, &over);
}
コード例 #15
0
ファイル: win_gtk.cpp プロジェクト: chromylei/third_party
static void pizza_size_allocate(GtkWidget* widget, GtkAllocation* alloc)
{
    wxPizza* pizza = WX_PIZZA(widget);
    GtkBorder border;
    pizza->get_border(border);
    int w = alloc->width - border.left - border.right;
    if (w < 0) w = 0;

    if (gtk_widget_get_realized(widget))
    {
        int h = alloc->height - border.top - border.bottom;
        if (h < 0) h = 0;
        const int x = alloc->x + border.left;
        const int y = alloc->y + border.top;

        GdkWindow* window = gtk_widget_get_window(widget);
        int old_x, old_y;
        gdk_window_get_position(window, &old_x, &old_y);

        if (x != old_x || y != old_y ||
            w != gdk_window_get_width(window) || h != gdk_window_get_height(window))
        {
            gdk_window_move_resize(window, x, y, w, h);

            if (border.left + border.right + border.top + border.bottom)
            {
                // old and new border areas need to be invalidated,
                // otherwise they will not be erased/redrawn properly
                GtkAllocation old_alloc;
                gtk_widget_get_allocation(widget, &old_alloc);
                GdkWindow* parent = gtk_widget_get_parent_window(widget);
                gdk_window_invalidate_rect(parent, &old_alloc, false);
                gdk_window_invalidate_rect(parent, alloc, false);
            }
        }
    }

    gtk_widget_set_allocation(widget, alloc);

    // adjust child positions
    for (const GList* p = pizza->m_children; p; p = p->next)
    {
        const wxPizzaChild* child = static_cast<wxPizzaChild*>(p->data);
        if (gtk_widget_get_visible(child->widget))
        {
            GtkAllocation child_alloc;
            // note that child positions do not take border into
            // account, they need to be relative to widget->window,
            // which has already been adjusted
            child_alloc.x = child->x - pizza->m_scroll_x;
            child_alloc.y = child->y - pizza->m_scroll_y;
            child_alloc.width  = child->width;
            child_alloc.height = child->height;
            if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
                child_alloc.x = w - child_alloc.x - child_alloc.width;
            gtk_widget_size_allocate(child->widget, &child_alloc);
        }
    }
}
コード例 #16
0
ファイル: test-scrollwin.c プロジェクト: GNOME/gtkimageview
/**
 * test_scrollbars_hide_when_zooming_out:
 *
 * The objective of this test is to verify that the scrollbars aren't
 * shown if the view is zoomed out so that it exactly fits inside its
 * allocation.
 *
 * For example if the image width is 100, zoom 1.0 and allocation
 * width 55, then the scrollbars are shown, 100 * 1.0 > 55. If the
 * image is then zoomed out to 0.5 zoom, the scrollbars shouldn't be
 * shown, 100 * 0.5 < 55.
 **/
static void
test_scrollbars_hide_when_zooming_out ()
{
    printf ("test_scrollbars_hide_when_zooming_out\n");
    setup ();

    GtkAllocation alloc = {0, 0, 105, 105};
    
    gtk_widget_set_allocation (GTK_WIDGET (scroll_win), &alloc);
    fake_realize (GTK_WIDGET (scroll_win));

    gtk_widget_set_allocation (GTK_WIDGET (view), &alloc);
    fake_realize (GTK_WIDGET (view));

    gtk_image_view_set_pixbuf (view, pixbuf, TRUE);
    // 105 > 100, so no scrollbars
    assert (!gtk_widget_get_visible (scroll_win->hscroll));
    assert (!gtk_widget_get_visible (scroll_win->vscroll));

    gtk_image_view_zoom_in (view);
    // 105 < 100 * 1.5, so show scrollbars. Due to the scrollbars, the
    // views allocation changes! The scrollbars are roughly 15 pixels
    // in width and height. In real code, the zoom in action would
    // automatically cause the allocation to be recalculated, but I
    // don't know how to simulate that.
    gtk_widget_get_allocation (GTK_WIDGET (view), &alloc);
    alloc.width -= 15;
    alloc.height -= 15;
    gtk_widget_set_allocation (GTK_WIDGET (view), &alloc);
    assert (gtk_widget_get_visible (scroll_win->hscroll));
    assert (gtk_widget_get_visible (scroll_win->vscroll));

    gtk_image_view_zoom_out (view);
    // 105 > 100, so no scrollbars. Same here as above, the zoom out
    // should cause the view to be resized.

    gtk_widget_get_allocation (GTK_WIDGET (view), &alloc);
    alloc.width += 15;
    alloc.height += 15;
    gtk_widget_set_allocation (GTK_WIDGET (view), &alloc);
    
    assert (!gtk_widget_get_visible (scroll_win->hscroll));
    assert (!gtk_widget_get_visible (scroll_win->vscroll));

    teardown();
}
コード例 #17
0
/* 
 * sysmenu have to adjusts: x, y, width, height 
 */
static void gtk_sys_menu_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
    GtkSysMenuPrivate * priv = GTK_SYS_MENU(widget)->priv;
    GdkRectangle rectangle;
    GdkScreen  * screen;

    if (gtk_widget_get_realized (widget))
    {
        screen = gdk_window_get_screen (priv->event_window);
        gdk_screen_get_monitor_geometry (screen, gdk_screen_get_primary_monitor (screen), &rectangle);
        priv->monitor_height = rectangle.height;
        priv->monitor_width  = rectangle.width;
        priv->allocation.height = MAX (allocation->height, priv->amount * SYS_MENU_ITEM_HEIGHT + 15);
        
        if (priv->allocation.height > priv->monitor_height)
        {
            priv->allocation.height = priv->monitor_height - SYS_MENU_BOTTOM_Y;
            priv->exceed = TRUE;
        }
        priv->allocation.y = priv->monitor_height - priv->allocation.height - SYS_MENU_BOTTOM_Y;
        if (priv->exceed)
        {
            priv->allocation.y += 5;
            priv->allocation.height -= 5;
        }
        if (allocation->x + priv->allocation.width > priv->monitor_width && allocation->x < priv->allocation.width)
            priv->allocation.x = allocation->x - priv->allocation.width;
        else
            priv->allocation.x = allocation->x;

        priv->end = priv->start + (priv->allocation.height - 15) / SYS_MENU_ITEM_HEIGHT - 1;

        gtk_widget_set_allocation (widget, &priv->allocation);
        gdk_window_move_resize (priv->event_window,
                                priv->allocation.x, 
                                priv->allocation.y + 7, 
                                priv->allocation.width, 
                                priv->allocation.height - 15);
    }
    else
    {
        gtk_widget_set_allocation (widget, allocation);
    }
}
コード例 #18
0
ファイル: statbox.cpp プロジェクト: 3v1n0/wxWidgets
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
{
    GtkAllocation alloc, child_alloc;
    gtk_widget_get_allocation(m_widget, &alloc);
    const int w_save = alloc.width;
    const int h_save = alloc.height;
    if (alloc.width < 50) alloc.width = 50;
    if (alloc.height < 50) alloc.height = 50;
    gtk_widget_set_allocation(m_widget, &alloc);

    GTK_FRAME_GET_CLASS(m_widget)->compute_child_allocation(GTK_FRAME(m_widget), &child_alloc);

    alloc.width = w_save;
    alloc.height = h_save;
    gtk_widget_set_allocation(m_widget, &alloc);

    *borderTop = child_alloc.y - alloc.y;
    *borderOther = child_alloc.x - alloc.x;
}
コード例 #19
0
ファイル: offscreen_window.c プロジェクト: 3v1n0/gtk
static void
gtk_rotated_bin_size_allocate (GtkWidget     *widget,
                               GtkAllocation *allocation)
{
  GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
  guint border_width;
  gint w, h;
  gdouble s, c;

  gtk_widget_set_allocation (widget, allocation);

  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));

  w = allocation->width - border_width * 2;
  h = allocation->height - border_width * 2;

  if (gtk_widget_get_realized (widget))
    gdk_window_move_resize (gtk_widget_get_window (widget),
                            allocation->x + border_width,
                            allocation->y + border_width,
                            w, h);

  if (bin->child && gtk_widget_get_visible (bin->child))
    {
      GtkRequisition child_requisition;
      GtkAllocation child_allocation;

      s = sin (bin->angle);
      c = cos (bin->angle);

      gtk_widget_get_preferred_size (bin->child,
                                     &child_requisition, NULL);
      child_allocation.x = 0;
      child_allocation.y = 0;
      child_allocation.height = child_requisition.height;
      if (c == 0.0)
        child_allocation.width = h / s;
      else if (s == 0.0)
        child_allocation.width = w / c;
      else
        child_allocation.width = MIN ((w - s * child_allocation.height) / c,
                                      (h - c * child_allocation.height) / s);

      if (gtk_widget_get_realized (widget))
        gdk_window_move_resize (bin->offscreen_window,
                                child_allocation.x,
                                child_allocation.y,
                                child_allocation.width,
                                child_allocation.height);

      child_allocation.x = child_allocation.y = 0;
      gtk_widget_size_allocate (bin->child, &child_allocation);
    }
}
コード例 #20
0
static void
color_swatch_size_allocate (GtkWidget *widget,
                            GtkAllocation *allocation)
{
	GtkhtmlColorSwatchPrivate *priv;

	priv = GTKHTML_COLOR_SWATCH (widget)->priv;

	gtk_widget_set_allocation (widget, allocation);
	gtk_widget_size_allocate (priv->frame, allocation);
}
コード例 #21
0
ファイル: bytes_view.c プロジェクト: pvons/wireshark
static void
bytes_view_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
	gtk_widget_set_allocation(widget, allocation);

	if (gtk_widget_get_realized(widget)) {
		BytesView *bv = BYTES_VIEW(widget);

		gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height);
		bytes_view_adjustment_set(bv);
	}
}
コード例 #22
0
ファイル: panel-frame.c プロジェクト: dnk/mate-panel
static void
panel_frame_size_allocate (GtkWidget     *widget,
			   GtkAllocation *allocation)
{
	PanelFrame      *frame = (PanelFrame *) widget;
	GtkBin          *bin   = (GtkBin *) widget;
	GtkStyleContext *context;
	GtkBorder        padding;
	GtkAllocation    child_allocation;
	GtkAllocation    child_allocation_current;
	GtkWidget       *child;
	int              border_width;

	gtk_widget_set_allocation (widget, allocation);

	context = gtk_widget_get_style_context (widget);
	gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding);
	border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));

	child_allocation.x      = allocation->x + border_width;
	child_allocation.y      = allocation->y + border_width;
	child_allocation.width  = allocation->width  - 2 * border_width;
	child_allocation.height = allocation->height - 2 * border_width;

	if (frame->edges & PANEL_EDGE_LEFT) {
		child_allocation.x     += padding.left;
		child_allocation.width -= padding.left;
	}

	if (frame->edges & PANEL_EDGE_TOP) {
		child_allocation.y      += padding.top;
		child_allocation.height -= padding.top;
	}

	if (frame->edges & PANEL_EDGE_RIGHT)
		child_allocation.width -= padding.left;

	if (frame->edges & PANEL_EDGE_BOTTOM)
		child_allocation.height -= padding.top;

	child = gtk_bin_get_child (bin);
	gtk_widget_get_allocation (child, &child_allocation_current);

	if (gtk_widget_get_mapped (widget) &&
	    (child_allocation.x != child_allocation_current.x ||
	     child_allocation.y != child_allocation_current.y ||
	     child_allocation.width  != child_allocation_current.width ||
	     child_allocation.height != child_allocation_current.height))
		gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE);

	if (child && gtk_widget_get_visible (child))
		gtk_widget_size_allocate (child, &child_allocation);
}
コード例 #23
0
ファイル: exo-wrap-table.c プロジェクト: bluesabre/exo-gtk3
static void
exo_wrap_table_size_allocate (GtkWidget     *widget,
                              GtkAllocation *allocation)
{
  ExoWrapTable *table = EXO_WRAP_TABLE (widget);

  /* setup the new allocation */
  gtk_widget_set_allocation (widget, allocation);

  /* layout the children */
  exo_wrap_table_layout (table);
}
コード例 #24
0
ファイル: itk_button.c プロジェクト: lanceng/idou-music
static void itk_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
	GtkButton *button = GTK_BUTTON (widget);
	gtk_widget_set_allocation(widget, allocation);

	if (gtk_widget_get_realized (widget))
	    gdk_window_move_resize (gtk_button_get_event_window(button),
	                            allocation->x,
	                            allocation->y,
	                            allocation->width,
	                            allocation->height);
}
コード例 #25
0
static void
gimp_message_box_size_allocate (GtkWidget     *widget,
                                GtkAllocation *allocation)
{
  GimpMessageBox *box       = GIMP_MESSAGE_BOX (widget);
  GtkContainer   *container = GTK_CONTAINER (widget);
  gint            width     = 0;
  gboolean        rtl;

  rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);

  if (box->image && gtk_widget_get_visible (box->image))
    {
      GtkRequisition  child_requisition;
      GtkAllocation   child_allocation;
      gint            border_width;
      gint            height;

      gtk_widget_size_request (box->image, &child_requisition);

      border_width = gtk_container_get_border_width (container);

      width  = MIN (allocation->width - 2 * border_width,
                    child_requisition.width + GIMP_MESSAGE_BOX_SPACING);
      width  = MAX (1, width);

      height = allocation->height - 2 * border_width;
      height = MAX (1, height);

      if (rtl)
        child_allocation.x  = (allocation->width -
                               border_width      -
                               child_requisition.width);
      else
        child_allocation.x  = allocation->x + border_width;

      child_allocation.y      = allocation->y + border_width;
      child_allocation.width  = width;
      child_allocation.height = height;

      gtk_widget_size_allocate (box->image, &child_allocation);
    }

  allocation->x     += rtl ? 0 : width;
  allocation->width -= width;

  GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);

  allocation->x      -= rtl ? 0 : width;
  allocation->width  += width;

  gtk_widget_set_allocation (widget, allocation);
}
コード例 #26
0
static void
gtk_notification_size_allocate (GtkWidget *widget,
                                GtkAllocation *allocation)
{
  GtkNotification *notification = GTK_NOTIFICATION (widget);
  GtkNotificationPrivate *priv = notification->priv;
  GtkBin *bin = GTK_BIN (widget);
  GtkAllocation child_allocation;
  GtkBorder padding;
  GtkWidget *child;
  int button_width;

  gtk_widget_set_allocation (widget, allocation);

  /* If somehow the notification changes while not hidden
     and we're not animating, immediately follow the resize */
  if (priv->animate_y > 0 &&
      !priv->animate_timeout)
    priv->animate_y = allocation->height;

  get_padding_and_border (notification, &padding);

  if (gtk_widget_get_realized (widget))
    {
      gdk_window_move_resize (gtk_widget_get_window (widget),
                              allocation->x,
                              allocation->y,
                              allocation->width,
                              allocation->height);
      gdk_window_move_resize (priv->bin_window,
                              0,
                              -allocation->height + priv->animate_y,
                              allocation->width,
                              allocation->height);
    }

  child_allocation.x = SHADOW_OFFSET_X + padding.left;
  child_allocation.y = padding.top;
  child_allocation.height = MAX (1, allocation->height - SHADOW_OFFSET_Y - padding.top - padding.bottom);
  gtk_widget_get_preferred_width_for_height (priv->close_button, child_allocation.height,
                                             NULL, &button_width);

  child_allocation.width = MAX (1, allocation->width - 2 * SHADOW_OFFSET_X - padding.left - padding.right - button_width);

  child = gtk_bin_get_child (bin);
  if (child && gtk_widget_get_visible (child))
    gtk_widget_size_allocate (child, &child_allocation);

  child_allocation.x += child_allocation.width;
  child_allocation.width = button_width;

  gtk_widget_size_allocate (priv->close_button, &child_allocation);
}
コード例 #27
0
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);
}
コード例 #28
0
ファイル: mozcontainer.c プロジェクト: at13/mozilla-central
void
moz_container_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
{
    MozContainer   *container;
    GList          *tmp_list;
    GtkAllocation   tmp_allocation;
    GtkRequisition  tmp_requisition;
    GtkWidget      *tmp_child;

    g_return_if_fail (IS_MOZ_CONTAINER (widget));

    /*  printf("moz_container_size_allocate %p %d %d %d %d\n",
        (void *)widget,
        allocation->x,
        allocation->y,
        allocation->width,
        allocation->height); */

    /* short circuit if you can */
    container = MOZ_CONTAINER (widget);
    gtk_widget_get_allocation(widget, &tmp_allocation);
    if (!container->children &&
        tmp_allocation.x == allocation->x &&
        tmp_allocation.y == allocation->y &&
        tmp_allocation.width == allocation->width &&
        tmp_allocation.height == allocation->height) {
        return;
    }

    gtk_widget_set_allocation(widget, allocation);

    tmp_list = container->children;

    while (tmp_list) {
        MozContainerChild *child = tmp_list->data;

        moz_container_allocate_child (container, child);

        tmp_list = tmp_list->next;
    }

    if (gtk_widget_get_has_window (widget) &&
        gtk_widget_get_realized (widget)) {

        gdk_window_move_resize(gtk_widget_get_window(widget),
                               allocation->x,
                               allocation->y,
                               allocation->width,
                               allocation->height);
    }
}
コード例 #29
0
static void
gtk_revealer_real_size_allocate (GtkWidget     *widget,
                                 GtkAllocation *allocation)
{
  GtkRevealer *revealer = GTK_REVEALER (widget);
  GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
  GtkAllocation child_allocation;
  GtkWidget *child;
  gboolean window_visible;
  int bin_x, bin_y;
  GtkRevealerTransitionType transition;

  g_return_if_fail (allocation != NULL);

  gtk_widget_set_allocation (widget, allocation);
  gtk_revealer_get_child_allocation (revealer, allocation, &child_allocation);

  child = gtk_bin_get_child (GTK_BIN (revealer));
  if (child != NULL && gtk_widget_get_visible (child))
    gtk_widget_size_allocate (child, &child_allocation);

  if (gtk_widget_get_realized (widget))
    {
      if (gtk_widget_get_mapped (widget))
        {
          window_visible = allocation->width > 0 && allocation->height > 0;

          if (!window_visible && gdk_window_is_visible (priv->view_window))
            gdk_window_hide (priv->view_window);

          if (window_visible && !gdk_window_is_visible (priv->view_window))
            gdk_window_show (priv->view_window);
        }

      gdk_window_move_resize (priv->view_window,
                              allocation->x, allocation->y,
                              allocation->width, allocation->height);

      bin_x = 0;
      bin_y = 0;
      transition = effective_transition (revealer);
      if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN)
        bin_y = allocation->height - child_allocation.height;
      else if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
        bin_x = allocation->width - child_allocation.width;

      gdk_window_move_resize (priv->bin_window,
                              bin_x, bin_y,
                              child_allocation.width, child_allocation.height);
    }
}
コード例 #30
0
ファイル: hand_display.c プロジェクト: ChristophBerg/tenace
static void
hand_display_size_allocate (GtkWidget *hand, GtkAllocation *allocation)
{
	g_return_if_fail (hand != NULL);
	g_return_if_fail (IS_HAND_DISPLAY (hand));
	g_return_if_fail (allocation != NULL);

	gtk_widget_set_allocation (hand, allocation);
	if (gtk_widget_get_realized (hand)) {
		gdk_window_move_resize (gtk_widget_get_window (hand),
				allocation->x, allocation->y,
				allocation->width, allocation->height);
	}
}