Skip to content

Commit 04437b3

Browse files
authored
Merge pull request #71 from WayfireWM/logout-button
panel menu: Add logout button
2 parents db2ef72 + db8b3e1 commit 04437b3

6 files changed

Lines changed: 31 additions & 2 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "subprojects/gvc"]
55
path = subprojects/gvc
66
url = https://github.com/GNOME/libgnome-volume-control
7+
[submodule "subprojects/wayland-logout"]
8+
path = subprojects/wayland-logout
9+
url = https://github.com/soreau/wayland-logout

meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ gtklayershell = dependency('gtk-layer-shell-0', version: '>= 0.1', fallback: ['
2222
libpulse = dependency('libpulse', required : get_option('pulse'))
2323
libgvc = subproject('gvc', default_options: ['static=true'], required : get_option('pulse'))
2424

25+
wayland_logout = subproject('wayland-logout')
26+
2527
if libpulse.found()
2628
libgvc = libgvc.get_variable('libgvc_dep')
2729
add_project_arguments('-DHAVE_PULSE=1', language : 'cpp')

metadata/panel.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
<hint>file</hint>
170170
<default></default>
171171
</option>
172+
<option name="menu_logout_command" type="string">
173+
<_short>Menu Logout Command</_short>
174+
<default>wayland-logout</default>
175+
</option>
172176
</group>
173177
<group>
174178
<_short>Volume</_short>

src/panel/widgets/menu.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ void WayfireMenu::update_popover_layout()
303303
popover_layout_box.show_all();
304304
}
305305

306+
void WayfireMenu::on_logout_click()
307+
{
308+
g_spawn_command_line_async(std::string(menu_logout_command).c_str(), NULL);
309+
}
310+
306311
void WayfireMenu::init(Gtk::HBox *container)
307312
{
308313
menu_icon.set_callback([=] () { update_icon(); });
@@ -324,6 +329,15 @@ void WayfireMenu::init(Gtk::HBox *container)
324329
container->pack_start(hbox, false, false);
325330
hbox.pack_start(*button, false, false);
326331

332+
logout_button.set_image_from_icon_name("system-shutdown", Gtk::ICON_SIZE_DIALOG);
333+
logout_button.signal_clicked().connect_notify(
334+
sigc::mem_fun(this, &WayfireMenu::on_logout_click));
335+
logout_button.property_margin().set_value(20);
336+
logout_button.set_margin_right(35);
337+
hbox_bottom.pack_end(logout_button, false, false);
338+
popover_layout_box.pack_end(hbox_bottom);
339+
popover_layout_box.pack_end(separator);
340+
327341
load_menu_items_all();
328342
update_popover_layout();
329343

src/panel/widgets/menu.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <gtkmm/image.h>
99
#include <gtkmm/flowbox.h>
1010
#include <gtkmm/scrolledwindow.h>
11+
#include <gtkmm/separator.h>
1112
#include <set>
1213

1314
class WayfireMenu;
@@ -37,12 +38,14 @@ class WfMenuMenuItem : public Gtk::HBox
3738
class WayfireMenu : public WayfireWidget
3839
{
3940
Gtk::Box flowbox_container;
40-
Gtk::HBox hbox;
41+
Gtk::HBox hbox, hbox_bottom;
4142
Gtk::VBox bottom_pad;
4243
Gtk::VBox popover_layout_box;
44+
Gtk::Separator separator;
4345
Gtk::Image main_image;
4446
Gtk::Entry search_box;
4547
Gtk::FlowBox flowbox;
48+
Gtk::Button logout_button;
4649
Gtk::ScrolledWindow scrolled_window;
4750
std::unique_ptr<WayfireMenuButton> button;
4851

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

71+
WfOption<std::string> menu_logout_command{"panel/menu_logout_command"};
6872
WfOption<bool> fuzzy_search_enabled{"panel/menu_fuzzy_search"};
6973
WfOption<std::string> panel_position{"panel/position"};
70-
WfOption<int> menu_size{"panel/launchers_size"};
7174
WfOption<std::string> menu_icon{"panel/menu_icon"};
75+
WfOption<int> menu_size{"panel/launchers_size"};
7276
void update_popover_layout();
77+
void on_logout_click();
7378

7479
public:
7580
void init(Gtk::HBox *container) override;

subprojects/wayland-logout

Submodule wayland-logout added at ab7c143

0 commit comments

Comments
 (0)