add gimp_canvas_draw_drop_zone() which simply renders a big "Drop Here" on
2008-03-18 Michael Natterer <mitch@gimp.org> * app/display/gimpcanvas.[ch]: add gimp_canvas_draw_drop_zone() which simply renders a big "Drop Here" on the canvas. Replaced Gimp member and construct property by GimpDisplayConfig. * app/display/gimpdisplayshell.c (gimp_display_shell_new): changed accordingly. svn path=/trunk/; revision=25112
This commit is contained in:
parent
89433fe929
commit
e2f6294c07
4 changed files with 149 additions and 98 deletions
|
|
@ -1,3 +1,12 @@
|
|||
2008-03-18 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpcanvas.[ch]: add gimp_canvas_draw_drop_zone()
|
||||
which simply renders a big "Drop Here" on the canvas. Replaced
|
||||
Gimp member and construct property by GimpDisplayConfig.
|
||||
|
||||
* app/display/gimpdisplayshell.c (gimp_display_shell_new): changed
|
||||
accordingly.
|
||||
|
||||
2008-03-18 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/uri/uri-backend-gio.c (uri_progress_callback):
|
||||
|
|
|
|||
|
|
@ -26,17 +26,17 @@
|
|||
|
||||
#include "config/gimpdisplayconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gimpcanvas.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_GIMP
|
||||
PROP_CONFIG
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -163,9 +163,9 @@ gimp_canvas_class_init (GimpCanvasClass *klass)
|
|||
widget_class->unrealize = gimp_canvas_unrealize;
|
||||
widget_class->style_set = gimp_canvas_style_set;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_GIMP,
|
||||
g_param_spec_object ("gimp", NULL, NULL,
|
||||
GIMP_TYPE_GIMP,
|
||||
g_object_class_install_property (object_class, PROP_CONFIG,
|
||||
g_param_spec_object ("config", NULL, NULL,
|
||||
GIMP_TYPE_DISPLAY_CONFIG,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
|
@ -192,8 +192,8 @@ gimp_canvas_set_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
canvas->gimp = g_value_get_object (value);
|
||||
case PROP_CONFIG:
|
||||
canvas->config = g_value_get_object (value); /* don't dup */
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
|
@ -211,8 +211,8 @@ gimp_canvas_get_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
g_value_set_object (value, canvas->gimp);
|
||||
case PROP_CONFIG:
|
||||
g_value_set_object (value, canvas->config);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
|
@ -262,6 +262,12 @@ gimp_canvas_unrealize (GtkWidget *widget)
|
|||
canvas->layout = NULL;
|
||||
}
|
||||
|
||||
if (canvas->drop_zone_layout)
|
||||
{
|
||||
g_object_unref (canvas->drop_zone_layout);
|
||||
canvas->drop_zone_layout = NULL;
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
||||
}
|
||||
|
||||
|
|
@ -279,6 +285,12 @@ gimp_canvas_style_set (GtkWidget *widget,
|
|||
g_object_unref (canvas->layout);
|
||||
canvas->layout = NULL;
|
||||
}
|
||||
|
||||
if (canvas->drop_zone_layout)
|
||||
{
|
||||
g_object_unref (canvas->drop_zone_layout);
|
||||
canvas->drop_zone_layout = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns: %TRUE if the XOR color is not white */
|
||||
|
|
@ -286,10 +298,9 @@ static gboolean
|
|||
gimp_canvas_get_xor_color (GimpCanvas *canvas,
|
||||
GdkColor *color)
|
||||
{
|
||||
GimpDisplayConfig *config = GIMP_DISPLAY_CONFIG (canvas->gimp->config);
|
||||
guchar r, g, b;
|
||||
guchar r, g, b;
|
||||
|
||||
gimp_rgb_get_uchar (&config->xor_color, &r, &g, &b);
|
||||
gimp_rgb_get_uchar (&canvas->config->xor_color, &r, &g, &b);
|
||||
|
||||
color->red = (r << 8) | r;
|
||||
color->green = (g << 8) | g;
|
||||
|
|
@ -491,13 +502,13 @@ gimp_canvas_ensure_style (GimpCanvas *canvas,
|
|||
* Return value: a new #GimpCanvas widget
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_canvas_new (Gimp *gimp)
|
||||
gimp_canvas_new (GimpDisplayConfig *config)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_DISPLAY_CONFIG (config), NULL);
|
||||
|
||||
return g_object_new (GIMP_TYPE_CANVAS,
|
||||
"name", "gimp-canvas",
|
||||
"gimp", gimp,
|
||||
"name", "gimp-canvas",
|
||||
"config", config,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -822,6 +833,34 @@ gimp_canvas_draw_rgb (GimpCanvas *canvas,
|
|||
rgb_buf, rowstride, xdith, ydith);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_canvas_draw_drop_zone (GimpCanvas *canvas,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (canvas);
|
||||
gint width;
|
||||
gint height;
|
||||
gdouble factor;
|
||||
|
||||
if (! canvas->drop_zone_layout)
|
||||
canvas->drop_zone_layout = gtk_widget_create_pango_layout (widget,
|
||||
_("Drop Files"));
|
||||
|
||||
pango_layout_get_pixel_size (canvas->drop_zone_layout, &width, &height);
|
||||
|
||||
factor = MIN (2.0 / 3.0 * widget->allocation.width / width,
|
||||
2.0 / 3.0 * widget->allocation.height / height);
|
||||
|
||||
cairo_scale (cr, factor, factor);
|
||||
|
||||
cairo_move_to (cr,
|
||||
(widget->allocation.width / factor - width) / 2.0,
|
||||
(widget->allocation.height / factor - height) / 2.0);
|
||||
|
||||
pango_cairo_show_layout (cr, canvas->drop_zone_layout);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_canvas_set_clip_rect:
|
||||
* @canvas: a #GimpCanvas widget
|
||||
|
|
|
|||
|
|
@ -59,13 +59,14 @@ typedef struct _GimpCanvasClass GimpCanvasClass;
|
|||
|
||||
struct _GimpCanvas
|
||||
{
|
||||
GtkDrawingArea parent_instance;
|
||||
GtkDrawingArea parent_instance;
|
||||
|
||||
Gimp *gimp;
|
||||
GimpDisplayConfig *config;
|
||||
|
||||
GdkGC *gc[GIMP_CANVAS_NUM_STYLES];
|
||||
GdkBitmap *stipple[GIMP_CANVAS_NUM_STIPPLES];
|
||||
PangoLayout *layout;
|
||||
GdkGC *gc[GIMP_CANVAS_NUM_STYLES];
|
||||
GdkBitmap *stipple[GIMP_CANVAS_NUM_STIPPLES];
|
||||
PangoLayout *layout;
|
||||
PangoLayout *drop_zone_layout;
|
||||
};
|
||||
|
||||
struct _GimpCanvasClass
|
||||
|
|
@ -76,84 +77,86 @@ struct _GimpCanvasClass
|
|||
|
||||
GType gimp_canvas_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_canvas_new (Gimp *gimp);
|
||||
GtkWidget * gimp_canvas_new (GimpDisplayConfig *config);
|
||||
|
||||
void gimp_canvas_draw_cursor (GimpCanvas *canvas,
|
||||
gint x,
|
||||
gint y);
|
||||
void gimp_canvas_draw_point (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gint x,
|
||||
gint y);
|
||||
void gimp_canvas_draw_points (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkPoint *points,
|
||||
gint num_points);
|
||||
void gimp_canvas_draw_line (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2);
|
||||
void gimp_canvas_draw_lines (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkPoint *points,
|
||||
gint num_points);
|
||||
void gimp_canvas_draw_rectangle (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gboolean filled,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gimp_canvas_draw_arc (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gboolean filled,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint angle1,
|
||||
gint angle2);
|
||||
void gimp_canvas_draw_polygon (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gboolean filled,
|
||||
GdkPoint *points,
|
||||
gint num_points);
|
||||
void gimp_canvas_draw_segments (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkSegment *segments,
|
||||
gint num_segments);
|
||||
void gimp_canvas_draw_text (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gint x,
|
||||
gint y,
|
||||
const gchar *format,
|
||||
void gimp_canvas_draw_cursor (GimpCanvas *canvas,
|
||||
gint x,
|
||||
gint y);
|
||||
void gimp_canvas_draw_point (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gint x,
|
||||
gint y);
|
||||
void gimp_canvas_draw_points (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkPoint *points,
|
||||
gint num_points);
|
||||
void gimp_canvas_draw_line (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2);
|
||||
void gimp_canvas_draw_lines (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkPoint *points,
|
||||
gint num_points);
|
||||
void gimp_canvas_draw_rectangle (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gboolean filled,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gimp_canvas_draw_arc (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gboolean filled,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint angle1,
|
||||
gint angle2);
|
||||
void gimp_canvas_draw_polygon (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gboolean filled,
|
||||
GdkPoint *points,
|
||||
gint num_points);
|
||||
void gimp_canvas_draw_segments (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkSegment *segments,
|
||||
gint num_segments);
|
||||
void gimp_canvas_draw_text (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gint x,
|
||||
gint y,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF (5, 6);
|
||||
void gimp_canvas_draw_rgb (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
guchar *rgb_buf,
|
||||
gint rowstride,
|
||||
gint xdith,
|
||||
gint ydith);
|
||||
void gimp_canvas_draw_rgb (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
guchar *rgb_buf,
|
||||
gint rowstride,
|
||||
gint xdith,
|
||||
gint ydith);
|
||||
void gimp_canvas_draw_drop_zone (GimpCanvas *canvas,
|
||||
cairo_t *cr);
|
||||
|
||||
void gimp_canvas_set_clip_rect (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkRectangle *rect);
|
||||
void gimp_canvas_set_clip_region (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkRegion *region);
|
||||
void gimp_canvas_set_stipple_index (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
guint index);
|
||||
void gimp_canvas_set_custom_gc (GimpCanvas *canvas,
|
||||
GdkGC *gc);
|
||||
void gimp_canvas_set_bg_color (GimpCanvas *canvas,
|
||||
GimpRGB *color);
|
||||
void gimp_canvas_set_clip_rect (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkRectangle *rect);
|
||||
void gimp_canvas_set_clip_region (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
GdkRegion *region);
|
||||
void gimp_canvas_set_stipple_index (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style,
|
||||
guint index);
|
||||
void gimp_canvas_set_custom_gc (GimpCanvas *canvas,
|
||||
GdkGC *gc);
|
||||
void gimp_canvas_set_bg_color (GimpCanvas *canvas,
|
||||
GimpRGB *color);
|
||||
|
||||
|
||||
#endif /* __GIMP_CANVAS_H__ */
|
||||
|
|
|
|||
|
|
@ -895,7 +895,7 @@ gimp_display_shell_new (GimpDisplay *display,
|
|||
_("Access the image menu"),
|
||||
GIMP_HELP_IMAGE_WINDOW_ORIGIN);
|
||||
|
||||
shell->canvas = gimp_canvas_new (shell->display->image->gimp);
|
||||
shell->canvas = gimp_canvas_new (GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config));
|
||||
|
||||
gimp_display_shell_selection_init (shell);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue