Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "subprojects/wayland-logout"]
path = subprojects/wayland-logout
url = https://github.com/soreau/wayland-logout
[submodule "subprojects/wf-json"]
path = subprojects/wf-json
url = https://github.com/WayfireWM/wf-json
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ project(
)

wayfire = dependency('wayfire')
json = subproject('wf-json').get_variable('wfjson')
wayland_client = dependency('wayland-client')
wayland_protos = dependency('wayland-protocols')
gtkmm = dependency('gtkmm-3.0', version: '>=3.24')
Expand All @@ -22,6 +23,7 @@ gtklayershell = dependency('gtk-layer-shell-0', version: '>= 0.6', fallback: ['
libpulse = dependency('libpulse', required : get_option('pulse'))
dbusmenu_gtk = dependency('dbusmenu-gtk3-0.4')
libgvc = subproject('gvc', default_options: ['static=true'], required : get_option('pulse'))
xkbregistry = dependency('xkbregistry')

if get_option('wayland-logout') == true
wayland_logout = subproject('wayland-logout')
Expand Down
10 changes: 10 additions & 0 deletions metadata/dock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
<_short>Autohide duration</_short>
<default>300</default>
</option>
<option name="autohide_show_delay" type="int">
<_short>Autohide show delay</_short>
<_long>Amount of time (in milliseconds) the cursor needs to be in the zone before showing.</_long>
<default>300</default>
</option>
<option name="autohide_hide_delay" type="int">
<_short>Autohide hide delay</_short>
<_long>Amount of time (in milliseconds) the cursor needs to be out of the zone before hiding.</_long>
<default>5000</default>
</option>
<option name="position" type="string">
<_short>Position</_short>
<default>bottom</default>
Expand Down
39 changes: 38 additions & 1 deletion metadata/panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
<_short>Autohide Duration</_short>
<default>300</default>
</option>
<option name="autohide_show_delay" type="int">
<_short>Autohide show delay</_short>
<_long>Amount of time (in milliseconds) the cursor needs to be in the zone before showing.</_long>
<default>300</default>
</option>
<option name="autohide_hide_delay" type="int">
<_short>Autohide hide delay</_short>
<_long>Amount of time (in milliseconds) the cursor needs to be out of the zone before hiding.</_long>
<default>5000</default>
</option>
<option name="position" type="string">
<_short>Panel Position</_short>
<default>top</default>
Expand Down Expand Up @@ -84,6 +94,21 @@
<option name="launchers_size" type="int">
<_short>Launchers Size</_short>
<default>42</default>
</option>
<option name="launchers" type="dynamic-list" type-hint="dict">
<_short>Launchers</_short>
<_long>Launchers</_long>
<entry prefix="launcher_cmd_" type="string" name="cmd">
<_short>Command</_short>
<_long>Command</_long>
<hint>file</hint>
</entry>
<entry prefix="launcher_icon_" type="string" name="cmd">
<_short>Icon</_short>
</entry>
<entry prefix="launcher_label_" type="string" name="label">
<_short>Label</_short>
</entry>
</option>
</group>
<group>
Expand Down Expand Up @@ -254,6 +279,18 @@
<_short>Notifications Display Timeout</_short>
<_long>Set to negative value to disable.</_long>
<default>2.5</default>
</option>
<option name="notification_width" type="int">
<_short>Notification center Width</_short>
<default>500</default>
<min>100</min>
<max>5000</max>
</option>
<option name="notification_height" type="int">
<_short>Notificaton center Height</_short>
<default>600</default>
<min>100</min>
<max>5000</max>
</option>
<option name="notifications_critical_in_dnd" type="bool">
<_short>Always Show Critical notifications</_short>
Expand All @@ -264,7 +301,7 @@
<_short>Notifications Icon Size</_short>
<default>32</default>
<min>1</min>
</option>
</option>
</group>
<group>
<_short>Tray</_short>
Expand Down
3 changes: 2 additions & 1 deletion src/panel/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ widget_sources = ['widgets/battery.cpp',
'widgets/network.cpp',
'widgets/spacing.cpp',
'widgets/separator.cpp',
'widgets/language.cpp',
'widgets/window-list/window-list.cpp',
'widgets/window-list/toplevel.cpp',
'widgets/notifications/daemon.cpp',
Expand All @@ -17,7 +18,7 @@ widget_sources = ['widgets/battery.cpp',
'widgets/tray/item.cpp',
'widgets/tray/host.cpp']

deps = [gtkmm, wayland_client, libutil, wf_protos, wfconfig, gtklayershell, dbusmenu_gtk]
deps = [gtkmm, wayland_client, libutil, wf_protos, wfconfig, gtklayershell, xkbregistry, json, dbusmenu_gtk]

if libpulse.found()
widget_sources += 'widgets/volume.cpp'
Expand Down
167 changes: 122 additions & 45 deletions src/panel/panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "widgets/battery.hpp"
#include "widgets/command-output.hpp"
#include "widgets/language.hpp"
#include "widgets/menu.hpp"
#include "widgets/clock.hpp"
#include "widgets/launchers.hpp"
Expand Down Expand Up @@ -78,7 +79,7 @@ class WayfirePanel::impl

window->override_background_color(rgba);
};

WfOption<std::string> panel_layer{"panel/layer"};
std::function<void()> set_panel_layer = [=] ()
{
Expand Down Expand Up @@ -119,10 +120,7 @@ class WayfirePanel::impl
bg_color.set_callback(on_window_color_updated);
on_window_color_updated(); // set initial color

window->show_all();
init_widgets();
init_layout();


window->signal_delete_event().connect(
sigc::mem_fun(this, &WayfirePanel::impl::on_delete));
}
Expand All @@ -134,22 +132,7 @@ class WayfirePanel::impl
return true;
}

void init_layout()
{
left_box.get_style_context()->add_class("left");
center_box.get_style_context()->add_class("center");
right_box.get_style_context()->add_class("right");
content_box.pack_start(left_box, false, false);
content_box.pack_end(right_box, false, false);
if (!center_box.get_children().empty())
{
content_box.set_center_widget(center_box);
}

center_box.show_all();
window->add(content_box);
window->show_all();
}

std::optional<int> widget_with_value(std::string value, std::string prefix)
{
Expand Down Expand Up @@ -225,6 +208,19 @@ class WayfirePanel::impl
{
return Widget(new WfCommandOutputButtons());
}

if (name == "language")
{
if (get_ipc_server_instance()->connected)
{
return Widget(new WayfireLanguage());
} else
{
std::cerr << "Wayfire IPC not connected, which is required to load language widget." <<
std::endl;
return nullptr;
}
}

if (auto pixel = widget_with_value(name, "spacing"))
{
Expand Down Expand Up @@ -285,34 +281,10 @@ class WayfirePanel::impl
WfOption<std::string> left_widgets_opt{"panel/widgets_left"};
WfOption<std::string> right_widgets_opt{"panel/widgets_right"};
WfOption<std::string> center_widgets_opt{"panel/widgets_center"};
void init_widgets()
{
left_widgets_opt.set_callback([=] ()
{
reload_widgets((std::string)left_widgets_opt, left_widgets, left_box);
});
right_widgets_opt.set_callback([=] ()
{
reload_widgets((std::string)right_widgets_opt, right_widgets, right_box);
});
center_widgets_opt.set_callback([=] ()
{
reload_widgets((std::string)center_widgets_opt, center_widgets, center_box);
if (center_box.get_children().empty())
{
content_box.unset_center_widget();
} else
{
content_box.set_center_widget(center_box);
}
});

reload_widgets((std::string)left_widgets_opt, left_widgets, left_box);
reload_widgets((std::string)right_widgets_opt, right_widgets, right_box);
reload_widgets((std::string)center_widgets_opt, center_widgets, center_box);
}

public:

impl(WayfireOutput *output) : output(output)
{
create_window();
Expand Down Expand Up @@ -345,6 +317,67 @@ class WayfirePanel::impl
w->handle_config_reload();
}
}

WayfirePanelApp *panel_app;
void set_panel_app(WayfirePanelApp *panel_app)
{
this->panel_app = panel_app;
}

void init_widgets()
{

left_widgets_opt.set_callback([=] ()
{
reload_widgets((std::string)left_widgets_opt, left_widgets, left_box);
});
right_widgets_opt.set_callback([=] ()
{
reload_widgets((std::string)right_widgets_opt, right_widgets, right_box);
});
center_widgets_opt.set_callback([=] ()
{
reload_widgets((std::string)center_widgets_opt, center_widgets, center_box);
if (center_box.get_children().empty())
{
content_box.unset_center_widget();
} else
{
content_box.set_center_widget(center_box);
}
});

reload_widgets((std::string)left_widgets_opt, left_widgets, left_box);
reload_widgets((std::string)right_widgets_opt, right_widgets, right_box);
reload_widgets((std::string)center_widgets_opt, center_widgets, center_box);
}

void init_layout()
{
left_box.get_style_context()->add_class("left");
center_box.get_style_context()->add_class("center");
right_box.get_style_context()->add_class("right");
content_box.pack_start(left_box, false, false);
content_box.pack_end(right_box, false, false);
if (!center_box.get_children().empty())
{
content_box.set_center_widget(center_box);
}

center_box.show_all();
window->add(content_box);
window->show_all();
}
void unhide_now()
{

window->m_show_uncertain();

}
std::shared_ptr<WayfireIPC> get_ipc_server_instance()
{
return panel_app->get_ipc_server_instance();
}
};

WayfirePanel::WayfirePanel(WayfireOutput *output) : pimpl(new impl(output))
Expand All @@ -364,6 +397,27 @@ void WayfirePanel::handle_config_reload()
return pimpl->handle_config_reload();
}

