edit-widget.cpp revision 8ca6d3d51fd675fba121c08465ba925f123b17f5
/**
* \brief This class implements the functionality of the window layout, menus,
* and signals.
*
* This is a reimplementation into C++/Gtkmm of Sodipodi's SPDesktopWidget class.
* Both SPDesktopWidget and EditWidget adhere to the EditWidgetInterface, so
*
* Ideally, this class should only contain the handling of the Window (i.e.,
* content construction and window signals) and implement its
* EditWidgetInterface.
*
* Authors:
* Ralf Stephan <ralf@ark.in-berlin.de>
* Bryce W. Harrington <bryce@bryceharrington.org>
* Derek P. Moore <derekm@hackunix.org>
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
*
* Copyright (C) 1999-2005 Authors
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtkwindow.h>
#include <gtk/gtkversion.h>
#include <gtk/gtklabel.h>
#include <gtkmm/radioaction.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/accelmap.h>
#include <gtkmm/separator.h>
#include "macros.h"
#include "path-prefix.h"
#include "prefs-utils.h"
#include "file.h"
#include "application/editor.h"
#include "edit-widget.h"
#include "ui/stock-items.h"
#include "display/sodipodi-ctrlrect.h"
#include "shortcuts.h"
#include "widgets/spw-utilities.h"
#include "event-context.h"
#include "document.h"
#include "sp-namedview.h"
#include "sp-item.h"
#include "interface.h"
#ifdef WITH_INKBOARD
#include "ui/dialog/whiteboard-connect.h"
#include "ui/dialog/whiteboard-sharewithuser.h"
#include "ui/dialog/whiteboard-sharewithchat.h"
#endif
namespace Inkscape {
namespace UI {
namespace View {
: _main_window_table(4),
_update_s_f(false),
_update_a_f(false)
{
g_warning("Creating new EditWidget");
_desktop = 0;
initActions();
initAccelMap();
initLayout();
g_warning("Done creating new EditWidget");
}
EditWidget::~EditWidget()
{
destroyEdit();
}
void
{
}
void
{
// fixme-charset: What charset should we pass to g_warning?
}
}
void
{
set_title("New document 1 - Inkscape");
// top level window into which all other portions of the UI get inserted
// attach box for horizontal toolbars
// attach sub-window for viewport and vertical toolbars
// viewport table with 3 rows by 3 columns
// Menus and Bars
initMenuBar();
initUriBar();
initToolsBar();
// Canvas Viewport
initTopRuler();
_viewport_table.attach(_svg_canvas.widget(), 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
// The statusbar comes last and appears at the bottom of _main_window_table
}
void
{
g_warning("onMenuItem called");
}
void
{
// g_warning("onActionFileNew called");
}
void
{
// g_warning("onActionFileOpen called");
}
void
{
g_warning("onActionFileQuit");
}
void
{
g_warning("onActionFilePrint");
}
void
{
g_warning("onToolbarItem called");
}
void
{
_tool_ctrl->remove();
}
void
{
_tool_ctrl->remove();
}
void
{
}
void
{
}
void
{
}
void
{
// manage (Inkscape::UI::Dialog::DocumentPreferences::create());
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
#ifdef WITH_INKBOARD
void
{
Dialog::WhiteboardConnectDialogImpl* dlg = dynamic_cast< Dialog::WhiteboardConnectDialogImpl* >(_dlg_mgr.getDialog("WhiteboardConnect"));
dlg->setSessionManager();
}
void
{
Dialog::WhiteboardShareWithUserDialogImpl* dlg = dynamic_cast< Dialog::WhiteboardShareWithUserDialogImpl* >(_dlg_mgr.getDialog("WhiteboardShareWithUser"));
dlg->setSessionManager();
}
void
{
Dialog::WhiteboardShareWithChatroomDialogImpl* dlg = dynamic_cast< Dialog::WhiteboardShareWithChatroomDialogImpl* >(_dlg_mgr.getDialog("WhiteboardShareWithChat"));
dlg->setSessionManager();
}
void
{
}
void
{
}
#endif
void
{
g_message("onUriChanged called");
}
// FIXME: strings are replaced by placeholders, NOT to be translated until the code is enabled
// See http://sourceforge.net/mailarchive/message.php?msg_id=11746016 for details
void
{
// _act_grp->add(Gtk::Action::create("MenuFile", _("PLACEHOLDER, do not translate")));
// _act_grp->add(Gtk::Action::create("MenuEdit", _("PLACEHOLDER, do not translate")));
// _act_grp->add(Gtk::Action::create("MenuView", _("PLACEHOLDER, do not translate")));
// _act_grp->add(Gtk::Action::create("MenuLayer", _("PLACEHOLDER, do not translate")));
// _act_grp->add(Gtk::Action::create("MenuObject", _("PLACEHOLDER, do not translate")));
// _act_grp->add(Gtk::Action::create("MenuPath", _("PLACEHOLDER, do not translate")));
// _act_grp->add(Gtk::Action::create("MenuText", _("PLACEHOLDER, do not translate")));
#ifdef WITH_INKBOARD
// _act_grp->add(Gtk::Action::create("MenuWhiteboard", _("PLACEHOLDER, do not translate")));
#endif
// _act_grp->add(Gtk::Action::create("MenuHelp", _("PLACEHOLDER, do not translate")));
// temporarily replaced with non-gettext version to have a well-sized menu
// for testing:
#ifdef WITH_INKBOARD
#endif
// File menu
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
Stock::OPEN_RECENT));
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
Stock::VACUUM_DEFS),
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
// EditWidget menu
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
Stock::PASTE_IN_PLACE));
Stock::PASTE_STYLE));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
Stock::MAKE_BITMAP));
Stock::SELECT_ALL));
Stock::SELECT_INVERT));
Stock::SELECT_NONE));
_("PLACEHOLDER, do not translate")),
// View menu
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
Stock::FULLSCREEN));
Stock::WINDOW_PREV));
Stock::WINDOW_NEXT));
// Layer menu
Stock::LAYER_RENAME));
Stock::LAYER_DUPLICATE));
Stock::LAYER_ANCHOR));
Stock::LAYER_DELETE));
Stock::LAYER_RAISE));
Stock::LAYER_LOWER));
Stock::LAYER_TO_TOP));
Stock::LAYER_TO_BOTTOM));
// Object menu
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
// Path menu
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
Stock::DIFFERENCE));
Stock::INTERSECTION));
Stock::BREAK_APART));
Stock::OFFSET_DYNAMIC));
Stock::OFFSET_LINKED));
_("PLACEHOLDER, do not translate")));
// Text menu
_("PLACEHOLDER, do not translate")),
Stock::PUT_ON_PATH));
// Whiteboard menu
#ifdef WITH_INKBOARD
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
#endif
// About menu
Stock::KEYS_MOUSE));
}
void
{
// Tools bar
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")),
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
// Select Controls bar
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
// Node Controls bar
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
_("PLACEHOLDER, do not translate")));
}
void
{
// One problem is that the keys 1-6 are zoom accelerators which get
// caught as accelerator _before_ any Entry input handler receives them,
// for example the zoom status. At the moment, the best way seems to
// disable them as accelerators when the Entry gets focus, and enable
// them when focus goes elsewhere. The code for this belongs here,
// and not in zoom-status.cpp .
_zoom_status.signal_focus_out_event().connect (sigc::mem_fun (*this, &EditWidget::onEntryFocusOut));
}
bool
{
return false;
}
bool
{
return false;
}
void
{
}
void
{
Gtk::TOOLBAR_ICONS);
}
void
{
// TODO: Do UIManager controlled widgets need to be deleted?
}
void
{
/// \todo Create an Inkscape::UI::Widget::UriBar class (?)
}
void
{
}
void
{
}
void
{
}
void
{
_bottom_scrollbar.signal_value_changed().connect (sigc::mem_fun (*this, &EditWidget::onAdjValueChanged));
_bottom_scrollbar.property_adjustment() = new Gtk::Adjustment (0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0);
}
void
{
_right_scrollbar.signal_value_changed().connect (sigc::mem_fun (*this, &EditWidget::onAdjValueChanged));
_right_scrollbar.property_adjustment() = new Gtk::Adjustment (0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0);
}
void
{
/// \todo icon not implemented
}
void
{
_select_status.set_markup (_("<b>Welcome to Inkscape!</b> Use shape or freehand tools to create objects; use selector (arrow) to move or transform them."));
// include this again with Gtk+-2.6
#endif
}
//========================================
//----------implements EditWidgetInterface
void *
{
return this;
}
void
{
}
void
EditWidget::layout()
{
}
void
{
}
void
{
get_position (x, y);
get_size (w, h);
}
void
{
resize (w, h);
}
void
{
}
/// \param p is already gobj()!
void
EditWidget::setTransient (void* p, int i)
{
#ifndef WIN32
if (i==2)
#endif
}
{
int x, y;
get_pointer (x, y);
}
void
{
fullscreen();
}
/**
* Shuts down the desktop object for the view being closed. It checks
* to see if the document has been edited, and if so prompts the user
* to save, discard, or cancel. Returns TRUE if the shutdown operation
* is cancelled or if the save is cancelled or fails, FALSE otherwise.
*/
bool
{
return false;
{
/// \todo FIXME !!! obviously this will have problems if the document
/// name contains markup characters
_("<span weight=\"bold\" size=\"larger\">Save changes to document \"%s\" before closing?</span>\n\n"
"If you close without saving, your changes will be discarded."),
true,
true);
close_button.show();
switch (response)
{
case Gtk::RESPONSE_YES:
if (sp_file_save_document(doc)) {
} else { // save dialog cancelled or save failed
return TRUE;
}
break;
case Gtk::RESPONSE_NO:
break;
default: // cancel pressed, or dialog was closed
return TRUE;
break;
}
}
/* Code to check data loss */
bool allow_data_loss = FALSE;
while (sp_document_repr_root(doc)->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE)
{
/// \todo FIXME !!! obviously this will have problems if the document
/// name contains markup characters
_("<span weight=\"bold\" size=\"larger\">The file \"%s\" was saved with a format (%s) that may cause data loss!</span>\n\n"
"Do you want to save this file in another format?"),
Inkscape::Extension::db.get(sp_document_repr_root(doc)->attribute("inkscape:output_extension"))->get_name());
true,
true);
close_button.show();
switch (response)
{
case Gtk::RESPONSE_YES:
if (sp_file_save_document(doc)) {
} else { // save dialog cancelled or save failed
return TRUE;
}
break;
case Gtk::RESPONSE_NO:
break;
default: // cancel pressed, or dialog was closed
return TRUE;
break;
}
}
return false;
}
void
{
delete this;
}
void
{
}
void
{
/// \todo active_desktop_indicator not implemented
}
void
{
/// \todo active_desktop_indicator not implemented
}
void
{
p -= _namedview->gridorigin;
}
void
{
/// \todo is that correct?
}
void
{
// do not call this function before canvas has its size allocated
if (!is_realized() || _update_s_f) {
return;
}
_update_s_f = true;
/* The desktop region we always show unconditionally */
/* Canvas region we always show unconditionally */
/* Viewbox is always included into scrollable region */
_update_s_f = false;
}
void
{
if (_top_ruler.is_visible())
{
prefs_set_int_attribute (_desktop->is_fullscreen ? "fullscreen.rulers" : "window.rulers", "state", 0);
} else {
prefs_set_int_attribute (_desktop->is_fullscreen ? "fullscreen.rulers" : "window.rulers", "state", 1);
}
}
void
{
if (_bottom_scrollbar.is_visible())
{
prefs_set_int_attribute (_desktop->is_fullscreen ? "fullscreen.scrollbars" : "window.scrollbars", "state", 0);
} else {
prefs_set_int_attribute (_desktop->is_fullscreen ? "fullscreen.scrollbars" : "window.scrollbars", "state", 1);
}
}
void
{
}
void
{
}
void
{
/// \todo not implemented
}
void
{
/// \todo not implemented
}
bool
{
/// \todo not implemented
return true;
}
void
{
}
void
{
}
bool
{
msg,
true,
true);
return r == Gtk::RESPONSE_YES;
}
void
{
_desktop->registerEditWidget (this);
/// \todo convert to sigc++ when SPObject hierarchy gets converted
/* Listen on namedview modification */
g_signal_connect (G_OBJECT (_desktop->namedview), "modified", G_CALLBACK (Inkscape::UI::View::_namedview_modified), this);
updateRulers();
}
void
{
if (_desktop) {
_desktop = 0;
}
}
//----------end of EditWidgetInterface implementation
//----------start of other callbacks
bool
{
// this is the original code from helper/window.cpp
unsigned int shortcut;
SP_SHORTCUT_SHIFT_MASK : 0 ) |
SP_SHORTCUT_CONTROL_MASK : 0 ) |
SP_SHORTCUT_ALT_MASK : 0 );
return sp_shortcut_invoke (shortcut,
}
bool
{
return shutdown();
}
bool
{
return false;
}
void
{
if (!is_realized()) return;
return;
}
if (_sticky_zoom.get_active()) {
/* Calculate zoom per pixel */
/* Find new visible area */
/* Calculate adjusted zoom */
}
}
void
{
return;
}
}
void
{
if (_update_a_f) return;
_update_a_f = true;
false);
updateRulers();
_update_a_f = false;
}
/// \todo make this a member function when the signal is a sigc++ signal
{
if (flags & SP_OBJECT_MODIFIED_FLAG)
{
ew->updateRulers();
}
}
} // namespace View
} // namespace UI
} // namespace Inkscape
/*
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:encoding=utf-8:textwidth=99 :