Пример #1
0
static void
panel_frame_get_preferred_height (GtkWidget *widget,
				  gint *minimal_height,
				  gint *natural_height)
{
	PanelFrame      *frame = (PanelFrame *) widget;
	GtkBin          *bin   = (GtkBin *) widget;
	GtkStyleContext *context;
	GtkWidget       *child;
	GtkBorder        padding;
	int              border_width;

	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));

	*minimal_height = 1;
	*natural_height = 1;

	child = gtk_bin_get_child (bin);
	if (child && gtk_widget_get_visible (child))
		gtk_widget_get_preferred_height (child, minimal_height, natural_height);

	*minimal_height += border_width;
	*natural_height += border_width;

	if (frame->edges & PANEL_EDGE_TOP) {
		*minimal_height += padding.top;
		*natural_height += padding.top;
	}

	if (frame->edges & PANEL_EDGE_BOTTOM) {
		*minimal_height += padding.bottom;
		*natural_height += padding.bottom;
	}
}
Пример #2
0
static gboolean
gnm_notebook_button_draw (GtkWidget *widget, cairo_t *cr)
{
	GnmNotebookButton *nbb = GNM_NOTEBOOK_BUTTON (widget);
	GnmNotebook *nb = GNM_NOTEBOOK (gtk_widget_get_parent (widget));
	GtkStyleContext *context = gtk_widget_get_style_context (widget);
	gboolean is_active = (widget == gnm_notebook_get_current_label (nb));
	GtkStateFlags state =
		is_active ? GTK_STATE_FLAG_ACTIVE : GTK_STATE_FLAG_NORMAL;
	GtkBorder padding;

	gtk_style_context_save (context);
	gtk_style_context_set_state (context, state);

	gtk_style_context_get_padding (context, state, &padding);

	gnm_notebook_button_ensure_layout (nbb);

	gtk_render_layout (context, cr,
			   padding.left + (is_active ? nbb->x_offset_active : nbb->x_offset),
			   0,
			   is_active ? nbb->layout_active : nbb->layout);

	gtk_style_context_restore (context);
	return FALSE;
}
Пример #3
0
static void
_gtk_theming_background_init_context (GtkThemingBackground *bg)
{
  bg->flags = gtk_style_context_get_state (bg->context);

  gtk_style_context_get_border (bg->context, bg->flags, &bg->border);
  gtk_style_context_get_padding (bg->context, bg->flags, &bg->padding);
  gtk_style_context_get_background_color (bg->context, bg->flags, &bg->bg_color);

  /* In the CSS box model, by default the background positioning area is
   * the padding-box, i.e. all the border-box minus the borders themselves,
   * which determines also its default size, see
   * http://dev.w3.org/csswg/css3-background/#background-origin
   *
   * In the future we might want to support different origins or clips, but
   * right now we just shrink to the default.
   */
  _gtk_rounded_box_init_rect (&bg->border_box, 0, 0, bg->paint_area.width, bg->paint_area.height);
  _gtk_rounded_box_apply_border_radius_for_context (&bg->border_box, bg->context, bg->junction);

  bg->padding_box = bg->border_box;
  _gtk_rounded_box_shrink (&bg->padding_box,
			   bg->border.top, bg->border.right,
			   bg->border.bottom, bg->border.left);
}
Пример #4
0
static void
anjuta_tabber_get_preferred_width (GtkWidget* widget, 
                                    gint* minimum,
                                    gint* preferred)
{
	g_return_if_fail (ANJUTA_IS_TABBER (widget));

	AnjutaTabber* tabber = ANJUTA_TABBER (widget);
	GtkStyleContext* context;
	GList* child;
	gint focus_width;
	gint focus_pad;
	gint tab_curvature;
	gint tab_overlap;

	*minimum = 0;
	*preferred = 0;
	
	gtk_widget_style_get (GTK_WIDGET (tabber->priv->notebook),
	                      "focus-line-width", &focus_width,
	                      "focus-padding", &focus_pad,
	                      "tab-curvature", &tab_curvature,
	                      "tab-overlap", &tab_overlap,
	                      NULL);

	context = gtk_widget_get_style_context (widget);

	for (child = tabber->priv->children; child != NULL; child = g_list_next (child))
	{
		GtkStateFlags state;
		GtkBorder tab_padding;
		gint xpadding;
		gint child_min;
		gint child_preferred;
		gint extra_space = 2 * (tab_curvature - tab_overlap);

		/* Get the padding of the tab */
		gtk_style_context_save (context);
		anjuta_tabber_setup_style_context (tabber, context, child, &state, NULL);
		gtk_style_context_get_padding (context, state, &tab_padding);
		gtk_style_context_restore (context);

		xpadding =  2 * (focus_width + focus_pad) + tab_padding.left + tab_padding.right;
		
		if (child->prev == NULL)
			extra_space += tab_overlap;
		if (child->next == NULL)
			extra_space += tab_overlap;
		
		gtk_widget_get_preferred_width (GTK_WIDGET (child->data), &child_min, &child_preferred);
		if (minimum)
		{
			*minimum += child_min + xpadding + extra_space;
		}
		if (preferred)
		{
			*preferred += child_preferred + xpadding + extra_space;
		}
	}
}
Пример #5
0
static void
gtk_tearoff_menu_item_get_preferred_height (GtkWidget      *widget,
        gint           *minimum,
        gint           *natural)
{
    GtkStyleContext *context;
    GtkBorder padding;
    GtkStateFlags state;
    GtkWidget *parent;
    guint border_width;

    context = gtk_widget_get_style_context (widget);
    state = gtk_widget_get_state_flags (widget);

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

    *minimum = *natural = (border_width * 2) + padding.top + padding.bottom;

    parent = gtk_widget_get_parent (widget);
    if (GTK_IS_MENU (parent) && gtk_menu_get_tearoff_state (GTK_MENU (parent)))
    {
        *minimum += ARROW_SIZE;
        *natural += ARROW_SIZE;
    }
    else
    {
        *minimum += padding.top + 4;
        *natural += padding.top + 4;
    }
}
Пример #6
0
Файл: vteapp.c Проект: ari3s/vte
static void
resize_window(GtkWidget *widget, guint width, guint height, gpointer data)
{
	VteTerminal *terminal;

	if ((GTK_IS_WINDOW(data)) && (width >= 2) && (height >= 2)) {
		gint owidth, oheight, char_width, char_height, column_count, row_count;
		GtkBorder padding;

		terminal = VTE_TERMINAL(widget);

		gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);

		/* Take into account border overhead. */
		char_width = vte_terminal_get_char_width (terminal);
		char_height = vte_terminal_get_char_height (terminal);
		column_count = vte_terminal_get_column_count (terminal);
		row_count = vte_terminal_get_row_count (terminal);
                gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
                                              gtk_widget_get_state_flags(widget),
                                              &padding);

                owidth -= char_width * column_count + padding.left + padding.right;
                oheight -= char_height * row_count + padding.top + padding.bottom;
		gtk_window_resize(GTK_WINDOW(data),
				  width + owidth, height + oheight);
	}
}
Пример #7
0
static void
_gtk_theming_background_init_context (GtkThemingBackground *bg,
                                      double                width,
                                      double                height,
                                      GtkJunctionSides      junction)
{
  GtkStateFlags flags = gtk_style_context_get_state (bg->context);
  GtkBorder border, padding;

  gtk_style_context_get_border (bg->context, flags, &border);
  gtk_style_context_get_padding (bg->context, flags, &padding);

  /* In the CSS box model, by default the background positioning area is
   * the padding-box, i.e. all the border-box minus the borders themselves,
   * which determines also its default size, see
   * http://dev.w3.org/csswg/css3-background/#background-origin
   *
   * In the future we might want to support different origins or clips, but
   * right now we just shrink to the default.
   */
  _gtk_rounded_box_init_rect (&bg->boxes[GTK_CSS_AREA_BORDER_BOX], 0, 0, width, height);
  _gtk_rounded_box_apply_border_radius_for_context (&bg->boxes[GTK_CSS_AREA_BORDER_BOX], bg->context, junction);

  bg->boxes[GTK_CSS_AREA_PADDING_BOX] = bg->boxes[GTK_CSS_AREA_BORDER_BOX];
  _gtk_rounded_box_shrink (&bg->boxes[GTK_CSS_AREA_PADDING_BOX],
			   border.top, border.right,
			   border.bottom, border.left);

  bg->boxes[GTK_CSS_AREA_CONTENT_BOX] = bg->boxes[GTK_CSS_AREA_PADDING_BOX];
  _gtk_rounded_box_shrink (&bg->boxes[GTK_CSS_AREA_CONTENT_BOX],
			   padding.top, padding.right,
			   padding.bottom, padding.left);
}
Пример #8
0
static void
term_char_size_changed (VteTerminal *vtterm,
                        guint        width,
                        guint        height,
                        gpointer     userdata)
{
    GdkGeometry geometry;
    geometry.height_inc = height;
    geometry.width_inc = width;

    GtkBorder padding;
    gtk_style_context_get_padding (gtk_widget_get_style_context (GTK_WIDGET (vtterm)),
                                   gtk_widget_get_state_flags (GTK_WIDGET (vtterm)),
                                   &padding);
    geometry.base_height = padding.top + padding.bottom;
    geometry.base_width = padding.left + padding.right;

    geometry.min_height = geometry.base_height + 3 * geometry.height_inc;
    geometry.min_width = geometry.base_width + 10 * geometry.width_inc;

    gtk_window_set_geometry_hints (GTK_WINDOW (userdata),
                                   GTK_WIDGET (vtterm),
                                   &geometry,
                                   GDK_HINT_MIN_SIZE |
                                   GDK_HINT_BASE_SIZE |
                                   GDK_HINT_RESIZE_INC);
    gtk_widget_queue_resize (GTK_WIDGET (vtterm));
}
Пример #9
0
static void
image_menuitem_set_size_request (GtkWidget  *menuitem,
                                 GtkIconSize icon_size)
{
        GtkStyleContext *context;
        GtkStateFlags state;
        GtkBorder padding, border;
        int border_width;
	int icon_height;
	int req_height;

	if (!gtk_icon_size_lookup (icon_size, NULL, &icon_height))
		return;

	/* If we don't have a pixmap for this menuitem
	 * at least make sure its the same height as
	 * the rest.
	 * This is a bit ugly, since we should keep this in sync with what's in
	 * gtk_menu_item_size_request()
	 */
        context = gtk_widget_get_style_context (menuitem);
        state = gtk_widget_get_state_flags (menuitem);
        gtk_style_context_get_padding (context, state, &padding);
        gtk_style_context_get_border (context, state, &border);

        border_width = gtk_container_get_border_width (GTK_CONTAINER (menuitem));
	req_height = icon_height;
	req_height += (border_width * 2) + padding.top + padding.bottom + border.top + border.bottom;
        gtk_widget_set_size_request (menuitem, -1, req_height);
}
Пример #10
0
static void
query_size (GtkStyleContext *context,
            gint            *width,
            gint            *height)
{
  GtkBorder margin, border, padding;
  int min_width, min_height;

  gtk_style_context_get_margin (context, &margin);
  gtk_style_context_get_border (context, &border);
  gtk_style_context_get_padding (context, &padding);

  gtk_style_context_get (context,
                         "min-width", &min_width,
                         "min-height", &min_height,
                         NULL);

  min_width += margin.left + margin.right + border.left + border.right + padding.left + padding.right;
  min_height += margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;

  if (width)
    *width = MAX (*width, min_width);
  if (height)
    *height = MAX (*height, min_height);
}
Пример #11
0
static void
gtk_switch_get_preferred_width (GtkWidget *widget,
                                gint      *minimum,
                                gint      *natural)
{
  GtkStyleContext *context;
  GtkStateFlags state;
  GtkBorder padding;
  gint width, slider_width, focus_width, focus_pad;
  PangoLayout *layout;
  PangoRectangle logical_rect;

  context = gtk_widget_get_style_context (widget);
  state = gtk_style_context_get_state (context);

  gtk_style_context_save (context);

  gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
  gtk_style_context_get_padding (context, state, &padding);

  width = padding.left + padding.right;

  gtk_style_context_restore (context);

  gtk_widget_style_get (widget,
                        "slider-width", &slider_width,
                        "focus-line-width", &focus_width,
                        "focus-padding", &focus_pad,
                        NULL);

  slider_width = MAX (slider_width, 3 * (focus_width + focus_pad));

  /* Translators: if the "on" state label requires more than three
   * glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for
   * the state
   */
  layout = gtk_widget_create_pango_layout (widget, C_("switch", "ON"));
  pango_layout_get_extents (layout, NULL, &logical_rect);
  pango_extents_to_pixels (&logical_rect, NULL);
  width += MAX (logical_rect.width, slider_width);

  /* Translators: if the "off" state label requires more than three
   * glyphs then use WHITE CIRCLE (U+25CB) as the text for the state
   */
  pango_layout_set_text (layout, C_("switch", "OFF"), -1);
  pango_layout_get_extents (layout, NULL, &logical_rect);
  pango_extents_to_pixels (&logical_rect, NULL);
  width += MAX (logical_rect.width, slider_width);

  g_object_unref (layout);

  if (minimum)
    *minimum = width;

  if (natural)
    *natural = width;
}
Пример #12
0
static gboolean
gtk_switch_motion (GtkWidget      *widget,
                   GdkEventMotion *event)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;

  /* if this is a direct toggle we don't handle motion */
  if (priv->in_press)
    return GDK_EVENT_PROPAGATE;

  if (ABS (event->x - priv->drag_start) < priv->drag_threshold)
    return GDK_EVENT_STOP;

  if (event->state & GDK_BUTTON1_MASK)
    {
      gint position = event->x - priv->offset;
      GtkAllocation allocation;
      GtkStyleContext *context;
      GtkStateFlags state;
      GtkBorder padding;
      gint width, focus_width, focus_pad;

      gtk_widget_style_get (widget,
                            "focus-line-width", &focus_width,
                            "focus-padding", &focus_pad,
                            NULL);

      context = gtk_widget_get_style_context (widget);
      state = gtk_widget_get_state_flags (widget);

      gtk_style_context_save (context);
      gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
      gtk_style_context_get_padding (context, state, &padding);
      gtk_style_context_restore (context);
      
      gtk_widget_get_allocation (widget, &allocation);

      width = allocation.width - 2 * (focus_width + focus_pad);

      /* constrain the handle within the trough width */
      if (position > (width / 2) - padding.right)
        priv->handle_x = width / 2 - padding.right;
      else if (position < padding.left)
        priv->handle_x = 0;
      else
        priv->handle_x = position;

      priv->is_dragging = TRUE;

      /* we need to redraw the handle */
      gtk_widget_queue_draw (widget);

      return GDK_EVENT_STOP;
    }

  return GDK_EVENT_PROPAGATE;
}
Пример #13
0
static void
gtk_switch_get_preferred_height (GtkWidget *widget,
                                 gint      *minimum,
                                 gint      *natural)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
  GtkStyleContext *context;
  GtkStateFlags state;
  GtkBorder padding;
  gint height, focus_width, focus_pad;
  PangoLayout *layout;
  PangoRectangle logical_rect;
  gchar *str;

  context = gtk_widget_get_style_context (widget);
  state = gtk_widget_get_state_flags (widget);

  if (priv->is_active)
    state |= GTK_STATE_FLAG_ACTIVE;

  gtk_style_context_save (context);

  gtk_style_context_set_state (context, state);
  gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
  gtk_style_context_get_padding (context, state, &padding);

  height = padding.top + padding.bottom;

  gtk_style_context_restore (context);

  gtk_widget_style_get (widget,
                        "focus-line-width", &focus_width,
                        "focus-padding", &focus_pad,
                        NULL);

  height += 2 * (focus_width + focus_pad);

  str = g_strdup_printf ("%s%s",
                         C_("switch", "ON"),
                         C_("switch", "OFF"));

  layout = gtk_widget_create_pango_layout (widget, str);
  pango_layout_get_extents (layout, NULL, &logical_rect);
  pango_extents_to_pixels (&logical_rect, NULL);
  height += MAX (DEFAULT_SLIDER_HEIGHT, logical_rect.height);

  g_object_unref (layout);
  g_free (str);

  if (minimum)
    *minimum = height;

  if (natural)
    *natural = height;
}
Пример #14
0
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);
}
Пример #15
0
static void
update_hours_sidebar_size (GcalWeekView *self)
{
  GtkStyleContext *context;
  GtkStateFlags state;
  GtkSizeGroup *sidebar_sizegroup;
  GtkWidget *widget;
  GtkBorder padding;

  PangoLayout *layout;
  PangoFontDescription *font_desc;

  gint hours_12_width, hours_24_width, sidebar_width;
  gint hours_12_height, hours_24_height, cell_height;

  widget = GTK_WIDGET (self);
  context = gtk_widget_get_style_context (widget);
  state = gtk_style_context_get_state (context);

  gtk_style_context_save (context);
  gtk_style_context_add_class (context, "hours");

  gtk_style_context_get (context, state,
                         "font", &font_desc,
                         NULL);
  gtk_style_context_get_padding (context, state, &padding);

  layout = pango_layout_new (gtk_widget_get_pango_context (widget));
  pango_layout_set_font_description (layout, font_desc);

  pango_layout_set_text (layout, _("00 AM"), -1);
  pango_layout_get_pixel_size (layout, &hours_12_width, &hours_12_height);

  pango_layout_set_text (layout, _("00:00"), -1);
  pango_layout_get_pixel_size (layout, &hours_24_width, &hours_24_height);

  sidebar_width = MAX (hours_12_width, hours_24_width) + padding.left + padding.right;
  cell_height = MAX (hours_12_height, hours_24_height) + padding.top + padding.bottom + 1;

  gtk_style_context_restore (context);

  /* Update the size requests */
  gtk_widget_set_size_request (self->hours_bar,
                               sidebar_width,
                               48 * cell_height);

  /* Sync with the week header sidebar */
  sidebar_sizegroup = gcal_week_header_get_sidebar_size_group (GCAL_WEEK_HEADER (self->header));
  gtk_size_group_add_widget (sidebar_sizegroup, self->hours_bar);

  pango_font_description_free (font_desc);
  g_object_unref (layout);
}
Пример #16
0
static void
gtk_revealer_get_padding (GtkRevealer *revealer,
                          GtkBorder   *padding)
{
  GtkWidget *widget = GTK_WIDGET (revealer);
  GtkStyleContext *context;
  GtkStateFlags state;

  context = gtk_widget_get_style_context (widget);
  state = gtk_style_context_get_state (context);

  gtk_style_context_get_padding (context, state, padding);
}
Пример #17
0
static void
gtk_switch_get_preferred_height (GtkWidget *widget,
                                 gint      *minimum,
                                 gint      *natural)
{
  GtkStyleContext *context;
  GtkStateFlags state;
  GtkBorder padding;
  gint height, focus_width, focus_pad, slider_width, min_height;
  PangoLayout *layout;
  PangoRectangle logical_rect;
  gchar *str;

  context = gtk_widget_get_style_context (widget);
  state = gtk_style_context_get_state (context);

  gtk_style_context_save (context);

  gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
  gtk_style_context_get_padding (context, state, &padding);

  height = padding.top + padding.bottom;

  gtk_style_context_restore (context);

  gtk_widget_style_get (widget,
                        "slider-width", &slider_width,
                        "focus-line-width", &focus_width,
                        "focus-padding", &focus_pad,
                        NULL);

  min_height = MAX (slider_width * 0.6, 3 * (focus_width + focus_pad));

  str = g_strdup_printf ("%s%s",
                         C_("switch", "ON"),
                         C_("switch", "OFF"));

  layout = gtk_widget_create_pango_layout (widget, str);
  pango_layout_get_extents (layout, NULL, &logical_rect);
  pango_extents_to_pixels (&logical_rect, NULL);
  height += MAX (min_height, logical_rect.height);

  g_object_unref (layout);
  g_free (str);

  if (minimum)
    *minimum = height;

  if (natural)
    *natural = height;
}
Пример #18
0
static void
gctt_combott_menu_position (GtkMenu  *menu,
                            gint     *x,
                            gint     *y,
                            gint     *push_in,
                            gpointer  user_data)
{
    GncCombott *combott = GNC_COMBOTT (user_data);
    GncCombottPrivate *priv = GNC_COMBOTT_GET_PRIVATE (combott);
    gint sx, sy;
    GtkWidget *child;
    GtkRequisition req;
    GtkAllocation alloc;
    GtkBorder padding;
    GtkStyleContext *sc = gtk_widget_get_style_context (GTK_WIDGET (priv->button));
    GtkStateFlags state_flags = gtk_style_context_get_state (sc);

    child = gtk_bin_get_child (GTK_BIN (priv->button));

    sx = sy = 0;

    if (!gtk_widget_get_has_window (child))
    {
        gtk_widget_get_allocation (child, &alloc);
        sx += alloc.x;
        sy += alloc.y;
    }

    gdk_window_get_root_coords (gtk_widget_get_window (child), sx, sy, &sx, &sy);

    gtk_style_context_get_padding (sc, state_flags, &padding);

    sx -= padding.left;

    gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);

    if (gtk_widget_get_direction (GTK_WIDGET (priv->button)) == GTK_TEXT_DIR_LTR)
        *x = sx;
    else
    {
        gtk_widget_get_allocation (child, &alloc);
        *x = sx + alloc.width - req.width;
    }

    if(priv->active == -1 || priv->active == 0)
        *y = sy;
    else
        *y = sy - ((req.height / priv->num_items) * (priv->active - 1));

    *push_in = FALSE;
}
static void _style_get_borders (GtkStyleContext *context, GtkBorder *border_out)
{
    GtkBorder padding, border;
    GtkStateFlags state;

    state = gtk_style_context_get_state (context);
    gtk_style_context_get_padding (context, state, &padding);
    gtk_style_context_get_border (context, state, &border);

    border_out->top = padding.top + border.top;
    border_out->bottom = padding.bottom + border.bottom;
    border_out->left = padding.left + border.left;
    border_out->right = padding.right + border.right;
}
Пример #20
0
static void
anjuta_tabber_get_preferred_height (GtkWidget* widget, 
                                    gint* minimum,
                                    gint* preferred)
{
	g_return_if_fail (ANJUTA_IS_TABBER (widget));

	AnjutaTabber* tabber = ANJUTA_TABBER (widget);
	GtkStyleContext* context;
	GList* child;
	gint focus_width;
	gint focus_pad;
	
	gtk_widget_style_get (GTK_WIDGET (tabber),
	                      "focus-line-width", &focus_width,
	                      "focus-padding", &focus_pad,
	                      NULL);

	context = gtk_widget_get_style_context (widget);

	for (child = tabber->priv->children; child != NULL; child = g_list_next (child))
	{
		GtkStateFlags state;
		GtkBorder tab_padding;
		gint ypadding;
		gint child_min;
		gint child_preferred;

		/* Get the padding of the tab */
		gtk_style_context_save (context);
		anjuta_tabber_setup_style_context (tabber, context, child, &state, NULL);
		gtk_style_context_get_padding (context, state, &tab_padding);
		gtk_style_context_restore (context);

		ypadding =  2 * (focus_width + focus_pad) + tab_padding.top + tab_padding.bottom;

		gtk_widget_get_preferred_height (GTK_WIDGET (child->data), &child_min, &child_preferred);
		if (minimum)
		{
			*minimum = MAX(*minimum, child_min + ypadding);
		}
		if (preferred)
		{
			*preferred = MAX(*preferred, child_preferred + ypadding);
		}
	}
}
Пример #21
0
static void
msd_osd_window_style_updated (GtkWidget *widget)
{
        GtkStyleContext *context;
        GtkBorder padding;

        GTK_WIDGET_CLASS (msd_osd_window_parent_class)->style_updated (widget);

        /* We set our border width to 12 (per the MATE standard), plus the
         * padding of the frame that we draw in our expose handler.  This will
         * make our child be 12 pixels away from the frame.
         */

        context = gtk_widget_get_style_context (widget);
        gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);
        gtk_container_set_border_width (GTK_CONTAINER (widget), 12 + MAX (padding.left, padding.top));
}
Пример #22
0
static void
get_padding_and_border (GtkWidget *widget,
                        GtkBorder *border)
{
  GtkStyleContext *context;
  GtkStateFlags state;
  GtkBorder tmp;

  context = gtk_widget_get_style_context (widget);
  state = gtk_widget_get_state_flags (widget);

  gtk_style_context_get_padding (context, state, border);
  gtk_style_context_get_border (context, state, &tmp);
  border->top += tmp.top;
  border->right += tmp.right;
  border->bottom += tmp.bottom;
  border->left += tmp.left;
}
Пример #23
0
static void
msd_osd_window_get_preferred_height (GtkWidget *widget,
                                     gint      *minimum,
                                     gint      *natural)
{
        GtkStyleContext *context;
        GtkBorder padding;

        GTK_WIDGET_CLASS (msd_osd_window_parent_class)->get_preferred_height (widget, minimum, natural);

        /* See the comment in msd_osd_window_style_updated() for why we add the padding here */

        context = gtk_widget_get_style_context (widget);
        gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);

        *minimum += padding.top;
        *natural += padding.top;
}
Пример #24
0
static void
xfce_arrow_button_get_thickness (GtkStyleContext *context, xfce_arrow_button_thickness *thickness)
{
    GtkBorder border;
    GtkBorder margin;
    GtkBorder padding;
    gint xthickness;
    gint ythickness;

    gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
    gtk_style_context_get_margin (context, GTK_STATE_FLAG_NORMAL, &margin);
    gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);

    thickness->x = MAX (border.left + margin.left + padding.left,
                        border.right + margin.right + padding.right);
    thickness->y = MAX (border.top + margin.top + padding.top,
                        border.bottom + margin.bottom + padding.bottom);
}
Пример #25
0
static void
gtk_tearoff_menu_item_get_preferred_width (GtkWidget      *widget,
        gint           *minimum,
        gint           *natural)
{
    GtkStyleContext *context;
    guint border_width;
    GtkBorder padding;
    GtkStateFlags state;

    context = gtk_widget_get_style_context (widget);
    state = gtk_widget_get_state_flags (widget);

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

    *minimum = *natural = (border_width + BORDER_SPACING) * 2 + padding.left + padding.right;
}
Пример #26
0
static gboolean
gtk_switch_motion (GtkWidget      *widget,
                   GdkEventMotion *event)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;

  /* if this is a direct toggle we don't handle motion */
  if (priv->in_press)
    return FALSE;

  if (ABS (event->x - priv->drag_start) < priv->drag_threshold)
    return TRUE;

  if (event->state & GDK_BUTTON1_MASK)
    {
      gint position = event->x - priv->offset;
      GtkAllocation allocation;
      GtkStyleContext *context;
      GtkStateFlags state;
      GtkBorder padding;

      context = gtk_widget_get_style_context (widget);
      state = gtk_widget_get_state_flags (widget);
      gtk_style_context_get_padding (context, state, &padding);
      gtk_widget_get_allocation (widget, &allocation);

      /* constrain the handle within the trough width */
      if (position > (allocation.width / 2 - padding.right))
        priv->handle_x = allocation.width / 2 - padding.right;
      else if (position < padding.left)
        priv->handle_x = padding.left;
      else
        priv->handle_x = position;

      priv->is_dragging = TRUE;

      /* we need to redraw the handle */
      gtk_widget_queue_draw (widget);

      return TRUE;
    }

  return FALSE;
}
Пример #27
0
static void
gtk_switch_pan_gesture_pan (GtkGesturePan   *gesture,
                            GtkPanDirection  direction,
                            gdouble          offset,
                            GtkSwitch       *sw)
{
  GtkWidget *widget = GTK_WIDGET (sw);
  GtkSwitchPrivate *priv = sw->priv;
  GtkAllocation allocation;
  GtkStyleContext *context;
  GtkStateFlags state;
  GtkBorder padding;
  gint width, position;

  if (direction == GTK_PAN_DIRECTION_LEFT)
    offset = -offset;

  gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
  position = priv->offset + offset;

  context = gtk_widget_get_style_context (widget);
  state = gtk_widget_get_state_flags (widget);

  gtk_style_context_save (context);
  gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
  gtk_style_context_get_padding (context, state, &padding);
  gtk_style_context_restore (context);

  gtk_widget_get_allocation (widget, &allocation);

  width = allocation.width;

  /* constrain the handle within the trough width */
  if (position > (width / 2) - padding.right)
    priv->handle_x = width / 2 - padding.right;
  else if (position < padding.left)
    priv->handle_x = 0;
  else
    priv->handle_x = position;

  /* we need to redraw the handle */
  gtk_widget_queue_draw (widget);
}
Пример #28
0
static void
draw_style_common (GtkStyleContext *context,
                   cairo_t         *cr,
                   gint             x,
                   gint             y,
                   gint             width,
                   gint             height,
                   gint            *contents_x,
                   gint            *contents_y,
                   gint            *contents_width,
                   gint            *contents_height)
{
  GtkBorder margin, border, padding;
  int min_width, min_height;

  gtk_style_context_get_margin (context, &margin);
  gtk_style_context_get_border (context, &border);
  gtk_style_context_get_padding (context, &padding);

  gtk_style_context_get (context,
                         "min-width", &min_width,
                         "min-height", &min_height,
                         NULL);
  x += margin.left;
  y += margin.top;
  width -= margin.left + margin.right;
  height -= margin.top + margin.bottom;

  width = MAX (width, min_width);
  height = MAX (height, min_height);

  gtk_render_background (context, cr, x, y, width, height);
  gtk_render_frame (context, cr, x, y, width, height);

  if (contents_x)
    *contents_x = x + border.left + padding.left;
  if (contents_y)
    *contents_y = y + border.top + padding.top;
  if (contents_width)
    *contents_width = width - border.left - border.right - padding.left - padding.right;
  if (contents_height)
    *contents_height = height - border.top - border.bottom - padding.top - padding.bottom;
}
Пример #29
0
wxSize wxSpinButton::DoGetBestSize() const
{
    wxSize best = base_type::DoGetBestSize();
#ifdef __WXGTK3__
    GtkStyleContext* sc = gtk_widget_get_style_context(m_widget);
    GtkBorder pad = { 0, 0, 0, 0 };
    gtk_style_context_get_padding(sc, GtkStateFlags(0), &pad);
    best.x -= pad.left + pad.right;
#else
    gtk_widget_ensure_style(m_widget);
    int w = PANGO_PIXELS(pango_font_description_get_size(m_widget->style->font_desc));
    w &= ~1;
    if (w < 6)
        w = 6;
    best.x = w + 2 * m_widget->style->xthickness;
#endif
    CacheBestSize(best);
    return best;
}
Пример #30
0
static void
get_padding_and_border (GdNotification *notification,
                        GtkBorder *border)
{
  GtkStyleContext *context;
  GtkStateFlags state;
  GtkBorder tmp;

  context = gtk_widget_get_style_context (GTK_WIDGET (notification));
  state = gtk_widget_get_state_flags (GTK_WIDGET (notification));

  gtk_style_context_get_padding (context, state, border);

  gtk_style_context_get_border (context, state, &tmp);
  border->top += tmp.top;
  border->right += tmp.right;
  border->bottom += tmp.bottom;
  border->left += tmp.left;
}