2013-12-11 14:42:10 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* Copyright © 2013 Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "gtk/gtk.h"
|
|
|
|
#include "gtkmagnifierprivate.h"
|
2017-08-23 13:00:59 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
2018-03-11 05:29:46 +00:00
|
|
|
#include "gtksnapshot.h"
|
2013-12-11 14:42:10 +00:00
|
|
|
#include "gtkintl.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_INSPECTED = 1,
|
2014-12-21 00:16:46 +00:00
|
|
|
PROP_RESIZE,
|
2013-12-11 14:42:10 +00:00
|
|
|
PROP_MAGNIFICATION
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _GtkMagnifierPrivate GtkMagnifierPrivate;
|
|
|
|
|
|
|
|
struct _GtkMagnifierPrivate
|
|
|
|
{
|
|
|
|
GtkWidget *inspected;
|
|
|
|
gdouble magnification;
|
|
|
|
gint x;
|
|
|
|
gint y;
|
2014-12-21 00:16:46 +00:00
|
|
|
gboolean resize;
|
|
|
|
gulong draw_handler;
|
|
|
|
gulong resize_handler;
|
2013-12-11 14:42:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkMagnifier, _gtk_magnifier,
|
|
|
|
GTK_TYPE_WIDGET)
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_magnifier_set_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
switch (param_id)
|
|
|
|
{
|
|
|
|
case PROP_INSPECTED:
|
|
|
|
_gtk_magnifier_set_inspected (GTK_MAGNIFIER (object),
|
|
|
|
g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case PROP_MAGNIFICATION:
|
|
|
|
_gtk_magnifier_set_magnification (GTK_MAGNIFIER (object),
|
|
|
|
g_value_get_double (value));
|
|
|
|
break;
|
2014-12-21 00:16:46 +00:00
|
|
|
case PROP_RESIZE:
|
|
|
|
_gtk_magnifier_set_resize (GTK_MAGNIFIER (object),
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
2013-12-11 14:42:10 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_magnifier_get_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkMagnifier *magnifier;
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
magnifier = GTK_MAGNIFIER (object);
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
|
|
|
case PROP_INSPECTED:
|
|
|
|
g_value_set_object (value, priv->inspected);
|
|
|
|
break;
|
|
|
|
case PROP_MAGNIFICATION:
|
|
|
|
g_value_set_double (value, priv->magnification);
|
|
|
|
break;
|
2014-12-21 00:16:46 +00:00
|
|
|
case PROP_RESIZE:
|
|
|
|
g_value_set_boolean (value, priv->resize);
|
|
|
|
break;
|
2013-12-11 14:42:10 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-23 13:00:59 +00:00
|
|
|
static void
|
|
|
|
gtk_magnifier_snapshot (GtkWidget *widget,
|
|
|
|
GtkSnapshot *snapshot)
|
2013-12-11 14:42:10 +00:00
|
|
|
{
|
2017-08-23 13:00:59 +00:00
|
|
|
GtkMagnifier *magnifier = GTK_MAGNIFIER (widget);
|
|
|
|
GtkMagnifierPrivate *priv = _gtk_magnifier_get_instance_private (magnifier);
|
2018-03-11 02:14:09 +00:00
|
|
|
GtkSnapshot *inspected_snapshot;
|
2017-08-23 13:00:59 +00:00
|
|
|
GskRenderNode *inspected_node;
|
|
|
|
graphene_matrix_t transform;
|
2013-12-11 14:42:10 +00:00
|
|
|
|
2014-12-21 00:16:46 +00:00
|
|
|
if (priv->inspected == NULL)
|
2017-08-23 13:00:59 +00:00
|
|
|
return;
|
2014-12-21 00:16:46 +00:00
|
|
|
|
2013-12-11 14:42:10 +00:00
|
|
|
if (!gtk_widget_is_visible (priv->inspected))
|
2017-08-23 13:00:59 +00:00
|
|
|
return;
|
2013-12-11 14:42:10 +00:00
|
|
|
|
2017-08-23 13:00:59 +00:00
|
|
|
g_signal_handler_block (priv->inspected, priv->draw_handler);
|
2014-12-21 00:16:46 +00:00
|
|
|
|
2018-03-24 20:41:53 +00:00
|
|
|
inspected_snapshot = gtk_snapshot_new (gtk_snapshot_get_record_names (snapshot),
|
2018-03-11 02:14:09 +00:00
|
|
|
NULL,
|
|
|
|
"MagnifierSnapshot");
|
2013-12-11 14:42:10 +00:00
|
|
|
|
2018-03-11 02:14:09 +00:00
|
|
|
gtk_widget_snapshot (priv->inspected, inspected_snapshot);
|
|
|
|
inspected_node = gtk_snapshot_free_to_node (inspected_snapshot);
|
2013-12-11 14:42:10 +00:00
|
|
|
|
2018-01-10 13:41:29 +00:00
|
|
|
if (inspected_node != NULL)
|
|
|
|
{
|
2018-03-16 20:30:31 +00:00
|
|
|
gtk_snapshot_push_clip (snapshot,
|
|
|
|
&GRAPHENE_RECT_INIT (0, 0,
|
|
|
|
gtk_widget_get_width (widget),
|
|
|
|
gtk_widget_get_height (widget)),
|
|
|
|
"MagnifierClip");
|
|
|
|
|
2018-01-10 13:41:29 +00:00
|
|
|
graphene_matrix_init_identity (&transform);
|
|
|
|
graphene_matrix_scale (&transform, priv->magnification, priv->magnification, 1);
|
2017-08-23 13:00:59 +00:00
|
|
|
|
2018-01-10 13:41:29 +00:00
|
|
|
gtk_snapshot_push_transform (snapshot, &transform, "Magnifier transform");
|
|
|
|
gtk_snapshot_append_node (snapshot, inspected_node);
|
|
|
|
gtk_snapshot_pop (snapshot);
|
2018-03-16 20:30:31 +00:00
|
|
|
|
|
|
|
gtk_snapshot_pop (snapshot);
|
2018-01-10 13:41:29 +00:00
|
|
|
}
|
2013-12-11 14:42:10 +00:00
|
|
|
|
2017-08-23 13:00:59 +00:00
|
|
|
|
|
|
|
g_signal_handler_unblock (priv->inspected, priv->draw_handler);
|
2013-12-11 14:42:10 +00:00
|
|
|
}
|
|
|
|
|
2014-12-21 00:16:46 +00:00
|
|
|
static void
|
2016-10-22 14:06:14 +00:00
|
|
|
gtk_magnifier_measure (GtkWidget *widget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
int for_size,
|
|
|
|
int *minimum,
|
|
|
|
int *natural,
|
|
|
|
int *minimum_baseline,
|
|
|
|
int *natural_baseline)
|
2014-12-21 00:16:46 +00:00
|
|
|
{
|
2016-10-22 14:06:14 +00:00
|
|
|
GtkMagnifier *magnifier = GTK_MAGNIFIER (widget);
|
|
|
|
GtkMagnifierPrivate *priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
gint size;
|
2014-12-21 00:16:46 +00:00
|
|
|
|
|
|
|
if (priv->resize && priv->inspected)
|
2016-10-22 14:06:14 +00:00
|
|
|
{
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
size = priv->magnification * gtk_widget_get_allocated_width (priv->inspected);
|
|
|
|
else
|
|
|
|
size = priv->magnification * gtk_widget_get_allocated_height (priv->inspected);
|
|
|
|
}
|
2014-12-21 00:16:46 +00:00
|
|
|
else
|
2016-10-22 14:06:14 +00:00
|
|
|
size = 0;
|
2014-12-21 00:16:46 +00:00
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
*minimum = size;
|
|
|
|
*natural = size;
|
2014-12-21 00:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
resize_handler (GtkWidget *widget,
|
|
|
|
GtkAllocation *alloc,
|
2017-07-11 07:58:21 +00:00
|
|
|
int baseline,
|
|
|
|
GtkAllocation *out_clip,
|
2014-12-21 00:16:46 +00:00
|
|
|
GtkWidget *magnifier)
|
|
|
|
{
|
|
|
|
gtk_widget_queue_resize (magnifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
connect_resize_handler (GtkMagnifier *magnifier)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
if (priv->inspected && priv->resize)
|
|
|
|
priv->resize_handler = g_signal_connect (priv->inspected, "size-allocate",
|
|
|
|
G_CALLBACK (resize_handler), magnifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
disconnect_resize_handler (GtkMagnifier *magnifier)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
if (priv->resize_handler)
|
|
|
|
{
|
2016-02-09 14:30:00 +00:00
|
|
|
if (priv->inspected)
|
|
|
|
g_signal_handler_disconnect (priv->inspected, priv->resize_handler);
|
2014-12-21 00:16:46 +00:00
|
|
|
priv->resize_handler = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
draw_handler (GtkWidget *widget,
|
|
|
|
cairo_t *cr,
|
|
|
|
GtkWidget *magnifier)
|
|
|
|
{
|
|
|
|
gtk_widget_queue_draw (magnifier);
|
2017-08-23 13:00:59 +00:00
|
|
|
|
2014-12-21 00:16:46 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
connect_draw_handler (GtkMagnifier *magnifier)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
2016-04-19 19:27:08 +00:00
|
|
|
if (!priv->draw_handler)
|
|
|
|
{
|
|
|
|
if (priv->inspected)
|
|
|
|
priv->draw_handler = g_signal_connect (priv->inspected, "draw",
|
|
|
|
G_CALLBACK (draw_handler), magnifier);
|
|
|
|
}
|
2014-12-21 00:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
disconnect_draw_handler (GtkMagnifier *magnifier)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
if (priv->draw_handler)
|
|
|
|
{
|
2016-02-09 14:30:00 +00:00
|
|
|
if (priv->inspected)
|
|
|
|
g_signal_handler_disconnect (priv->inspected, priv->draw_handler);
|
2014-12-21 00:16:46 +00:00
|
|
|
priv->draw_handler = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_magnifier_destroy (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
_gtk_magnifier_set_inspected (GTK_MAGNIFIER (widget), NULL);
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (_gtk_magnifier_parent_class)->destroy (widget);
|
|
|
|
}
|
|
|
|
|
2016-04-19 19:27:08 +00:00
|
|
|
static void
|
|
|
|
gtk_magnifier_map (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
connect_draw_handler (GTK_MAGNIFIER (widget));
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (_gtk_magnifier_parent_class)->map (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_magnifier_unmap (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GTK_WIDGET_CLASS (_gtk_magnifier_parent_class)->unmap (widget);
|
|
|
|
|
|
|
|
disconnect_draw_handler (GTK_MAGNIFIER (widget));
|
|
|
|
}
|
|
|
|
|
2013-12-11 14:42:10 +00:00
|
|
|
static void
|
|
|
|
_gtk_magnifier_class_init (GtkMagnifierClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->set_property = _gtk_magnifier_set_property;
|
|
|
|
object_class->get_property = _gtk_magnifier_get_property;
|
|
|
|
|
2014-12-21 00:16:46 +00:00
|
|
|
widget_class->destroy = _gtk_magnifier_destroy;
|
2017-08-23 13:00:59 +00:00
|
|
|
widget_class->snapshot = gtk_magnifier_snapshot;
|
2016-10-22 14:06:14 +00:00
|
|
|
widget_class->measure = gtk_magnifier_measure;
|
2016-04-19 19:27:08 +00:00
|
|
|
widget_class->map = gtk_magnifier_map;
|
|
|
|
widget_class->unmap = gtk_magnifier_unmap;
|
2013-12-11 14:42:10 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_INSPECTED,
|
2014-02-07 07:17:11 +00:00
|
|
|
g_param_spec_object ("inspected",
|
2013-12-11 14:42:10 +00:00
|
|
|
P_("Inspected"),
|
|
|
|
P_("Inspected widget"),
|
|
|
|
GTK_TYPE_WIDGET,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_MAGNIFICATION,
|
2014-02-07 07:17:11 +00:00
|
|
|
g_param_spec_double ("magnification",
|
2013-12-11 14:42:10 +00:00
|
|
|
P_("magnification"),
|
|
|
|
P_("magnification"),
|
|
|
|
1, G_MAXDOUBLE, 1,
|
|
|
|
G_PARAM_READWRITE));
|
2014-12-21 00:16:46 +00:00
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_RESIZE,
|
|
|
|
g_param_spec_boolean ("resize",
|
|
|
|
P_("resize"),
|
|
|
|
P_("resize"),
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE));
|
2013-12-11 14:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_magnifier_init (GtkMagnifier *magnifier)
|
|
|
|
{
|
|
|
|
GtkWidget *widget = GTK_WIDGET (magnifier);
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
2018-03-20 14:21:12 +00:00
|
|
|
gtk_widget_set_has_surface (widget, FALSE);
|
2013-12-11 14:42:10 +00:00
|
|
|
priv->magnification = 1;
|
2014-12-21 00:16:46 +00:00
|
|
|
priv->resize = FALSE;
|
2013-12-11 14:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
_gtk_magnifier_new (GtkWidget *inspected)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (inspected), NULL);
|
|
|
|
|
|
|
|
return g_object_new (GTK_TYPE_MAGNIFIER,
|
|
|
|
"inspected", inspected,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
_gtk_magnifier_get_inspected (GtkMagnifier *magnifier)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_MAGNIFIER (magnifier), NULL);
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
return priv->inspected;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_magnifier_set_inspected (GtkMagnifier *magnifier,
|
|
|
|
GtkWidget *inspected)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
2014-01-22 19:48:51 +00:00
|
|
|
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
|
2013-12-11 14:42:10 +00:00
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
if (priv->inspected == inspected)
|
|
|
|
return;
|
|
|
|
|
2014-12-21 00:16:46 +00:00
|
|
|
disconnect_draw_handler (magnifier);
|
|
|
|
disconnect_resize_handler (magnifier);
|
|
|
|
|
2016-02-09 14:30:00 +00:00
|
|
|
if (priv->inspected)
|
|
|
|
g_object_remove_weak_pointer (G_OBJECT (priv->inspected),
|
|
|
|
(gpointer *) &priv->inspected);
|
2013-12-11 14:42:10 +00:00
|
|
|
priv->inspected = inspected;
|
2016-02-09 14:30:00 +00:00
|
|
|
if (priv->inspected)
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (priv->inspected),
|
|
|
|
(gpointer *) &priv->inspected);
|
2014-12-21 00:16:46 +00:00
|
|
|
|
2016-04-19 19:27:08 +00:00
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (magnifier)))
|
|
|
|
connect_draw_handler (magnifier);
|
2014-12-21 00:16:46 +00:00
|
|
|
connect_resize_handler (magnifier);
|
|
|
|
|
2013-12-11 14:42:10 +00:00
|
|
|
g_object_notify (G_OBJECT (magnifier), "inspected");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_magnifier_set_coords (GtkMagnifier *magnifier,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
if (priv->x == x && priv->y == y)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv->x = x;
|
|
|
|
priv->y = y;
|
|
|
|
|
|
|
|
if (gtk_widget_is_visible (GTK_WIDGET (magnifier)))
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (magnifier));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_magnifier_get_coords (GtkMagnifier *magnifier,
|
|
|
|
gdouble *x,
|
|
|
|
gdouble *y)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
if (x)
|
|
|
|
*x = priv->x;
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
*y = priv->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_magnifier_set_magnification (GtkMagnifier *magnifier,
|
|
|
|
gdouble magnification)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
if (priv->magnification == magnification)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv->magnification = magnification;
|
|
|
|
g_object_notify (G_OBJECT (magnifier), "magnification");
|
|
|
|
|
2014-12-21 00:16:46 +00:00
|
|
|
if (priv->resize)
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (magnifier));
|
|
|
|
|
2013-12-11 14:42:10 +00:00
|
|
|
if (gtk_widget_is_visible (GTK_WIDGET (magnifier)))
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (magnifier));
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
|
|
|
_gtk_magnifier_get_magnification (GtkMagnifier *magnifier)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_MAGNIFIER (magnifier), 1);
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
return priv->magnification;
|
|
|
|
}
|
2014-12-21 00:16:46 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_magnifier_set_resize (GtkMagnifier *magnifier,
|
|
|
|
gboolean resize)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
if (priv->resize == resize)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv->resize = resize;
|
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (magnifier));
|
|
|
|
if (resize)
|
|
|
|
connect_resize_handler (magnifier);
|
|
|
|
else
|
|
|
|
disconnect_resize_handler (magnifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_gtk_magnifier_get_resize (GtkMagnifier *magnifier)
|
|
|
|
{
|
|
|
|
GtkMagnifierPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_MAGNIFIER (magnifier), FALSE);
|
|
|
|
|
|
|
|
priv = _gtk_magnifier_get_instance_private (magnifier);
|
|
|
|
|
|
|
|
return priv->resize;
|
|
|
|
}
|