sp-widget.cpp revision a1c83ca671ae9b97c6a30901ee3542faf93defb4
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Abstract base class for dynamic control widgets
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Lauris Kaplinski <lauris@kaplinski.com>
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * bulia byak <buliabyak@users.sf.net>
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Copyright (C) 1999-2002 Lauris Kaplinski
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Copyright (C) 2000-2001 Ximian, Inc.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Released under GNU GPL, read the file 'COPYING' for more information
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_class_init (SPWidgetClass *klass);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_destroy (GtkObject *object);
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 Engelenstatic void sp_widget_get_preferred_width(GtkWidget *widget,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_get_preferred_height(GtkWidget *widget,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
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 parent_class = (GtkBinClass*)g_type_class_peek_parent (klass);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen signals[CONSTRUCT] = g_signal_new ("construct",
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen signals[CHANGE_SELECTION] = g_signal_new ("change_selection",
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_STRUCT_OFFSET (SPWidgetClass, change_selection),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen signals[MODIFY_SELECTION] = g_signal_new ("modify_selection",
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_STRUCT_OFFSET (SPWidgetClass, modify_selection),
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen signals[SET_SELECTION] = g_signal_new ("set_selection",
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen G_STRUCT_OFFSET (SPWidgetClass, set_selection),
ea7d8c8f5752fe8fe4f814fc01baf6f250825817Johan Engelen widget_class->expose_event = sp_widget_expose;
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 widget_class->size_request = sp_widget_size_request;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen widget_class->size_allocate = sp_widget_size_allocate;
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 if (((GtkObjectClass *) parent_class)->destroy)
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White (* ((GtkObjectClass *) parent_class)->destroy) (object);
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 (* ((GtkWidgetClass *) parent_class)->show) (widget);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen /* Disconnect signals */
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen sp_signal_disconnect_by_data (spw->inkscape, spw);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen (* ((GtkWidgetClass *) parent_class)->hide) (widget);
b49365c42b99e3cc135dcde0077aad31d930f6c1Johan B. C. Engelensp_widget_expose (GtkWidget *widget, GdkEventExpose *event)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen gtk_container_propagate_expose (GTK_CONTAINER(widget), child, event);
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen if ((bin->child) && (!gtk_widget_get_has_window (bin->child))) {
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen GdkEventExpose ce;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen gtk_widget_event (bin->child, (GdkEvent *) &ce);
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. Whitesp_widget_size_request (GtkWidget *widget, GtkRequisition *requisition)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen *minimal_width = *natural_width = requisition.width;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic void sp_widget_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen *minimal_height = *natural_height = requisition.height;
if (child)
return NULL;
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);
sp_widget_modify_selection (Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, guint flags, SPWidget *spw)
sp_widget_change_selection (Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, SPWidget *spw)
sp_widget_set_selection (Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, SPWidget *spw)