sp-widget.cpp revision a1c83ca671ae9b97c6a30901ee3542faf93defb4
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#define __SP_WIDGET_C__
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen/*
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Abstract base class for dynamic control widgets
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen *
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Authors:
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Lauris Kaplinski <lauris@kaplinski.com>
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * bulia byak <buliabyak@users.sf.net>
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen *
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Copyright (C) 1999-2002 Lauris Kaplinski
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Copyright (C) 2000-2001 Ximian, Inc.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen *
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Released under GNU GPL, read the file 'COPYING' for more information
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen */
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#include "macros.h"
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#include "../document.h"
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#include "sp-widget.h"
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#include "helper/sp-marshal.h"
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenenum {
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen CONSTRUCT,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen MODIFY_SELECTION,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen CHANGE_SELECTION,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen SET_SELECTION,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen LAST_SIGNAL
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen};
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_class_init (SPWidgetClass *klass);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitestatic void sp_widget_init (SPWidget *widget);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_destroy (GtkObject *object);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_show (GtkWidget *widget);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_hide (GtkWidget *widget);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic gint sp_widget_expose (GtkWidget *widget, GdkEventExpose *event);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_size_request (GtkWidget *widget, GtkRequisition *requisition);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_get_preferred_width(GtkWidget *widget,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen gint *minimal_width,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen gint *natural_width);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_get_preferred_height(GtkWidget *widget,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen gint *minimal_height,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen gint *natural_height);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_modify_selection (Inkscape::Application *inkscape, Inkscape::Selection *selection, guint flags, SPWidget *spw);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_change_selection (Inkscape::Application *inkscape, Inkscape::Selection *selection, SPWidget *spw);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_set_selection (Inkscape::Application *inkscape, Inkscape::Selection *selection, SPWidget *spw);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic GtkBinClass *parent_class;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic guint signals[LAST_SIGNAL] = {0};
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan EngelenGType
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelensp_widget_get_type (void)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen{
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen static GType type = 0;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen if (!type) {
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen static const GTypeInfo info = {
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen sizeof (SPWidgetClass),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen NULL, NULL,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen (GClassInitFunc) sp_widget_class_init,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen NULL, NULL,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen sizeof (SPWidget),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen 0,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen (GInstanceInitFunc) sp_widget_init,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen NULL
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen };
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen type = g_type_register_static (GTK_TYPE_BIN,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen "SPWidget",
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen &info,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen (GTypeFlags)0);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen }
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen return type;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen}
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelensp_widget_class_init (SPWidgetClass *klass)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen{
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GtkObjectClass *object_class;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GtkWidgetClass *widget_class;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen object_class = (GtkObjectClass *) klass;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen widget_class = (GtkWidgetClass *) klass;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen parent_class = (GtkBinClass*)g_type_class_peek_parent (klass);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen object_class->destroy = sp_widget_destroy;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen signals[CONSTRUCT] = g_signal_new ("construct",
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_FROM_CLASS(object_class),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_SIGNAL_RUN_FIRST,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_STRUCT_OFFSET (SPWidgetClass, construct),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen NULL, NULL,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen g_cclosure_marshal_VOID__VOID,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_NONE, 0);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen signals[CHANGE_SELECTION] = g_signal_new ("change_selection",
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_FROM_CLASS(object_class),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_SIGNAL_RUN_FIRST,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_STRUCT_OFFSET (SPWidgetClass, change_selection),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen NULL, NULL,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen g_cclosure_marshal_VOID__POINTER,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_NONE, 1,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_POINTER);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen signals[MODIFY_SELECTION] = g_signal_new ("modify_selection",
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_FROM_CLASS(object_class),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_SIGNAL_RUN_FIRST,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_STRUCT_OFFSET (SPWidgetClass, modify_selection),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen NULL, NULL,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen sp_marshal_VOID__POINTER_UINT,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_NONE, 2,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_POINTER, G_TYPE_UINT);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen signals[SET_SELECTION] = g_signal_new ("set_selection",
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_FROM_CLASS(object_class),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_SIGNAL_RUN_FIRST,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_STRUCT_OFFSET (SPWidgetClass, set_selection),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen NULL, NULL,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen g_cclosure_marshal_VOID__POINTER,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_NONE, 1,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_TYPE_POINTER);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen widget_class->show = sp_widget_show;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen widget_class->hide = sp_widget_hide;
ea7d8c8f5752fe8fe4f814fc01baf6f250825817Johan Engelen widget_class->expose_event = sp_widget_expose;
ea7d8c8f5752fe8fe4f814fc01baf6f250825817Johan Engelen#if GTK_CHECK_VERSION(3,0,0)
ea7d8c8f5752fe8fe4f814fc01baf6f250825817Johan Engelen widget_class->get_preferred_width = sp_widget_get_preferred_width;
ea7d8c8f5752fe8fe4f814fc01baf6f250825817Johan Engelen widget_class->get_preferred_height = sp_widget_get_preferred_height;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#else
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen widget_class->size_request = sp_widget_size_request;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#endif
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen widget_class->size_allocate = sp_widget_size_allocate;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen}
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitesp_widget_init (SPWidget *spw)
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White{
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White spw->inkscape = NULL;
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White}
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitestatic void
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitesp_widget_destroy (GtkObject *object)
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White{
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White SPWidget *spw;
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White spw = (SPWidget *) object;
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White if (spw->inkscape) {
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White /* Disconnect signals */
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White // the checks are necessary because when destroy is caused by the the program shutting down,
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White // the inkscape object may already be (partly?) invalid --bb
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White if (G_IS_OBJECT(spw->inkscape) && G_OBJECT_GET_CLASS(G_OBJECT(spw->inkscape)))
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White sp_signal_disconnect_by_data (spw->inkscape, spw);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White spw->inkscape = NULL;
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White }
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White if (((GtkObjectClass *) parent_class)->destroy)
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White (* ((GtkObjectClass *) parent_class)->destroy) (object);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White}
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitestatic void
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitesp_widget_show (GtkWidget *widget)
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White{
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White SPWidget *spw;
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White spw = SP_WIDGET (widget);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White if (spw->inkscape) {
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White /* Connect signals */
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White g_signal_connect (G_OBJECT (spw->inkscape), "modify_selection", G_CALLBACK (sp_widget_modify_selection), spw);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White g_signal_connect (G_OBJECT (spw->inkscape), "change_selection", G_CALLBACK (sp_widget_change_selection), spw);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White g_signal_connect (G_OBJECT (spw->inkscape), "set_selection", G_CALLBACK (sp_widget_set_selection), spw);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen }
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen if (((GtkWidgetClass *) parent_class)->show)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen (* ((GtkWidgetClass *) parent_class)->show) (widget);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen}
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelensp_widget_hide (GtkWidget *widget)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen{
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen SPWidget *spw;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen spw = SP_WIDGET (widget);
b49365c42b99e3cc135dcde0077aad31d930f6c1Johan B. C. Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen if (spw->inkscape) {
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen /* Disconnect signals */
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen sp_signal_disconnect_by_data (spw->inkscape, spw);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen }
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen if (((GtkWidgetClass *) parent_class)->hide)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen (* ((GtkWidgetClass *) parent_class)->hide) (widget);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen}
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic gint
b49365c42b99e3cc135dcde0077aad31d930f6c1Johan B. C. Engelensp_widget_expose (GtkWidget *widget, GdkEventExpose *event)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen{
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GtkBin *bin;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GtkWidget *child;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen bin = GTK_BIN (widget);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen child = gtk_bin_get_child (bin);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen if (child) {
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen gtk_container_propagate_expose (GTK_CONTAINER(widget), child, event);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen }
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen /*
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen if ((bin->child) && (!gtk_widget_get_has_window (bin->child))) {
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GdkEventExpose ce;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen ce = *event;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen gtk_widget_event (bin->child, (GdkEvent *) &ce);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen }
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen */
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen return FALSE;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen}
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitesp_widget_size_request (GtkWidget *widget, GtkRequisition *requisition)
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White{
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GtkBin *bin = GTK_BIN (widget);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GtkWidget *child = gtk_bin_get_child (bin);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen if (child)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen gtk_widget_size_request (child, requisition);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen}
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen{
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GtkRequisition requisition;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen sp_widget_size_request(widget, &requisition);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen *minimal_width = *natural_width = requisition.width;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen}
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen{
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GtkRequisition requisition;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen sp_widget_size_request(widget, &requisition);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen *minimal_height = *natural_height = requisition.height;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen}
static void
sp_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child = gtk_bin_get_child (bin);
gtk_widget_set_allocation (widget, allocation);
if (child)
gtk_widget_size_allocate (child, allocation);
}
/* Methods */
GtkWidget *
sp_widget_new_global (Inkscape::Application *inkscape)
{
SPWidget *spw;
spw = (SPWidget*)g_object_new (SP_TYPE_WIDGET, NULL);
if (!sp_widget_construct_global (spw, inkscape)) {
g_object_unref (spw);
return NULL;
}
return (GtkWidget *) spw;
}
GtkWidget *
sp_widget_construct_global (SPWidget *spw, Inkscape::Application *inkscape)
{
g_return_val_if_fail (!spw->inkscape, NULL);
spw->inkscape = inkscape;
if (gtk_widget_get_visible (GTK_WIDGET(spw))) {
g_signal_connect (G_OBJECT (inkscape), "modify_selection", G_CALLBACK (sp_widget_modify_selection), spw);
g_signal_connect (G_OBJECT (inkscape), "change_selection", G_CALLBACK (sp_widget_change_selection), spw);
g_signal_connect (G_OBJECT (inkscape), "set_selection", G_CALLBACK (sp_widget_set_selection), spw);
}
g_signal_emit (G_OBJECT (spw), signals[CONSTRUCT], 0);
return (GtkWidget *) spw;
}
static void
sp_widget_modify_selection (Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, guint flags, SPWidget *spw)
{
g_signal_emit (G_OBJECT (spw), signals[MODIFY_SELECTION], 0, selection, flags);
}
static void
sp_widget_change_selection (Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, SPWidget *spw)
{
g_signal_emit (G_OBJECT (spw), signals[CHANGE_SELECTION], 0, selection);
}
static void
sp_widget_set_selection (Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, SPWidget *spw)
{
/* Emit "set_selection" signal */
g_signal_emit (G_OBJECT (spw), signals[SET_SELECTION], 0, selection);
/* Inkscape will force "change_selection" anyways */
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :