Commit 539ff359 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

connect-after to "realize" and "size-allocate" signals of the preview area

2006-02-06  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimppreview.c: connect-after to "realize" and
	"size-allocate" signals of the preview area and call the
	set-cursor method from the callback.

	* libgimpwidgets/gimpscrolledpreview.c: no need to explicitely set
	the cursor now that the virtual method is used correctly.

	* libgimp/gimpzoompreview.c: implement set-cursor and set the move
	cursor in accordance with the zoom factor.
parent a81454bb
2006-02-06 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimppreview.c: connect-after to "realize" and
"size-allocate" signals of the preview area and call the
set-cursor method from the callback.
* libgimpwidgets/gimpscrolledpreview.c: no need to explicitely set
the cursor now that the virtual method is used correctly.
* libgimp/gimpzoompreview.c: implement set-cursor and set the move
cursor in accordance with the zoom factor.
2006-02-06 DindinX <dindinx@gimp.org>
* plug-ins/common/mblur.c: length should at least be 1, or the zoom
......
......@@ -68,12 +68,14 @@ static void gimp_zoom_preview_draw_thumb (GimpPreview *preview,
GimpPreviewArea *area,
gint width,
gint height);
static void gimp_zoom_preview_set_cursor (GimpPreview *preview);
static gboolean gimp_zoom_preview_get_bounds (GimpDrawable *drawable,
gint *xmin,
gint *ymin,
gint *xmax,
gint *ymax);
G_DEFINE_TYPE (GimpZoomPreview, gimp_zoom_preview, GIMP_TYPE_SCROLLED_PREVIEW)
#define parent_class gimp_zoom_preview_parent_class
......@@ -89,6 +91,7 @@ gimp_zoom_preview_class_init (GimpZoomPreviewClass *klass)
preview_class->draw = gimp_zoom_preview_draw;
preview_class->draw_buffer = gimp_zoom_preview_draw_buffer;
preview_class->draw_thumb = gimp_zoom_preview_draw_thumb;
preview_class->set_cursor = gimp_zoom_preview_set_cursor;
g_type_class_add_private (object_class, sizeof (GimpZoomPreviewPrivate));
}
......@@ -478,6 +481,24 @@ gimp_zoom_preview_draw_thumb (GimpPreview *preview,
}
}
static void
gimp_zoom_preview_set_cursor (GimpPreview *preview)
{
if (! GTK_WIDGET_REALIZED (preview->area))
return;
if (gimp_zoom_preview_get_factor (GIMP_ZOOM_PREVIEW (preview)) > 1.0)
{
gdk_window_set_cursor (preview->area->window,
GIMP_SCROLLED_PREVIEW (preview)->cursor_move);
}
else
{
gdk_window_set_cursor (preview->area->window, preview->default_cursor);
}
}
#define MAX3(a, b, c) (MAX (MAX ((a), (b)), (c)))
#define MIN3(a, b, c) (MIN (MIN ((a), (b)), (c)))
......
......@@ -79,6 +79,7 @@ static void gimp_preview_area_unrealize (GtkWidget *widget,
static void gimp_preview_area_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
GimpPreview *preview);
static void gimp_preview_area_set_cursor (GimpPreview *preview);
static gboolean gimp_preview_area_event (GtkWidget *area,
GdkEvent *event,
GimpPreview *preview);
......@@ -89,7 +90,7 @@ static void gimp_preview_toggle_callback (GtkWidget *toggle,
static void gimp_preview_notify_checks (GimpPreview *preview);
static gboolean gimp_preview_invalidate_now (GimpPreview *preview);
static void gimp_preview_set_cursor (GimpPreview *preview);
static void gimp_preview_real_set_cursor (GimpPreview *preview);
static guint preview_signals[LAST_SIGNAL] = { 0 };
......@@ -153,7 +154,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
klass->draw = NULL;
klass->draw_thumb = NULL;
klass->draw_buffer = NULL;
klass->set_cursor = gimp_preview_set_cursor;
klass->set_cursor = gimp_preview_real_set_cursor;
g_type_class_add_private (object_class, sizeof (GimpPreviewPrivate));
......@@ -243,10 +244,18 @@ gimp_preview_init (GimpPreview *preview)
G_CALLBACK (gimp_preview_area_unrealize),
preview);
g_signal_connect_data (preview->area, "realize",
G_CALLBACK (gimp_preview_area_set_cursor),
preview, NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect (preview->area, "size-allocate",
G_CALLBACK (gimp_preview_area_size_allocate),
preview);
g_signal_connect_data (preview->area, "size-allocate",
G_CALLBACK (gimp_preview_area_set_cursor),
preview, NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
priv->controls = gtk_hbox_new (FALSE, 6);
gtk_table_attach (GTK_TABLE (preview->table), priv->controls, 0, 2, 2, 3,
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
......@@ -381,6 +390,11 @@ gimp_preview_area_size_allocate (GtkWidget *widget,
gimp_preview_invalidate (preview);
}
static void
gimp_preview_area_set_cursor (GimpPreview *preview)
{
GIMP_PREVIEW_GET_CLASS (preview)->set_cursor (preview);
}
static gboolean
gimp_preview_area_event (GtkWidget *area,
......@@ -471,10 +485,11 @@ gimp_preview_invalidate_now (GimpPreview *preview)
}
static void
gimp_preview_set_cursor (GimpPreview *preview)
gimp_preview_real_set_cursor (GimpPreview *preview)
{
gdk_window_set_cursor (preview->area->window,
preview->default_cursor);
if (GTK_WIDGET_REALIZED (preview->area))
gdk_window_set_cursor (preview->area->window,
preview->default_cursor);
}
/**
......
......@@ -241,8 +241,6 @@ gimp_scrolled_preview_area_realize (GtkWidget *widget,
g_return_if_fail (preview->cursor_move == NULL);
preview->cursor_move = gdk_cursor_new_for_display (display, GDK_FLEUR);
gimp_scrolled_preview_set_cursor (GIMP_PREVIEW (preview));
}
static void
......@@ -300,18 +298,15 @@ gimp_scrolled_preview_area_size_allocate (GtkWidget *widget,
GimpScrolledPreview *preview)
{
GimpScrolledPreviewPrivate *priv = GIMP_SCROLLED_PREVIEW_GET_PRIVATE (preview);
GdkCursor *cursor = GIMP_PREVIEW (preview)->default_cursor;
gint width = GIMP_PREVIEW (preview)->xmax - GIMP_PREVIEW (preview)->xmin;
gint height = GIMP_PREVIEW (preview)->ymax - GIMP_PREVIEW (preview)->ymin;
gint width = GIMP_PREVIEW (preview)->xmax - GIMP_PREVIEW (preview)->xmin;
gint height = GIMP_PREVIEW (preview)->ymax - GIMP_PREVIEW (preview)->ymin;
GIMP_PREVIEW (preview)->width = MIN (width, allocation->width);
GIMP_PREVIEW (preview)->height = MIN (height, allocation->height);
gimp_scrolled_preview_hscr_update (preview);
if (width > GIMP_PREVIEW (preview)->width)
cursor = preview->cursor_move;
switch (priv->hscr_policy)
{
case GTK_POLICY_AUTOMATIC:
......@@ -332,9 +327,6 @@ gimp_scrolled_preview_area_size_allocate (GtkWidget *widget,
gimp_scrolled_preview_vscr_update (preview);
if (height > GIMP_PREVIEW (preview)->height)
cursor = preview->cursor_move;
switch (priv->vscr_policy)
{
case GTK_POLICY_AUTOMATIC:
......@@ -364,9 +356,6 @@ gimp_scrolled_preview_area_size_allocate (GtkWidget *widget,
gtk_widget_hide (preview->nav_icon);
}
if (GTK_WIDGET_REALIZED (widget))
gdk_window_set_cursor (widget->window, cursor);
gimp_preview_draw (GIMP_PREVIEW (preview));
gimp_preview_invalidate (GIMP_PREVIEW (preview));
}
......@@ -757,6 +746,9 @@ gimp_scrolled_preview_nav_popup_expose (GtkWidget *widget,
static void
gimp_scrolled_preview_set_cursor (GimpPreview *preview)
{
if (! GTK_WIDGET_REALIZED (preview->area))
return;
if (preview->xmax - preview->xmin > preview->width ||
preview->ymax - preview->ymin > preview->height)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment