summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2012-10-25 08:17:43 +0000
committer~suv <suv-sf@users.sourceforge.net>2012-10-25 08:17:43 +0000
commit537f0c2aeef6659f6ecda13f111f6d2031f3fe85 (patch)
treeb67b484a53b2919f2fe81aa1ebb8094ca325d01c /src
parentchanges_2012_10_22b.patch, changes_2012_10_24a.patch (diff)
parentBuild. Cleaning build.xml. (diff)
downloadinkscape-537f0c2aeef6659f6ecda13f111f6d2031f3fe85.tar.gz
inkscape-537f0c2aeef6659f6ecda13f111f6d2031f3fe85.zip
merge from trunk (r11826)
(bzr r11668.1.35)
Diffstat (limited to 'src')
-rw-r--r--src/pixmaps/cursor-adj-a.xpm38
-rw-r--r--src/ui/dialog/layers.cpp52
-rw-r--r--src/ui/dialog/layers.h9
-rw-r--r--src/ui/widget/rotateable.cpp31
-rw-r--r--src/ui/widget/rotateable.h3
-rw-r--r--src/ui/widget/selected-style.cpp109
-rw-r--r--src/ui/widget/selected-style.h3
-rw-r--r--src/widgets/gradient-selector.cpp9
-rw-r--r--src/widgets/gradient-selector.h2
9 files changed, 178 insertions, 78 deletions
diff --git a/src/pixmaps/cursor-adj-a.xpm b/src/pixmaps/cursor-adj-a.xpm
new file mode 100644
index 000000000..7af3d9c12
--- /dev/null
+++ b/src/pixmaps/cursor-adj-a.xpm
@@ -0,0 +1,38 @@
+/* XPM */
+static const char * cursor_adj_a_xpm[] = {
+"32 32 3 1",
+" c None",
+". c #FFFFFF",
+"+ c #000000",
+" .. ",
+" .++. ",
+" .++. ",
+" .+..+. ",
+" .+..+. ",
+" .++++. ",
+" .+ .+. ",
+" .... .+..+. ",
+" .++. . ...... ",
+" .++. .+. ",
+" ....++.... .+. ",
+" .++++++++. .+. ",
+" .++++++++. .+. ",
+" ....++.... .+. ",
+" .++. .+. ",
+" .++. .+. ",
+" .... .+. ",
+" .+. ",
+" .+. ",
+" .+. ",
+" .+. .......... ",
+" .+. .++++++++. ",
+" .+. .++++++++. ",
+" .+. .......... ",
+" .+. ",
+" .+. ",
+" .+. ",
+" .+. ",
+" .+. ",
+" . ",
+" ",
+" "};
diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp
index 55a2f19a5..f851f72c1 100644
--- a/src/ui/dialog/layers.cpp
+++ b/src/ui/dialog/layers.cpp
@@ -838,43 +838,34 @@ LayersPanel::LayersPanel() :
SPDesktop* targetDesktop = getDesktop();
-#if !WITH_GTKMM_3_0
- // TODO: This has been removed from Gtkmm 3.0. Check that everything still
- // looks OK!
- _buttonsRow.set_child_min_width( 16 );
-#endif
-
- _buttonsRow.set_layout (Gtk::BUTTONBOX_END);
-
Gtk::Button* btn = manage( new Gtk::Button() );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_NEW, GTK_STOCK_ADD, C_("Layers", "New") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_NEW) );
- _buttonsRow.add( *btn );
- _buttonsRow.set_child_secondary( *btn , true);
-
- btn = manage( new Gtk::Button() );
- _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_TOP, C_("Layers", "Top") );
- btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) );
- _watchingNonTop.push_back( btn );
- _buttonsRow.add( *btn );
+ _buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK);
btn = manage( new Gtk::Button() );
- _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, C_("Layers", "Up") );
- btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) );
- _watchingNonTop.push_back( btn );
- _buttonsRow.add( *btn );
-
+ _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, C_("Layers", "Bot") );
+ btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) );
+ _watchingNonBottom.push_back( btn );
+ _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK);
+
btn = manage( new Gtk::Button() );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, C_("Layers", "Dn") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) );
_watchingNonBottom.push_back( btn );
- _buttonsRow.add( *btn );
-
+ _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK);
+
btn = manage( new Gtk::Button() );
- _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, C_("Layers", "Bot") );
- btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) );
- _watchingNonBottom.push_back( btn );
- _buttonsRow.add( *btn );
+ _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, C_("Layers", "Up") );
+ btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) );
+ _watchingNonTop.push_back( btn );
+ _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK);
+
+ btn = manage( new Gtk::Button() );
+ _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_TOP, C_("Layers", "Top") );
+ btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) );
+ _watchingNonTop.push_back( btn );
+ _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK);
// btn = manage( new Gtk::Button("Dup") );
// btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DUPLICATE) );
@@ -884,9 +875,10 @@ LayersPanel::LayersPanel() :
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_DELETE, GTK_STOCK_REMOVE, _("X") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DELETE) );
_watching.push_back( btn );
- _buttonsRow.add( *btn );
- _buttonsRow.set_child_secondary( *btn , true);
-
+ _buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK);
+
+ _buttonsRow.pack_start(_buttonsSecondary, Gtk::PACK_EXPAND_WIDGET);
+ _buttonsRow.pack_end(_buttonsPrimary, Gtk::PACK_EXPAND_WIDGET);
diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h
index 12e5f7986..cbd9515d7 100644
--- a/src/ui/dialog/layers.h
+++ b/src/ui/dialog/layers.h
@@ -13,7 +13,6 @@
#define SEEN_LAYERS_PANEL_H
#include <gtkmm/box.h>
-#include <gtkmm/buttonbox.h>
#include <gtkmm/treeview.h>
#include <gtkmm/treestore.h>
#include <gtkmm/scrolledwindow.h>
@@ -122,9 +121,13 @@ private:
Gtk::CellRendererText *_text_renderer;
Gtk::TreeView::Column *_name_column;
#if WITH_GTKMM_3_0
- Gtk::ButtonBox _buttonsRow;
+ Gtk::Box _buttonsRow;
+ Gtk::Box _buttonsPrimary;
+ Gtk::Box _buttonsSecondary;
#else
- Gtk::HButtonBox _buttonsRow;
+ Gtk::HBox _buttonsRow;
+ Gtk::HBox _buttonsPrimary;
+ Gtk::HBox _buttonsSecondary;
#endif
Gtk::ScrolledWindow _scroller;
Gtk::Menu _popupMenu;
diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp
index 7be666843..1d91515e5 100644
--- a/src/ui/widget/rotateable.cpp
+++ b/src/ui/widget/rotateable.cpp
@@ -24,12 +24,15 @@ Rotateable::Rotateable():
{
dragging = false;
working = false;
+ scrolling = false;
modifier = 0;
current_axis = axis;
signal_button_press_event().connect(sigc::mem_fun(*this, &Rotateable::on_click));
signal_motion_notify_event().connect(sigc::mem_fun(*this, &Rotateable::on_motion));
signal_button_release_event().connect(sigc::mem_fun(*this, &Rotateable::on_release));
+ signal_scroll_event().connect(sigc::mem_fun(*this, &Rotateable::on_scroll));
+
}
bool Rotateable::on_click(GdkEventButton *event) {
@@ -124,6 +127,34 @@ bool Rotateable::on_release(GdkEventButton *event) {
return false;
}
+bool Rotateable::on_scroll(GdkEventScroll* event)
+{
+ double change = 0.0;
+
+ if (event->direction == GDK_SCROLL_UP) {
+ change = 1.0;
+ } else if (event->direction == GDK_SCROLL_DOWN) {
+ change = -1.0;
+ } else {
+ return FALSE;
+ }
+
+ drag_started_x = event->x;
+ drag_started_y = event->y;
+ modifier = get_single_modifier(modifier, event->state);
+ dragging = false;
+ working = false;
+ scrolling = true;
+ current_axis = axis;
+
+ do_scroll(change, modifier);
+
+ dragging = false;
+ working = false;
+ scrolling = false;
+
+ return TRUE;
+}
Rotateable::~Rotateable() {
}
diff --git a/src/ui/widget/rotateable.h b/src/ui/widget/rotateable.h
index 15e0bf71c..52fb5306c 100644
--- a/src/ui/widget/rotateable.h
+++ b/src/ui/widget/rotateable.h
@@ -31,10 +31,12 @@ public:
bool on_click(GdkEventButton *event);
bool on_motion(GdkEventMotion *event);
bool on_release(GdkEventButton *event);
+ bool on_scroll(GdkEventScroll* event);
double axis;
double current_axis;
double maxdecl;
+ bool scrolling;
private:
double drag_started_x;
@@ -47,6 +49,7 @@ private:
virtual void do_motion (double /*by*/, guint /*state*/) {}
virtual void do_release (double /*by*/, guint /*state*/) {}
+ virtual void do_scroll (double /*by*/, guint /*state*/) {}
};
} // namespace Widget
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index e5992958b..ee835216d 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -47,6 +47,7 @@
#include "pixmaps/cursor-adj-h.xpm"
#include "pixmaps/cursor-adj-s.xpm"
#include "pixmaps/cursor-adj-l.xpm"
+#include "pixmaps/cursor-adj-a.xpm"
#include "sp-cursor.h"
#include "gradient-chemistry.h"
@@ -338,6 +339,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
_stroke_width_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
+
_opacity_sb.signal_populate_popup().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_menu));
_opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed));
// Connect to key-press to ensure focus is consistent with other spin buttons when using the keys vs mouse-click
@@ -1008,7 +1010,7 @@ SelectedStyle::update()
guint32 color = paint->value.color.toRGBA32(
SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value));
_lastselected[i] = _thisselected[i];
- _thisselected[i] = color | 0xff; // only color, opacity === 1
+ _thisselected[i] = color; // include opacity
((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color);
_color_preview[i]->show_all();
place->add(*_color_preview[i]);
@@ -1211,39 +1213,43 @@ RotateableSwatch::~RotateableSwatch() {
}
double
-RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier)
+RotateableSwatch::color_adjust(float *hsla, double by, guint32 cc, guint modifier)
{
- sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(cc), SP_RGBA32_G_F(cc), SP_RGBA32_B_F(cc));
-
+ sp_color_rgb_to_hsl_floatv (hsla, SP_RGBA32_R_F(cc), SP_RGBA32_G_F(cc), SP_RGBA32_B_F(cc));
+ hsla[3] = SP_RGBA32_A_F(cc);
double diff = 0;
if (modifier == 2) { // saturation
- double old = hsl[1];
+ double old = hsla[1];
if (by > 0) {
- hsl[1] += by * (1 - hsl[1]);
+ hsla[1] += by * (1 - hsla[1]);
} else {
- hsl[1] += by * (hsl[1]);
+ hsla[1] += by * (hsla[1]);
}
- diff = hsl[1] - old;
+ diff = hsla[1] - old;
} else if (modifier == 1) { // lightness
- double old = hsl[2];
+ double old = hsla[2];
if (by > 0) {
- hsl[2] += by * (1 - hsl[2]);
+ hsla[2] += by * (1 - hsla[2]);
} else {
- hsl[2] += by * (hsl[2]);
+ hsla[2] += by * (hsla[2]);
}
- diff = hsl[2] - old;
+ diff = hsla[2] - old;
+ } else if (modifier == 3) { // alpha
+ double old = hsla[3];
+ hsla[3] += by/2;
+ diff = hsla[3] - old;
} else { // hue
- double old = hsl[0];
- hsl[0] += by/2;
- while (hsl[0] < 0)
- hsl[0] += 1;
- while (hsl[0] > 1)
- hsl[0] -= 1;
- diff = hsl[0] - old;
+ double old = hsla[0];
+ hsla[0] += by/2;
+ while (hsla[0] < 0)
+ hsla[0] += 1;
+ while (hsla[0] > 1)
+ hsla[0] -= 1;
+ diff = hsla[0] - old;
}
float rgb[3];
- sp_color_hsl_to_rgb_floatv (rgb, hsl[0], hsl[1], hsl[2]);
+ sp_color_hsl_to_rgb_floatv (rgb, hsla[0], hsla[1], hsla[2]);
gchar c[64];
sp_svg_write_color (c, sizeof(c),
@@ -1256,10 +1262,14 @@ RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier
);
SPCSSAttr *css = sp_repr_css_attr_new ();
- if (fillstroke == SS_FILL)
- sp_repr_css_set_property (css, "fill", c);
- else
- sp_repr_css_set_property (css, "stroke", c);
+
+ if (modifier == 3) { // alpha
+ Inkscape::CSSOStringStream osalpha;
+ osalpha << hsla[3];
+ sp_repr_css_set_property(css, (fillstroke == SS_FILL) ? "fill-opacity" : "stroke-opacity", osalpha.str().c_str());
+ } else {
+ sp_repr_css_set_property (css, (fillstroke == SS_FILL) ? "fill" : "stroke", c);
+ }
sp_desktop_set_style (parent->getDesktop(), css);
sp_repr_css_attr_unref (css);
return diff;
@@ -1270,7 +1280,7 @@ RotateableSwatch::do_motion(double by, guint modifier) {
if (parent->_mode[fillstroke] != SS_COLOR)
return;
- if (!cr_set && modifier != 3) {
+ if (!scrolling && !cr_set) {
GtkWidget *w = GTK_WIDGET(gobj());
GdkPixbuf *pixbuf = NULL;
@@ -1278,6 +1288,8 @@ RotateableSwatch::do_motion(double by, guint modifier) {
pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_s_xpm);
} else if (modifier == 1) { // lightness
pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_l_xpm);
+ } else if (modifier == 3) { // alpha
+ pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_a_xpm);
} else { // hue
pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_h_xpm);
}
@@ -1305,43 +1317,51 @@ RotateableSwatch::do_motion(double by, guint modifier) {
cc = startcolor;
}
- float hsl[3];
+ float hsla[4];
double diff = 0;
- if (modifier != 3) {
- diff = color_adjust(hsl, by, cc, modifier);
- }
- if (modifier == 3) { // Alt, do nothing
+ diff = color_adjust(hsla, by, cc, modifier);
+
+ if (modifier == 3) { // alpha
+ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, (_("Adjust alpha")));
+ double ch = hsla[3];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>alpha</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff);
} else if (modifier == 2) { // saturation
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust saturation")));
- double ch = hsl[1];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, without modifiers to adjust hue"), ch - diff, ch, diff);
+ double ch = hsla[1];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff);
} else if (modifier == 1) { // lightness
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness")));
- double ch = hsl[2];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff);
+ double ch = hsla[2];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff);
} else { // hue
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue")));
- double ch = hsl[0];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
+ double ch = hsla[0];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
}
}
+
+void
+RotateableSwatch::do_scroll(double by, guint modifier) {
+ do_motion(by/30.0, modifier);
+ do_release(by/30.0, modifier);
+}
+
void
RotateableSwatch::do_release(double by, guint modifier) {
if (parent->_mode[fillstroke] != SS_COLOR)
return;
- float hsl[3];
- if (modifier != 3) {
- color_adjust(hsl, by, startcolor, modifier);
- }
+ float hsla[4];
+ color_adjust(hsla, by, startcolor, modifier);
if (cr_set) {
GtkWidget *w = GTK_WIDGET(gobj());
@@ -1357,7 +1377,9 @@ RotateableSwatch::do_release(double by, guint modifier) {
cr_set = false;
}
- if (modifier == 3) { // Alt, do nothing
+ if (modifier == 3) { // alpha
+ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, ("Adjust alpha"));
} else if (modifier == 2) { // saturation
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation"));
@@ -1467,6 +1489,11 @@ RotateableStrokeWidth::do_release(double by, guint modifier) {
parent->getDesktop()->event_context->_message_context->clear();
}
+void
+RotateableStrokeWidth::do_scroll(double by, guint modifier) {
+ do_motion(by/10.0, modifier);
+ startvalue_set = false;
+}
Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop)
{
diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h
index a9e9d7274..fac4f22e6 100644
--- a/src/ui/widget/selected-style.h
+++ b/src/ui/widget/selected-style.h
@@ -61,8 +61,10 @@ public:
~RotateableSwatch();
double color_adjust (float *hsl, double by, guint32 cc, guint state);
+
virtual void do_motion (double by, guint state);
virtual void do_release (double by, guint state);
+ virtual void do_scroll (double by, guint state);
private:
guint fillstroke;
@@ -87,6 +89,7 @@ public:
double value_adjust(double current, double by, guint modifier, bool final);
virtual void do_motion (double by, guint state);
virtual void do_release (double by, guint state);
+ virtual void do_scroll (double by, guint state);
private:
SelectedStyle *parent;
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp
index 65608585b..0cf1c2c51 100644
--- a/src/widgets/gradient-selector.cpp
+++ b/src/widgets/gradient-selector.cpp
@@ -19,6 +19,7 @@
#include <gtk/gtk.h>
#include "document.h"
+#include "../document-undo.h"
#include "../document-private.h"
#include "../gradient-chemistry.h"
#include "inkscape.h"
@@ -169,7 +170,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel)
count_column->signal_clicked().connect( sigc::mem_fun(*sel, &SPGradientSelector::onTreeCountColClick) );
gvs->tree_select_connection = sel->treeview->get_selection()->signal_changed().connect( sigc::mem_fun(*sel, &SPGradientSelector::onTreeSelection) );
- sel->text_renderer->signal_edited().connect( sigc::mem_fun(*sel, &SPGradientSelector::onTreeEdited) );
+ sel->text_renderer->signal_edited().connect( sigc::mem_fun(*sel, &SPGradientSelector::onGradientRename) );
sel->scrolled_window = Gtk::manage(new Gtk::ScrolledWindow());
sel->scrolled_window->add(*sel->treeview);
@@ -289,7 +290,7 @@ SPGradientSpread SPGradientSelector::getSpread()
return gradientSpread;
}
-void SPGradientSelector::onTreeEdited( const Glib::ustring& path_string, const Glib::ustring& new_text)
+void SPGradientSelector::onGradientRename( const Glib::ustring& path_string, const Glib::ustring& new_text)
{
Gtk::TreePath path(path_string);
Gtk::TreeModel::iterator iter = store->get_iter(path);
@@ -300,10 +301,12 @@ void SPGradientSelector::onTreeEdited( const Glib::ustring& path_string, const G
if ( row ) {
SPObject* obj = row[columns->data];
if ( obj ) {
+ row[columns->name] = gr_prepare_label(obj);
if (!new_text.empty() && new_text != row[columns->name]) {
rename_id(obj, new_text );
+ Inkscape::DocumentUndo::done(obj->document, SP_VERB_CONTEXT_GRADIENT,
+ _("Rename gradient"));
}
- row[columns->name] = gr_prepare_label(obj);
}
}
}
diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h
index f7cc3cc14..01c18a48d 100644
--- a/src/widgets/gradient-selector.h
+++ b/src/widgets/gradient-selector.h
@@ -61,7 +61,7 @@ struct SPGradientSelector {
/* Tree */
bool _checkForSelected(const Gtk::TreePath& path, const Gtk::TreeIter& iter, SPGradient *vector);
void onTreeSelection();
- void onTreeEdited( const Glib::ustring& path_string, const Glib::ustring& new_text);
+ void onGradientRename( const Glib::ustring& path_string, const Glib::ustring& new_text);
void onTreeNameColClick();
void onTreeColorColClick();
void onTreeCountColClick();