/// Remove desktop from list of desktops void Editor::removeDesktop (SPDesktop *dt) { g_return_if_fail (dt != 0); g_assert (g_slist_find (_instance->_desktops, dt)); if (dt == _instance->_desktops->data) { // is it the active desktop? _instance->_desktop_deactivated_signal.emit (dt); if (_instance->_desktops->next != 0) { SPDesktop * new_desktop = (SPDesktop *) _instance->_desktops->next->data; _instance->_desktops = g_slist_remove (_instance->_desktops, new_desktop); _instance->_desktops = g_slist_prepend (_instance->_desktops, new_desktop); _instance->_desktop_activated_signal.emit (new_desktop); _instance->_event_context_set_signal.emit (sp_desktop_event_context (new_desktop)); _instance->_selection_set_signal.emit (sp_desktop_selection (new_desktop)); _instance->_selection_changed_signal.emit (sp_desktop_selection (new_desktop)); } else { _instance->_event_context_set_signal.emit (0); if (sp_desktop_selection(dt)) sp_desktop_selection(dt)->clear(); } } _instance->_desktops = g_slist_remove (_instance->_desktops, dt); // if this was the last desktop, shut down the program if (_instance->_desktops == NULL) { _instance->_shutdown_signal.emit(); Inkscape::NSApplication::Application::exit(); } }
static void sp_box3d_context_setup(SPEventContext *ec) { Box3DContext *bc = SP_BOX3D_CONTEXT(ec); if (((SPEventContextClass *) parent_class)->setup) { ((SPEventContextClass *) parent_class)->setup(ec); } ec->shape_editor = new ShapeEditor(ec->desktop); SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); if (item) { ec->shape_editor->set_item(item, SH_KNOTHOLDER); } bc->sel_changed_connection.disconnect(); bc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged( sigc::bind(sigc::ptr_fun(&sp_box3d_context_selection_changed), (gpointer)bc) ); bc->_vpdrag = new Box3D::VPDrag(sp_desktop_document (ec->desktop)); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/shapes/selcue")) { ec->enableSelectionCue(); } if (prefs->getBool("/tools/shapes/gradientdrag")) { ec->enableGrDrag(); } bc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); }
static void sp_spiral_context_setup(SPEventContext *ec) { SPSpiralContext *sc = SP_SPIRAL_CONTEXT(ec); if (((SPEventContextClass *) parent_class)->setup) ((SPEventContextClass *) parent_class)->setup(ec); sp_event_context_read(ec, "expansion"); sp_event_context_read(ec, "revolution"); sp_event_context_read(ec, "t0"); ec->shape_editor = new ShapeEditor(ec->desktop); SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); if (item) { ec->shape_editor->set_item(item, SH_KNOTHOLDER); } Inkscape::Selection *selection = sp_desktop_selection(ec->desktop); sc->sel_changed_connection.disconnect(); sc->sel_changed_connection = selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_spiral_context_selection_changed), (gpointer)sc)); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/shapes/selcue")) { ec->enableSelectionCue(); } if (prefs->getBool("/tools/shapes/gradientdrag")) { ec->enableGrDrag(); } sc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); }
/// Add desktop to list of desktops void Editor::addDesktop (SPDesktop *dt) { g_return_if_fail (dt != 0); g_assert (!g_slist_find (_instance->_desktops, dt)); _instance->_desktops = g_slist_append (_instance->_desktops, dt); if (isDesktopActive (dt)) { _instance->_desktop_activated_signal.emit (dt); _instance->_event_context_set_signal.emit (sp_desktop_event_context (dt)); _instance->_selection_set_signal.emit (sp_desktop_selection (dt)); _instance->_selection_changed_signal.emit (sp_desktop_selection (dt)); } }
static void sp_text_edit_dialog_apply( GtkButton */*button*/, GtkWidget *dlg ) { g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (TRUE)); GtkWidget *apply = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "apply"); GtkWidget *def = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "default"); SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; const GSList *item_list = sp_desktop_selection(desktop)->itemList(); SPCSSAttr *css = sp_get_text_dialog_style (); sp_desktop_set_style(desktop, css, true); for (; item_list != NULL; item_list = item_list->next) { // apply style to the reprs of all text objects in the selection if (SP_IS_TEXT (item_list->data)) { // backwards compatibility: SP_OBJECT_REPR(item_list->data)->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); ++items; } else if (SP_IS_FLOWTEXT (item_list->data)) // no need to set sodipodi:linespacing, because Inkscape never supported it on flowtext ++items; } if (items == 0) { // no text objects; apply style to prefs for new objects Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->mergeStyle("/tools/text/style", css); gtk_widget_set_sensitive (def, FALSE); } else if (items == 1) { /* exactly one text object; now set its text, too */ SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT(item)) { sp_text_edit_dialog_update_object_text (item); } } // complete the transaction sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Set text style")); gtk_widget_set_sensitive (apply, FALSE); sp_repr_css_attr_unref (css); g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (FALSE)); }
static void sp_item_create_link(GtkMenuItem *menuitem, SPItem *item) { g_assert(SP_IS_ITEM(item)); g_assert(!SP_IS_ANCHOR(item)); SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); Inkscape::XML::Node *repr = xml_doc->createElement("svg:a"); SP_OBJECT_REPR(SP_OBJECT_PARENT(item))->addChild(repr, SP_OBJECT_REPR(item)); SPObject *object = SP_OBJECT_DOCUMENT(item)->getObjectByRepr(repr); g_return_if_fail(SP_IS_ANCHOR(object)); const char *id = SP_OBJECT_REPR(item)->attribute("id"); Inkscape::XML::Node *child = SP_OBJECT_REPR(item)->duplicate(xml_doc); SP_OBJECT(item)->deleteObject(false); repr->addChild(child, NULL); child->setAttribute("id", id); Inkscape::GC::release(repr); Inkscape::GC::release(child); sp_document_done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE, _("Create link")); sp_object_attributes_dialog(object, "SPAnchor"); sp_desktop_selection(desktop)->set(SP_ITEM(object)); }
void sp_select_context_up_one_layer(SPDesktop *desktop) { /* Click in empty place, go up one level -- but don't leave a layer to root. * * (Rationale: we don't usually allow users to go to the root, since that * detracts from the layer metaphor: objects at the root level can in front * of or behind layers. Whereas it's fine to go to the root if editing * a document that has no layers (e.g. a non-Inkscape document).) * * Once we support editing SVG "islands" (e.g. <svg> embedded in an xhtml * document), we might consider further restricting the below to disallow * leaving a layer to go to a non-layer. */ SPObject *const current_layer = desktop->currentLayer(); if (current_layer) { SPObject *const parent = SP_OBJECT_PARENT(current_layer); if ( parent && ( SP_OBJECT_PARENT(parent) || !( SP_IS_GROUP(current_layer) && ( SPGroup::LAYER == SP_GROUP(current_layer)->layerMode() ) ) ) ) { desktop->setCurrentLayer(parent); if (SP_IS_GROUP(current_layer) && SPGroup::LAYER != SP_GROUP(current_layer)->layerMode()) sp_desktop_selection(desktop)->set(current_layer); } } }
//FIXME: must work with text selection void text_remove_all_kerns() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; Inkscape::Selection *selection = sp_desktop_selection(desktop); if (selection->isEmpty()) { sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>text(s)</b> to remove kerns from.")); return; } bool did = false; for (GSList *items = g_slist_copy((GSList *) selection->itemList()); items != NULL; items = items->next) { SPObject *obj = SP_OBJECT(items->data); if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) { continue; } text_remove_all_kerns_recursively(obj); obj->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); did = true; } if (!did) { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("Select <b>text(s)</b> to remove kerns from.")); } else { sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Remove manual kerns")); } }
void LivePathEffectEditor::setDesktop(SPDesktop *desktop) { Panel::setDesktop(desktop); if ( desktop == current_desktop ) { return; } if (current_desktop) { selection_changed_connection.disconnect(); selection_modified_connection.disconnect(); } lpe_list_locked = false; current_desktop = desktop; if (desktop) { Inkscape::Selection *selection = sp_desktop_selection(desktop); selection_changed_connection = selection->connectChanged( sigc::bind (sigc::ptr_fun(&lpeeditor_selection_changed), this ) ); selection_modified_connection = selection->connectModified( sigc::bind (sigc::ptr_fun(&lpeeditor_selection_modified), this ) ); onSelectionChanged(selection); } else { onSelectionChanged(NULL); } }
VPDrag::VPDrag (SPDocument *document) { this->document = document; this->selection = sp_desktop_selection(inkscape_active_desktop()); this->draggers = NULL; this->lines = NULL; this->show_lines = true; this->front_or_rear_lines = 0x1; this->dragging = false; this->sel_changed_connection = this->selection->connectChanged( sigc::bind ( sigc::ptr_fun(&vp_drag_sel_changed), (gpointer)this ) ); this->sel_modified_connection = this->selection->connectModified( sigc::bind( sigc::ptr_fun(&vp_drag_sel_modified), (gpointer)this ) ); this->updateDraggers (); this->updateLines (); }
static void sp_box3d_finish(Box3DContext *bc) { bc->_message_context->clear(); bc->ctrl_dragged = false; bc->extruded = false; if ( bc->item != NULL ) { SPDesktop * desktop = SP_EVENT_CONTEXT_DESKTOP(bc); SPDocument *doc = sp_desktop_document(desktop); if (!doc || !doc->getCurrentPersp3D()) return; SPBox3D *box = SP_BOX3D(bc->item); box->orig_corner0 = bc->drag_origin_proj; box->orig_corner7 = bc->drag_ptC_proj; box->updateRepr(); box3d_relabel_corners(box); desktop->canvas->end_forced_full_redraws(); sp_desktop_selection(desktop)->set(bc->item); sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX, _("Create 3D box")); bc->item = NULL; } }
static void sp_shape_fill_settings(GtkMenuItem *menuitem, SPItem *item) { SPDesktop *desktop; g_assert(SP_IS_ITEM(item)); desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); if (sp_desktop_selection(desktop)->isEmpty()) { sp_desktop_selection(desktop)->set(item); } desktop->_dlg_mgr->showDialog("FillAndStroke"); }
void FontSubstitution::show(Glib::ustring out, GSList *l) { Gtk::MessageDialog warning(_("\nSome fonts are not available and have been substituted."), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true); warning.set_resizable(true); warning.set_title(_("Font substitution")); GtkWidget *dlg = GTK_WIDGET(warning.gobj()); sp_transientize(dlg); Gtk::TextView * textview = new Gtk::TextView(); textview->set_editable(false); textview->set_wrap_mode(Gtk::WRAP_WORD); textview->show(); textview->get_buffer()->set_text(_(out.c_str())); Gtk::ScrolledWindow * scrollwindow = new Gtk::ScrolledWindow(); scrollwindow->add(*textview); scrollwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); scrollwindow->set_shadow_type(Gtk::SHADOW_IN); scrollwindow->set_size_request(0, 100); scrollwindow->show(); Gtk::CheckButton *cbSelect = new Gtk::CheckButton(); cbSelect->set_label(_("Select all the affected items")); cbSelect->set_active(true); cbSelect->show(); Gtk::CheckButton *cbWarning = new Gtk::CheckButton(); cbWarning->set_label(_("Don't show this warning again")); cbWarning->show(); #if GTK_CHECK_VERSION(3,0,0) Gtk::Box * box = warning.get_content_area(); #else Gtk::Box * box = warning.get_vbox(); #endif box->set_spacing(2); box->pack_start(*scrollwindow, true, true, 4); box->pack_start(*cbSelect, false, false, 0); box->pack_start(*cbWarning, false, false, 0); warning.run(); if (cbWarning->get_active()) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt("/options/font/substitutedlg", 0); } if (cbSelect->get_active()) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; Inkscape::Selection *selection = sp_desktop_selection (desktop); selection->clear(); selection->setList(l); } }
void Editor::activateDesktop (SPDesktop* dt) { g_assert (dt != 0); if (isDesktopActive (dt)) return; g_assert (g_slist_find (_instance->_desktops, dt)); SPDesktop *curr = (SPDesktop*)_instance->_desktops->data; _instance->_desktop_deactivated_signal.emit (curr); _instance->_desktops = g_slist_remove (_instance->_desktops, dt); _instance->_desktops = g_slist_prepend (_instance->_desktops, dt); _instance->_desktop_activated_signal.emit (dt); _instance->_event_context_set_signal.emit (sp_desktop_event_context(dt)); _instance->_selection_set_signal.emit (sp_desktop_selection(dt)); _instance->_selection_changed_signal.emit (sp_desktop_selection(dt)); }
void sp_selected_path_reverse(SPDesktop *desktop) { Inkscape::Selection *selection = sp_desktop_selection(desktop); GSList *items = (GSList *) selection->itemList(); if (!items) { sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse.")); return; } // set "busy" cursor desktop->setWaitingCursor(); bool did = false; desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); for (GSList *i = items; i != NULL; i = i->next) { if (!SP_IS_PATH(i->data)) continue; did = true; SPPath *path = SP_PATH(i->data); SPCurve *rcurve = sp_path_get_curve_reference(path)->create_reverse(); gchar *str = sp_svg_write_path(rcurve->get_pathvector()); if ( sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path)) ) { SP_OBJECT_REPR(path)->setAttribute("inkscape:original-d", str); } else { SP_OBJECT_REPR(path)->setAttribute("d", str); } g_free(str); rcurve->unref(); // reverse nodetypes order (Bug #179866) gchar *nodetypes = g_strdup(SP_OBJECT_REPR(path)->attribute("sodipodi:nodetypes")); if ( nodetypes ) { SP_OBJECT_REPR(path)->setAttribute("sodipodi:nodetypes", g_strreverse(nodetypes)); g_free(nodetypes); } } desktop->clearWaitingCursor(); if (did) { sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE, _("Reverse path")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection.")); } }
static void sp_item_select_this(GtkMenuItem *menuitem, SPItem *item) { SPDesktop *desktop; g_assert(SP_IS_ITEM(item)); desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_desktop_selection(desktop)->set(item); }
void OriginalPathParam::on_select_original_button_click() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPItem *original = ref.getObject(); if (desktop == NULL || original == NULL) { return; } Inkscape::Selection *selection = sp_desktop_selection(desktop); selection->clear(); selection->set(original); }
void gr_item_activate (GtkMenuItem *menuitem, gpointer data) { SPGradient *gr = (SPGradient *) g_object_get_data (G_OBJECT (menuitem), "gradient"); gr = sp_gradient_ensure_vector_normalized(gr); SPDesktop *desktop = (SPDesktop *) data; Inkscape::Selection *selection = sp_desktop_selection (desktop); SPEventContext *ev = sp_desktop_event_context (desktop); gr_apply_gradient (selection, ev? ev->get_drag() : NULL, gr); sp_document_done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, _("Assign gradient to object")); }
void sp_find_dialog_find(GObject *, GObject *dlg) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; bool hidden = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includehidden"))); bool locked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includelocked"))); GSList *l = NULL; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inselection")))) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) { l = all_selection_items (desktop->selection, l, desktop->currentLayer(), hidden, locked); } else { l = all_selection_items (desktop->selection, l, NULL, hidden, locked); } } else { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) { l = all_items (desktop->currentLayer(), l, hidden, locked); } else { l = all_items (SP_DOCUMENT_ROOT (sp_desktop_document (desktop)), l, hidden, locked); } } guint all = g_slist_length (l); bool exact = true; GSList *n = NULL; n = filter_list (l, dlg, exact); if (n == NULL) { exact = false; n = filter_list (l, dlg, exact); } if (n != NULL) { int count = g_slist_length (n); desktop->messageStack()->flashF(Inkscape::NORMAL_MESSAGE, // TRANSLATORS: "%s" is replaced with "exact" or "partial" when this string is displayed ngettext("<b>%d</b> object found (out of <b>%d</b>), %s match.", "<b>%d</b> objects found (out of <b>%d</b>), %s match.", count), count, all, exact? _("exact") : _("partial")); Inkscape::Selection *selection = sp_desktop_selection (desktop); selection->clear(); selection->setList(n); scroll_to_show_item (desktop, SP_ITEM(n->data)); } else { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No objects found")); } }
static SPItem * sp_ted_get_selected_text_item (void) { if (!SP_ACTIVE_DESKTOP) return NULL; for (const GSList *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList(); item != NULL; item = item->next) { if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) return SP_ITEM (item->data); } return NULL; }
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(); //The use of ngettext in the following code is intentional even if the English singular form would never be used if (n_sel == 1) { if (drag->singleSelectedDraggerNumDraggables() == 1) { gchar * message = g_strconcat( //TRANSLATORS: %s will be substituted with the point name (see previous messages); This is part of a compound message _("%s selected"), //TRANSLATORS: Mind the space in front. This is part of a compound message ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot), ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, message,_(gr_handle_descr[drag->singleSelectedDraggerSingleDraggableType()]), n_tot, n_obj); } else { gchar * message = g_strconcat( //TRANSLATORS: This is a part of a compound message (out of two more indicating: grandint handle count & object count) ngettext("One handle merging %d stop (drag with <b>Shift</b> to separate) selected", "One handle merging %d stops (drag with <b>Shift</b> to separate) selected",drag->singleSelectedDraggerNumDraggables()), ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot), ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,message,drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj); } } else if (n_sel > 1) { //TRANSLATORS: The plural refers to number of selected gradient handles. This is part of a compound message (part two indicates selected object count) gchar * message = g_strconcat(ngettext("<b>%d</b> gradient handle selected out of %d","<b>%d</b> gradient handles selected out of %d",n_sel), //TRANSLATORS: Mind the space in front. (Refers to gradient handles selected). This is part of a compound message ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,message, n_sel, n_tot, n_obj); } else if (n_sel == 0) { rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, //TRANSLATORS: The plural refers to number of selected objects ngettext("<b>No</b> gradient handles selected out of %d on %d selected object", "<b>No</b> gradient handles selected out of %d on %d selected objects",n_obj), n_tot, n_obj); } }
static void sp_item_group_ungroup_activate(GtkMenuItem *menuitem, SPGroup *group) { SPDesktop *desktop; GSList *children; g_assert(SP_IS_GROUP(group)); desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); children = NULL; sp_item_group_ungroup(group, &children); sp_desktop_selection(desktop)->setList(children); g_slist_free(children); }
std::set<VanishingPoint*, less_ptr> VPDragger::VPsOfSelectedBoxes() { std::set<VanishingPoint*, less_ptr> sel_vps; VanishingPoint *vp; // FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference. Inkscape::Selection *sel = sp_desktop_selection(inkscape_active_desktop()); for (GSList const* i = sel->itemList(); i != NULL; i = i->next) { if (!SP_IS_BOX3D(i->data)) continue; SPBox3D *box = SP_BOX3D(i->data); vp = this->findVPWithBox(box); if (vp) { sel_vps.insert (vp); } } return sel_vps; }
void sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) { if (gtk_object_get_data (GTK_OBJECT (spw), "blocked")) return; SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); g_return_if_fail (item != NULL); gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); item->setExplicitlyHidden(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))); sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))? _("Hide object") : _("Unhide object")); gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); }
static unsigned sp_ted_get_selected_text_count (void) { if (!SP_ACTIVE_DESKTOP) return 0; unsigned int items = 0; for (const GSList *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList(); item != NULL; item = item->next) { if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) ++items; } return items; }
/* This function is an entry point from GUI */ void sp_selected_path_to_curves(SPDesktop *desktop, bool interactive) { Inkscape::Selection *selection = sp_desktop_selection(desktop); if (selection->isEmpty()) { if (interactive) sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to path.")); return; } bool did = false; if (interactive) { desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Converting objects to paths...")); // set "busy" cursor desktop->setWaitingCursor(); } GSList *selected = g_slist_copy((GSList *) selection->itemList()); GSList *to_select = NULL; selection->clear(); GSList *items = g_slist_copy(selected); did = sp_item_list_to_curves(items, &selected, &to_select); g_slist_free (items); selection->setReprList(to_select); selection->addList(selected); g_slist_free (to_select); g_slist_free (selected); if (interactive) { desktop->clearWaitingCursor(); if (did) { sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE, _("Object to path")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No objects</b> to convert to path in the selection.")); return; } } }
static void sp_spiral_finish(SPSpiralContext *sc) { sc->_message_context->clear(); if (sc->item != NULL) { SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop; SPSpiral *spiral = SP_SPIRAL(sc->item); sp_shape_set_shape(SP_SHAPE(spiral)); SP_OBJECT(spiral)->updateRepr(SP_OBJECT_WRITE_EXT); sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(sc->item); sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, _("Create spiral")); sc->item = NULL; } }
static void sp_gradient_context_setup(SPEventContext *ec) { SPGradientContext *rc = SP_GRADIENT_CONTEXT(ec); if (((SPEventContextClass *) parent_class)->setup) { ((SPEventContextClass *) parent_class)->setup(ec); } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/gradient/selcue", true)) { ec->enableSelectionCue(); } 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); }
/** Converts the selected items to LPEItems if they are not already so; e.g. SPRects) */ void sp_selected_to_lpeitems(SPDesktop *desktop) { Inkscape::Selection *selection = sp_desktop_selection(desktop); if (selection->isEmpty()) { return; } bool did = false; GSList *selected = g_slist_copy((GSList *) selection->itemList()); GSList *to_select = NULL; selection->clear(); GSList *items = g_slist_copy(selected); did = sp_item_list_to_curves(items, &selected, &to_select, true); g_slist_free (items); selection->setReprList(to_select); selection->addList(selected); g_slist_free (to_select); g_slist_free (selected); }
void text_remove_from_path() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; Inkscape::Selection *selection = sp_desktop_selection(desktop); if (selection->isEmpty()) { sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text on path</b> to remove it from path.")); return; } bool did = false; for (GSList *items = g_slist_copy((GSList *) selection->itemList()); items != NULL; items = items->next) { if (!SP_IS_TEXT_TEXTPATH(SP_OBJECT(items->data))) { continue; } SPObject *tp = sp_object_first_child(SP_OBJECT(items->data)); did = true; sp_textpath_to_text(tp); } if (!did) { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No texts-on-paths</b> in the selection.")); } else { sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Remove text from path")); selection->setList(g_slist_copy((GSList *) selection->itemList())); // reselect to update statusbar description } }