diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-03-16 23:57:40 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-03-16 23:57:40 +0000 |
| commit | aec329617cf6f1aa3654d49150a9df4383d42dd8 (patch) | |
| tree | d7989e206b9df2dc56c82a74dbff8876be8e4d59 /src | |
| parent | Fix to solve static var in isBSpline function (diff) | |
| parent | Fix header and copyright licence (diff) | |
| download | inkscape-aec329617cf6f1aa3654d49150a9df4383d42dd8.tar.gz inkscape-aec329617cf6f1aa3654d49150a9df4383d42dd8.zip | |
update to trunk
(bzr r11950.1.299)
Diffstat (limited to 'src')
| -rw-r--r-- | src/file.cpp | 23 | ||||
| -rw-r--r-- | src/helper/pixbuf-ops.cpp | 3 | ||||
| -rw-r--r-- | src/preferences.cpp | 25 | ||||
| -rw-r--r-- | src/preferences.h | 2 | ||||
| -rw-r--r-- | src/style.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/object-properties.cpp | 553 | ||||
| -rw-r--r-- | src/ui/dialog/object-properties.h | 126 | ||||
| -rw-r--r-- | src/ui/dialog/xml-tree.cpp | 3 |
8 files changed, 347 insertions, 390 deletions
diff --git a/src/file.cpp b/src/file.cpp index 35039fed3..51e629c7d 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -690,7 +690,7 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); return FALSE; } catch (Inkscape::Extension::Output::no_overwrite &e) { - return sp_file_save_dialog(parentWindow, doc, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS); + return sp_file_save_dialog(parentWindow, doc, save_method); } catch (...) { SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); return FALSE; @@ -855,7 +855,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens int i = 1; if ( !doc->getURI() ) { // We are saving for the first time; create a unique default filename - save_loc = save_loc + Glib::ustring(_("drawing")) + filename_extension; + save_loc = save_loc + _("drawing") + filename_extension; while (Inkscape::IO::file_test(save_loc.c_str(), G_FILE_TEST_EXISTS)) { save_loc = save_path; @@ -922,9 +922,9 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens Inkscape::Extension::Output *omod = dynamic_cast<Inkscape::Extension::Output *>(selectionType); if (omod) { - Glib::ustring save_extension = (std::string)omod->get_extension(); - if ( !hasEnding(fileName, save_extension.c_str()) ) { - fileName += save_extension.c_str(); + Glib::ustring save_extension = (omod->get_extension()) ? (omod->get_extension()) : ""; + if ( !hasEnding(fileName, save_extension) ) { + fileName += save_extension; } } @@ -1385,8 +1385,6 @@ sp_file_export_dialog(Gtk::Window &parentWindow) if (doc->uri == NULL) { - char formatBuf[256]; - Glib::ustring filename_extension = ".svg"; extension = dynamic_cast<Inkscape::Extension::Output *> (Inkscape::Extension::db.get(default_extension.c_str())); @@ -1400,15 +1398,12 @@ sp_file_export_dialog(Gtk::Window &parentWindow) if (!Inkscape::IO::file_test(export_path.c_str(), (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) - export_path = ""; + export_path = Glib::ustring(""); - if (export_path.size()<1) + if (export_path.empty()) export_path = g_get_home_dir(); - export_loc = export_path; - export_loc.append(G_DIR_SEPARATOR_S); - snprintf(formatBuf, 255, _("drawing%s"), filename_extension.c_str()); - export_loc.append(formatBuf); + export_loc = export_path + G_DIR_SEPARATOR_S + _("drawing") + filename_extension; } else @@ -1420,7 +1415,7 @@ sp_file_export_dialog(Gtk::Window &parentWindow) // is this needed any more, now that everything is handled in // Inkscape::IO? Glib::ustring export_path_local = Glib::filename_from_utf8(export_path); - if ( export_path_local.size() > 0) + if (!export_path_local.empty()) export_path = export_path_local; //# Show the Export dialog diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 1ba6628c5..d44b2207b 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -75,8 +75,7 @@ bool sp_export_jpg_file(SPDocument *doc, gchar const *filename, gchar c[32]; g_snprintf(c, 32, "%f", quality); gboolean saved = gdk_pixbuf_save(pixbuf->getPixbufRaw(), filename, "jpeg", NULL, "quality", c, NULL); - g_free(c); - + return saved; } diff --git a/src/preferences.cpp b/src/preferences.cpp index b4b873dc8..2fec3b307 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -438,9 +438,7 @@ void Preferences::setBool(Glib::ustring const &pref_path, bool value) */ void Preferences::setInt(Glib::ustring const &pref_path, int value) { - gchar intstr[32]; - g_snprintf(intstr, 32, "%d", value); - _setRawValue(pref_path, intstr); + _setRawValue(pref_path, Glib::ustring::compose("%1",value)); } /** @@ -451,9 +449,7 @@ void Preferences::setInt(Glib::ustring const &pref_path, int value) */ void Preferences::setDouble(Glib::ustring const &pref_path, double value) { - gchar buf[G_ASCII_DTOSTR_BUF_SIZE]; - g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value); - _setRawValue(pref_path, buf); + _setRawValue(pref_path, Glib::ustring::compose("%1",value)); } /** @@ -465,11 +461,8 @@ void Preferences::setDouble(Glib::ustring const &pref_path, double value) */ void Preferences::setDoubleUnit(Glib::ustring const &pref_path, double value, Glib::ustring const &unit_abbr) { - gchar buf[G_ASCII_DTOSTR_BUF_SIZE]; - g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value); - Glib::ustring str(buf); - str += unit_abbr; - _setRawValue(pref_path, str.c_str()); + Glib::ustring str = Glib::ustring::compose("%1%2",value,unit_abbr); + _setRawValue(pref_path, str); } void Preferences::setColor(Glib::ustring const &pref_path, guint32 value) @@ -487,14 +480,14 @@ void Preferences::setColor(Glib::ustring const &pref_path, guint32 value) */ void Preferences::setString(Glib::ustring const &pref_path, Glib::ustring const &value) { - _setRawValue(pref_path, value.c_str()); + _setRawValue(pref_path, value); } void Preferences::setStyle(Glib::ustring const &pref_path, SPCSSAttr *style) { Glib::ustring css_str; sp_repr_css_write_string(style, css_str); - _setRawValue(pref_path, css_str.c_str()); + _setRawValue(pref_path, css_str); } void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style) @@ -503,7 +496,7 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style) sp_repr_css_merge(current, style); Glib::ustring css_str; sp_repr_css_write_string(current, css_str); - _setRawValue(pref_path, css_str.c_str()); + _setRawValue(pref_path, css_str); sp_repr_css_attr_unref(current); } @@ -738,7 +731,7 @@ void Preferences::_getRawValue(Glib::ustring const &path, gchar const *&result) } } -void Preferences::_setRawValue(Glib::ustring const &path, gchar const *value) +void Preferences::_setRawValue(Glib::ustring const &path, Glib::ustring const &value) { // create node and attribute keys Glib::ustring node_key, attr_key; @@ -746,7 +739,7 @@ void Preferences::_setRawValue(Glib::ustring const &path, gchar const *value) // set the attribute Inkscape::XML::Node *node = _getNode(node_key, true); - node->setAttribute(attr_key.c_str(), value); + node->setAttribute(attr_key.c_str(), value.c_str()); } // The _extract* methods are where the actual wrok is done - they define how preferences are stored diff --git a/src/preferences.h b/src/preferences.h index 66fa11542..d5429815e 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -532,7 +532,7 @@ private: void _loadDefaults(); void _load(); void _getRawValue(Glib::ustring const &path, gchar const *&result); - void _setRawValue(Glib::ustring const &path, gchar const *value); + void _setRawValue(Glib::ustring const &path, Glib::ustring const &value); void _reportError(Glib::ustring const &, Glib::ustring const &); void _keySplit(Glib::ustring const &pref_path, Glib::ustring &node_key, Glib::ustring &attr_key); XML::Node *_getNode(Glib::ustring const &pref_path, bool create=false); diff --git a/src/style.cpp b/src/style.cpp index 132972164..c57cf6349 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -4373,7 +4373,7 @@ sp_style_write_ilengthornormal(gchar *p, gint const len, gchar const *const key, * Write SPIDashArray object into string. */ static gint -sp_style_write_idasharray(gchar *p, gint const len, gchar const *const key, +sp_style_write_idasharray(gchar *p, gint const len, gchar const *const /*key*/, SPIDashArray const *const val, SPIDashArray const *const base, guint const flags) { if ((flags & SP_STYLE_FLAG_ALWAYS) diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index 82b2cf6b1..28e9b360b 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -28,9 +28,9 @@ #include "object-properties.h" #include "widgets/sp-attribute-widget.h" -#include "../../desktop-handles.h" -#include "../../document.h" -#include "../../document-undo.h" +#include "desktop-handles.h" +#include "document.h" +#include "document-undo.h" #include "verbs.h" #include "inkscape.h" #include "selection.h" @@ -51,481 +51,479 @@ namespace Inkscape { namespace UI { namespace Dialog { -ObjectProperties::ObjectProperties (void) : - UI::Widget::Panel ("", "/dialogs/object/", SP_VERB_DIALOG_ITEM), - blocked (false), - CurrentItem(NULL), -#if WITH_GTKMM_3_0 - TopTable(Gtk::manage(new Gtk::Grid())), -#else - TopTable(Gtk::manage(new Gtk::Table(4, 4))), -#endif - LabelID(_("_ID:"), 1), - LabelLabel(_("_Label:"), 1), - LabelTitle(_("_Title:"),1), - LabelImageRendering(_("_Image Rendering:"),1), - LabelDescription(_("_Description:"),1), - FrameDescription("", FALSE), - HBoxCheck(FALSE, 0), -#if WITH_GTKMM_3_0 - CheckTable(Gtk::manage(new Gtk::Grid())), -#else - CheckTable(Gtk::manage(new Gtk::Table(1, 2, true))), -#endif - CBHide(_("_Hide"), 1), - CBLock(_("L_ock"), 1), - BSet (_("_Set"), 1), - LabelInteractivity(_("_Interactivity"), 1), - attrTable(Gtk::manage(new SPAttributeTable())), - desktop(NULL), - deskTrack(), - selectChangedConn(), - subselChangedConn() +ObjectProperties::ObjectProperties() + : UI::Widget::Panel ("", "/dialogs/object/", SP_VERB_DIALOG_ITEM) + , _blocked (false) + , _current_item(NULL) + , _label_id(_("_ID:"), 1) + , _label_label(_("_Label:"), 1) + , _label_title(_("_Title:"), 1) + , _label_image_rendering(_("_Image Rendering:"), 1) + , _cb_hide(_("_Hide"), 1) + , _cb_lock(_("L_ock"), 1) + , _attr_table(Gtk::manage(new SPAttributeTable())) + , _desktop(NULL) { //initialize labels for the table at the bottom of the dialog - int_attrs.push_back("onclick"); - int_attrs.push_back("onmouseover"); - int_attrs.push_back("onmouseout"); - int_attrs.push_back("onmousedown"); - int_attrs.push_back("onmouseup"); - int_attrs.push_back("onmousemove"); - int_attrs.push_back("onfocusin"); - int_attrs.push_back("onfocusout"); - int_attrs.push_back("onload"); - - int_labels.push_back("onclick:"); - int_labels.push_back("onmouseover:"); - int_labels.push_back("onmouseout:"); - int_labels.push_back("onmousedown:"); - int_labels.push_back("onmouseup:"); - int_labels.push_back("onmousemove:"); - int_labels.push_back("onfocusin:"); - int_labels.push_back("onfocusout:"); - int_labels.push_back("onload:"); - - desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &ObjectProperties::setTargetDesktop) ); - deskTrack.connect(GTK_WIDGET(gobj())); - -#if WITH_GTKMM_3_0 - CheckTable->set_row_homogeneous(); - CheckTable->set_column_homogeneous(true); -#endif - - MakeWidget(); + _int_attrs.push_back("onclick"); + _int_attrs.push_back("onmouseover"); + _int_attrs.push_back("onmouseout"); + _int_attrs.push_back("onmousedown"); + _int_attrs.push_back("onmouseup"); + _int_attrs.push_back("onmousemove"); + _int_attrs.push_back("onfocusin"); + _int_attrs.push_back("onfocusout"); + _int_attrs.push_back("onload"); + + _int_labels.push_back("onclick:"); + _int_labels.push_back("onmouseover:"); + _int_labels.push_back("onmouseout:"); + _int_labels.push_back("onmousedown:"); + _int_labels.push_back("onmouseup:"); + _int_labels.push_back("onmousemove:"); + _int_labels.push_back("onfocusin:"); + _int_labels.push_back("onfocusout:"); + _int_labels.push_back("onload:"); + + _desktop_changed_connection = _desktop_tracker.connectDesktopChanged( + sigc::mem_fun(*this, &ObjectProperties::_setTargetDesktop) + ); + _desktop_tracker.connect(GTK_WIDGET(gobj())); + + _init(); } -ObjectProperties::~ObjectProperties (void) +ObjectProperties::~ObjectProperties() { - subselChangedConn.disconnect(); - selectChangedConn.disconnect(); - desktopChangeConn.disconnect(); - deskTrack.disconnect(); + _subselection_changed_connection.disconnect(); + _selection_changed_connection.disconnect(); + _desktop_changed_connection.disconnect(); + _desktop_tracker.disconnect(); } -void ObjectProperties::MakeWidget(void) +void ObjectProperties::_init() { Gtk::Box *contents = _getContents(); contents->set_spacing(0); - - TopTable->set_border_width(4); #if WITH_GTKMM_3_0 - TopTable->set_row_spacing(4); - TopTable->set_column_spacing(0); + Gtk::Grid *grid_top = Gtk::manage(new Gtk::Grid()); + grid_top->set_row_spacing(4); + grid_top->set_column_spacing(0); #else - TopTable->set_row_spacings(4); - TopTable->set_col_spacings(0); + Gtk::Table *grid_top = Gtk::manage(new Gtk::Table(4, 4)); + grid_top->set_row_spacings(4); + grid_top->set_col_spacings(0); #endif - contents->pack_start (*TopTable, false, false, 0); + grid_top->set_border_width(4); + + contents->pack_start(*grid_top, false, false, 0); + /* Create the label for the object id */ - LabelID.set_label (LabelID.get_label() + " "); - LabelID.set_alignment (1, 0.5); + _label_id.set_label(_label_id.get_label() + " "); + _label_id.set_alignment(1, 0.5); #if WITH_GTKMM_3_0 - LabelID.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(LabelID, 0, 0, 1, 1); + _label_id.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_label_id, 0, 0, 1, 1); #else - TopTable->attach(LabelID, 0, 1, 0, 1, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); + grid_top->attach(_label_id, 0, 1, 0, 1, + Gtk::SHRINK | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); #endif + /* Create the entry box for the object id */ - EntryID.set_tooltip_text (_("The id= attribute (only letters, digits, and the characters .-_: allowed)")); - EntryID.set_max_length (64); + _entry_id.set_tooltip_text(_("The id= attribute (only letters, digits, and the characters .-_: allowed)")); + _entry_id.set_max_length(64); #if WITH_GTKMM_3_0 - EntryID.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(EntryID, 1, 0, 1, 1); + _entry_id.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_entry_id, 1, 0, 1, 1); #else - TopTable->attach(EntryID, 1, 2, 0, 1, + grid_top->attach(_entry_id, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - LabelID.set_mnemonic_widget (EntryID); + _label_id.set_mnemonic_widget(_entry_id); // pressing enter in the id field is the same as clicking Set: - EntryID.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); + _entry_id.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); // focus is in the id field initially: - EntryID.grab_focus(); + _entry_id.grab_focus(); + /* Create the label for the object label */ - LabelLabel.set_label (LabelLabel.get_label() + " "); - LabelLabel.set_alignment (1, 0.5); + _label_label.set_label(_label_label.get_label() + " "); + _label_label.set_alignment(1, 0.5); #if WITH_GTKMM_3_0 - LabelLabel.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(LabelLabel, 0, 1, 1, 1); + _label_label.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_label_label, 0, 1, 1, 1); #else - TopTable->attach(LabelLabel, 0, 1, 1, 2, + grid_top->attach(_label_label, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif + /* Create the entry box for the object label */ - EntryLabel.set_tooltip_text (_("A freeform label for the object")); - EntryLabel.set_max_length (256); + _entry_label.set_tooltip_text(_("A freeform label for the object")); + _entry_label.set_max_length(256); #if WITH_GTKMM_3_0 - EntryLabel.set_hexpand(); - EntryLabel.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(EntryLabel, 1, 1, 1, 1); + _entry_label.set_hexpand(); + _entry_label.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_entry_label, 1, 1, 1, 1); #else - TopTable->attach(EntryLabel, 1, 2, 1, 2, + grid_top->attach(_entry_label, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - LabelLabel.set_mnemonic_widget (EntryLabel); + _label_label.set_mnemonic_widget(_entry_label); // pressing enter in the label field is the same as clicking Set: - EntryLabel.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); + _entry_label.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); + /* Create the label for the object title */ - LabelTitle.set_label (LabelTitle.get_label() + " "); - LabelTitle.set_alignment (1, 0.5); + _label_title.set_label(_label_title.get_label() + " "); + _label_title.set_alignment (1, 0.5); #if WITH_GTKMM_3_0 - LabelTitle.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(LabelTitle, 0, 2, 1, 1); + _label_title.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_label_title, 0, 2, 1, 1); #else - TopTable->attach(LabelTitle, 0, 1, 2, 3, + grid_top->attach(_label_title, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif /* Create the entry box for the object title */ - EntryTitle.set_sensitive (FALSE); - EntryTitle.set_max_length (256); + _entry_title.set_sensitive (FALSE); + _entry_title.set_max_length (256); #if WITH_GTKMM_3_0 - EntryTitle.set_hexpand(); - EntryTitle.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(EntryTitle, 1, 2, 1, 1); + _entry_title.set_hexpand(); + _entry_title.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_entry_title, 1, 2, 1, 1); #else - TopTable->attach(EntryTitle, 1, 2, 2, 3, + grid_top->attach(_entry_title, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - LabelTitle.set_mnemonic_widget (EntryTitle); + _label_title.set_mnemonic_widget(_entry_title); // pressing enter in the label field is the same as clicking Set: - EntryTitle.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); + _entry_title.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); /* Create the frame for the object description */ - FrameDescription.set_label_widget (LabelDescription); - FrameDescription.set_padding (0,0,0,0); - contents->pack_start (FrameDescription, true, true, 0); + Gtk::Label *label_desc = Gtk::manage(new Gtk::Label(_("_Description:"), 1)); + UI::Widget::Frame *frame_desc = Gtk::manage(new UI::Widget::Frame("", FALSE)); + frame_desc->set_label_widget(*label_desc); + frame_desc->set_padding (0,0,0,0); + contents->pack_start(*frame_desc, true, true, 0); /* Create the text view box for the object description */ - FrameTextDescription.set_border_width(4); - FrameTextDescription.set_sensitive (FALSE); - FrameDescription.add (FrameTextDescription); - FrameTextDescription.set_shadow_type (Gtk::SHADOW_IN); + _ft_description.set_border_width(4); + _ft_description.set_sensitive(FALSE); + frame_desc->add(_ft_description); + _ft_description.set_shadow_type(Gtk::SHADOW_IN); - TextViewDescription.set_wrap_mode(Gtk::WRAP_WORD); - TextViewDescription.get_buffer()->set_text(""); - FrameTextDescription.add (TextViewDescription); - TextViewDescription.add_mnemonic_label(LabelDescription); + _tv_description.set_wrap_mode(Gtk::WRAP_WORD); + _tv_description.get_buffer()->set_text(""); + _ft_description.add(_tv_description); + _tv_description.add_mnemonic_label(*label_desc); /* Image rendering */ /* Create the label for the object ImageRendering */ - LabelImageRendering.set_label (LabelImageRendering.get_label() + " "); - LabelImageRendering.set_alignment (1, 0.5); + _label_image_rendering.set_label(_label_image_rendering.get_label() + " "); + _label_image_rendering.set_alignment(1, 0.5); #if WITH_GTKMM_3_0 - LabelImageRendering.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(LabelImageRendering, 0, 3, 1, 1); + _label_image_rendering.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_label_image_rendering, 0, 3, 1, 1); #else - TopTable->attach(LabelImageRendering, 0, 1, 3, 4, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); + grid_top->attach(_label_image_rendering, 0, 1, 3, 4, + Gtk::SHRINK | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); #endif /* Create the combo box text for the 'image-rendering' property */ - ComboBoxTextImageRendering.append( "auto" ); - ComboBoxTextImageRendering.append( "optimizeQuality" ); - ComboBoxTextImageRendering.append( "optimizeSpeed" ); - ComboBoxTextImageRendering.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.append( "auto" ); + _combo_image_rendering.append( "optimizeQuality" ); + _combo_image_rendering.append( "optimizeSpeed" ); + _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.")); #if WITH_GTKMM_3_0 - ComboBoxTextImageRendering.set_valign(Gtk::ALIGN_CENTER); - TopTable->attach(ComboBoxTextImageRendering, 1, 3, 1, 1); + _combo_image_rendering.set_valign(Gtk::ALIGN_CENTER); + grid_top->attach(_combo_image_rendering, 1, 3, 1, 1); #else - TopTable->attach(ComboBoxTextImageRendering, 1, 2, 3, 4, + grid_top->attach(_combo_image_rendering, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - LabelImageRendering.set_mnemonic_widget (ComboBoxTextImageRendering); + _label_image_rendering.set_mnemonic_widget(_combo_image_rendering); - ComboBoxTextImageRendering.signal_changed().connect(sigc::mem_fun(this, &ObjectProperties::image_rendering_changed)); + _combo_image_rendering.signal_changed().connect( + sigc::mem_fun(this, &ObjectProperties::_imageRenderingChanged) + ); /* Check boxes */ - contents->pack_start (HBoxCheck, FALSE, FALSE, 0); - CheckTable->set_border_width(4); - HBoxCheck.pack_start(*CheckTable, true, true, 0); + Gtk::HBox *hb_checkboxes = Gtk::manage(new Gtk::HBox()); + contents->pack_start(*hb_checkboxes, FALSE, FALSE, 0); + +#if WITH_GTKMM_3_0 + Gtk::Grid *grid_cb = Gtk::manage(new Gtk::Grid()); + grid_cb->set_row_homogeneous(); + grid_cb->set_column_homogeneous(true); +#else + Gtk::Table *grid_cb = Gtk::manage(new Gtk::Table(1, 2, true)); +#endif + + grid_cb->set_border_width(4); + hb_checkboxes->pack_start(*grid_cb, true, true, 0); /* Hide */ - CBHide.set_tooltip_text (_("Check to make the object invisible")); + _cb_hide.set_tooltip_text (_("Check to make the object invisible")); #if WITH_GTKMM_3_0 - CBHide.set_hexpand(); - CBHide.set_valign(Gtk::ALIGN_CENTER); - CheckTable->attach(CBHide, 0, 0, 1, 1); + _cb_hide.set_hexpand(); + _cb_hide.set_valign(Gtk::ALIGN_CENTER); + grid_cb->attach(_cb_hide, 0, 0, 1, 1); #else - CheckTable->attach(CBHide, 0, 1, 0, 1, + grid_cb->attach(_cb_hide, 0, 1, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); #endif - CBHide.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::hidden_toggled)); + _cb_hide.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_hiddenToggled)); /* Lock */ // TRANSLATORS: "Lock" is a verb here - CBLock.set_tooltip_text (_("Check to make the object insensitive (not selectable by mouse)")); + _cb_lock.set_tooltip_text(_("Check to make the object insensitive (not selectable by mouse)")); #if WITH_GTKMM_3_0 - CBLock.set_hexpand(); - CBLock.set_valign(Gtk::ALIGN_CENTER); - CheckTable->attach(CBLock, 1, 0, 1, 1); + _cb_lock.set_hexpand(); + _cb_lock.set_valign(Gtk::ALIGN_CENTER); + grid_cb->attach(_cb_lock, 1, 0, 1, 1); #else - CheckTable->attach(CBLock, 1, 2, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); + grid_cb->attach(_cb_lock, 1, 2, 0, 1, + Gtk::EXPAND | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); #endif - CBLock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::sensitivity_toggled)); + _cb_lock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_sensitivityToggled)); /* Button for setting the object's id, label, title and description. */ + Gtk::Button *btn_set = Gtk::manage(new Gtk::Button(_("_Set"), 1)); #if WITH_GTKMM_3_0 - BSet.set_hexpand(); - BSet.set_valign(Gtk::ALIGN_CENTER); - CheckTable->attach(BSet, 2, 0, 1, 1); + btn_set->set_hexpand(); + btn_set->set_valign(Gtk::ALIGN_CENTER); + grid_cb->attach(*btn_set, 2, 0, 1, 1); #else - CheckTable->attach(BSet, 2, 3, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); + grid_cb->attach(*btn_set, 2, 3, 0, 1, + Gtk::EXPAND | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); #endif - BSet.signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); + btn_set->signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); /* Create the frame for interactivity options */ - EInteractivity.set_label_widget (LabelInteractivity); - contents->pack_start (EInteractivity, FALSE, FALSE, 0); - show_all (); - widget_setup(); + Gtk::Label *label_interactivity = Gtk::manage(new Gtk::Label(_("_Interactivity"), 1)); + _exp_interactivity.set_label_widget(*label_interactivity); + contents->pack_start(_exp_interactivity, FALSE, FALSE, 0); + + show_all(); + update(); } -void ObjectProperties::widget_setup(void) +void ObjectProperties::update() { - if (blocked || !desktop) - { + if (_blocked || !_desktop) { return; } - if (SP_ACTIVE_DESKTOP != desktop) - { + if (SP_ACTIVE_DESKTOP != _desktop) { return; } - Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP); + Inkscape::Selection *selection = sp_desktop_selection(SP_ACTIVE_DESKTOP); Gtk::Box *contents = _getContents(); if (!selection->singleItem()) { contents->set_sensitive (false); - CurrentItem = NULL; + _current_item = NULL; //no selection anymore or multiple objects selected, means that we need //to close the connections to the previously selected object - attrTable->clear(); + _attr_table->clear(); return; } else { contents->set_sensitive (true); } SPItem *item = selection->singleItem(); - if (CurrentItem == item) + if (_current_item == item) { //otherwise we would end up wasting resources through the modify selection - //callback when moving an object (endlessly setting the labels and recreating attrTable) + //callback when moving an object (endlessly setting the labels and recreating _attr_table) return; } - blocked = true; + _blocked = true; - CBLock.set_active (item->isLocked()); /* Sensitive */ - CBHide.set_active (item->isExplicitlyHidden()); /* Hidden */ + _cb_lock.set_active(item->isLocked()); /* Sensitive */ + _cb_hide.set_active(item->isExplicitlyHidden()); /* Hidden */ if (item->cloned) { /* ID */ - EntryID.set_text (""); - EntryID.set_sensitive (FALSE); - LabelID.set_text (_("Ref")); + _entry_id.set_text(""); + _entry_id.set_sensitive(FALSE); + _label_id.set_text(_("Ref")); /* Label */ - EntryLabel.set_text (""); - EntryLabel.set_sensitive (FALSE); - LabelLabel.set_text (_("Ref")); + _entry_label.set_text(""); + _entry_label.set_sensitive(FALSE); + _label_label.set_text(_("Ref")); } else { SPObject *obj = static_cast<SPObject*>(item); /* ID */ - EntryID.set_text (obj->getId()); - EntryID.set_sensitive (TRUE); - LabelID.set_markup_with_mnemonic (_("_ID:")); + _entry_id.set_text(obj->getId()); + _entry_id.set_sensitive(TRUE); + _label_id.set_markup_with_mnemonic(_("_ID:") + Glib::ustring(" ")); /* Label */ - EntryLabel.set_text(obj->defaultLabel()); - EntryLabel.set_sensitive (TRUE); + _entry_label.set_text(obj->defaultLabel()); + _entry_label.set_sensitive(TRUE); /* Title */ gchar *title = obj->title(); if (title) { - EntryTitle.set_text(title); + _entry_title.set_text(title); g_free(title); } else { - EntryTitle.set_text(""); + _entry_title.set_text(""); } - EntryTitle.set_sensitive(TRUE); + _entry_title.set_sensitive(TRUE); /* Image Rendering */ - if( SP_IS_IMAGE( item ) ) { - ComboBoxTextImageRendering.show(); - LabelImageRendering.show(); + if (SP_IS_IMAGE(item)) { + _combo_image_rendering.show(); + _label_image_rendering.show(); char const *str = obj->getStyleProperty( "image-rendering", "auto" ); - if( strcmp( str, "auto" ) == 0 ) { - ComboBoxTextImageRendering.set_active(0); - } else if( strcmp( str, "optimizeQuality" ) == 0 ) { - ComboBoxTextImageRendering.set_active(1); - } else { - ComboBoxTextImageRendering.set_active(2); + if (strcmp( str, "auto" ) == 0) { + _combo_image_rendering.set_active(0); + } else if (strcmp(str, "optimizeQuality") == 0) { + _combo_image_rendering.set_active(1); + } else { + _combo_image_rendering.set_active(2); } } else { - ComboBoxTextImageRendering.hide(); - ComboBoxTextImageRendering.unset_active(); - LabelImageRendering.hide(); + _combo_image_rendering.hide(); + _combo_image_rendering.unset_active(); + _label_image_rendering.hide(); } /* Description */ gchar *desc = obj->desc(); if (desc) { - TextViewDescription.get_buffer()->set_text(desc); + _tv_description.get_buffer()->set_text(desc); g_free(desc); } else { - TextViewDescription.get_buffer()->set_text(""); + _tv_description.get_buffer()->set_text(""); } - FrameTextDescription.set_sensitive(TRUE); + _ft_description.set_sensitive(TRUE); - if (CurrentItem == NULL) - { - attrTable->set_object(obj, int_labels, int_attrs, (GtkWidget*)EInteractivity.gobj()); - } - else - { - attrTable->change_object(obj); + if (_current_item == NULL) { + _attr_table->set_object(obj, _int_labels, _int_attrs, (GtkWidget*) _exp_interactivity.gobj()); + } else { + _attr_table->change_object(obj); } - attrTable->show_all(); + _attr_table->show_all(); } - CurrentItem = item; - blocked = false; + _current_item = item; + _blocked = false; } -void ObjectProperties::label_changed(void) +void ObjectProperties::_labelChanged() { - if (blocked) - { + if (_blocked) { return; } SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); g_return_if_fail (item != NULL); - blocked = true; + _blocked = true; /* Retrieve the label widget for the object's id */ - gchar *id = g_strdup(EntryID.get_text().c_str()); - g_strcanon (id, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:", '_'); - if (!strcmp (id, item->getId())) { - LabelID.set_markup_with_mnemonic(_("_ID:")); + gchar *id = g_strdup(_entry_id.get_text().c_str()); + g_strcanon(id, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:", '_'); + if (strcmp(id, item->getId()) == 0) { + _label_id.set_markup_with_mnemonic(_("_ID:")); } else if (!*id || !isalnum (*id)) { - LabelID.set_text (_("Id invalid! ")); + _label_id.set_text(_("Id invalid! ")); } else if (SP_ACTIVE_DOCUMENT->getObjectById(id) != NULL) { - LabelID.set_text (_("Id exists! ")); + _label_id.set_text(_("Id exists! ")); } else { SPException ex; - LabelID.set_markup_with_mnemonic(_("_ID:")); - SP_EXCEPTION_INIT (&ex); + _label_id.set_markup_with_mnemonic(_("_ID:")); + SP_EXCEPTION_INIT(&ex); item->setAttribute("id", id, &ex); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object ID")); } - g_free (id); + g_free(id); /* Retrieve the label widget for the object's label */ - Glib::ustring label = EntryLabel.get_text(); + Glib::ustring label = _entry_label.get_text(); /* Give feedback on success of setting the drawing object's label * using the widget's label text */ SPObject *obj = static_cast<SPObject*>(item); - if (label.compare (obj->defaultLabel())) { + if (label.compare(obj->defaultLabel())) { obj->setLabel(label.c_str()); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object label")); } /* Retrieve the title */ - if (obj->setTitle(EntryTitle.get_text().c_str())) + if (obj->setTitle(_entry_title.get_text().c_str())) { DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object title")); + } /* Retrieve the description */ Gtk::TextBuffer::iterator start, end; - TextViewDescription.get_buffer()->get_bounds(start, end); - Glib::ustring desc = TextViewDescription.get_buffer()->get_text(start, end, TRUE); - if (obj->setDesc(desc.c_str())) + _tv_description.get_buffer()->get_bounds(start, end); + Glib::ustring desc = _tv_description.get_buffer()->get_text(start, end, TRUE); + if (obj->setDesc(desc.c_str())) { DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object description")); + } - blocked = false; + _blocked = false; } -void ObjectProperties::image_rendering_changed(void) +void ObjectProperties::_imageRenderingChanged() { - if (blocked) - { + if (_blocked) { return; } SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); g_return_if_fail (item != NULL); - blocked = true; + _blocked = true; - Glib::ustring scale = ComboBoxTextImageRendering.get_active_text(); + Glib::ustring scale = _combo_image_rendering.get_active_text(); // We should unset if the parent computed value is auto and the desired value is auto. SPCSSAttr *css = sp_repr_css_attr_new(); @@ -536,64 +534,67 @@ void ObjectProperties::image_rendering_changed(void) } sp_repr_css_attr_unref( css ); - blocked = false; + _blocked = false; } -void ObjectProperties::sensitivity_toggled (void) +void ObjectProperties::_sensitivityToggled() { - if (blocked) - { + if (_blocked) { return; } SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); - g_return_if_fail (item != NULL); + g_return_if_fail(item != NULL); - blocked = true; - item->setLocked(CBLock.get_active()); + _blocked = true; + item->setLocked(_cb_lock.get_active()); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - CBLock.get_active()? _("Lock object") : _("Unlock object")); - blocked = false; + _cb_lock.get_active() ? _("Lock object") : _("Unlock object")); + _blocked = false; } -void ObjectProperties::hidden_toggled(void) +void ObjectProperties::_hiddenToggled() { - if (blocked) - { + if (_blocked) { return; } SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); - g_return_if_fail (item != NULL); + g_return_if_fail(item != NULL); - blocked = true; - item->setExplicitlyHidden(CBHide.get_active()); + _blocked = true; + item->setExplicitlyHidden(_cb_hide.get_active()); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - CBHide.get_active()? _("Hide object") : _("Unhide object")); - blocked = false; + _cb_hide.get_active() ? _("Hide object") : _("Unhide object")); + _blocked = false; } -void ObjectProperties::setDesktop(SPDesktop *desktop) +void ObjectProperties::_setDesktop(SPDesktop *desktop) { Panel::setDesktop(desktop); - deskTrack.setBase(desktop); + _desktop_tracker.setBase(desktop); } -void ObjectProperties::setTargetDesktop(SPDesktop *desktop) +void ObjectProperties::_setTargetDesktop(SPDesktop *desktop) { - if (this->desktop != desktop) { - if (this->desktop) { - subselChangedConn.disconnect(); - selectChangedConn.disconnect(); + if (this->_desktop != desktop) { + if (this->_desktop) { + _subselection_changed_connection.disconnect(); + _selection_changed_connection.disconnect(); } - this->desktop = desktop; + this->_desktop = desktop; if (desktop && desktop->selection) { - selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &ObjectProperties::widget_setup))); - subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &ObjectProperties::widget_setup))); + _selection_changed_connection = desktop->selection->connectChanged( + sigc::hide(sigc::mem_fun(*this, &ObjectProperties::update)) + ); + _subselection_changed_connection = desktop->connectToolSubselectionChanged( + sigc::hide(sigc::mem_fun(*this, &ObjectProperties::update)) + ); } - widget_setup(); + update(); } } + } } } diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h index 721c12c56..093f273f6 100644 --- a/src/ui/dialog/object-properties.h +++ b/src/ui/dialog/object-properties.h @@ -69,98 +69,64 @@ namespace Dialog { */ class ObjectProperties : public Widget::Panel { public: - ObjectProperties (); - ~ObjectProperties (); + ObjectProperties(); + ~ObjectProperties(); static ObjectProperties &getInstance() { return *new ObjectProperties(); } - /** - * Updates entries and other child widgets on selection change, object modification, etc. - */ - void widget_setup(void); + /// Updates entries and other child widgets on selection change, object modification, etc. + void update(); private: - bool blocked; - SPItem *CurrentItem; //to store the current item, for not wasting resources - std::vector<Glib::ustring> int_attrs; - std::vector<Glib::ustring> int_labels; + bool _blocked; + SPItem *_current_item; //to store the current item, for not wasting resources + std::vector<Glib::ustring> _int_attrs; + std::vector<Glib::ustring> _int_labels; + + Gtk::Label _label_id; //the label for the object ID + Gtk::Entry _entry_id; //the entry for the object ID + Gtk::Label _label_label; //the label for the object label + 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' -#if WITH_GTKMM_3_0 - Gtk::Grid *TopTable; //the table with the object properties -#else - Gtk::Table *TopTable; //the table with the object properties -#endif + Gtk::Frame _ft_description; //the frame for the text of the object description + Gtk::TextView _tv_description; //the text view object showing the object description - Gtk::Label LabelID; //the label for the object ID - Gtk::Entry EntryID; //the entry for the object ID - Gtk::Label LabelLabel; //the label for the object label - Gtk::Entry EntryLabel; //the entry for the object label - Gtk::Label LabelTitle; //the label for the object title - Gtk::Entry EntryTitle; //the entry for the object title - Gtk::Label LabelImageRendering; // the label for 'image-rendering' - Gtk::ComboBoxText ComboBoxTextImageRendering; // the combo box text for 'image-rendering' + Gtk::CheckButton _cb_hide; //the check button hide + Gtk::CheckButton _cb_lock; //the check button lock + + Gtk::Expander _exp_interactivity; //the expander for interactivity + SPAttributeTable *_attr_table; //the widget for showing the on... names at the bottom - Gtk::Label LabelDescription; //the label for the object description - UI::Widget::Frame FrameDescription; //the frame for the object description - Gtk::Frame FrameTextDescription; //the frame for the text of the object description - Gtk::TextView TextViewDescription; //the text view object showing the object description + SPDesktop *_desktop; + DesktopTracker _desktop_tracker; + sigc::connection _desktop_changed_connection; + sigc::connection _selection_changed_connection; + sigc::connection _subselection_changed_connection; - Gtk::HBox HBoxCheck; // the HBox for the check boxes + /// Constructor auxiliary function creating the child widgets. + void _init(); -#if WITH_GTKMM_3_0 - Gtk::Grid *CheckTable; //the table for the check boxes -#else - Gtk::Table *CheckTable; //the table for the check boxes -#endif + /// Sets object properties (ID, label, title, description) on user input. + void _labelChanged(); - Gtk::CheckButton CBHide; //the check button hide - Gtk::CheckButton CBLock; //the check button lock - Gtk::Button BSet; //the button set - - Gtk::Label LabelInteractivity; //the label for interactivity - Gtk::Expander EInteractivity; //the label for interactivity - SPAttributeTable *attrTable; //the widget for showing the on... names at the bottom - - SPDesktop *desktop; - DesktopTracker deskTrack; - sigc::connection desktopChangeConn; - sigc::connection selectChangedConn; - sigc::connection subselChangedConn; - - /** - * Constructor auxiliary function creating the child widgets. - */ - void MakeWidget(void); - - /** - * Sets object properties (ID, label, title, description) on user input. - */ - void label_changed(void); - - /** - * Callback for 'image-rendering'. - */ - void image_rendering_changed(void); - - /** - * Callback for checkbox Lock. - */ - void sensitivity_toggled (void); - - /** - * Callback for checkbox Hide. - */ - void hidden_toggled(void); - - /** - * Can be invoked for setting the desktop. Currently not used. - */ - void setDesktop(SPDesktop *desktop); + /// Callback for 'image-rendering'. + void _imageRenderingChanged(); + + /// Callback for checkbox Lock. + void _sensitivityToggled(); + + /// Callback for checkbox Hide. + void _hiddenToggled(); + + /// Can be invoked for setting the desktop. Currently not used. + void _setDesktop(SPDesktop *desktop); - /** - * Is invoked by the desktop tracker when the desktop changes. - */ - void setTargetDesktop(SPDesktop *desktop); + /// Is invoked by the desktop tracker when the desktop changes. + void _setTargetDesktop(SPDesktop *desktop); }; } diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 0e1e9f7a6..55d0aff09 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -100,6 +100,9 @@ XmlTree::XmlTree (void) : status.set_alignment( 0.0, 0.5); status.set_size_request(1, -1); status.set_markup(""); +#if WITH_GTKMM_3_0 + status.set_line_wrap(true); +#endif status_box.pack_start( status, TRUE, TRUE, 0); contents->pack_end(status_box, false, false, 2); |
