item-properties.cpp revision 1160eb7a6e90b1efe44156277727f93860364743
/**
* @file
* Object properties dialog.
*/
/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <goejendaagh@zonnet.nl>
* Abhishek Sharma
* Kris De Gussem <Kris.DeGussem@gmail.com>
*
* Copyright (C) 1999-2011 Authors
* Copyright (C) 2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "../desktop-handles.h"
#include "../document.h"
#include "../inkscape.h"
#include "../interface.h"
#include "../macros.h"
#include "../preferences.h"
#include "../selection.h"
#include "../sp-item.h"
#include "../verbs.h"
#include "../widgets/sp-widget.h"
#include "item-properties.h"
using Inkscape::DocumentUndo;
#define MIN_ONSCREEN_DISTANCE 50
static void sp_item_widget_modify_selection (SPWidget *spw, Inkscape::Selection *selection, guint flags, GtkWidget *itemw);
static void sp_item_widget_change_selection (SPWidget *spw, Inkscape::Selection *selection, GtkWidget *itemw);
/**
* \brief SPItemDialog callback for closing the dialog.
*/
{
if (spid)
{
delete spid;
}
}
/**
* \brief SPItemDialog callback for a modification of the selected object (e.g. size, color, fill, etc.).
*/
guint /*flags*/,
GtkWidget */*itemw*/ )
{
if (spid)
{
spid->widget_setup();
}
}
/**
* \brief SPItemDialog callback for the selection of an other object.
*/
GtkWidget */*itemw*/ )
{
if (spid)
{
spid->widget_setup();
}
}
/**
* Create a new static instance of the items dialog.
*/
void sp_item_dialog(void)
{
spid = new SPItemDialog();
}
}
/**
* \brief Constructor.
*/
SPItemDialog::SPItemDialog (void) :
prefs_path("/dialogs/object/"),
x(-1000),// impossible original value to make sure they are read from prefs
y(-1000),// impossible original value to make sure they are read from prefs
w(0),
h(0),
blocked (false),
closing (false),
attrTable(),
CurrentItem(0)
{
//intializing dialog
//reading dialog position from preferences
if (x == -1000 || y == -1000) {
}
if (w ==0 || h == 0) {
}
if (w && h) {
}
if (x >= 0 && y >= 0 && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE))) {
} else {
}
//set callback for the new dialog
g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
// g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (sp_item_dialog_delete), dlg);
//initialize labels for the table at the bottom of the dialog
MakeWidget();
}
/**
* \brief Destructor.
*/
SPItemDialog::~SPItemDialog (void)
{
if (closing)
{
return;
}
blocked = true;
closing = true;
if (x<0) x=0;
if (y<0) y=0;
if (window)
{
//should actually always be true, but for safety check
delete window;
}
}
/**
* \brief Constructor auxiliary function creating the child widgets.
*/
void SPItemDialog::MakeWidget(void)
{
// if (gtk_widget_get_visible (GTK_WIDGET(spw))) {
g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (sp_item_widget_modify_selection), wd.win);
g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (sp_item_widget_change_selection), wd.win);
g_signal_connect (G_OBJECT (INKSCAPE), "set_selection", G_CALLBACK (sp_item_widget_change_selection), wd.win);
// }
/* Create the label for the object id */
Gtk::AttachOptions(), 0, 0 );
/* Create the entry box for the object id */
EntryID.set_tooltip_text (_("The id= attribute (only letters, digits, and the characters .-_: allowed)"));
Gtk::AttachOptions(), 0, 0 );
// pressing enter in the id field is the same as clicking Set:
// focus is in the id field initially:
/* Create the label for the object label */
Gtk::AttachOptions(), 0, 0 );
/* Create the entry box for the object label */
Gtk::AttachOptions(), 0, 0 );
// pressing enter in the label field is the same as clicking Set:
/* Create the label for the object title */
Gtk::AttachOptions(), 0, 0 );
/* Create the entry box for the object title */
Gtk::AttachOptions(), 0, 0 );
/* Create the frame for the object description */
/* Create the text view box for the object description */
/* Check boxes */
/* Hide */
Gtk::AttachOptions(), 0, 0 );
/* Lock */
// TRANSLATORS: "Lock" is a verb here
Gtk::AttachOptions(), 0, 0 );
/* Button for setting the object's id, label, title and description. */
/* Create the frame for interactivity options */
widget_setup();
}
/**
* \brief Updates entries and other child widgets on selection change, object modification, etc.
*/
void SPItemDialog::widget_setup(void)
{
if (blocked)
{
return;
}
if (!selection->singleItem()) {
vb.set_sensitive (false);
CurrentItem = NULL;
//no selection anymore or multiple objects selected, means that we need
//to close the connections to the previously selected object
return;
} else {
vb.set_sensitive (true);
}
if (CurrentItem == item)
{
//otherwise we would end up wasting resources through the modify selection
//callback when moving an object (endlessly setting the labels and recreating attrTable)
return;
}
blocked = true;
/* ID */
/* Label */
} else {
/* ID */
/* Label */
/* Title */
if (title) {
}
else {
}
/* Description */
if (desc) {
} else {
}
if (CurrentItem == NULL)
{
}
else
{
}
}
CurrentItem = item;
blocked = false;
}
/**
* \brief Sets object properties (ID, label, title, description) on user input.
*/
void SPItemDialog::label_changed(void)
{
if (blocked)
{
return;
}
blocked = true;
/* Retrieve the label widget for the object's id */
} else {
SP_EXCEPTION_INIT (&ex);
}
/* Retrieve the label widget for the object's label */
/* Give feedback on success of setting the drawing object's label
* using the widget's label text
*/
_("Set object label"));
}
/* Retrieve the title */
_("Set object title"));
/* Retrieve the description */
_("Set object description"));
blocked = false;
}
/**
* \brief Callback for checkbox Lock.
*/
void SPItemDialog::sensitivity_toggled (void)
{
if (blocked)
{
return;
}
blocked = true;
blocked = false;
}
/**
* \brief Callback for checkbox Hide.
*/
void SPItemDialog::hidden_toggled(void)
{
if (blocked)
{
return;
}
blocked = true;
blocked = false;
}
/*
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:fileencoding=utf-8:textwidth=99 :