forked from AuroraMiddleware/gtk
Merge branch 'ebassi/cell-renderer-get-size' into 'master'
Remove GtkCellRendererClass.get_size() See merge request GNOME/gtk!2896
This commit is contained in:
commit
8cf4ce5d9e
@ -86,7 +86,6 @@ static void gtk_cell_renderer_set_property (GObject *object,
|
||||
static void set_cell_bg_color (GtkCellRenderer *cell,
|
||||
GdkRGBA *rgba);
|
||||
|
||||
/* Fallback GtkCellRenderer implementation to use remaining ->get_size() implementations */
|
||||
static GtkSizeRequestMode gtk_cell_renderer_real_get_request_mode(GtkCellRenderer *cell);
|
||||
static void gtk_cell_renderer_real_get_preferred_width (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
@ -201,7 +200,6 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
|
||||
object_class->set_property = gtk_cell_renderer_set_property;
|
||||
|
||||
class->snapshot = NULL;
|
||||
class->get_size = NULL;
|
||||
class->get_request_mode = gtk_cell_renderer_real_get_request_mode;
|
||||
class->get_preferred_width = gtk_cell_renderer_real_get_preferred_width;
|
||||
class->get_preferred_height = gtk_cell_renderer_real_get_preferred_height;
|
||||
@ -1177,15 +1175,8 @@ gtk_cell_renderer_real_get_preferred_size (GtkCellRenderer *cell,
|
||||
{
|
||||
GtkRequisition min_req;
|
||||
|
||||
/* Fallback on the old API to get the size. */
|
||||
if (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size)
|
||||
GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (GTK_CELL_RENDERER (cell), widget, NULL, NULL, NULL,
|
||||
&min_req.width, &min_req.height);
|
||||
else
|
||||
{
|
||||
min_req.width = 0;
|
||||
min_req.height = 0;
|
||||
}
|
||||
min_req.width = 0;
|
||||
min_req.height = 0;
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
@ -1240,7 +1231,6 @@ gtk_cell_renderer_real_get_preferred_height_for_width (GtkCellRenderer *cell,
|
||||
int *minimum_height,
|
||||
int *natural_height)
|
||||
{
|
||||
/* Fall back on the height reported from ->get_size() */
|
||||
gtk_cell_renderer_get_preferred_height (cell, widget, minimum_height, natural_height);
|
||||
}
|
||||
|
||||
@ -1251,7 +1241,6 @@ gtk_cell_renderer_real_get_preferred_width_for_height (GtkCellRenderer *cell,
|
||||
int *minimum_width,
|
||||
int *natural_width)
|
||||
{
|
||||
/* Fall back on the width reported from ->get_size() */
|
||||
gtk_cell_renderer_get_preferred_width (cell, widget, minimum_width, natural_width);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,6 @@ struct _GtkCellRenderer
|
||||
* @get_preferred_height: Called to get a renderer’s natural height.
|
||||
* @get_preferred_width_for_height: Called to get a renderer’s natural width for height.
|
||||
* @get_aligned_area: Called to get the aligned area used by @cell inside @cell_area.
|
||||
* @get_size: Called to get the width and height needed to render the cell. Deprecated: 3.0.
|
||||
* @snapshot: Called to snapshot the content of the #GtkCellRenderer.
|
||||
* @activate: Called to activate the content of the #GtkCellRenderer.
|
||||
* @start_editing: Called to initiate editing the content of the #GtkCellRenderer.
|
||||
@ -138,13 +137,6 @@ struct _GtkCellRendererClass
|
||||
GtkCellRendererState flags,
|
||||
const GdkRectangle *cell_area,
|
||||
GdkRectangle *aligned_area);
|
||||
void (* get_size) (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height);
|
||||
void (* snapshot) (GtkCellRenderer *cell,
|
||||
GtkSnapshot *snapshot,
|
||||
GtkWidget *widget,
|
||||
|
@ -58,7 +58,7 @@ static void gtk_cell_renderer_pixbuf_set_property (GObject *
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
|
||||
static void gtk_cell_renderer_pixbuf_get_size (GtkCellRendererPixbuf *self,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *rectangle,
|
||||
int *x_offset,
|
||||
@ -134,6 +134,48 @@ gtk_cell_renderer_pixbuf_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (gtk_cell_renderer_pixbuf_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static GtkSizeRequestMode
|
||||
gtk_cell_renderer_pixbuf_get_request_mode (GtkCellRenderer *cell)
|
||||
{
|
||||
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_pixbuf_get_preferred_width (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
gtk_cell_renderer_pixbuf_get_size (GTK_CELL_RENDERER_PIXBUF (cell), widget, NULL,
|
||||
NULL, NULL, &size, NULL);
|
||||
|
||||
if (minimum != NULL)
|
||||
*minimum = size;
|
||||
|
||||
if (natural != NULL)
|
||||
*natural = size;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_pixbuf_get_preferred_height (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
gtk_cell_renderer_pixbuf_get_size (GTK_CELL_RENDERER_PIXBUF (cell), widget, NULL,
|
||||
NULL, NULL, NULL, &size);
|
||||
|
||||
if (minimum != NULL)
|
||||
*minimum = size;
|
||||
|
||||
if (natural != NULL)
|
||||
*natural = size;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
|
||||
{
|
||||
@ -145,7 +187,9 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
|
||||
object_class->get_property = gtk_cell_renderer_pixbuf_get_property;
|
||||
object_class->set_property = gtk_cell_renderer_pixbuf_set_property;
|
||||
|
||||
cell_class->get_size = gtk_cell_renderer_pixbuf_get_size;
|
||||
cell_class->get_request_mode = gtk_cell_renderer_pixbuf_get_request_mode;
|
||||
cell_class->get_preferred_width = gtk_cell_renderer_pixbuf_get_preferred_width;
|
||||
cell_class->get_preferred_height = gtk_cell_renderer_pixbuf_get_preferred_height;
|
||||
cell_class->snapshot = gtk_cell_renderer_pixbuf_snapshot;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
@ -403,16 +447,16 @@ create_icon_helper (GtkCellRendererPixbuf *cellpixbuf,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height)
|
||||
gtk_cell_renderer_pixbuf_get_size (GtkCellRendererPixbuf *self,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (cell);
|
||||
GtkCellRendererPixbufPrivate *priv = gtk_cell_renderer_pixbuf_get_instance_private (cellpixbuf);
|
||||
GtkCellRendererPixbufPrivate *priv = gtk_cell_renderer_pixbuf_get_instance_private (self);
|
||||
GtkCellRenderer *cell = GTK_CELL_RENDERER (self);
|
||||
int pixbuf_width;
|
||||
int pixbuf_height;
|
||||
int calc_width;
|
||||
@ -425,7 +469,7 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, "image");
|
||||
gtk_icon_size_set_style_classes (gtk_style_context_get_node (context), priv->icon_size);
|
||||
icon_helper = create_icon_helper (cellpixbuf, widget);
|
||||
icon_helper = create_icon_helper (self, widget);
|
||||
|
||||
if (_gtk_icon_helper_get_is_empty (icon_helper))
|
||||
pixbuf_width = pixbuf_height = 0;
|
||||
@ -505,7 +549,8 @@ gtk_cell_renderer_pixbuf_snapshot (GtkCellRenderer *cell,
|
||||
int xpad, ypad;
|
||||
GtkIconHelper *icon_helper;
|
||||
|
||||
gtk_cell_renderer_pixbuf_get_size (cell, widget, (GdkRectangle *) cell_area,
|
||||
gtk_cell_renderer_pixbuf_get_size (cellpixbuf, widget,
|
||||
cell_area,
|
||||
&pix_rect.x,
|
||||
&pix_rect.y,
|
||||
&pix_rect.width,
|
||||
|
@ -20,7 +20,7 @@
|
||||
* Modified by the GTK+ Team and others 1997-2007. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -104,13 +104,6 @@ static void compute_dimensions (GtkCellRenderer *ce
|
||||
const char *text,
|
||||
int *width,
|
||||
int *height);
|
||||
static void gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height);
|
||||
static void gtk_cell_renderer_progress_snapshot (GtkCellRenderer *cell,
|
||||
GtkSnapshot *snapshot,
|
||||
GtkWidget *widget,
|
||||
@ -118,151 +111,73 @@ static void gtk_cell_renderer_progress_snapshot (GtkCellRenderer *ce
|
||||
const GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags);
|
||||
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkCellRendererProgress, gtk_cell_renderer_progress, GTK_TYPE_CELL_RENDERER,
|
||||
G_ADD_PRIVATE (GtkCellRendererProgress)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *klass)
|
||||
recompute_label (GtkCellRendererProgress *cellprogress)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_cell_renderer_progress_finalize;
|
||||
object_class->get_property = gtk_cell_renderer_progress_get_property;
|
||||
object_class->set_property = gtk_cell_renderer_progress_set_property;
|
||||
|
||||
cell_class->get_size = gtk_cell_renderer_progress_get_size;
|
||||
cell_class->snapshot = gtk_cell_renderer_progress_snapshot;
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:value:
|
||||
*
|
||||
* The "value" property determines the percentage to which the
|
||||
* progress bar will be "filled in".
|
||||
**/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_VALUE,
|
||||
g_param_spec_int ("value",
|
||||
P_("Value"),
|
||||
P_("Value of the progress bar"),
|
||||
0, 100, 0,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
char *label;
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:text:
|
||||
*
|
||||
* The "text" property determines the label which will be drawn
|
||||
* over the progress bar. Setting this property to %NULL causes the default
|
||||
* label to be displayed. Setting this property to an empty string causes
|
||||
* no label to be displayed.
|
||||
**/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TEXT,
|
||||
g_param_spec_string ("text",
|
||||
P_("Text"),
|
||||
P_("Text on the progress bar"),
|
||||
NULL,
|
||||
GTK_PARAM_READWRITE));
|
||||
if (priv->text)
|
||||
label = g_strdup (priv->text);
|
||||
else if (priv->pulse < 0)
|
||||
label = g_strdup_printf (C_("progress bar label", "%d %%"), priv->value);
|
||||
else
|
||||
label = NULL;
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:pulse:
|
||||
*
|
||||
* Setting this to a non-negative value causes the cell renderer to
|
||||
* enter "activity mode", where a block bounces back and forth to
|
||||
* indicate that some progress is made, without specifying exactly how
|
||||
* much.
|
||||
*
|
||||
* Each increment of the property causes the block to move by a little
|
||||
* bit.
|
||||
*
|
||||
* To indicate that the activity has not started yet, set the property
|
||||
* to zero. To indicate completion, set the property to %G_MAXINT.
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PULSE,
|
||||
g_param_spec_int ("pulse",
|
||||
P_("Pulse"),
|
||||
P_("Set this to positive values to indicate that some progress is made, but you don’t know how much."),
|
||||
-1, G_MAXINT, -1,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:text-xalign:
|
||||
*
|
||||
* The "text-xalign" property controls the horizontal alignment of the
|
||||
* text in the progress bar. Valid values range from 0 (left) to 1
|
||||
* (right). Reserved for RTL layouts.
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TEXT_XALIGN,
|
||||
g_param_spec_float ("text-xalign",
|
||||
P_("Text x alignment"),
|
||||
P_("The horizontal text alignment, from 0 (left) to 1 (right). Reversed for RTL layouts."),
|
||||
0.0, 1.0, 0.5,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:text-yalign:
|
||||
*
|
||||
* The "text-yalign" property controls the vertical alignment of the
|
||||
* text in the progress bar. Valid values range from 0 (top) to 1
|
||||
* (bottom).
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TEXT_YALIGN,
|
||||
g_param_spec_float ("text-yalign",
|
||||
P_("Text y alignment"),
|
||||
P_("The vertical text alignment, from 0 (top) to 1 (bottom)."),
|
||||
0.0, 1.0, 0.5,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_override_property (object_class,
|
||||
PROP_ORIENTATION,
|
||||
"orientation");
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_INVERTED,
|
||||
g_param_spec_boolean ("inverted",
|
||||
P_("Inverted"),
|
||||
P_("Invert the direction in which the progress bar grows"),
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
g_free (priv->label);
|
||||
priv->label = label;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_init (GtkCellRendererProgress *cellprogress)
|
||||
gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress,
|
||||
int value)
|
||||
{
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
|
||||
priv->value = 0;
|
||||
priv->text = NULL;
|
||||
priv->label = NULL;
|
||||
priv->min_w = -1;
|
||||
priv->min_h = -1;
|
||||
priv->pulse = -1;
|
||||
priv->offset = 0;
|
||||
|
||||
priv->text_xalign = 0.5;
|
||||
priv->text_yalign = 0.5;
|
||||
|
||||
priv->orientation = GTK_ORIENTATION_HORIZONTAL,
|
||||
priv->inverted = FALSE;
|
||||
if (priv->value != value)
|
||||
{
|
||||
priv->value = value;
|
||||
recompute_label (cellprogress);
|
||||
g_object_notify (G_OBJECT (cellprogress), "value");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_cell_renderer_progress_new:
|
||||
*
|
||||
* Creates a new #GtkCellRendererProgress.
|
||||
*
|
||||
* Returns: the new cell renderer
|
||||
**/
|
||||
GtkCellRenderer*
|
||||
gtk_cell_renderer_progress_new (void)
|
||||
static void
|
||||
gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
|
||||
const char *text)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_CELL_RENDERER_PROGRESS, NULL);
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
char *new_text;
|
||||
|
||||
new_text = g_strdup (text);
|
||||
g_free (priv->text);
|
||||
priv->text = new_text;
|
||||
recompute_label (cellprogress);
|
||||
g_object_notify (G_OBJECT (cellprogress), "text");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_set_pulse (GtkCellRendererProgress *cellprogress,
|
||||
int pulse)
|
||||
{
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
|
||||
if (pulse != priv->pulse)
|
||||
{
|
||||
if (pulse <= 0)
|
||||
priv->offset = 0;
|
||||
else
|
||||
priv->offset = pulse;
|
||||
g_object_notify (G_OBJECT (cellprogress), "pulse");
|
||||
}
|
||||
|
||||
priv->pulse = pulse;
|
||||
recompute_label (cellprogress);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -270,10 +185,10 @@ gtk_cell_renderer_progress_finalize (GObject *object)
|
||||
{
|
||||
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (object);
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
|
||||
|
||||
g_free (priv->text);
|
||||
g_free (priv->label);
|
||||
|
||||
|
||||
G_OBJECT_CLASS (gtk_cell_renderer_progress_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@ -285,7 +200,7 @@ gtk_cell_renderer_progress_get_property (GObject *object,
|
||||
{
|
||||
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (object);
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
@ -322,11 +237,11 @@ gtk_cell_renderer_progress_set_property (GObject *object,
|
||||
{
|
||||
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (object);
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
gtk_cell_renderer_progress_set_value (cellprogress,
|
||||
gtk_cell_renderer_progress_set_value (cellprogress,
|
||||
g_value_get_int (value));
|
||||
break;
|
||||
case PROP_TEXT:
|
||||
@ -334,7 +249,7 @@ gtk_cell_renderer_progress_set_property (GObject *object,
|
||||
g_value_get_string (value));
|
||||
break;
|
||||
case PROP_PULSE:
|
||||
gtk_cell_renderer_progress_set_pulse (cellprogress,
|
||||
gtk_cell_renderer_progress_set_pulse (cellprogress,
|
||||
g_value_get_int (value));
|
||||
break;
|
||||
case PROP_TEXT_XALIGN:
|
||||
@ -362,89 +277,25 @@ gtk_cell_renderer_progress_set_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
recompute_label (GtkCellRendererProgress *cellprogress)
|
||||
{
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
char *label;
|
||||
|
||||
if (priv->text)
|
||||
label = g_strdup (priv->text);
|
||||
else if (priv->pulse < 0)
|
||||
label = g_strdup_printf (C_("progress bar label", "%d %%"), priv->value);
|
||||
else
|
||||
label = NULL;
|
||||
|
||||
g_free (priv->label);
|
||||
priv->label = label;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress,
|
||||
int value)
|
||||
{
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
|
||||
if (priv->value != value)
|
||||
{
|
||||
priv->value = value;
|
||||
recompute_label (cellprogress);
|
||||
g_object_notify (G_OBJECT (cellprogress), "value");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
|
||||
const char *text)
|
||||
{
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
char *new_text;
|
||||
|
||||
new_text = g_strdup (text);
|
||||
g_free (priv->text);
|
||||
priv->text = new_text;
|
||||
recompute_label (cellprogress);
|
||||
g_object_notify (G_OBJECT (cellprogress), "text");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_set_pulse (GtkCellRendererProgress *cellprogress,
|
||||
int pulse)
|
||||
{
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
|
||||
if (pulse != priv->pulse)
|
||||
{
|
||||
if (pulse <= 0)
|
||||
priv->offset = 0;
|
||||
else
|
||||
priv->offset = pulse;
|
||||
g_object_notify (G_OBJECT (cellprogress), "pulse");
|
||||
}
|
||||
|
||||
priv->pulse = pulse;
|
||||
recompute_label (cellprogress);
|
||||
}
|
||||
|
||||
static void
|
||||
compute_dimensions (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const char *text,
|
||||
int *width,
|
||||
GtkWidget *widget,
|
||||
const char *text,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
PangoRectangle logical_rect;
|
||||
PangoLayout *layout;
|
||||
int xpad, ypad;
|
||||
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, text);
|
||||
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
|
||||
|
||||
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
|
||||
|
||||
|
||||
if (width)
|
||||
*width = logical_rect.width + xpad * 2;
|
||||
|
||||
|
||||
if (height)
|
||||
*height = logical_rect.height + ypad * 2;
|
||||
|
||||
@ -452,51 +303,63 @@ compute_dimensions (GtkCellRenderer *cell,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height)
|
||||
gtk_cell_renderer_progress_get_preferred_width (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell);
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
GtkCellRendererProgress *self = GTK_CELL_RENDERER_PROGRESS (cell);
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (self);
|
||||
int w, h;
|
||||
char *text;
|
||||
int size;
|
||||
|
||||
if (priv->min_w < 0)
|
||||
{
|
||||
text = g_strdup_printf (C_("progress bar label", "%d %%"), 100);
|
||||
char *text = g_strdup_printf (C_("progress bar label", "%d %%"), 100);
|
||||
compute_dimensions (cell, widget, text,
|
||||
&priv->min_w,
|
||||
&priv->min_h);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
compute_dimensions (cell, widget, priv->label, &w, &h);
|
||||
|
||||
if (width)
|
||||
*width = MAX (priv->min_w, w);
|
||||
|
||||
if (height)
|
||||
*height = MIN (priv->min_h, h);
|
||||
|
||||
/* FIXME: at the moment cell_area is only set when we are requesting
|
||||
* the size for drawing the focus rectangle. We now just return
|
||||
* the last size we used for drawing the progress bar, which will
|
||||
* work for now. Not a really nice solution though.
|
||||
*/
|
||||
if (cell_area)
|
||||
compute_dimensions (cell, widget, priv->label, &w, &h);
|
||||
|
||||
size = MAX (priv->min_w, w);
|
||||
|
||||
if (minimum != NULL)
|
||||
*minimum = size;
|
||||
if (natural != NULL)
|
||||
*natural = size;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_get_preferred_height (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
GtkCellRendererProgress *self = GTK_CELL_RENDERER_PROGRESS (cell);
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (self);
|
||||
int w, h;
|
||||
int size;
|
||||
|
||||
if (priv->min_w < 0)
|
||||
{
|
||||
if (width)
|
||||
*width = cell_area->width;
|
||||
if (height)
|
||||
*height = cell_area->height;
|
||||
char *text = g_strdup_printf (C_("progress bar label", "%d %%"), 100);
|
||||
compute_dimensions (cell, widget, text,
|
||||
&priv->min_w,
|
||||
&priv->min_h);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
if (x_offset) *x_offset = 0;
|
||||
if (y_offset) *y_offset = 0;
|
||||
compute_dimensions (cell, widget, priv->label, &w, &h);
|
||||
|
||||
size = MIN (priv->min_h, h);
|
||||
|
||||
if (minimum != NULL)
|
||||
*minimum = size;
|
||||
if (natural != NULL)
|
||||
*natural = size;
|
||||
}
|
||||
|
||||
static inline int
|
||||
@ -731,3 +594,145 @@ gtk_cell_renderer_progress_snapshot (GtkCellRenderer *cell,
|
||||
g_object_unref (layout);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_cell_renderer_progress_finalize;
|
||||
object_class->get_property = gtk_cell_renderer_progress_get_property;
|
||||
object_class->set_property = gtk_cell_renderer_progress_set_property;
|
||||
|
||||
cell_class->get_preferred_width = gtk_cell_renderer_progress_get_preferred_width;
|
||||
cell_class->get_preferred_height = gtk_cell_renderer_progress_get_preferred_height;
|
||||
cell_class->snapshot = gtk_cell_renderer_progress_snapshot;
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:value:
|
||||
*
|
||||
* The "value" property determines the percentage to which the
|
||||
* progress bar will be "filled in".
|
||||
**/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_VALUE,
|
||||
g_param_spec_int ("value",
|
||||
P_("Value"),
|
||||
P_("Value of the progress bar"),
|
||||
0, 100, 0,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:text:
|
||||
*
|
||||
* The "text" property determines the label which will be drawn
|
||||
* over the progress bar. Setting this property to %NULL causes the default
|
||||
* label to be displayed. Setting this property to an empty string causes
|
||||
* no label to be displayed.
|
||||
**/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TEXT,
|
||||
g_param_spec_string ("text",
|
||||
P_("Text"),
|
||||
P_("Text on the progress bar"),
|
||||
NULL,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:pulse:
|
||||
*
|
||||
* Setting this to a non-negative value causes the cell renderer to
|
||||
* enter "activity mode", where a block bounces back and forth to
|
||||
* indicate that some progress is made, without specifying exactly how
|
||||
* much.
|
||||
*
|
||||
* Each increment of the property causes the block to move by a little
|
||||
* bit.
|
||||
*
|
||||
* To indicate that the activity has not started yet, set the property
|
||||
* to zero. To indicate completion, set the property to %G_MAXINT.
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PULSE,
|
||||
g_param_spec_int ("pulse",
|
||||
P_("Pulse"),
|
||||
P_("Set this to positive values to indicate that some progress is made, but you don’t know how much."),
|
||||
-1, G_MAXINT, -1,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:text-xalign:
|
||||
*
|
||||
* The "text-xalign" property controls the horizontal alignment of the
|
||||
* text in the progress bar. Valid values range from 0 (left) to 1
|
||||
* (right). Reserved for RTL layouts.
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TEXT_XALIGN,
|
||||
g_param_spec_float ("text-xalign",
|
||||
P_("Text x alignment"),
|
||||
P_("The horizontal text alignment, from 0 (left) to 1 (right). Reversed for RTL layouts."),
|
||||
0.0, 1.0, 0.5,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:text-yalign:
|
||||
*
|
||||
* The "text-yalign" property controls the vertical alignment of the
|
||||
* text in the progress bar. Valid values range from 0 (top) to 1
|
||||
* (bottom).
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TEXT_YALIGN,
|
||||
g_param_spec_float ("text-yalign",
|
||||
P_("Text y alignment"),
|
||||
P_("The vertical text alignment, from 0 (top) to 1 (bottom)."),
|
||||
0.0, 1.0, 0.5,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_override_property (object_class,
|
||||
PROP_ORIENTATION,
|
||||
"orientation");
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_INVERTED,
|
||||
g_param_spec_boolean ("inverted",
|
||||
P_("Inverted"),
|
||||
P_("Invert the direction in which the progress bar grows"),
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_init (GtkCellRendererProgress *cellprogress)
|
||||
{
|
||||
GtkCellRendererProgressPrivate *priv = gtk_cell_renderer_progress_get_instance_private (cellprogress);
|
||||
|
||||
priv->value = 0;
|
||||
priv->text = NULL;
|
||||
priv->label = NULL;
|
||||
priv->min_w = -1;
|
||||
priv->min_h = -1;
|
||||
priv->pulse = -1;
|
||||
priv->offset = 0;
|
||||
|
||||
priv->text_xalign = 0.5;
|
||||
priv->text_yalign = 0.5;
|
||||
|
||||
priv->orientation = GTK_ORIENTATION_HORIZONTAL,
|
||||
priv->inverted = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_cell_renderer_progress_new:
|
||||
*
|
||||
* Creates a new #GtkCellRendererProgress.
|
||||
*
|
||||
* Returns: the new cell renderer
|
||||
**/
|
||||
GtkCellRenderer*
|
||||
gtk_cell_renderer_progress_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_CELL_RENDERER_PROGRESS, NULL);
|
||||
}
|
||||
|
@ -100,13 +100,13 @@ static void gtk_cell_renderer_spinner_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_spinner_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height);
|
||||
static void gtk_cell_renderer_spinner_get_size (GtkCellRendererSpinner *self,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height);
|
||||
static void gtk_cell_renderer_spinner_snapshot (GtkCellRenderer *cell,
|
||||
GtkSnapshot *snapshot,
|
||||
GtkWidget *widget,
|
||||
@ -116,6 +116,48 @@ static void gtk_cell_renderer_spinner_snapshot (GtkCellRenderer *cell,
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererSpinner, gtk_cell_renderer_spinner, GTK_TYPE_CELL_RENDERER)
|
||||
|
||||
static GtkSizeRequestMode
|
||||
gtk_cell_renderer_spinner_get_request_mode (GtkCellRenderer *cell)
|
||||
{
|
||||
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_spinner_get_preferred_width (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
gtk_cell_renderer_spinner_get_size (GTK_CELL_RENDERER_SPINNER (cell), widget,
|
||||
NULL,
|
||||
NULL, NULL, &size, NULL);
|
||||
|
||||
if (minimum != NULL)
|
||||
*minimum = size;
|
||||
if (natural != NULL)
|
||||
*natural = size;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_spinner_get_preferred_height (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
gtk_cell_renderer_spinner_get_size (GTK_CELL_RENDERER_SPINNER (cell), widget,
|
||||
NULL,
|
||||
NULL, NULL, NULL, &size);
|
||||
|
||||
if (minimum != NULL)
|
||||
*minimum = size;
|
||||
if (natural != NULL)
|
||||
*natural = size;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_spinner_class_init (GtkCellRendererSpinnerClass *klass)
|
||||
{
|
||||
@ -125,7 +167,9 @@ gtk_cell_renderer_spinner_class_init (GtkCellRendererSpinnerClass *klass)
|
||||
object_class->get_property = gtk_cell_renderer_spinner_get_property;
|
||||
object_class->set_property = gtk_cell_renderer_spinner_set_property;
|
||||
|
||||
cell_class->get_size = gtk_cell_renderer_spinner_get_size;
|
||||
cell_class->get_request_mode = gtk_cell_renderer_spinner_get_request_mode;
|
||||
cell_class->get_preferred_width = gtk_cell_renderer_spinner_get_preferred_width;
|
||||
cell_class->get_preferred_height = gtk_cell_renderer_spinner_get_preferred_height;
|
||||
cell_class->snapshot = gtk_cell_renderer_spinner_snapshot;
|
||||
|
||||
/* GtkCellRendererSpinner:active:
|
||||
@ -278,16 +322,15 @@ gtk_cell_renderer_spinner_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_spinner_get_size (GtkCellRenderer *cellr,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height)
|
||||
gtk_cell_renderer_spinner_get_size (GtkCellRendererSpinner *self,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
GtkCellRendererSpinner *cell = GTK_CELL_RENDERER_SPINNER (cellr);
|
||||
GtkCellRendererSpinnerPrivate *priv = gtk_cell_renderer_spinner_get_instance_private (cell);
|
||||
GtkCellRendererSpinnerPrivate *priv = gtk_cell_renderer_spinner_get_instance_private (self);
|
||||
double align;
|
||||
int w, h;
|
||||
int xpad, ypad;
|
||||
@ -296,14 +339,15 @@ gtk_cell_renderer_spinner_get_size (GtkCellRenderer *cellr,
|
||||
|
||||
rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
|
||||
|
||||
gtk_cell_renderer_spinner_update_size (cell, widget);
|
||||
gtk_cell_renderer_spinner_update_size (self, widget);
|
||||
|
||||
g_object_get (cellr,
|
||||
g_object_get (self,
|
||||
"xpad", &xpad,
|
||||
"ypad", &ypad,
|
||||
"xalign", &xalign,
|
||||
"yalign", &yalign,
|
||||
NULL);
|
||||
|
||||
w = h = priv->size;
|
||||
|
||||
if (cell_area)
|
||||
@ -400,15 +444,15 @@ gtk_paint_spinner (GtkStyleContext *context,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_spinner_snapshot (GtkCellRenderer *cellr,
|
||||
gtk_cell_renderer_spinner_snapshot (GtkCellRenderer *cell,
|
||||
GtkSnapshot *snapshot,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *background_area,
|
||||
const GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
GtkCellRendererSpinner *cell = GTK_CELL_RENDERER_SPINNER (cellr);
|
||||
GtkCellRendererSpinnerPrivate *priv = gtk_cell_renderer_spinner_get_instance_private (cell);
|
||||
GtkCellRendererSpinner *self = GTK_CELL_RENDERER_SPINNER (cell);
|
||||
GtkCellRendererSpinnerPrivate *priv = gtk_cell_renderer_spinner_get_instance_private (self);
|
||||
GdkRectangle pix_rect;
|
||||
GdkRectangle draw_rect;
|
||||
int xpad, ypad;
|
||||
@ -417,14 +461,17 @@ gtk_cell_renderer_spinner_snapshot (GtkCellRenderer *cellr,
|
||||
if (!priv->active)
|
||||
return;
|
||||
|
||||
gtk_cell_renderer_spinner_get_size (cellr, widget, (GdkRectangle *) cell_area,
|
||||
&pix_rect.x, &pix_rect.y,
|
||||
&pix_rect.width, &pix_rect.height);
|
||||
gtk_cell_renderer_spinner_get_size (self, widget, cell_area,
|
||||
&pix_rect.x,
|
||||
&pix_rect.y,
|
||||
&pix_rect.width,
|
||||
&pix_rect.height);
|
||||
|
||||
g_object_get (cellr,
|
||||
g_object_get (self,
|
||||
"xpad", &xpad,
|
||||
"ypad", &ypad,
|
||||
NULL);
|
||||
|
||||
pix_rect.x += cell_area->x + xpad;
|
||||
pix_rect.y += cell_area->y + ypad;
|
||||
pix_rect.width -= xpad * 2;
|
||||
|
@ -51,7 +51,7 @@ static void gtk_cell_renderer_toggle_set_property (GObject *
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
||||
static void gtk_cell_renderer_toggle_get_size (GtkCellRendererToggle *self,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
@ -146,6 +146,48 @@ gtk_cell_renderer_toggle_dispose (GObject *object)
|
||||
G_OBJECT_CLASS (gtk_cell_renderer_toggle_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static GtkSizeRequestMode
|
||||
gtk_cell_renderer_toggle_get_request_mode (GtkCellRenderer *cell)
|
||||
{
|
||||
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_toggle_get_preferred_width (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
int width = 0;
|
||||
|
||||
gtk_cell_renderer_toggle_get_size (GTK_CELL_RENDERER_TOGGLE (cell), widget,
|
||||
NULL,
|
||||
NULL, NULL, &width, NULL);
|
||||
|
||||
if (minimum)
|
||||
*minimum = width;
|
||||
if (natural)
|
||||
*natural = width;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_toggle_get_preferred_height (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
int height = 0;
|
||||
|
||||
gtk_cell_renderer_toggle_get_size (GTK_CELL_RENDERER_TOGGLE (cell), widget,
|
||||
NULL,
|
||||
NULL, NULL, NULL, &height);
|
||||
|
||||
if (minimum)
|
||||
*minimum = height;
|
||||
if (natural)
|
||||
*natural = height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class)
|
||||
{
|
||||
@ -156,7 +198,9 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class)
|
||||
object_class->set_property = gtk_cell_renderer_toggle_set_property;
|
||||
object_class->dispose = gtk_cell_renderer_toggle_dispose;
|
||||
|
||||
cell_class->get_size = gtk_cell_renderer_toggle_get_size;
|
||||
cell_class->get_request_mode = gtk_cell_renderer_toggle_get_request_mode;
|
||||
cell_class->get_preferred_width = gtk_cell_renderer_toggle_get_preferred_width;
|
||||
cell_class->get_preferred_height = gtk_cell_renderer_toggle_get_preferred_height;
|
||||
cell_class->snapshot = gtk_cell_renderer_toggle_snapshot;
|
||||
cell_class->activate = gtk_cell_renderer_toggle_activate;
|
||||
|
||||
@ -345,14 +389,15 @@ calc_indicator_size (GtkStyleContext *context)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height)
|
||||
gtk_cell_renderer_toggle_get_size (GtkCellRendererToggle *self,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
GtkCellRenderer *cell = GTK_CELL_RENDERER (self);
|
||||
int calc_width;
|
||||
int calc_height;
|
||||
int xpad, ypad;
|
||||
@ -361,7 +406,7 @@ gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
||||
|
||||
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
|
||||
|
||||
context = gtk_cell_renderer_toggle_save_context (GTK_CELL_RENDERER_TOGGLE (cell), widget);
|
||||
context = gtk_cell_renderer_toggle_save_context (self, widget);
|
||||
gtk_style_context_get_padding (context, &padding);
|
||||
gtk_style_context_get_border (context, &border);
|
||||
|
||||
@ -369,7 +414,7 @@ gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
||||
calc_width += xpad * 2 + padding.left + padding.right + border.left + border.right;
|
||||
calc_height += ypad * 2 + padding.top + padding.bottom + border.top + border.bottom;
|
||||
|
||||
gtk_cell_renderer_toggle_restore_context (GTK_CELL_RENDERER_TOGGLE (cell), context);
|
||||
gtk_cell_renderer_toggle_restore_context (self, context);
|
||||
|
||||
if (width)
|
||||
*width = calc_width;
|
||||
@ -397,8 +442,10 @@ gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x_offset) *x_offset = 0;
|
||||
if (y_offset) *y_offset = 0;
|
||||
if (x_offset)
|
||||
*x_offset = 0;
|
||||
if (y_offset)
|
||||
*y_offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,7 +466,7 @@ gtk_cell_renderer_toggle_snapshot (GtkCellRenderer *cell,
|
||||
GtkStateFlags state;
|
||||
GtkBorder padding, border;
|
||||
|
||||
gtk_cell_renderer_toggle_get_size (cell, widget, cell_area,
|
||||
gtk_cell_renderer_toggle_get_size (celltoggle, widget, cell_area,
|
||||
&x_offset, &y_offset,
|
||||
&width, &height);
|
||||
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
|
||||
|
@ -115,44 +115,43 @@ gtk_cell_renderer_graph_set_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_graph_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const GdkRectangle *cell_area,
|
||||
int *x_offset,
|
||||
int *y_offset,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
int xpad, ypad;
|
||||
|
||||
#define MIN_HEIGHT 24
|
||||
#define MIN_WIDTH 3 * MIN_HEIGHT
|
||||
#define MIN_WIDTH (3 * MIN_HEIGHT)
|
||||
|
||||
g_object_get (cell,
|
||||
"xpad", &xpad,
|
||||
"ypad", &ypad,
|
||||
NULL);
|
||||
static void
|
||||
gtk_cell_renderer_graph_get_preferred_width (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
int xpad, size;
|
||||
|
||||
if (cell_area)
|
||||
{
|
||||
if (width)
|
||||
*width = cell_area->width - 2 * xpad;
|
||||
if (height)
|
||||
*height = cell_area->height - 2 * ypad;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width)
|
||||
*width = MIN_WIDTH + 2 * xpad;
|
||||
if (height)
|
||||
*height = MIN_HEIGHT + 2 * ypad;
|
||||
}
|
||||
g_object_get (cell, "xpad", &xpad, NULL);
|
||||
|
||||
if (x_offset)
|
||||
*x_offset = xpad;
|
||||
if (y_offset)
|
||||
*y_offset = ypad;
|
||||
size = MIN_WIDTH + 2 * xpad;
|
||||
|
||||
if (minimum != NULL)
|
||||
*minimum = size;
|
||||
if (natural != NULL)
|
||||
*natural = size;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_graph_get_preferred_height (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
int *minimum,
|
||||
int *natural)
|
||||
{
|
||||
int ypad, size;
|
||||
|
||||
g_object_get (cell, "ypad", &ypad, NULL);
|
||||
|
||||
size = MIN_HEIGHT + 2 * ypad;
|
||||
|
||||
if (minimum != NULL)
|
||||
*minimum = size;
|
||||
if (natural != NULL)
|
||||
*natural = size;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -250,7 +249,8 @@ gtk_cell_renderer_graph_class_init (GtkCellRendererGraphClass *klass)
|
||||
object_class->get_property = gtk_cell_renderer_graph_get_property;
|
||||
object_class->set_property = gtk_cell_renderer_graph_set_property;
|
||||
|
||||
cell_class->get_size = gtk_cell_renderer_graph_get_size;
|
||||
cell_class->get_preferred_width = gtk_cell_renderer_graph_get_preferred_width;
|
||||
cell_class->get_preferred_height = gtk_cell_renderer_graph_get_preferred_height;
|
||||
cell_class->snapshot = gtk_cell_renderer_graph_snapshot;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
@ -292,4 +292,3 @@ gtk_cell_renderer_graph_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_CELL_RENDERER_GRAPH, NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user