How to send click signal to the Apply button without using mouse?

Discussion about writing code for Inkscape.
user1
Posts: 5
Joined: Tue Sep 19, 2017 2:27 am

How to send click signal to the Apply button without using mouse?

Postby user1 » Sun Jan 07, 2018 6:14 am

After inkscape is compiled and started is it possible to send click signal to the Apply button without using mouse.

Code: Select all

Transformation::Transformation()
    : UI::Widget::Panel ("", "/dialogs/transformation", SP_VERB_DIALOG_TRANSFORM),
      _page_move              (4, 2),
      _page_scale             (4, 2),
      _page_rotate            (4, 2),
      _page_skew              (4, 2),
      _page_transform         (3, 3),
      _scalar_move_horizontal (_("_Horizontal:"), _("Horizontal displacement (relative) or position (absolute)"), UNIT_TYPE_LINEAR,
                               "", "transform-move-horizontal", &_units_move),
      _scalar_move_vertical   (_("_Vertical:"),  _("Vertical displacement (relative) or position (absolute)"), UNIT_TYPE_LINEAR,
                               "", "transform-move-vertical", &_units_move),
      _scalar_scale_horizontal(_("_Width:"), _("Horizontal size (absolute or percentage of current)"), UNIT_TYPE_DIMENSIONLESS,
                               "", "transform-scale-horizontal", &_units_scale),
      _scalar_scale_vertical  (_("_Height:"),  _("Vertical size (absolute or percentage of current)"), UNIT_TYPE_DIMENSIONLESS,
                               "", "transform-scale-vertical", &_units_scale),
      _scalar_rotate          (_("A_ngle:"), _("Rotation angle (positive = counterclockwise)"), UNIT_TYPE_RADIAL,
                               "", "transform-rotate", &_units_rotate),
      _scalar_skew_horizontal (_("_Horizontal:"), _("Horizontal skew angle (positive = counterclockwise), or absolute displacement, or percentage displacement"), UNIT_TYPE_LINEAR,
                               "", "transform-skew-horizontal", &_units_skew),
      _scalar_skew_vertical   (_("_Vertical:"),  _("Vertical skew angle (positive = counterclockwise), or absolute displacement, or percentage displacement"),  UNIT_TYPE_LINEAR,
                               "", "transform-skew-vertical", &_units_skew),

      _scalar_transform_a     ("_A:", _("Transformation matrix element A")),
      _scalar_transform_b     ("_B:", _("Transformation matrix element B")),
      _scalar_transform_c     ("_C:", _("Transformation matrix element C")),
      _scalar_transform_d     ("_D:", _("Transformation matrix element D")),
      _scalar_transform_e     ("_E:", _("Transformation matrix element E")),
      _scalar_transform_f     ("_F:", _("Transformation matrix element F")),

      _counterclockwise_rotate (),
      _clockwise_rotate (),

      _check_move_relative    (_("Rela_tive move"), _("Add the specified relative displacement to the current position; otherwise, edit the current absolute position directly")),
      _check_scale_proportional (_("_Scale proportionally"), _("Preserve the width/height ratio of the scaled objects")),
      _check_apply_separately    (_("Apply to each _object separately"), _("Apply the scale/rotate/skew to each selected object separately; otherwise, transform the selection as a whole")),
      _check_replace_matrix    (_("Edit c_urrent matrix"), _("Edit the current transform= matrix; otherwise, post-multiply transform= by this matrix"))

{
    Gtk::Box *contents = _getContents();

    contents->set_spacing(0);

    // Notebook for individual transformations
    contents->pack_start(_notebook, true, true);

    _notebook.append_page(_page_move, _("_Move"), true);
    layoutPageMove();

    _notebook.append_page(_page_scale, _("_Scale"), true);
    layoutPageScale();

    _notebook.append_page(_page_rotate, _("_Rotate"), true);
    layoutPageRotate();

    _notebook.append_page(_page_skew, _("Ske_w"), true);
    layoutPageSkew();

    _notebook.append_page(_page_transform, _("Matri_x"), true);
    layoutPageTransform();

    _notebook.signal_switch_page().connect(sigc::mem_fun(*this, &Transformation::onSwitchPage));

    // Apply separately
    contents->pack_start(_check_apply_separately, true, true);
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
    _check_apply_separately.set_active(prefs->getBool("/dialogs/transformation/applyseparately"));
    _check_apply_separately.signal_toggled().connect(sigc::mem_fun(*this, &Transformation::onApplySeparatelyToggled));

    // make sure all spinbuttons activate Apply on pressing Enter
      ((Gtk::Entry *) (_scalar_move_horizontal.getWidget()))->set_activates_default(true);
      ((Gtk::Entry *) (_scalar_move_vertical.getWidget()))->set_activates_default(true);
      ((Gtk::Entry *) (_scalar_scale_horizontal.getWidget()))->set_activates_default(true);
      ((Gtk::Entry *) (_scalar_scale_vertical.getWidget()))->set_activates_default(true);
      ((Gtk::Entry *) (_scalar_rotate.getWidget()))->set_activates_default(true);
      ((Gtk::Entry *) (_scalar_skew_horizontal.getWidget()))->set_activates_default(true);
      ((Gtk::Entry *) (_scalar_skew_vertical.getWidget()))->set_activates_default(true);

    updateSelection(PAGE_MOVE, _getSelection());

    resetButton = addResponseButton(Gtk::Stock::CLEAR, 0);
    if (resetButton) {
        resetButton->set_tooltip_text(_("Reset the values on the current tab to defaults"));
        resetButton->set_sensitive(true);
        resetButton->signal_clicked().connect(sigc::mem_fun(*this, &Transformation::onClear));
    }


    applyButton = addResponseButton(Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY);
    if (applyButton) {
        applyButton->set_tooltip_text(_("Apply transformation to selection"));
        applyButton->set_sensitive(false);      
   
    }


    // Connect to the global selection changed & modified signals
    g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this);
    g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (on_selection_modified), this);   
       
   
       _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Transformation::setDesktop) );
    _deskTrack.connect(GTK_WIDGET(gobj()));

    show_all_children();
   
   
}

