From c94d8e65d4519165ff8ace1b60bfb254f69df6b5 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Sun, 7 Oct 2007 20:51:12 +0000 Subject: [PATCH] add gradient selection describer for statusbar --- src/gradient-context.cpp | 60 ++++++++++++++++++++++++++++++++++++++++ src/gradient-context.h | 3 ++ 2 files changed, 63 insertions(+) diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index e3e0fcf1a..93cf79214 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -120,9 +120,64 @@ static void sp_gradient_context_dispose(GObject *object) delete rc->_message_context; } + rc->selcon->disconnect(); + delete rc->selcon; + rc->subselcon->disconnect(); + delete rc->subselcon; + G_OBJECT_CLASS(parent_class)->dispose(object); } +const gchar *gr_handle_descr [] = { + N_("Linear gradient start"), //POINT_LG_BEGIN + N_("Linear gradient end"), + N_("Linear gradient mid stop"), + N_("Radial gradient center"), + N_("Radial gradient radius"), + N_("Radial gradient radius"), + N_("Radial gradient focus"), // POINT_RG_FOCUS + N_("Radial gradient mid stop"), + N_("Radial gradient mid stop") +}; + +static void +gradient_selection_changed (Inkscape::Selection *, gpointer data) +{ + SPGradientContext *rc = (SPGradientContext *) data; + + GrDrag *drag = rc->_grdrag; + Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(rc)->desktop); + guint n_obj = g_slist_length((GSList *) selection->itemList()); + + if (!drag->isNonEmpty() || selection->isEmpty()) + return; + guint n_tot = drag->numDraggers(); + guint n_sel = drag->numSelected(); + + if (n_sel == 1) { + if (drag->singleSelectedDraggerNumDraggables() == 1) { + rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, + _("%s selected out of %d gradient handles on %d selected object(s)"), gr_handle_descr[drag->singleSelectedDraggerSingleDraggableType()], n_tot, n_obj); + } else { + rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, + _("One handle merging %d stops (drag with Shift to separate) selected out of %d gradient handles on %d selected object(s)"), drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj); + } + } else if (n_sel > 1) { + rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, + _("%d gradient handles selected out of %d on %d selected object(s)"), n_sel, n_tot, n_obj); + } else if (n_sel == 0) { + rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, + _("No gradient handles selected out of %d on %d selected object(s)"), n_tot, n_obj); + } +} + +static void +gradient_subselection_changed (gpointer, gpointer data) +{ + gradient_selection_changed (NULL, data); +} + + static void sp_gradient_context_setup(SPEventContext *ec) { SPGradientContext *rc = SP_GRADIENT_CONTEXT(ec); @@ -136,8 +191,13 @@ static void sp_gradient_context_setup(SPEventContext *ec) } ec->enableGrDrag(); + Inkscape::Selection *selection = sp_desktop_selection(ec->desktop); rc->_message_context = new Inkscape::MessageContext(sp_desktop_message_stack(ec->desktop)); + + rc->selcon = new sigc::connection (selection->connectChanged( sigc::bind (sigc::ptr_fun(&gradient_selection_changed), rc))); + rc->subselcon = new sigc::connection (ec->desktop->connectToolSubselectionChanged(sigc::bind (sigc::ptr_fun(&gradient_subselection_changed), rc))); + gradient_selection_changed(selection, rc); } void diff --git a/src/gradient-context.h b/src/gradient-context.h index 3e74865b1..d0fe0d421 100644 --- a/src/gradient-context.h +++ b/src/gradient-context.h @@ -39,6 +39,9 @@ struct SPGradientContext : public SPEventContext { NR::Point mousepoint_doc; // stores mousepoint when over_line in doc coords Inkscape::MessageContext *_message_context; + + sigc::connection *selcon; + sigc::connection *subselcon; }; struct SPGradientContextClass { -- 2.30.2