libgimpwidgets/gimpoffsetarea.c set a cursor to indicate that the area is
2007-07-20 Sven Neumann <sven@gimp.org> * libgimpwidgets/gimpoffsetarea.c * plug-ins/print/print-preview.c: set a cursor to indicate that the area is interactive. * plug-ins/print/print-page-layout.c: minor dialog tweaks. svn path=/trunk/; revision=22963
This commit is contained in:
committed by
Sven Neumann
parent
5db980554c
commit
18d3c4835d
@ -1,3 +1,11 @@
|
||||
2007-07-20 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpoffsetarea.c
|
||||
* plug-ins/print/print-preview.c: set a cursor to indicate that
|
||||
the area is interactive.
|
||||
|
||||
* plug-ins/print/print-page-layout.c: minor dialog tweaks.
|
||||
|
||||
2007-07-20 Sven Neumann <sven@gimp.org>
|
||||
|
||||
Applied patch from Stefan Röllin attached to bug #387604:
|
||||
|
||||
@ -41,6 +41,8 @@ enum
|
||||
|
||||
|
||||
static void gimp_offset_area_resize (GimpOffsetArea *area);
|
||||
|
||||
static void gimp_offset_area_realize (GtkWidget *widget);
|
||||
static void gimp_offset_area_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static gboolean gimp_offset_area_event (GtkWidget *widget,
|
||||
@ -72,9 +74,10 @@ gimp_offset_area_class_init (GimpOffsetAreaClass *klass)
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT);
|
||||
|
||||
widget_class->size_allocate = gimp_offset_area_size_allocate;
|
||||
widget_class->realize = gimp_offset_area_realize;
|
||||
widget_class->event = gimp_offset_area_event;
|
||||
widget_class->expose_event = gimp_offset_area_expose_event;
|
||||
widget_class->size_allocate = gimp_offset_area_size_allocate;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -89,8 +92,7 @@ gimp_offset_area_init (GimpOffsetArea *area)
|
||||
area->display_ratio_x = 1.0;
|
||||
area->display_ratio_y = 1.0;
|
||||
|
||||
gtk_widget_add_events (GTK_WIDGET (area),
|
||||
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
|
||||
gtk_widget_add_events (GTK_WIDGET (area), GDK_BUTTON_PRESS_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,6 +310,19 @@ gimp_offset_area_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_offset_area_realize (GtkWidget *widget)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
||||
|
||||
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
|
||||
GDK_FLEUR);
|
||||
gdk_window_set_cursor (widget->window, cursor);
|
||||
gdk_cursor_unref (cursor);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_offset_area_event (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
|
||||
@ -101,7 +101,7 @@ print_page_layout_gui (PrintData *data)
|
||||
gtk_box_set_spacing (GTK_BOX(main_hbox), 12);
|
||||
gtk_widget_show (main_hbox);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
vbox = gtk_vbox_new (FALSE, 6);
|
||||
gtk_box_pack_start (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
@ -163,7 +163,7 @@ print_page_layout_gui (PrintData *data)
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
button = gtk_check_button_new_with_label (_("Ignore Page Margins"));
|
||||
button = gtk_check_button_new_with_mnemonic (_("Ignore Page _Margins"));
|
||||
data->use_full_page = FALSE;
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
@ -325,11 +325,11 @@ print_size_frame (PrintData *data)
|
||||
gtk_size_group_add_widget (entry_group, height);
|
||||
|
||||
label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry),
|
||||
_("_X resolution:"), 0, 0, 0.0);
|
||||
_("X resolution:"), 0, 0, 0.0);
|
||||
gtk_size_group_add_widget (label_group, label);
|
||||
|
||||
label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry),
|
||||
_("_Y resolution:"), 1, 0, 0.0);
|
||||
_("Y resolution:"), 1, 0, 0.0);
|
||||
gtk_size_group_add_widget (label_group, label);
|
||||
|
||||
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (entry), 0,
|
||||
@ -419,11 +419,11 @@ print_offset_frame (PrintData *data)
|
||||
g_object_unref (entry_group);
|
||||
|
||||
label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry),
|
||||
_("X:"), 0, 0, 0.0);
|
||||
_("_X:"), 0, 0, 0.0);
|
||||
gtk_size_group_add_widget (label_group, label);
|
||||
|
||||
label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry),
|
||||
_("Y:"), 1, 0, 0.0);
|
||||
_("_Y:"), 1, 0, 0.0);
|
||||
gtk_size_group_add_widget (label_group, label);
|
||||
g_object_unref (label_group);
|
||||
|
||||
@ -439,7 +439,7 @@ print_offset_frame (PrintData *data)
|
||||
G_CALLBACK (print_size_info_offset_changed),
|
||||
NULL);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
hbox = gtk_hbox_new (FALSE, 6);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
@ -448,18 +448,18 @@ print_offset_frame (PrintData *data)
|
||||
gtk_widget_show (label);
|
||||
|
||||
hbuttonbox = gtk_hbutton_box_new ();
|
||||
gtk_box_pack_start (GTK_BOX (hbox), hbuttonbox, FALSE, FALSE, 6);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), hbuttonbox, FALSE, FALSE, 0);
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX(hbuttonbox), GTK_BUTTONBOX_START);
|
||||
gtk_widget_show (hbuttonbox);
|
||||
|
||||
button = gtk_button_new_with_mnemonic (_("Horizontally"));
|
||||
button = gtk_button_new_with_mnemonic (_("H_orizontally"));
|
||||
gtk_container_add (GTK_CONTAINER (hbuttonbox), button);
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (print_size_info_center_clicked),
|
||||
GINT_TO_POINTER (1));
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_mnemonic (_("Vertically"));
|
||||
button = gtk_button_new_with_mnemonic (_("_Vertically"));
|
||||
gtk_container_add (GTK_CONTAINER (hbuttonbox), button);
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (print_size_info_center_clicked),
|
||||
|
||||
@ -36,6 +36,10 @@ enum
|
||||
|
||||
static void gimp_print_preview_finalize (GObject *object);
|
||||
|
||||
static void gimp_print_preview_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation,
|
||||
GimpPrintPreview *preview);
|
||||
static void gimp_print_preview_realize (GtkWidget *widget);
|
||||
static gboolean gimp_print_preview_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GimpPrintPreview *preview);
|
||||
@ -46,10 +50,6 @@ static gboolean gimp_print_preview_expose_event (GtkWidget *widget,
|
||||
|
||||
static gdouble gimp_print_preview_get_scale (GimpPrintPreview *preview);
|
||||
|
||||
static void gimp_print_preview_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation,
|
||||
GimpPrintPreview *preview);
|
||||
|
||||
static void gimp_print_preview_get_page_margins (GimpPrintPreview *preview,
|
||||
gdouble *left_margin,
|
||||
gdouble *right_margin,
|
||||
@ -107,9 +107,7 @@ marshal_VOID__DOUBLE_DOUBLE (GClosure *closure,
|
||||
static void
|
||||
gimp_print_preview_class_init (GimpPrintPreviewClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
|
||||
gobject_class = (GObjectClass*) klass;
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gimp_print_preview_signals[OFFSETS_CHANGED] =
|
||||
g_signal_new ("offsets-changed",
|
||||
@ -122,9 +120,9 @@ gimp_print_preview_class_init (GimpPrintPreviewClass *klass)
|
||||
G_TYPE_DOUBLE,
|
||||
G_TYPE_DOUBLE);
|
||||
|
||||
gobject_class->finalize = gimp_print_preview_finalize;
|
||||
object_class->finalize = gimp_print_preview_finalize;
|
||||
|
||||
klass->offsets_changed = NULL;
|
||||
klass->offsets_changed = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -144,8 +142,20 @@ gimp_print_preview_init (GimpPrintPreview *preview)
|
||||
gtk_container_add (GTK_CONTAINER (preview), preview->area);
|
||||
gtk_widget_show (preview->area);
|
||||
|
||||
gtk_widget_set_events (GTK_WIDGET (preview->area),
|
||||
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
|
||||
gtk_widget_add_events (GTK_WIDGET (preview->area), GDK_BUTTON_PRESS_MASK);
|
||||
|
||||
g_signal_connect (preview->area, "size-allocate",
|
||||
G_CALLBACK (gimp_print_preview_size_allocate),
|
||||
preview);
|
||||
g_signal_connect (preview->area, "realize",
|
||||
G_CALLBACK (gimp_print_preview_realize),
|
||||
NULL);
|
||||
g_signal_connect (preview->area, "event",
|
||||
G_CALLBACK (gimp_print_preview_event),
|
||||
preview);
|
||||
g_signal_connect (preview->area, "expose-event",
|
||||
G_CALLBACK (gimp_print_preview_expose_event),
|
||||
preview);
|
||||
}
|
||||
|
||||
|
||||
@ -187,6 +197,8 @@ gimp_print_preview_new (GtkPageSetup *page,
|
||||
|
||||
preview = g_object_new (GIMP_TYPE_PRINT_PREVIEW, NULL);
|
||||
|
||||
preview->drawable_id = drawable_id;
|
||||
|
||||
if (page != NULL)
|
||||
preview->page = gtk_page_setup_copy (page);
|
||||
else
|
||||
@ -197,23 +209,9 @@ gimp_print_preview_new (GtkPageSetup *page,
|
||||
|
||||
gtk_aspect_frame_set (GTK_ASPECT_FRAME (preview), 0.5, 0.5, ratio, FALSE);
|
||||
|
||||
g_signal_connect (preview->area, "event",
|
||||
G_CALLBACK (gimp_print_preview_event),
|
||||
preview);
|
||||
|
||||
g_signal_connect (preview->area, "expose-event",
|
||||
G_CALLBACK (gimp_print_preview_expose_event),
|
||||
preview);
|
||||
|
||||
g_signal_connect (preview->area, "size-allocate",
|
||||
G_CALLBACK (gimp_print_preview_size_allocate),
|
||||
preview);
|
||||
|
||||
gtk_widget_set_size_request (preview->area,
|
||||
DRAWING_AREA_SIZE, DRAWING_AREA_SIZE);
|
||||
|
||||
preview->drawable_id = drawable_id;
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
||||
@ -297,8 +295,8 @@ gimp_print_preview_set_image_offsets (GimpPrintPreview *preview,
|
||||
* @offset_x_max: the maximum X offset allowed
|
||||
* @offset_y_max: the maximum Y offset allowed
|
||||
*
|
||||
* Sets the maximum offsets of the image/drawable displayed by the #GimpPrintPreview.
|
||||
* It does not emit the "offsets-changed" signal.
|
||||
* Sets the maximum offsets of the image/drawable displayed by the
|
||||
* #GimpPrintPreview. It does not emit the "offsets-changed" signal.
|
||||
**/
|
||||
void
|
||||
gimp_print_preview_set_image_offsets_max (GimpPrintPreview *preview,
|
||||
@ -330,6 +328,17 @@ gimp_print_preview_set_use_full_page (GimpPrintPreview *preview,
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview->area));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_print_preview_realize (GtkWidget *widget)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
|
||||
GDK_FLEUR);
|
||||
gdk_window_set_cursor (widget->window, cursor);
|
||||
gdk_cursor_unref (cursor);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_print_preview_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
@ -403,8 +412,6 @@ gimp_print_preview_expose_event (GtkWidget *widget,
|
||||
gdouble top_margin;
|
||||
gdouble bottom_margin;
|
||||
gdouble scale;
|
||||
gdouble scale_x;
|
||||
gdouble scale_y;
|
||||
cairo_t *cr;
|
||||
|
||||
paper_width = gtk_page_setup_get_paper_width (preview->page,
|
||||
@ -444,7 +451,7 @@ gimp_print_preview_expose_event (GtkWidget *widget,
|
||||
left_margin + preview->image_offset_x,
|
||||
top_margin + preview->image_offset_y);
|
||||
|
||||
if (preview->pixbuf == NULL)
|
||||
if (preview->pixbuf == NULL && gimp_drawable_is_valid (preview->drawable_id))
|
||||
{
|
||||
gint width = MIN (widget->allocation.width, 1024);
|
||||
gint height = MIN (widget->allocation.height, 1024);
|
||||
@ -454,24 +461,27 @@ gimp_print_preview_expose_event (GtkWidget *widget,
|
||||
GIMP_PIXBUF_KEEP_ALPHA);
|
||||
}
|
||||
|
||||
scale_x = ((gdouble) gimp_drawable_width (preview->drawable_id) /
|
||||
gdk_pixbuf_get_width (preview->pixbuf));
|
||||
scale_y = ((gdouble) gimp_drawable_height (preview->drawable_id) /
|
||||
gdk_pixbuf_get_height (preview->pixbuf));
|
||||
if (preview->pixbuf != NULL && gimp_drawable_is_valid (preview->drawable_id))
|
||||
{
|
||||
gdouble scale_x = ((gdouble) gimp_drawable_width (preview->drawable_id) /
|
||||
gdk_pixbuf_get_width (preview->pixbuf));
|
||||
gdouble scale_y = ((gdouble) gimp_drawable_height (preview->drawable_id) /
|
||||
gdk_pixbuf_get_height (preview->pixbuf));
|
||||
|
||||
if (scale_x < scale_y)
|
||||
scale_x = scale_y;
|
||||
else
|
||||
scale_y = scale_x;
|
||||
if (scale_x < scale_y)
|
||||
scale_x = scale_y;
|
||||
else
|
||||
scale_y = scale_x;
|
||||
|
||||
scale_x = scale_x * 72.0 / preview->image_xres;
|
||||
scale_y = scale_y * 72.0 / preview->image_yres;
|
||||
scale_x = scale_x * 72.0 / preview->image_xres;
|
||||
scale_y = scale_y * 72.0 / preview->image_yres;
|
||||
|
||||
cairo_scale (cr, scale_x, scale_y);
|
||||
cairo_scale (cr, scale_x, scale_y);
|
||||
|
||||
gdk_cairo_set_source_pixbuf (cr, preview->pixbuf, 0, 0);
|
||||
}
|
||||
|
||||
gdk_cairo_set_source_pixbuf (cr, preview->pixbuf, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
||||
return FALSE;
|
||||
|
||||
Reference in New Issue
Block a user