User avatar
brynn
Posts: 9849
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How to send click signal to the Apply button without using mouse?

Postby brynn » Sun Jan 07, 2018 10:16 am

Unfortunately, I don't have the skills to understand your code. I just wanted to mention that if you want to contact developers, you'll need to use either the devel mailing list, or dev IRC. Mailing list is probably the most dependable way. https://inkscape.org/en/community/mailing-lists/ (Inkscape developers tend not to visit bb style forums.)

Moini
Posts: 2612
Joined: Mon Oct 05, 2015 10:44 am

Re: How to send click signal to the Apply button without using mouse?

Postby Moini » Sun Jan 07, 2018 1:21 pm

I think it would help us to answer your question if you could elaborate on your goal. What do you want to achieve? Hitting apply might not be the best way to do it.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

user1
Posts: 5
Joined: Tue Sep 19, 2017 2:27 am

Re: How to send click signal to the Apply button without using mouse?

Postby user1 » Sun Jan 07, 2018 10:42 pm

I want automaticaly duplicate the particular object when start inkscape and load a SVG file.
Then I want new duplicated object automaticaly moved to another place using Transform dialog, the Move option.
I want do it without having to use mouse

Moini
Posts: 2612
Joined: Mon Oct 05, 2015 10:44 am

Re: How to send click signal to the Apply button without using mouse?

Postby Moini » Mon Jan 08, 2018 3:26 am

What is your goal? Could this be done using the command line? Do you want batch processing?
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

user1
Posts: 5
Joined: Tue Sep 19, 2017 2:27 am

Re: How to send click signal to the Apply button without using mouse?

Postby user1 » Mon Jan 08, 2018 5:38 pm

Yes I want batch processing if it is possible over it.

user1
Posts: 5
Joined: Tue Sep 19, 2017 2:27 am

Re: How to send click signal to the Apply button without using mouse?

Postby user1 » Mon Jan 08, 2018 5:51 pm

If I enter this command line
inkscape --verb EditSelectAll drawing.svg


the object will be automaticaly selected after inkscape starts.

If I enter this command line

inkscape --verb EditSelectAll --verb DialogTransform drawing.svg


the object will be selected and the transform dialog will be open automatocaly.

How to add move parameters directly over command line so the selected object is moved automaticaly.

Moini
Posts: 2612
Joined: Mon Oct 05, 2015 10:44 am

Re: How to send click signal to the Apply button without using mouse?

Postby Moini » Tue Jan 09, 2018 12:14 am

That's impossible, currently... The command line doesn't take any parameters, except for those listed in the man page and this: http://wiki.inkscape.org/wiki/index.php/Using_xverbs . You could do alignment with other objects automagically, but almost everything that opens a dialog needing user input is doomed to fail.
You can, however, use an xml parsing library of your choice or an extension to add those transforms programatically. (they can be removed programatically, though: ObjectRemoveTransform) - an extension can be called from the command line, and doesn't necessarily need user input.

Btw. there's also an interactive command line that lets you try things out.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

user1
Posts: 5
Joined: Tue Sep 19, 2017 2:27 am

Re: How to send click signal to the Apply button without using mouse?

Postby user1 » Fri Jan 12, 2018 2:00 am

May somebody refer or write a simple example how to move selected object with python script.

Moini
Posts: 2612
Joined: Mon Oct 05, 2015 10:44 am

Re: How to send click signal to the Apply button without using mouse?

Postby Moini » Fri Jan 12, 2018 8:11 am

Look into the extensions that come with Inkscape, and look for those that add a tranform (or rather: translate) attribute to an object. Or look at how some use functions from simpletransform.py - or use an XML library of your choice to add that translate attribute.
(depending upon the question if you want to use an extension, or write your own script that you can use without relying on Inkscape).

For external scripts to work reliably, make sure that there are either no transforms in your drawing that affect the object you want to move, or that you deal with them properly.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest