gimp r26708 - in trunk: . app/display
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26708 - in trunk: . app/display
- Date: Thu, 21 Aug 2008 23:55:58 +0000 (UTC)
Author: mitch
Date: Thu Aug 21 23:55:58 2008
New Revision: 26708
URL: http://svn.gnome.org/viewvc/gimp?rev=26708&view=rev
Log:
2008-08-21 Michael Natterer <mitch gimp org>
* app/display/gimpcanvas.[ch]: turn into a GtkContainer subclass
mainly to reduce the diff to a local hack I'm at. Also swallow
some code that used to be called on the canvas widget externally.
* app/display/gimpdisplayshell.c (gimp_display_shell_new): remove
the swallowed code.
* app/display/gimpdisplayshell-callbacks.h: remove canvas event
mask define.
Modified:
trunk/ChangeLog
trunk/app/display/gimpcanvas.c
trunk/app/display/gimpcanvas.h
trunk/app/display/gimpdisplayshell-callbacks.h
trunk/app/display/gimpdisplayshell.c
Modified: trunk/app/display/gimpcanvas.c
==============================================================================
--- trunk/app/display/gimpcanvas.c (original)
+++ trunk/app/display/gimpcanvas.c Thu Aug 21 23:55:58 2008
@@ -56,6 +56,8 @@
static void gimp_canvas_realize (GtkWidget *widget);
static void gimp_canvas_unrealize (GtkWidget *widget);
+static void gimp_canvas_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
static void gimp_canvas_style_set (GtkWidget *widget,
GtkStyle *prev_style);
@@ -63,7 +65,7 @@
GimpCanvasStyle style);
-G_DEFINE_TYPE (GimpCanvas, gimp_canvas, GTK_TYPE_DRAWING_AREA)
+G_DEFINE_TYPE (GimpCanvas, gimp_canvas, GTK_TYPE_CONTAINER)
#define parent_class gimp_canvas_parent_class
@@ -159,12 +161,13 @@
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->set_property = gimp_canvas_set_property;
- object_class->get_property = gimp_canvas_get_property;
+ object_class->set_property = gimp_canvas_set_property;
+ object_class->get_property = gimp_canvas_get_property;
- widget_class->realize = gimp_canvas_realize;
- widget_class->unrealize = gimp_canvas_unrealize;
- widget_class->style_set = gimp_canvas_style_set;
+ widget_class->realize = gimp_canvas_realize;
+ widget_class->unrealize = gimp_canvas_unrealize;
+ widget_class->size_allocate = gimp_canvas_size_allocate;
+ widget_class->style_set = gimp_canvas_style_set;
g_object_class_install_property (object_class, PROP_CONFIG,
g_param_spec_object ("config", NULL, NULL,
@@ -176,7 +179,12 @@
static void
gimp_canvas_init (GimpCanvas *canvas)
{
- gint i;
+ GtkWidget *widget = GTK_WIDGET (canvas);
+ gint i;
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+
+ gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_ALL);
for (i = 0; i < GIMP_CANVAS_NUM_STYLES; i++)
canvas->gc[i] = NULL;
@@ -226,9 +234,42 @@
static void
gimp_canvas_realize (GtkWidget *widget)
{
- GimpCanvas *canvas = GIMP_CANVAS (widget);
+ GimpCanvas *canvas = GIMP_CANVAS (widget);
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.x = widget->allocation.x;
+ attributes.y = widget->allocation.y;
+ attributes.width = widget->allocation.width;
+ attributes.height = widget->allocation.height;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.visual = gtk_widget_get_visual (widget);
+ attributes.colormap = gtk_widget_get_colormap (widget);
+ attributes.event_mask = (gtk_widget_get_events (widget) |
+ GDK_EXPOSURE_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_STRUCTURE_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK |
+ GDK_FOCUS_CHANGE_MASK |
+ GDK_KEY_PRESS_MASK |
+ GDK_KEY_RELEASE_MASK |
+ GDK_PROXIMITY_OUT_MASK);
+
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+
+ widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data (widget->window, widget);
- GTK_WIDGET_CLASS (parent_class)->realize (widget);
+ widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
canvas->stipple[0] =
gdk_bitmap_create_from_data (widget->window,
@@ -269,6 +310,18 @@
}
static void
+gimp_canvas_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ widget->allocation = *allocation;
+
+ if (GTK_WIDGET_REALIZED (widget))
+ gdk_window_move_resize (widget->window,
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
+}
+
+static void
gimp_canvas_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
Modified: trunk/app/display/gimpcanvas.h
==============================================================================
--- trunk/app/display/gimpcanvas.h (original)
+++ trunk/app/display/gimpcanvas.h Thu Aug 21 23:55:58 2008
@@ -56,7 +56,7 @@
struct _GimpCanvas
{
- GtkDrawingArea parent_instance;
+ GtkContainer parent_instance;
GimpDisplayConfig *config;
@@ -67,7 +67,7 @@
struct _GimpCanvasClass
{
- GtkDrawingAreaClass parent_class;
+ GtkContainerClass parent_class;
};
Modified: trunk/app/display/gimpdisplayshell-callbacks.h
==============================================================================
--- trunk/app/display/gimpdisplayshell-callbacks.h (original)
+++ trunk/app/display/gimpdisplayshell-callbacks.h Thu Aug 21 23:55:58 2008
@@ -20,20 +20,6 @@
#define __GIMP_DISPLAY_SHELL_CALLBACKS_H__
-#define GIMP_DISPLAY_SHELL_CANVAS_EVENT_MASK (GDK_EXPOSURE_MASK | \
- GDK_POINTER_MOTION_MASK | \
- GDK_POINTER_MOTION_HINT_MASK | \
- GDK_BUTTON_PRESS_MASK | \
- GDK_BUTTON_RELEASE_MASK | \
- GDK_STRUCTURE_MASK | \
- GDK_ENTER_NOTIFY_MASK | \
- GDK_LEAVE_NOTIFY_MASK | \
- GDK_FOCUS_CHANGE_MASK | \
- GDK_KEY_PRESS_MASK | \
- GDK_KEY_RELEASE_MASK | \
- GDK_PROXIMITY_OUT_MASK)
-
-
gboolean gimp_display_shell_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell);
Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c (original)
+++ trunk/app/display/gimpdisplayshell.c Thu Aug 21 23:55:58 2008
@@ -1020,6 +1020,7 @@
GIMP_HELP_IMAGE_WINDOW_ORIGIN);
shell->canvas = gimp_canvas_new (display->config);
+ gtk_widget_set_size_request (shell->canvas, shell_width, shell_height);
gimp_display_shell_dnd_init (shell);
gimp_display_shell_selection_init (shell);
@@ -1058,12 +1059,6 @@
gtk_widget_set_extension_events (shell->hrule, GDK_EXTENSION_EVENTS_ALL);
gtk_widget_set_extension_events (shell->vrule, GDK_EXTENSION_EVENTS_ALL);
- /* the canvas */
- gtk_widget_set_size_request (shell->canvas, shell_width, shell_height);
- gtk_widget_set_events (shell->canvas, GIMP_DISPLAY_SHELL_CANVAS_EVENT_MASK);
- gtk_widget_set_extension_events (shell->canvas, GDK_EXTENSION_EVENTS_ALL);
- GTK_WIDGET_SET_FLAGS (shell->canvas, GTK_CAN_FOCUS);
-
g_signal_connect (shell->canvas, "realize",
G_CALLBACK (gimp_display_shell_canvas_realize),
shell);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]