summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/object-attributes.cpp1
-rw-r--r--src/ui/dialog/object-properties.cpp73
-rw-r--r--src/ui/dialog/object-properties.h8
-rw-r--r--src/ui/interface.cpp3
4 files changed, 79 insertions, 6 deletions
diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp
index ec3ce1b71..6801afa9c 100644
--- a/src/ui/dialog/object-attributes.cpp
+++ b/src/ui/dialog/object-attributes.cpp
@@ -67,7 +67,6 @@ static const SPAttrDesc image_desc[] = {
{ N_("Y:"), "y"},
{ N_("Width:"), "width"},
{ N_("Height:"), "height"},
- { N_("Image Rendering:"), "image-rendering"},
{ nullptr, nullptr}
};
diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp
index 8daa83e9c..849ffae0a 100644
--- a/src/ui/dialog/object-properties.cpp
+++ b/src/ui/dialog/object-properties.cpp
@@ -48,14 +48,16 @@ namespace Dialog {
ObjectProperties::ObjectProperties()
: UI::Widget::Panel("/dialogs/object/", SP_VERB_DIALOG_ITEM)
- , _blocked (false)
+ , _blocked(false)
, _current_item(nullptr)
, _label_id(_("_ID:"), true)
, _label_label(_("_Label:"), true)
, _label_title(_("_Title:"), true)
+ , _label_dpi(_("_DPI SVG:"), true)
, _label_image_rendering(_("_Image Rendering:"), true)
, _cb_hide(_("_Hide"), true)
, _cb_lock(_("L_ock"), true)
+ , _cb_aspect_ratio(_("Pereserve Ratio"), true)
, _attr_table(Gtk::manage(new SPAttributeTable()))
, _desktop(nullptr)
{
@@ -185,12 +187,28 @@ void ObjectProperties::_init()
_ft_description.add(_tv_description);
_tv_description.add_mnemonic_label(*label_desc);
+ /* Create the label for the object title */
+ _label_dpi.set_label(_label_dpi.get_label() + " ");
+ _label_dpi.set_halign(Gtk::ALIGN_END);
+ _label_dpi.set_valign(Gtk::ALIGN_CENTER);
+ grid_top->attach(_label_dpi, 0, 3, 1, 1);
+
+ /* Create the entry box for the SVG DPI */
+ _spin_dpi.set_digits(2);
+ _spin_dpi.set_range(1, 1200);
+ grid_top->attach(_spin_dpi, 1, 3, 1, 1);
+
+ _label_dpi.set_mnemonic_widget(_spin_dpi);
+ // pressing enter in the label field is the same as clicking Set:
+ _spin_dpi.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged));
+
+
/* Image rendering */
/* Create the label for the object ImageRendering */
_label_image_rendering.set_label(_label_image_rendering.get_label() + " ");
_label_image_rendering.set_halign(Gtk::ALIGN_END);
_label_image_rendering.set_valign(Gtk::ALIGN_CENTER);
- grid_top->attach(_label_image_rendering, 0, 3, 1, 1);
+ grid_top->attach(_label_image_rendering, 0, 4, 1, 1);
/* Create the combo box text for the 'image-rendering' property */
_combo_image_rendering.append( "auto" );
@@ -199,7 +217,7 @@ void ObjectProperties::_init()
_combo_image_rendering.set_tooltip_text(_("The 'image-rendering' property can influence how a bitmap is up-scaled:\n\t'auto' no preference;\n\t'optimizeQuality' smooth;\n\t'optimizeSpeed' blocky.\nNote that this behaviour is not defined in the SVG 1.1 specification and not all browsers follow this interpretation."));
_combo_image_rendering.set_valign(Gtk::ALIGN_CENTER);
- grid_top->attach(_combo_image_rendering, 1, 3, 1, 1);
+ grid_top->attach(_combo_image_rendering, 1, 4, 1, 1);
_label_image_rendering.set_mnemonic_widget(_combo_image_rendering);
@@ -207,6 +225,8 @@ void ObjectProperties::_init()
sigc::mem_fun(this, &ObjectProperties::_imageRenderingChanged)
);
+
+
/* Check boxes */
Gtk::HBox *hb_checkboxes = Gtk::manage(new Gtk::HBox());
contents->pack_start(*hb_checkboxes, FALSE, FALSE, 0);
@@ -235,12 +255,20 @@ void ObjectProperties::_init()
_cb_lock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_sensitivityToggled));
+ /* Preserve aspect ratio */
+ _cb_aspect_ratio.set_tooltip_text(_("Check to preserve aspect ratio on images"));
+ _cb_aspect_ratio.set_hexpand();
+ _cb_aspect_ratio.set_valign(Gtk::ALIGN_CENTER);
+ grid_cb->attach(_cb_aspect_ratio, 0, 1, 1, 1);
+
+ _cb_aspect_ratio.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_aspectRatioToggled));
+
/* Button for setting the object's id, label, title and description. */
Gtk::Button *btn_set = Gtk::manage(new Gtk::Button(_("_Set"), true));
btn_set->set_hexpand();
btn_set->set_valign(Gtk::ALIGN_CENTER);
- grid_cb->attach(*btn_set, 2, 0, 1, 1);
+ grid_cb->attach(*btn_set, 1, 1, 1, 1);
btn_set->signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged));
@@ -284,7 +312,7 @@ void ObjectProperties::update()
return;
}
_blocked = true;
-
+ _cb_aspect_ratio.set_active(item->getAttribute("preserveAspectRatio") == "true");
_cb_lock.set_active(item->isLocked()); /* Sensitive */
_cb_hide.set_active(item->isExplicitlyHidden()); /* Hidden */
@@ -409,6 +437,13 @@ void ObjectProperties::_labelChanged()
_("Set object title"));
}
+ /* Retrieve the DPI */
+ if (SP_IS_IMAGE(obj)) {
+ Glib::ustring dpi_value = Glib::ustring::format(_spin_dpi.get_value());
+ obj->setAttribute("inkscape:svg-dpi", dpi_value);
+ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set image DPI"));
+ }
+
/* Retrieve the description */
Gtk::TextBuffer::iterator start, end;
_tv_description.get_buffer()->get_bounds(start, end);
@@ -464,6 +499,34 @@ void ObjectProperties::_sensitivityToggled()
_blocked = false;
}
+void ObjectProperties::_aspectRatioToggled()
+{
+ if (_blocked) {
+ return;
+ }
+
+ SPItem *item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
+ g_return_if_fail(item != nullptr);
+
+ _blocked = true;
+
+ item->setLocked(_cb_aspect_ratio.get_active());
+ const char *active;
+ if (_cb_aspect_ratio.get_active()) {
+ active = "true";
+ }
+ else {
+ active = "none";
+ }
+ /* Retrieve the DPI */
+ if (SP_IS_IMAGE(item)) {
+ Glib::ustring dpi_value = Glib::ustring::format(_spin_dpi.get_value());
+ item->setAttribute("preserveAspectRatio", active);
+ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set preserve ratio"));
+ }
+ _blocked = false;
+}
+
void ObjectProperties::_hiddenToggled()
{
if (_blocked) {
diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h
index 4ce72ae1a..f603219c4 100644
--- a/src/ui/dialog/object-properties.h
+++ b/src/ui/dialog/object-properties.h
@@ -40,6 +40,7 @@
#include <gtkmm/entry.h>
#include <gtkmm/expander.h>
#include <gtkmm/frame.h>
+#include <gtkmm/spinbutton.h>
#include <gtkmm/textview.h>
#include <gtkmm/comboboxtext.h>
@@ -85,6 +86,7 @@ private:
Gtk::Entry _entry_label; //the entry for the object label
Gtk::Label _label_title; //the label for the object title
Gtk::Entry _entry_title; //the entry for the object title
+
Gtk::Label _label_image_rendering; // the label for 'image-rendering'
Gtk::ComboBoxText _combo_image_rendering; // the combo box text for 'image-rendering'
@@ -93,7 +95,10 @@ private:
Gtk::CheckButton _cb_hide; //the check button hide
Gtk::CheckButton _cb_lock; //the check button lock
+ Gtk::CheckButton _cb_aspect_ratio; //the preserve aspect ratio of images
+ Gtk::Label _label_dpi; //the entry for the dpi value
+ Gtk::SpinButton _spin_dpi; //the expander for interactivity
Gtk::Expander _exp_interactivity; //the expander for interactivity
SPAttributeTable *_attr_table; //the widget for showing the on... names at the bottom
@@ -118,6 +123,9 @@ private:
/// Callback for checkbox Hide.
void _hiddenToggled();
+ /// Callback for checkbox Preserve Aspect Ratio.
+ void _aspectRatioToggled();
+
/// Can be invoked for setting the desktop. Currently not used.
void _setDesktop(SPDesktop *desktop);
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 5f9a402f1..b19b10221 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -750,6 +750,8 @@ static void
sp_recent_open(GtkRecentChooser *recent_menu, gpointer /*user_data*/)
{
// dealing with the bizarre filename convention in Inkscape for now
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("/options/openmethod/value", "open");
gchar *uri = gtk_recent_chooser_get_current_uri(GTK_RECENT_CHOOSER(recent_menu));
gchar *local_fn = g_filename_from_uri(uri, nullptr, nullptr);
gchar *utf8_fn = g_filename_to_utf8(local_fn, -1, nullptr, nullptr, nullptr);
@@ -757,6 +759,7 @@ sp_recent_open(GtkRecentChooser *recent_menu, gpointer /*user_data*/)
g_free(utf8_fn);
g_free(local_fn);
g_free(uri);
+ prefs->setString("/options/openmethod/value", "done");
}
static void