index dbac65938e639cba3d584a8a3c0d3c2f332959b9..756f4df73a72f0f6d651a5296e97ca0982a627c0 100644 (file)
/**
* \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
* they both can serve as widget for the same SPDesktop/Edit class.
*
* Ideally, this class should only contain the handling of the Window (i.e.,
- * content construction and window signals) and implement its
+ * content construction and window signals) and implement its
* EditWidgetInterface.
*
* Authors:
* Derek P. Moore <derekm@hackunix.org>
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
+ * John Bintz <jcoswell@coswellproductions.org>
+ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
+ * Copyright (C) 2007 Johan Engelen
+ * Copyright (C) 2006 John Bintz
* Copyright (C) 1999-2005 Authors
* Copyright (C) 2000-2001 Ximian, Inc.
*
#include <gtkmm/separator.h>
#include <gtkmm/base.h>
+#include <sigc++/functors/mem_fun.h>
+
#include "macros.h"
#include "path-prefix.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "file.h"
#include "application/editor.h"
#include "edit-widget.h"
-#include "ui/stock.h"
-#include "ui/stock-items.h"
-#include "ui/icons.h"
#include "display/sodipodi-ctrlrect.h"
#include "helper/units.h"
#include "interface.h"
#include "extension/db.h"
-#ifdef WITH_INKBOARD
-#include "ui/dialog/whiteboard-connect.h"
-#include "ui/dialog/whiteboard-sharewithuser.h"
-#include "ui/dialog/whiteboard-sharewithchat.h"
-#endif
+#include "ui/dialog/dialog-manager.h"
using namespace Inkscape::UI;
using namespace Inkscape::UI::Widget;
_act_grp(Gtk::ActionGroup::create()),
_ui_mgr(Gtk::UIManager::create()),
_update_s_f(false),
- _update_a_f(false)
+ _update_a_f(false),
+ _interaction_disabled_counter(0)
{
g_warning("Creating new EditWidget");
_desktop = 0;
- Icons::init();
- Stock::init();
initActions();
initAccelMap();
initUIManager();
_viewport_table.attach(_svg_canvas.widget(), 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
_svg_canvas.widget().show_all();
-
// The statusbar comes last and appears at the bottom of _main_window_table
initStatusbar();
EditWidget::onActionFileOpen()
{
// g_warning("onActionFileOpen called");
- sp_file_open_dialog (NULL, NULL);
+ sp_file_open_dialog (*this, NULL, NULL);
}
void
_dlg_mgr.showDialog("ObjectProperties");
}
-void
+void
EditWidget::onDialogTextProperties()
{
_dlg_mgr.showDialog("TextProperties");
{
}
-void
+void
EditWidget::onDialogTransformation()
{
_dlg_mgr.showDialog("Transformation");
_dlg_mgr.showDialog("XmlEditor");
}
-#ifdef WITH_INKBOARD
-void
-EditWidget::onDialogWhiteboardConnect()
-{
- Dialog::WhiteboardConnectDialogImpl* dlg = dynamic_cast< Dialog::WhiteboardConnectDialogImpl* >(_dlg_mgr.getDialog("WhiteboardConnect"));
- dlg->setSessionManager();
- _dlg_mgr.showDialog("WhiteboardConnect");
-}
-
-void
-EditWidget::onDialogWhiteboardShareWithUser()
-{
- Dialog::WhiteboardShareWithUserDialogImpl* dlg = dynamic_cast< Dialog::WhiteboardShareWithUserDialogImpl* >(_dlg_mgr.getDialog("WhiteboardShareWithUser"));
- dlg->setSessionManager();
- _dlg_mgr.showDialog("WhiteboardShareWithUser");
-}
-
-void
-EditWidget::onDialogWhiteboardShareWithChat()
-{
- Dialog::WhiteboardShareWithChatroomDialogImpl* dlg = dynamic_cast< Dialog::WhiteboardShareWithChatroomDialogImpl* >(_dlg_mgr.getDialog("WhiteboardShareWithChat"));
- dlg->setSessionManager();
- _dlg_mgr.showDialog("WhiteboardShareWithChat");
-}
-
-void
-EditWidget::onDialogOpenSessionFile()
-{
- g_log(NULL, G_LOG_LEVEL_DEBUG, "not reimplemented yet");
-}
-
-void
-EditWidget::onDumpXMLTracker()
-{
- g_log(NULL, G_LOG_LEVEL_DEBUG, "not reimplemented yet");
-}
-
-#endif
-
void
EditWidget::onUriChanged()
{
g_message("onUriChanged called");
-
+
}
// FIXME: strings are replaced by placeholders, NOT to be translated until the code is enabled
void
EditWidget::initMenuActions()
{
-// _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:
+// This has no chance of working right now.
+// Has to be converted to Gtk::Action::create_with_icon_name.
_act_grp->add(Gtk::Action::create("MenuFile", "File"));
_act_grp->add(Gtk::Action::create("MenuEdit", "Edit"));
_act_grp->add(Gtk::Action::create("MenuObject", "Object"));
_act_grp->add(Gtk::Action::create("MenuPath", "Path"));
_act_grp->add(Gtk::Action::create("MenuText", "Text"));
-#ifdef WITH_INKBOARD
- _act_grp->add(Gtk::Action::create("MenuWhiteboard", "Whiteboard"));
-#endif
_act_grp->add(Gtk::Action::create("MenuHelp", "Help"));
// File menu
Gtk::Stock::OPEN, Glib::ustring(),
_("PLACEHOLDER, do not translate")),
sigc::mem_fun(*this, &EditWidget::onActionFileOpen));
-
+/*
_act_grp->add(Gtk::Action::create("OpenRecent",
- Stock::OPEN_RECENT));
+ Stock::OPEN_RECENT));*/
_act_grp->add(Gtk::Action::create("Revert",
Gtk::Stock::REVERT_TO_SAVED, Glib::ustring(),
Gtk::Stock::SAVE_AS, Glib::ustring(),
_("PLACEHOLDER, do not translate")),
sigc::mem_fun(*this, &EditWidget::onActionFileOpen));
-
+/*
_act_grp->add(Gtk::Action::create("Import",
Stock::IMPORT, Glib::ustring(),
_("PLACEHOLDER, do not translate")),
_act_grp->add(Gtk::Action::create("Export",
Stock::EXPORT, Glib::ustring(),
_("PLACEHOLDER, do not translate")),
- sigc::mem_fun(*this, &EditWidget::onDialogExport));
+ sigc::mem_fun(*this, &EditWidget::onDialogExport));*/
_act_grp->add(Gtk::Action::create("Print",
Gtk::Stock::PRINT, Glib::ustring(),
_act_grp->add(Gtk::Action::create("PrintPreview",
Gtk::Stock::PRINT_PREVIEW),
sigc::mem_fun(*this, &EditWidget::onActionFileOpen));
-
+/*
_act_grp->add(Gtk::Action::create("VacuumDefs",
Stock::VACUUM_DEFS),
- sigc::mem_fun(*this, &EditWidget::onActionFileOpen));
+ sigc::mem_fun(*this, &EditWidget::onActionFileOpen));*/
_act_grp->add(Gtk::Action::create("DocumentProperties",
Gtk::Stock::PROPERTIES, Glib::ustring(),
_act_grp->add(Gtk::Action::create("Redo",
Gtk::Stock::REDO, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
+/*
+ _act_grp->add(Gtk::Action::create("UndoHistory",
+ Stock::UNDO_HISTORY, Glib::ustring(),
+ _("PLACEHOLDER, do not translate")));*/
_act_grp->add(Gtk::Action::create("Cut",
Gtk::Stock::CUT, Glib::ustring(),
_act_grp->add(Gtk::Action::create("Paste",
Gtk::Stock::PASTE, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
-
+/*
_act_grp->add(Gtk::Action::create("PasteInPlace",
Stock::PASTE_IN_PLACE));
_act_grp->add(Gtk::Action::create("PasteStyle",
- Stock::PASTE_STYLE));
+ Stock::PASTE_STYLE));*/
_act_grp->add(Gtk::Action::create("Find",
Gtk::Stock::FIND),
sigc::mem_fun(*this, &EditWidget::onDialogFind));
-
+/*
_act_grp->add(Gtk::Action::create("Duplicate",
Stock::DUPLICATE, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
Stock::OBJECT_PROPERTIES),
sigc::mem_fun(*this, &EditWidget::onDialogObjectProperties));
+ _act_grp->add(Gtk::Action::create("FilterEffects",
+ Stock::FILTER_EFFECTS));
+
_act_grp->add(Gtk::Action::create("Group",
Stock::GROUP, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
Stock::SIMPLIFY));
_act_grp->add(Gtk::Action::create("Reverse",
- Stock::REVERSE));
+ Stock::REVERSE));*/
_act_grp->add(Gtk::Action::create("Cleanup",
Gtk::Stock::CLEAR,
Gtk::Stock::SELECT_FONT, Glib::ustring(),
_("PLACEHOLDER, do not translate")),
sigc::mem_fun(*this, &EditWidget::onDialogTextProperties));
-
+/*
_act_grp->add(Gtk::Action::create("PutOnPath",
Stock::PUT_ON_PATH));
Stock::REMOVE_FROM_PATH));
_act_grp->add(Gtk::Action::create("RemoveManualKerns",
- Stock::REMOVE_MANUAL_KERNS));
+ Stock::REMOVE_MANUAL_KERNS));*/
// Whiteboard menu
#ifdef WITH_INKBOARD
- _act_grp->add(Gtk::Action::create("DialogWhiteboardConnect",
- Gtk::Stock::CLEAR, Glib::ustring(),
- _("PLACEHOLDER, do not translate")),
- sigc::mem_fun(*this, &EditWidget::onDialogWhiteboardConnect));
-
- _act_grp->add(Gtk::Action::create("DialogWhiteboardShareWithUser",
- Gtk::Stock::CLEAR, Glib::ustring(),
- _("PLACEHOLDER, do not translate")),
- sigc::mem_fun(*this, &EditWidget::onDialogWhiteboardShareWithUser));
-
- _act_grp->add(Gtk::Action::create("DialogWhiteboardShareWithChat",
- Gtk::Stock::CLEAR, Glib::ustring(),
- _("PLACEHOLDER, do not translate")),
- sigc::mem_fun(*this, &EditWidget::onDialogWhiteboardShareWithChat));
-
- _act_grp->add(Gtk::Action::create("WhiteboardOpenSessionFile",
- Gtk::Stock::CLEAR, Glib::ustring(),
- _("PLACEHOLDER, do not translate")),
- sigc::mem_fun(*this, &EditWidget::onDialogOpenSessionFile));
-
- _act_grp->add(Gtk::Action::create("WhiteboardDumpXMLTracker",
- Gtk::Stock::CLEAR, Glib::ustring(),
- _("PLACEHOLDER, do not translate")),
- sigc::mem_fun(*this, &EditWidget::onDumpXMLTracker));
#endif
// About menu
+/*
_act_grp->add(Gtk::Action::create("KeysAndMouse",
Stock::KEYS_MOUSE));
_act_grp->add(Gtk::Action::create("About",
Stock::ABOUT),
- sigc::mem_fun(*this, &EditWidget::onDialogAbout));
+ sigc::mem_fun(*this, &EditWidget::onDialogAbout));*/
}
void
EditWidget::initToolbarActions()
{
// Tools bar
+ // This has zero chance to work, and has to be converted to create_with_icon_name
Gtk::RadioAction::Group tools;
-
+/*
_act_grp->add(Gtk::RadioAction::create(tools, "ToolSelect",
Stock::TOOL_SELECT, Glib::ustring(),
_("PLACEHOLDER, do not translate")),
_act_grp->add(Gtk::ToggleAction::create("TransformPattern",
Stock::TRANSFORM_PATTERN, Glib::ustring(),
- _("PLACEHOLDER, do not translate")));
+ _("PLACEHOLDER, do not translate")));*/
// Node Controls bar
_act_grp->add(Gtk::Action::create("NodeInsert",
_act_grp->add(Gtk::Action::create("NodeDelete",
Gtk::Stock::REMOVE, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
-
+/*
_act_grp->add(Gtk::Action::create("NodeJoin",
Stock::NODE_JOIN, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
_act_grp->add(Gtk::Action::create("NodeCurve",
Stock::NODE_CURVE, Glib::ustring(),
- _("PLACEHOLDER, do not translate")));
+ _("PLACEHOLDER, do not translate")));*/
}
void
}
bool
-EditWidget::onEntryFocusIn (GdkEventFocus* ev)
+EditWidget::onEntryFocusIn (GdkEventFocus* /*ev*/)
{
Gdk::ModifierType m = static_cast<Gdk::ModifierType>(0);
Gtk::AccelMap::change_entry ("<Actions>//Zoom100", 0, m, false);
}
bool
-EditWidget::onEntryFocusOut (GdkEventFocus* ev)
+EditWidget::onEntryFocusOut (GdkEventFocus* /*ev*/)
{
Gdk::ModifierType m = static_cast<Gdk::ModifierType>(0);
Gtk::AccelMap::change_entry ("<Actions>//Zoom100", '1', m, false);
_uri_ctrl = new Gtk::Toolbar();
- _uri_label.set_label(_("PLACEHOLDER, DO NOT TRANSLATE"));
+ _uri_label.set_label(_("PLACEHOLDER, do not translate"));
_uri_ctrl->add(_uri_label);
_uri_ctrl->add(_uri_entry);
EditWidget::initTopRuler()
{
_viewport_table.attach(_top_ruler, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK);
-
+
_tooltips.set_tip (_top_ruler, _top_ruler.get_tip());
}
EditWidget::initLeftRuler()
{
_viewport_table.attach(_left_ruler, 0, 1, 1, 2, Gtk::SHRINK, Gtk::FILL|Gtk::EXPAND);
-
+
_tooltips.set_tip (_left_ruler, _left_ruler.get_tip());
}
_right_scrollbar.property_adjustment() = new Gtk::Adjustment (0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0);
}
-void
+void
EditWidget::initStickyZoom()
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_viewport_table.attach(_sticky_zoom, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-
- _sticky_zoom.set_active (prefs_get_int_attribute ("options.stickyzoom", "value", 0) != 0);
+ _sticky_zoom.set_active (prefs->getBool("/options/stickyzoom/value"));
_tooltips.set_tip (_sticky_zoom, _("Zoom drawing if window size changes"));
-
+
/// \todo icon not implemented
}
_layer_selector.reference();
_statusbar.pack_start (_layer_selector, false, false, 1);
- _coord_status.property_n_rows() = 2;
- _coord_status.property_n_columns() = 5;
+ _coord_status.property_n_rows() = 2;
+ _coord_status.property_n_columns() = 5;
_coord_status.property_row_spacing() = 0;
_coord_status.property_column_spacing() = 2;
_coord_eventbox.add (_coord_status);
_tooltips.set_tip (_coord_eventbox, _("Cursor coordinates"));
_coord_status.attach (*new Gtk::VSeparator(), 0,1, 0,2, Gtk::FILL,Gtk::FILL, 0,0);
- _coord_status.attach (*new Gtk::Label("X:", 0.0, 0.5), 1,2, 0,1, Gtk::FILL,Gtk::FILL, 0,0);
- _coord_status.attach (*new Gtk::Label("Y:", 0.0, 0.5), 1,2, 1,2, Gtk::FILL,Gtk::FILL, 0,0);
+ _coord_status.attach (*new Gtk::Label(_("X:"), 0.0, 0.5), 1,2, 0,1, Gtk::FILL,Gtk::FILL, 0,0);
+ _coord_status.attach (*new Gtk::Label(_("Y:"), 0.0, 0.5), 1,2, 1,2, Gtk::FILL,Gtk::FILL, 0,0);
_coord_status_x.set_text ("0.0");
_coord_status_x.set_alignment (0.0, 0.5);
_coord_status_y.set_text ("0.0");
_coord_status_y.set_alignment (0.0, 0.5);
_coord_status.attach (_coord_status_x, 2,3, 0,1, Gtk::FILL,Gtk::FILL, 0,0);
_coord_status.attach (_coord_status_y, 2,3, 1,2, Gtk::FILL,Gtk::FILL, 0,0);
- _coord_status.attach (*new Gtk::Label("Z:", 0.0, 0.5), 3,4, 0,2, Gtk::FILL,Gtk::FILL, 0,0);
+ _coord_status.attach (*new Gtk::Label(_("Z:"), 0.0, 0.5), 3,4, 0,2, Gtk::FILL,Gtk::FILL, 0,0);
_coord_status.attach (_zoom_status, 4,5, 0,2, Gtk::FILL,Gtk::FILL, 0,0);
sp_set_font_size_smaller (static_cast<GtkWidget*>((void*)_coord_status.gobj()));
_statusbar.pack_end (_coord_eventbox, false, false, 1);
_select_status.property_xalign() = 0.0;
_select_status.property_yalign() = 0.5;
- _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."));
+ _select_status.set_markup (_("<b>Welcome to Inkscape!</b> Use shape or drawing tools to create objects; use selector (arrow) to move or transform them."));
// include this again with Gtk+-2.6
#if GTK_VERSION_GE(2,6)
gtk_label_set_ellipsize (GTK_LABEL(_select_status.gobj()), PANGO_ELLIPSIZE_END);
#endif
_select_status.set_size_request (1, -1);
_statusbar.pack_start (_select_status, true, true, 0);
-
+
_main_window_table.attach(_statusbar, 0, 1, 3, 4, Gtk::FILL, Gtk::SHRINK);
}
//========================================
//----------implements EditWidgetInterface
-void *
-EditWidget::getWindow()
-{
- return this;
+Gtk::Window *
+EditWidget::getWindow()
+{
+ return this;
}
-void
-EditWidget::setTitle (gchar const* new_title)
+void
+EditWidget::setTitle (gchar const* new_title)
{
- set_title (new_title);
+ set_title (new_title);
}
-void
-EditWidget::layout()
+void
+EditWidget::layout()
{
show_all_children();
}
-void
-EditWidget::present()
+void
+EditWidget::present()
{
this->Gtk::Window::present();
}
-void
-EditWidget::getGeometry (gint &x, gint &y, gint &w, gint &h)
+void
+EditWidget::getGeometry (gint &x, gint &y, gint &w, gint &h)
{
get_position (x, y);
get_size (w, h);
}
-void
-EditWidget::setSize (gint w, gint h)
+void
+EditWidget::setSize (gint w, gint h)
{
resize (w, h);
}
-void
-EditWidget::setPosition (NR::Point p)
+void
+EditWidget::setPosition (Geom::Point p)
{
- move (int(p[NR::X]), int(p[NR::Y]));
+ move (int(p[Geom::X]), int(p[Geom::Y]));
}
/// \param p is already gobj()!
-void
-EditWidget::setTransient (void* p, int i)
+void
+EditWidget::setTransient (void* p, int i)
{
-#ifndef WIN32
gtk_window_set_transient_for (static_cast<GtkWindow*>(p), this->gobj());
if (i==2)
this->Gtk::Window::present();
-#endif
}
-NR::Point
-EditWidget::getPointer()
-{
+Geom::Point
+EditWidget::getPointer()
+{
int x, y;
get_pointer (x, y);
- return NR::Point (x, y);
+ return Geom::Point (x, y);
+}
+
+void
+EditWidget::setIconified()
+{
+ iconify();
}
-void
-EditWidget::setFullscreen()
+void
+EditWidget::setMaximized()
+{
+ maximize();
+}
+
+void
+EditWidget::setFullscreen()
{
fullscreen();
}
* to save, discard, or cancel. Returns TRUE if the shutdown operation
* is cancelled or if the save is cancelled or fails, FALSE otherwise.
*/
-bool
-EditWidget::shutdown()
+bool
+EditWidget::shutdown()
{
g_assert (_desktop != NULL);
if (Inkscape::NSApplication::Editor::isDuplicatedView (_desktop))
return false;
SPDocument *doc = _desktop->doc();
- if (sp_document_repr_root(doc)->attribute("sodipodi:modified") != NULL)
- {
+ if (doc->isModifiedSinceSave()) {
gchar *markup;
- /// \todo FIXME !!! obviously this will have problems if the document
+ /// \todo FIXME !!! obviously this will have problems if the document
/// name contains markup characters
markup = g_strdup_printf(
_("<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."),
SP_DOCUMENT_NAME(doc));
-
- Gtk::MessageDialog dlg (*this,
+
+ Gtk::MessageDialog dlg (*this,
markup,
true,
Gtk::MESSAGE_WARNING,
dlg.set_default_response (Gtk::RESPONSE_YES);
int response = dlg.run();
- switch (response)
+ switch (response)
{
case Gtk::RESPONSE_YES:
sp_document_ref(doc);
- if (sp_file_save_document(doc)) {
+ sp_namedview_document_from_window(_desktop);
+ if (sp_file_save_document(*this, doc)) {
sp_document_unref(doc);
} else { // save dialog cancelled or save failed
sp_document_unref(doc);
/* Code to check data loss */
bool allow_data_loss = FALSE;
- while (sp_document_repr_root(doc)->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE)
+ while (sp_document_repr_root(doc)->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE)
{
gchar *markup;
- /// \todo FIXME !!! obviously this will have problems if the document
+ /// \todo FIXME !!! obviously this will have problems if the document
/// name contains markup characters
markup = g_strdup_printf(
_("<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?"),
+ "Do you want to save this file as an Inkscape SVG?"),
SP_DOCUMENT_NAME(doc),
Inkscape::Extension::db.get(sp_document_repr_root(doc)->attribute("inkscape:output_extension"))->get_name());
-
- Gtk::MessageDialog dlg (*this,
+
+ Gtk::MessageDialog dlg (*this,
markup,
true,
Gtk::MESSAGE_WARNING,
Gtk::Button close_button (_("Close _without saving"), true);
dlg.add_action_widget (close_button, Gtk::RESPONSE_NO);
close_button.show();
+ Gtk::Button save_button (_("_Save as SVG"), true);
dlg.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- dlg.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_YES);
+ dlg.add_action_widget (save_button, Gtk::RESPONSE_YES);
+ save_button.show();
dlg.set_default_response (Gtk::RESPONSE_YES);
int response = dlg.run();
-
- switch (response)
+
+ switch (response)
{
case Gtk::RESPONSE_YES:
sp_document_ref(doc);
- if (sp_file_save_document(doc)) {
+ if (sp_file_save_document(*this, doc)) {
sp_document_unref(doc);
} else { // save dialog cancelled or save failed
sp_document_unref(doc);
break;
}
}
-
+
return false;
}
-void
-EditWidget::destroy()
-{
- delete this;
+void
+EditWidget::destroy()
+{
+ delete this;
}
-void
-EditWidget::requestCanvasUpdate()
+void
+EditWidget::requestCanvasUpdate()
{
_svg_canvas.widget().queue_draw();
}
-void
-EditWidget::activateDesktop()
+void
+EditWidget::requestCanvasUpdateAndWait()
{
- /// \todo active_desktop_indicator not implemented
+ requestCanvasUpdate();
+
+ while (gtk_events_pending())
+ gtk_main_iteration_do(FALSE);
+}
+
+void
+EditWidget::enableInteraction()
+{
+ g_return_if_fail(_interaction_disabled_counter > 0);
+
+ _interaction_disabled_counter--;
+
+ if (_interaction_disabled_counter == 0) {
+ this->set_sensitive(true);
+ }
+}
+
+void
+EditWidget::disableInteraction()
+{
+ if (_interaction_disabled_counter == 0) {
+ this->set_sensitive(false);
+ }
+
+ _interaction_disabled_counter++;
+}
+
+void
+EditWidget::activateDesktop()
+{
+ /// \todo active_desktop_indicator not implemented
}
-void
-EditWidget::deactivateDesktop()
+void
+EditWidget::deactivateDesktop()
{
/// \todo active_desktop_indicator not implemented
}
-void
-EditWidget::viewSetPosition (NR::Point p)
+void
+EditWidget::viewSetPosition (Geom::Point p)
{
- p -= _namedview->gridorigin;
+ // p -= _namedview->gridorigin;
+ /// \todo Why was the origin corrected for the grid origin? (johan)
+
double lo, up, pos, max;
_top_ruler.get_range (lo, up, pos, max);
- _top_ruler.set_range (lo, up, p[NR::X], max);
+ _top_ruler.set_range (lo, up, p[Geom::X], max);
_left_ruler.get_range (lo, up, pos, max);
- _left_ruler.set_range (lo, up, p[NR::Y], max);
+ _left_ruler.set_range (lo, up, p[Geom::Y], max);
}
-void
-EditWidget::updateRulers()
-{
- NR::Point origin = _namedview->gridorigin;
+void
+EditWidget::updateRulers()
+{
+ //Geom::Point gridorigin = _namedview->gridorigin;
+ /// \todo Why was the origin corrected for the grid origin? (johan)
- NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
+ Geom::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
double lo, up, pos, max;
double const scale = _desktop->current_zoom();
- double s = viewbox.min()[NR::X] / scale - origin[NR::X];
- double e = viewbox.max()[NR::X] / scale - origin[NR::X];
+ double s = viewbox.min()[Geom::X] / scale; //- gridorigin[Geom::X];
+ double e = viewbox.max()[Geom::X] / scale; //- gridorigin[Geom::X];
_top_ruler.get_range(lo, up, pos, max);
_top_ruler.set_range(s, e, pos, e);
- s = viewbox.min()[NR::Y] / -scale - origin[NR::Y];
- e = viewbox.max()[NR::Y] / -scale - origin[NR::Y];
- _left_ruler.set_range(s, e, origin[NR::Y], e);
+ s = viewbox.min()[Geom::Y] / -scale; //- gridorigin[Geom::Y];
+ e = viewbox.max()[Geom::Y] / -scale; //- gridorigin[Geom::Y];
+ _left_ruler.set_range(s, e, 0 /*gridorigin[Geom::Y]*/, e);
/// \todo is that correct?
}
-void
-EditWidget::updateScrollbars (double scale)
+void
+EditWidget::updateScrollbars (double scale)
{
// do not call this function before canvas has its size allocated
if (!is_realized() || _update_s_f) {
/* The desktop region we always show unconditionally */
SPDocument *doc = _desktop->doc();
- NR::Rect const r = sp_item_bbox_desktop(SP_ITEM(SP_DOCUMENT_ROOT(doc)));
- NR::Rect darea(NR::Point(MIN(r.min()[NR::X], -sp_document_width(doc)),
- MIN(r.min()[NR::Y], -sp_document_height(doc))),
- NR::Point(MAX(r.max()[NR::X], 2 * sp_document_width(doc)),
- MAX(r.max()[NR::Y], 2 * sp_document_height(doc))));
+ Geom::Rect darea ( Geom::Point(-sp_document_width(doc), -sp_document_height(doc)),
+ Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc)) );
+ SPObject* root = doc->root;
+ SPItem* item = SP_ITEM(root);
+ Geom::OptRect deskarea = Geom::unify(darea, sp_item_bbox_desktop(item));
/* Canvas region we always show unconditionally */
- NR::Rect carea(NR::Point(darea.min()[NR::X] * scale - 64,
- darea.max()[NR::Y] * -scale - 64),
- NR::Point(darea.max()[NR::X] * scale + 64,
- darea.min()[NR::Y] * -scale + 64));
+ Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64),
+ Geom::Point(deskarea->max()[Geom::X] * scale + 64, deskarea->min()[Geom::Y] * -scale + 64) );
- NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
+ Geom::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
/* Viewbox is always included into scrollable region */
- carea = NR::Rect::union_bounds(carea, viewbox);
+ carea = Geom::unify(carea, viewbox);
Gtk::Adjustment *adj = _bottom_scrollbar.get_adjustment();
- adj->set_value(viewbox.min()[NR::X]);
- adj->set_lower(carea.min()[NR::X]);
- adj->set_upper(carea.max()[NR::X]);
- adj->set_page_increment(viewbox.dimensions()[NR::X]);
- adj->set_step_increment(0.1 * (viewbox.dimensions()[NR::X]));
- adj->set_page_size(viewbox.dimensions()[NR::X]);
+ adj->set_value(viewbox.min()[Geom::X]);
+ adj->set_lower(carea.min()[Geom::X]);
+ adj->set_upper(carea.max()[Geom::X]);
+ adj->set_page_increment(viewbox.dimensions()[Geom::X]);
+ adj->set_step_increment(0.1 * (viewbox.dimensions()[Geom::X]));
+ adj->set_page_size(viewbox.dimensions()[Geom::X]);
adj = _right_scrollbar.get_adjustment();
- adj->set_value(viewbox.min()[NR::Y]);
- adj->set_lower(carea.min()[NR::Y]);
- adj->set_upper(carea.max()[NR::Y]);
- adj->set_page_increment(viewbox.dimensions()[NR::Y]);
- adj->set_step_increment(0.1 * viewbox.dimensions()[NR::Y]);
- adj->set_page_size(viewbox.dimensions()[NR::Y]);
+ adj->set_value(viewbox.min()[Geom::Y]);
+ adj->set_lower(carea.min()[Geom::Y]);
+ adj->set_upper(carea.max()[Geom::Y]);
+ adj->set_page_increment(viewbox.dimensions()[Geom::Y]);
+ adj->set_step_increment(0.1 * viewbox.dimensions()[Geom::Y]);
+ adj->set_page_size(viewbox.dimensions()[Geom::Y]);
_update_s_f = false;
}
void
-EditWidget::toggleRulers()
+EditWidget::toggleRulers()
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (_top_ruler.is_visible())
{
_top_ruler.hide_all();
_left_ruler.hide_all();
- prefs_set_int_attribute (_desktop->is_fullscreen ? "fullscreen.rulers" : "window.rulers", "state", 0);
+ prefs->setBool(_desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", false);
} else {
_top_ruler.show_all();
_left_ruler.show_all();
- prefs_set_int_attribute (_desktop->is_fullscreen ? "fullscreen.rulers" : "window.rulers", "state", 1);
+ prefs->setBool(_desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", true);
}
}
-void
-EditWidget::toggleScrollbars()
+void
+EditWidget::toggleScrollbars()
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (_bottom_scrollbar.is_visible())
{
_bottom_scrollbar.hide_all();
_right_scrollbar.hide_all();
- prefs_set_int_attribute (_desktop->is_fullscreen ? "fullscreen.scrollbars" : "window.scrollbars", "state", 0);
+ prefs->setBool(_desktop->is_fullscreen() ? "/fullscreen/scrollbars/state" : "/window/scrollbars/state", false);
} else {
_bottom_scrollbar.show_all();
_right_scrollbar.show_all();
- prefs_set_int_attribute (_desktop->is_fullscreen ? "fullscreen.scrollbars" : "window.scrollbars", "state", 1);
+ prefs->setBool(_desktop->is_fullscreen() ? "/fullscreen/scrollbars/state" : "/window/scrollbars/state", true);
}
}
-void
-EditWidget::updateZoom()
+void EditWidget::toggleColorProfAdjust()
+{
+ // TODO implement
+}
+
+void
+EditWidget::updateZoom()
{
_zoom_status.update();
}
-void
-EditWidget::letZoomGrabFocus()
+void
+EditWidget::letZoomGrabFocus()
{
_zoom_status.grab_focus();
}
-void
+void
EditWidget::setToolboxFocusTo (const gchar *)
{
/// \todo not implemented
}
-void
+void
EditWidget::setToolboxAdjustmentValue (const gchar *, double)
{
/// \todo not implemented
}
-bool
+void
+EditWidget::setToolboxSelectOneValue (const gchar *, gint)
+{
+ /// \todo not implemented
+}
+
+bool
EditWidget::isToolboxButtonActive (gchar const*)
{
/// \todo not implemented
return true;
}
-void
-EditWidget::setCoordinateStatus (NR::Point p)
+void
+EditWidget::setCoordinateStatus (Geom::Point p)
{
- gchar *cstr = g_strdup_printf ("%6.2f", _dt2r * p[NR::X]);
+ gchar *cstr = g_strdup_printf ("%6.2f", _dt2r * p[Geom::X]);
_coord_status_x.property_label() = cstr;
g_free (cstr);
- cstr = g_strdup_printf ("%6.2f", _dt2r * p[NR::Y]);
+ cstr = g_strdup_printf ("%6.2f", _dt2r * p[Geom::Y]);
_coord_status_y.property_label() = cstr;
g_free (cstr);
}
-void
-EditWidget::setMessage (Inkscape::MessageType type, gchar const* msg)
+void
+EditWidget::setMessage (Inkscape::MessageType /*type*/, gchar const* msg)
{
_select_status.set_markup (msg? msg : "");
}
-bool
+bool
EditWidget::warnDialog (gchar* msg)
{
- Gtk::MessageDialog dlg (*this,
+ Gtk::MessageDialog dlg (*this,
msg,
true,
Gtk::MESSAGE_WARNING,
}
-void
+Inkscape::UI::Widget::Dock*
+EditWidget::getDock ()
+{
+ return &_dock;
+}
+
+void EditWidget::_namedview_modified (SPObject *obj, guint flags) {
+ SPNamedView *nv = static_cast<SPNamedView *>(obj);
+ if (flags & SP_OBJECT_MODIFIED_FLAG) {
+ this->_dt2r = 1.0 / nv->doc_units->unittobase;
+ this->_top_ruler.update_metric();
+ this->_left_ruler.update_metric();
+ this->_tooltips.set_tip(this->_top_ruler, this->_top_ruler.get_tip());
+ this->_tooltips.set_tip(this->_left_ruler, this->_left_ruler.get_tip());
+ this->updateRulers();
+ }
+}
+
+void
EditWidget::initEdit (SPDocument *doc)
{
_desktop = new SPDesktop();
_svg_canvas.init (_desktop);
_desktop->init (_namedview, _svg_canvas.spobj());
sp_namedview_window_from_document (_desktop);
+ sp_namedview_update_layers_from_document (_desktop);
_dt2r = 1.0 / _namedview->doc_units->unittobase;
/// \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);
+ _namedview_modified_connection = _desktop->namedview->connectModified(sigc::mem_fun(*this, &EditWidget::_namedview_modified));
_layer_selector.setDesktop (_desktop);
_selected_style_status.setDesktop (_desktop);
-
+
Inkscape::NSApplication::Editor::addDesktop (_desktop);
_zoom_status.init (_desktop);
updateRulers();
}
-void
+void
EditWidget::destroyEdit()
{
if (_desktop) {
_layer_selector.unreference();
Inkscape::NSApplication::Editor::removeDesktop (_desktop); // clears selection too
- sp_signal_disconnect_by_data (G_OBJECT (_desktop->namedview), this);
+ _namedview_modified_connection.disconnect();
_desktop->destroy();
Inkscape::GC::release (_desktop);
_desktop = 0;
//----------start of other callbacks
-bool
+bool
EditWidget::on_key_press_event (GdkEventKey* event)
{
// this is the original code from helper/window.cpp
SP_SHORTCUT_CONTROL_MASK : 0 ) |
( event->state & GDK_MOD1_MASK ?
SP_SHORTCUT_ALT_MASK : 0 );
- return sp_shortcut_invoke (shortcut,
+ return sp_shortcut_invoke (shortcut,
Inkscape::NSApplication::Editor::getActiveDesktop());
}
-bool
+bool
EditWidget::on_delete_event (GdkEventAny*)
{
return shutdown();
}
-bool
+bool
EditWidget::on_focus_in_event (GdkEventFocus*)
{
Inkscape::NSApplication::Editor::activateDesktop (_desktop);
EditWidget::onWindowSizeAllocate (Gtk::Allocation &newall)
{
if (!is_realized()) return;
-
+
const Gtk::Allocation& all = get_allocation();
if ((newall.get_x() == all.get_x()) &&
(newall.get_y() == all.get_y()) &&
return;
}
- NR::Rect const area = _desktop->get_display_area();
+ Geom::Rect const area = _desktop->get_display_area();
double zoom = _desktop->current_zoom();
if (_sticky_zoom.get_active()) {
/* Calculate zoom per pixel */
- double const zpsp = zoom / hypot(area.dimensions()[NR::X], area.dimensions()[NR::Y]);
+ double const zpsp = zoom / hypot(area.dimensions()[Geom::X], area.dimensions()[Geom::Y]);
/* Find new visible area */
- NR::Rect const newarea = _desktop->get_display_area();
+ Geom::Rect const newarea = _desktop->get_display_area();
/* Calculate adjusted zoom */
- zoom = zpsp * hypot(newarea.dimensions()[NR::X], newarea.dimensions()[NR::Y]);
+ zoom = zpsp * hypot(newarea.dimensions()[Geom::X], newarea.dimensions()[Geom::Y]);
}
- _desktop->zoom_absolute(area.midpoint()[NR::X], area.midpoint()[NR::Y], zoom);
+ _desktop->zoom_absolute(area.midpoint()[Geom::X], area.midpoint()[Geom::Y], zoom);
}
void
EditWidget::onWindowRealize()
{
- NR::Rect d(NR::Point(0, 0),
- NR::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc())));
- if (fabs(d.dimensions()[NR::X]) < 1.0 || fabs(d.dimensions()[NR::Y]) < 1.0) {
+ if ( (sp_document_width(_desktop->doc()) < 1.0) || (sp_document_height(_desktop->doc()) < 1.0) ) {
return;
}
- _desktop->set_display_area(d.min()[NR::X], d.min()[NR::Y], d.max()[NR::X], d.max()[NR::Y], 10);
- _namedview_modified(_desktop->namedview, SP_OBJECT_MODIFIED_FLAG, this);
+ Geom::Rect d( Geom::Point(0, 0),
+ Geom::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc())) );
+
+ _desktop->set_display_area(d.min()[Geom::X], d.min()[Geom::Y], d.max()[Geom::X], d.max()[Geom::Y], 10);
+ _namedview_modified(_desktop->namedview, SP_OBJECT_MODIFIED_FLAG);
setTitle (SP_DOCUMENT_NAME(_desktop->doc()));
}
{
if (_update_a_f) return;
_update_a_f = true;
-
- sp_canvas_scroll_to (_svg_canvas.spobj(),
- _bottom_scrollbar.get_value(),
- _right_scrollbar.get_value(),
+
+ sp_canvas_scroll_to (_svg_canvas.spobj(),
+ _bottom_scrollbar.get_value(),
+ _right_scrollbar.get_value(),
false);
updateRulers();
-
+
_update_a_f = false;
}
-/// \todo make this a member function when the signal is a sigc++ signal
-void _namedview_modified (SPNamedView* nv, guint flags, EditWidget* ew)
-{
- if (flags & SP_OBJECT_MODIFIED_FLAG)
- {
- ew->_dt2r = 1.0 / nv->doc_units->unittobase;
- ew->_top_ruler.update_metric();
- ew->_left_ruler.update_metric();
- ew->_tooltips.set_tip (ew->_top_ruler, ew->_top_ruler.get_tip());
- ew->_tooltips.set_tip (ew->_left_ruler, ew->_left_ruler.get_tip());
- ew->updateRulers();
- }
-}
} // namespace View
} // namespace UI