void WayfirePanel::init_widgets()
{
pimpl->init_widgets();
}

void WayfirePanel::init_layout()
{
pimpl->init_layout();
}

void WayfirePanel::unhide_now()
{
pimpl->unhide_now();
}

void WayfirePanel::set_panel_app(WayfirePanelApp *panel_app)
{
pimpl->set_panel_app(panel_app);
}


class WayfirePanelApp::impl
{
public:
Expand Down Expand Up @@ -436,8 +490,18 @@ void WayfirePanelApp::add_css_file(std::string file, int priority)

void WayfirePanelApp::handle_new_output(WayfireOutput *output)
{
if (!ipc_server)
{
ipc_server = WayfireIPC::get_instance();
}

priv->panels[output] = std::unique_ptr<WayfirePanel>(
new WayfirePanel(output));
priv->panels[output]->handle_config_reload();
priv->panels[output]->set_panel_app(this);
priv->panels[output]->init_widgets();
priv->panels[output]->init_layout();

}

WayfirePanel*WayfirePanelApp::panel_for_wl_output(wl_output *output)
Expand Down Expand Up @@ -468,6 +532,11 @@ WayfirePanelApp& WayfirePanelApp::get()
return dynamic_cast<WayfirePanelApp&>(*instance.get());
}

std::shared_ptr<WayfireIPC> WayfirePanelApp::get_ipc_server_instance()
{
return ipc_server;
}

void WayfirePanelApp::create(int argc, char **argv)
{
if (instance)
Expand All @@ -479,6 +548,14 @@ void WayfirePanelApp::create(int argc, char **argv)
instance->run();
}

void WayfirePanelApp::unhide_now()
{
for (auto& p : priv->panels)
{
p.second->unhide_now();
}
}

WayfirePanelApp::~WayfirePanelApp() = default;
WayfirePanelApp::WayfirePanelApp(int argc, char **argv) :
WayfireShellApp(argc, argv), priv(new impl())
Expand Down
Loading