Skip to content

Commit e99b123

Browse files
rpaciorektrigg
authored andcommitted
use boxflow in tray and launchers
* use FlowBox instead of Box in tray and launchers widgets to allow configure multi row panel * fixed respecting `tray_icon_size` setting - add css class directly to icon
1 parent 06269c5 commit e99b123

6 files changed

Lines changed: 30 additions & 9 deletions

File tree

metadata/panel.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ If full_span is off, both sides of the panel will take the same amount of space,
154154
<default>0</default>
155155
<min>0</min>
156156
</option>
157+
<option name="launchers_rows_cols" type="int">
158+
<_short>Number of rows (in horizontall panels) or columns (in vertical panels) in Launchers widget</_short>
159+
<default>1</default>
160+
<min>1</min>
161+
</option>
157162
<option name="launchers" type="dynamic-list" type-hint="dict">
158163
<_short>Launchers</_short>
159164
<_long>Launchers</_long>
@@ -560,6 +565,11 @@ If full_span is off, both sides of the panel will take the same amount of space,
560565
<default>5</default>
561566
<min>0</min>
562567
</option>
568+
<option name="tray_rows_cols" type="int">
569+
<_short>Number of rows (in horizontall panels) or columns (in vertical panels) in tray widget</_short>
570+
<default>1</default>
571+
<min>1</min>
572+
</option>
563573
<option name="tray_menu_on_middle_click" type="bool">
564574
<_short>Middle Button Activates Menu</_short>
565575
<_long>Mouse right button activates a tray item's secondary action instead of the item's menu.</_long>

src/panel/widgets/launchers.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,20 @@ void WayfireLaunchers::init(Gtk::Box *container)
171171

172172
void WayfireLaunchers::update_layout()
173173
{
174-
box.set_spacing(spacing);
174+
box.set_column_spacing(spacing);
175+
box.set_row_spacing(spacing);
176+
box.set_max_children_per_line(rows_cols);
177+
box.set_min_children_per_line(rows_cols);
178+
box.set_selection_mode(Gtk::SelectionMode::NONE);
175179

176180
WfOption<std::string> panel_position{"panel/position"};
177181

178182
if (panel_position.value() == PANEL_POSITION_LEFT or panel_position.value() == PANEL_POSITION_RIGHT)
179183
{
180-
box.set_orientation(Gtk::Orientation::VERTICAL);
184+
box.set_orientation(Gtk::Orientation::HORIZONTAL);
181185
} else
182186
{
183-
box.set_orientation(Gtk::Orientation::HORIZONTAL);
187+
box.set_orientation(Gtk::Orientation::VERTICAL);
184188
}
185189
}
186190

src/panel/widgets/launchers.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <vector>
55
#include <giomm/desktopappinfo.h>
66
#include <gtkmm/image.h>
7-
#include <gtkmm/box.h>
7+
#include <gtkmm/flowbox.h>
88
#include <gtkmm/button.h>
99
#include <wayfire/util/duration.hpp>
1010

@@ -27,11 +27,12 @@ struct WfLauncherButton
2727
using launcher_container = std::vector<std::unique_ptr<WfLauncherButton>>;
2828
class WayfireLaunchers : public WayfireWidget
2929
{
30-
Gtk::Box box;
30+
Gtk::FlowBox box;
3131
launcher_container launchers;
3232
launcher_container get_launchers_from_config();
3333

3434
WfOption<int> spacing{"panel/launchers_spacing"};
35+
WfOption<int> rows_cols{"panel/launchers_rows_cols"};
3536

3637
public:
3738
virtual void init(Gtk::Box *container);

src/panel/widgets/tray/item.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void StatusNotifierItem::init_widget()
7878
setup_tooltip();
7979
init_menu();
8080
icon.add_css_class("widget-icon");
81+
icon.add_css_class("tray-button");
8182
add_css_class("tray-button");
8283

8384
auto scroll_gesture = Gtk::EventControllerScroll::create();

src/panel/widgets/tray/tray.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@ void WayfireStatusNotifier::remove_item(const Glib::ustring & service)
3535

3636
void WayfireStatusNotifier::update_layout()
3737
{
38-
icons_box.set_spacing(spacing);
38+
icons_box.set_column_spacing(spacing);
39+
icons_box.set_row_spacing(spacing);
40+
icons_box.set_max_children_per_line(rows_cols);
41+
icons_box.set_min_children_per_line(rows_cols);
42+
icons_box.set_selection_mode(Gtk::SelectionMode::NONE);
3943

4044
WfOption<std::string> panel_position{"panel/position"};
4145

4246
if ((panel_position.value() == PANEL_POSITION_LEFT) || (panel_position.value() == PANEL_POSITION_RIGHT))
4347
{
44-
icons_box.set_orientation(Gtk::Orientation::VERTICAL);
48+
icons_box.set_orientation(Gtk::Orientation::HORIZONTAL);
4549
} else
4650
{
47-
icons_box.set_orientation(Gtk::Orientation::HORIZONTAL);
51+
icons_box.set_orientation(Gtk::Orientation::VERTICAL);
4852
}
4953
}
5054

src/panel/widgets/tray/tray.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ class WayfireStatusNotifier : public WayfireWidget
1111
private:
1212
StatusNotifierHost host = StatusNotifierHost(this);
1313

14-
Gtk::Box icons_box;
14+
Gtk::FlowBox icons_box;
1515
std::map<Glib::ustring, StatusNotifierItem> items;
1616

1717
WfOption<int> spacing{"panel/tray_spacing"};
18+
WfOption<int> rows_cols{"panel/tray_rows_cols"};
1819

1920
void update_layout();
2021
void handle_config_reload();

0 commit comments

Comments
 (0)