Skip to content

panel menu: Add logout button #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2020
Merged
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 @@ -4,3 +4,6 @@
[submodule "subprojects/gvc"]
path = subprojects/gvc
url = https://github.com/GNOME/libgnome-volume-control
[submodule "subprojects/wayland-logout"]
path = subprojects/wayland-logout
url = https://github.com/soreau/wayland-logout
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ gtklayershell = dependency('gtk-layer-shell-0', version: '>= 0.1', fallback: ['
libpulse = dependency('libpulse', required : get_option('pulse'))
libgvc = subproject('gvc', default_options: ['static=true'], required : get_option('pulse'))

wayland_logout = subproject('wayland-logout')

if libpulse.found()
libgvc = libgvc.get_variable('libgvc_dep')
add_project_arguments('-DHAVE_PULSE=1', language : 'cpp')
Expand Down
4 changes: 4 additions & 0 deletions metadata/panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
<hint>file</hint>
<default></default>
</option>
<option name="menu_logout_command" type="string">
<_short>Menu Logout Command</_short>
<default>wayland-logout</default>
</option>
</group>
<group>
<_short>Volume</_short>
Expand Down
14 changes: 14 additions & 0 deletions src/panel/widgets/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ void WayfireMenu::update_popover_layout()
popover_layout_box.show_all();
}

void WayfireMenu::on_logout_click()
{
g_spawn_command_line_async(std::string(menu_logout_command).c_str(), NULL);
}

void WayfireMenu::init(Gtk::HBox *container)
{
menu_icon.set_callback([=] () { update_icon(); });
Expand All @@ -324,6 +329,15 @@ void WayfireMenu::init(Gtk::HBox *container)
container->pack_start(hbox, false, false);
hbox.pack_start(*button, false, false);

logout_button.set_image_from_icon_name("system-shutdown", Gtk::ICON_SIZE_DIALOG);
logout_button.signal_clicked().connect_notify(
sigc::mem_fun(this, &WayfireMenu::on_logout_click));
logout_button.property_margin().set_value(20);
logout_button.set_margin_right(35);
hbox_bottom.pack_end(logout_button, false, false);
popover_layout_box.pack_end(hbox_bottom);
popover_layout_box.pack_end(separator);

load_menu_items_all();
update_popover_layout();

Expand Down
9 changes: 7 additions & 2 deletions src/panel/widgets/menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <gtkmm/image.h>
#include <gtkmm/flowbox.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/separator.h>
#include <set>

class WayfireMenu;
Expand Down Expand Up @@ -37,12 +38,14 @@ class WfMenuMenuItem : public Gtk::HBox
class WayfireMenu : public WayfireWidget
{
Gtk::Box flowbox_container;
Gtk::HBox hbox;
Gtk::HBox hbox, hbox_bottom;
Gtk::VBox bottom_pad;
Gtk::VBox popover_layout_box;
Gtk::Separator separator;
Gtk::Image main_image;
Gtk::Entry search_box;
Gtk::FlowBox flowbox;
Gtk::Button logout_button;
Gtk::ScrolledWindow scrolled_window;
std::unique_ptr<WayfireMenuButton> button;

Expand All @@ -65,11 +68,13 @@ class WayfireMenu : public WayfireWidget
* so that we don't show duplicate entries */
std::set<std::pair<std::string, std::string>> loaded_apps;

WfOption<std::string> menu_logout_command{"panel/menu_logout_command"};
WfOption<bool> fuzzy_search_enabled{"panel/menu_fuzzy_search"};
WfOption<std::string> panel_position{"panel/position"};
WfOption<int> menu_size{"panel/launchers_size"};
WfOption<std::string> menu_icon{"panel/menu_icon"};
WfOption<int> menu_size{"panel/launchers_size"};
void update_popover_layout();
void on_logout_click();

public:
void init(Gtk::HBox *container) override;
Expand Down
1 change: 1 addition & 0 deletions subprojects/wayland-logout
Submodule wayland-logout added at ab7c14