index 67091fc40c6e19e6ee831f9efccce084fc5aa008..756f4df73a72f0f6d651a5296e97ca0982a627c0 100644 (file)
#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"
g_warning("Creating new EditWidget");
_desktop = 0;
- Icons::init();
- Stock::init();
initActions();
initAccelMap();
initUIManager();
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")));
-// _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"));
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")));
+ _("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::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
#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
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
_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);
{
case Gtk::RESPONSE_YES:
sp_document_ref(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
{
requestCanvasUpdate();
- while (gtk_events_pending())
+ while (gtk_events_pending())
gtk_main_iteration_do(FALSE);
}
EditWidget::enableInteraction()
{
g_return_if_fail(_interaction_disabled_counter > 0);
-
+
_interaction_disabled_counter--;
-
+
if (_interaction_disabled_counter == 0) {
this->set_sensitive(true);
}
if (_interaction_disabled_counter == 0) {
this->set_sensitive(false);
}
-
+
_interaction_disabled_counter++;
}
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[Geom::X], max);
{
//Geom::Point gridorigin = _namedview->gridorigin;
/// \todo Why was the origin corrected for the grid origin? (johan)
-
+
Geom::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
double lo, up, pos, max;
double const scale = _desktop->current_zoom();
Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc)) );
SPObject* root = doc->root;
SPItem* item = SP_ITEM(root);
- boost::optional<Geom::Rect> deskarea = Geom::unify(darea, sp_item_bbox_desktop(item));
+ Geom::OptRect deskarea = Geom::unify(darea, sp_item_bbox_desktop(item));
/* Canvas region we always show unconditionally */
Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64),
void
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()
{
+ 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::onWindowRealize()
{
- NR::Rect d(Geom::Point(0, 0),
- Geom::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc())));
- if (d.isEmpty(1.0)) {
+ if ( (sp_document_width(_desktop->doc()) < 1.0) || (sp_document_height(_desktop->doc()) < 1.0) ) {
return;
}
+ 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()));