Introduction
I am Vaibhav Malik, a Google Summer Of Code contributor and developer at Inkscape. This blog summarizes my progress during the third week of the Google Summer Of Code 2023.
June 12
As per Mikekov's suggestions, I started working on using multiple popover buttons to manage overflowing content in the toolbars. After thinking for some time, I decided to create a new ToolbarMenuButton
widget for this task. And it will also be Gtk::Builder
derivable. Below is the ToolbarMenuButton
class structure.
class ToolbarMenuButton : public Gtk::MenuButton
{
int _priority;
std::string _tag;
std::vector<std::pair<int, Gtk::Widget *>> _children;
Gtk::Box *_popover_box;
public:
ToolbarMenuButton();
~ToolbarMenuButton() override{};
ToolbarMenuButton(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &refGlade);
void init(int priority, std::string tag, std::string icon_name, Gtk::Box *popover_box,
std::vector<Gtk::Widget *> &children);
int get_priority();
std::string get_tag();
std::vector<std::pair<int, Gtk::Widget *>> get_children();
Gtk::Box *get_popover_box();
int get_required_width();
};
June 13
Even though the class structure was clear to me, the class methods were yet to be defined. I started by asking questions to myself.
How will Glade identify which child belongs to which popover?
Assign a
tag
to eachToolbarMenuButton
and add the sametag
style class to its children widgets.Then, as soon as the button is initialized, add the children to its
children
vector.
Which
ToolbarMenuButton
will be collapsed first?- Use the priority property.
How to handle the movement of children between the toolbar and their
ToolbarMenuButton
?- Use the same logic as used for
resize_handler
but, this time, move all the children of that popover in or out at once.
- Use the same logic as used for
How to manage different
ToolbarMenuButton
widgets in the toolbar?Use two stacks, one to store the collapsed
ToolbarMenuButton
widgets and the other to store theexpanded
ones.If the toolbar size is decreasing, pop out the top-most menu button widget in the
expanded
stack, move its children inside the popover and push the menu button into thecollapsed
stack. In the end, set the menu button visible.On the other hand, if the toolbar size increases, check if the toolbar is large enough to house the last collapsed menu button's children widgets. If yes, then move the children from the popover to the toolbar. And transfer the just expanded menu button to the
expanded
stack. And set the menu button invisible.
June 14
I was determined to wrap up the toolbar menu button's class methods today. Just as I expected, configuring the widget to integrate with the builder consumed most of my time. But as I kept trying, I started getting the hang of it. When I got it working, I gave myself a treat, lol. Next, I added the remaining methods to the class.
Link to the video featuring the Select toolbar having multiple toolbar menu button widgets:
https://drive.google.com/file/d/11JGpcjO8KKAZu6yH8_sAc3vOrxzg6n57/view?usp=sharing
June 15
Today, I Asked Mikov and Tav for a review of the latest implementation. They liked this idea and gave some suggestions to make it better.
Add icons to the menu buttons.
Remove the
Gtk::Separator
widget from the popovers. As it looks like a line in some themes.Some translatable strings fixes.
Create a new CSS style class for all the popovers to keep the style consistent between different popovers.
Try removing the
context_item
style class, as it seems odd in the code and not very noticeable.
June 16
Worked on the suggestions and added CSS style classes to the popovers in the toolbar-select.ui
file. Fixed translatable strings and removed separators from popovers. Added dummy images as icons inside the ToolbarMenuButton
widgets.
June 17 and June 18
I noticed that, on switching tools, the new toolbar was behaving bizarrely. I tried to investigate this issue. It seems like some allocation problem to me. I will fix it in the coming days. And then I enjoyed the weekend :)
Conclusion
That's all for this week. I'm happy I could add some code and better functionality this week. Stay tuned for further updates. Thanks for reading. Sayonara :)