Setting text of entry box

The text in the entry box (the one in the dialog that opens up on clicking ‘+’ at the bottom of style dialog) determines the value of ‘class’ attribute of an object. A default text value shows up in the dialog box if no object is selected in the drawing.

Screenshot from 2016-06-07 00:14:38

In case, one object is selected, by default its id shows up in the text dialog. The user can change this text if he/she wishes.
Screenshot from 2016-06-07 00:15:35

However, if two or more objects are selected, then the text value in the entry box contains id of each of the selected objects separated by a space. In all the cases, clicking ‘Add’ adds a new selector to the treeview.
Screenshot from 2016-06-07 00:20:00

Also if some selection exists, then the class attribute of the object is set with value equal to text in the entry box. If class attribute for an object already has a value, then the new value added by the user is appended to the existing one.

_setClassAttribute(std::vector<spobject *>) is used to append the values in case multiple objects are selected. This function is called when text in the entry box has to be set up.

Adding UI components to Style Dialog

The list of UI components to be added to the style dialog include:

  • A treeView to display the list of selectors.
  • A button to add a new selector to the list of selectors
  • A button to delete selector from the selectors’ list

The buttons have been added to a HBox _buttonBox which is further contained in a bigger VBox _mainbox in the dialog. The _mainBox contains both the treeview and the HBox containing the two buttons to add and delete selectors. Currently, I have disabled the delete button, keeping my focus on functionality to add selector.

Lack of documentation of gtkmm was not very helpful. I faced some issues which I was unable to solve initially. Since Inkscape is migrating to Gtk+ 3, so I developed the UI components using Gtk+ instead of gtkmm. But the long term goal of Inkscape’s development cycle involves migrating to gtkmm completely, so as guided by mentor Tavmjong Bah, I moved back to gtkmm.

Some of the issues I confronted include:

  1. Button size expanded as I changed the size of the dialog. In the correct case, it should have remained standard. Using the appropriate flag from the enum Gtk::PackOptions, I was able to fix it.
  2. On adding the treeview to the dialog, empty space appeared at the top in the widget. Using the pack_start() function with appropriate packing options, all options available, this is not fixed yet.

Screenshot from 2016-06-04 22:13:55