Skip to content
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
9 changes: 3 additions & 6 deletions src/dock/dock.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#ifndef WF_DOCK_HPP
#define WF_DOCK_HPP
#pragma once

#include <gtkmm/box.h>
#include <wayland-client.h>
#include <wlr-foreign-toplevel-management-unstable-v1-client-protocol.h>
#include <wf-option-wrap.hpp>

#include "wf-shell-app.hpp"
#include "wlr-foreign-toplevel-management-unstable-v1-client-protocol.h"
#include <wf-option-wrap.hpp>

class WfDock
{
Expand Down Expand Up @@ -49,5 +48,3 @@ class WfDockApp : public WayfireShellApp
class impl;
std::unique_ptr<impl> priv;
};

#endif /* end of include guard: WF_DOCK_HPP */
5 changes: 1 addition & 4 deletions src/dock/toplevel-icon.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef WF_DOCK_TOPLEVEL_ICON_HPP
#define WF_DOCK_TOPLEVEL_ICON_HPP
#pragma once

#include <memory>
#include <wlr-foreign-toplevel-management-unstable-v1-client-protocol.h>
Expand All @@ -26,5 +25,3 @@ namespace IconProvider
* They have the format icon_mapping_<app_id> = <icon file> */
void load_custom_icons();
}

#endif /* end of include guard: WF_DOCK_TOPLEVEL_ICON_HPP */
5 changes: 1 addition & 4 deletions src/dock/toplevel.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef WF_DOCK_TOPLEVEL_HPP
#define WF_DOCK_TOPLEVEL_HPP
#pragma once

#include <memory>
#include <wlr-foreign-toplevel-management-unstable-v1-client-protocol.h>
Expand Down Expand Up @@ -27,5 +26,3 @@ class WfToplevel
private:
std::unique_ptr<impl> pimpl;
};

#endif /* end of include guard: WF_DOCK_TOPLEVEL_HPP */
1 change: 0 additions & 1 deletion src/panel/panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <css-config.hpp>
#include "panel.hpp"

#include "wf-ipc.hpp"
#include "widgets/battery.hpp"
#include "widgets/command-output.hpp"
#include "widgets/language.hpp"
Expand Down
5 changes: 1 addition & 4 deletions src/panel/panel.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef WF_PANEL_HPP
#define WF_PANEL_HPP
#pragma once

#include <memory>
#include <wayland-client.h>
Expand Down Expand Up @@ -45,5 +44,3 @@ class WayfirePanelApp : public WayfireShellApp
class impl;
std::unique_ptr<impl> priv;
};

#endif /* end of include guard: WF_PANEL_HPP */
5 changes: 1 addition & 4 deletions src/panel/widget.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef WIDGET_HPP
#define WIDGET_HPP
#pragma once

#include <gtkmm/box.h>
#include <wf-option-wrap.hpp>
Expand All @@ -23,5 +22,3 @@ class WayfireWidget
virtual ~WayfireWidget()
{}
};

#endif /* end of include guard: WIDGET_HPP */
12 changes: 9 additions & 3 deletions src/panel/widgets/battery.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "battery.hpp"
#include <gtk-utils.hpp>
#include <iostream>
#include <algorithm>

#include "battery.hpp"

#define UPOWER_NAME "org.freedesktop.UPower"
#define DISPLAY_DEVICE "/org/freedesktop/UPower/devices/DisplayDevice"
Expand Down Expand Up @@ -197,7 +197,7 @@ bool WayfireBatteryInfo::setup_dbus()
display_device->get_cached_property(present, SHOULD_DISPLAY);
if (present.get())
{
display_device->signal_properties_changed().connect(
disp_dev_sig = display_device->signal_properties_changed().connect(
sigc::mem_fun(*this, &WayfireBatteryInfo::on_properties_changed));

return true;
Expand Down Expand Up @@ -232,3 +232,9 @@ void WayfireBatteryInfo::init(Gtk::Box *container)
button.property_scale_factor().signal_changed()
.connect(sigc::mem_fun(*this, &WayfireBatteryInfo::update_icon));
}

WayfireBatteryInfo::~WayfireBatteryInfo()
{
btn_sig.disconnect();
disp_dev_sig.disconnect();
}
12 changes: 6 additions & 6 deletions src/panel/widgets/battery.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef WIDGETS_BATTERY_HPP
#define WIDGETS_BATTERY_HPP
#pragma once

#include <gtkmm/button.h>
#include <gtkmm/image.h>
Expand All @@ -9,6 +8,8 @@
#include <giomm/dbusproxy.h>
#include <giomm/dbusconnection.h>

#include <sigc++/connection.h>

#include "../widget.hpp"

using DBusConnection = Glib::RefPtr<Gio::DBus::Connection>;
Expand All @@ -23,6 +24,8 @@ class WayfireBatteryInfo : public WayfireWidget
{
WfOption<std::string> status_opt{"panel/battery_status"};

sigc::connection btn_sig, disp_dev_sig;

Gtk::Button button;
Gtk::Label label;
Gtk::Box button_box;
Expand All @@ -44,8 +47,5 @@ class WayfireBatteryInfo : public WayfireWidget

public:
virtual void init(Gtk::Box *container);
virtual ~WayfireBatteryInfo() = default;
virtual ~WayfireBatteryInfo();
};


#endif /* end of include guard: WIDGETS_BATTERY_HPP */
3 changes: 2 additions & 1 deletion src/panel/widgets/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void WayfireClock::init(Gtk::Box *container)
button->get_popover()->get_style_context()->add_class("clock-popover");
button->get_children()[0]->get_style_context()->add_class("flat");
button->get_popover()->set_child(calendar);
button->get_popover()->signal_show().connect(
btn_sig = button->get_popover()->signal_show().connect(
sigc::mem_fun(*this, &WayfireClock::on_calendar_shown));

container->append(*button);
Expand Down Expand Up @@ -57,5 +57,6 @@ bool WayfireClock::update_label()

WayfireClock::~WayfireClock()
{
btn_sig.disconnect();
timeout.disconnect();
}
7 changes: 2 additions & 5 deletions src/panel/widgets/clock.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef WIDGETS_CLOCK_HPP
#define WIDGETS_CLOCK_HPP
#pragma once

#include "../widget.hpp"
#include "wf-popover.hpp"
Expand All @@ -12,7 +11,7 @@ class WayfireClock : public WayfireWidget
Gtk::Calendar calendar;
std::unique_ptr<WayfireMenuButton> button;

sigc::connection timeout;
sigc::connection timeout, btn_sig;
WfOption<std::string> format{"panel/clock_format"};

void on_calendar_shown();
Expand All @@ -22,5 +21,3 @@ class WayfireClock : public WayfireWidget
bool update_label();
~WayfireClock();
};

#endif /* end of include guard: WIDGETS_CLOCK_HPP */
22 changes: 16 additions & 6 deletions src/panel/widgets/command-output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <gtk-utils.hpp>

static void label_set_from_command(std::string command_line,
static sigc::connection label_set_from_command(std::string command_line,
Gtk::Label& label)
{
command_line = "/bin/sh -c \"" + command_line + "\"";
Expand All @@ -21,7 +21,7 @@ static void label_set_from_command(std::string command_line,
Glib::spawn_async_with_pipes("", Glib::shell_parse_argv(command_line),
Glib::SpawnFlags::DO_NOT_REAP_CHILD | Glib::SpawnFlags::SEARCH_PATH_FROM_ENVP,
Glib::SlotSpawnChildSetup{}, &pid, nullptr, &output_fd, nullptr);
Glib::signal_child_watch().connect([=, &label] (Glib::Pid pid, int exit_status)
return Glib::signal_child_watch().connect([=, &label] (Glib::Pid pid, int exit_status)
{
FILE *file = fdopen(output_fd, "r");
Glib::ustring output;
Expand Down Expand Up @@ -95,10 +95,11 @@ WfCommandOutputButtons::CommandOutput::CommandOutput(const std::string & name,

const auto update_output = [=] ()
{
label_set_from_command(command, main_label);
command_sig.disconnect();
command_sig = label_set_from_command(command, main_label);
};

signal_clicked().connect(update_output);
signals.push_back(signal_clicked().connect(update_output));

if (period > 0)
{
Expand All @@ -118,8 +119,17 @@ WfCommandOutputButtons::CommandOutput::CommandOutput(const std::string & name,
{
set_has_tooltip();
tooltip_label.show();
signal_query_tooltip().connect(sigc::mem_fun(*this,
&WfCommandOutputButtons::CommandOutput::query_tooltip), false);
signals.push_back(signal_query_tooltip().connect(sigc::mem_fun(*this,
&WfCommandOutputButtons::CommandOutput::query_tooltip), false));
}
}

WfCommandOutputButtons::CommandOutput::~CommandOutput()
{
timeout_connection.disconnect();
for (auto signal : signals)
{
signal.disconnect();
}
}

Expand Down
15 changes: 6 additions & 9 deletions src/panel/widgets/command-output.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef COMMAND_OUTPUT_HPP
#define COMMAND_OUTPUT_HPP
#pragma once

#include "../widget.hpp"

Expand All @@ -8,13 +7,16 @@
#include <gtkmm/label.h>
#include <gtkmm/scrolledwindow.h>

#include <vector>
#include <sigc++/connection.h>
#include <wayfire/config/compound-option.hpp>

class WfCommandOutputButtons : public WayfireWidget
{
struct CommandOutput : public Gtk::Button
{
sigc::connection timeout_connection;
sigc::connection timeout_connection, command_sig;
std::vector<sigc::connection> signals;

Gtk::Box box;
Gtk::Image icon;
Expand All @@ -39,10 +41,7 @@ class WfCommandOutputButtons : public WayfireWidget
CommandOutput& operator =(const CommandOutput&) = delete;
bool query_tooltip(int i, int j, bool k, const std::shared_ptr<Gtk::Tooltip>& tooltip);
void update_tooltip();
~CommandOutput() override
{
timeout_connection.disconnect();
}
~CommandOutput() override;
};

Gtk::Box box;
Expand All @@ -55,5 +54,3 @@ class WfCommandOutputButtons : public WayfireWidget
void init(Gtk::Box *container) override;
void update_buttons();
};

#endif /* end of include guard: COMMAND_OUTPUT_HPP */
10 changes: 6 additions & 4 deletions src/panel/widgets/language.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
#include <cstddef>
#include <cstdint>

#include <glibmm.h>
#include <iostream>
#include <gtkmm/button.h>

#include <map>
#include <memory>
#include <string>
#include <vector>
#include <wayfire/util/log.hpp>
#include <xkbcommon/xkbregistry.h>

#include "language.hpp"
#include "gtkmm/button.h"
#include "sigc++/functors/mem_fun.h"
#include "wf-ipc.hpp"

void WayfireLanguage::init(Gtk::Box *container)
{
button.get_style_context()->add_class("language");
button.get_style_context()->add_class("flat");
button.get_style_context()->remove_class("activated");
button.signal_clicked().connect(sigc::mem_fun(*this, &WayfireLanguage::next_layout));
btn_sig = button.signal_clicked().connect(sigc::mem_fun(*this, &WayfireLanguage::next_layout));
button.show();

ipc_client->subscribe(this, {"keyboard-modifier-state-changed"});
Expand Down Expand Up @@ -121,4 +122,5 @@ WayfireLanguage::WayfireLanguage()
WayfireLanguage::~WayfireLanguage()
{
ipc_client->unsubscribe(this);
btn_sig.disconnect();
}
14 changes: 7 additions & 7 deletions src/panel/widgets/language.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#ifndef WIDGETS_LANGUAGE_HPP
#define WIDGETS_LANGUAGE_HPP
#pragma once

#include "../widget.hpp"
#include "gtkmm/button.h"
#include "wf-ipc.hpp"
#include <cstdint>
#include <gtkmm/button.h>
#include <gtkmm/calendar.h>
#include <gtkmm/label.h>
#include <wayfire/nonstd/json.hpp>
#include <string>
#include <vector>
#include <sigc++/connection.h>

#include "../widget.hpp"
#include "wf-ipc.hpp"

struct Layout
{
Expand All @@ -21,6 +22,7 @@ class WayfireLanguage : public WayfireWidget, public IIPCSubscriber
{
// Gtk::Label label;
Gtk::Button button;
sigc::connection btn_sig;

std::shared_ptr<IPCClient> ipc_client;
uint32_t current_layout;
Expand All @@ -36,5 +38,3 @@ class WayfireLanguage : public WayfireWidget, public IIPCSubscriber
WayfireLanguage();
~WayfireLanguage();
};

#endif /* end of include guard: WIDGETS_LANGUAGE_HPP */
11 changes: 7 additions & 4 deletions src/panel/widgets/launchers.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "launchers.hpp"

#include <giomm/file.h>
#include <glibmm/spawn.h>
#include <glibmm/keyfile.h>
#include <gtkmm/icontheme.h>
#include <gdk/gdkcairo.h>
#include <cassert>
#include <iostream>
#include <gtk-utils.hpp>
#include <wf-shell-app.hpp>

#include "wf-shell-app.hpp"

bool WfLauncherButton::initialize(std::string name, std::string icon, std::string label)
{
Expand Down Expand Up @@ -49,7 +50,7 @@ bool WfLauncherButton::initialize(std::string name, std::string icon, std::strin
style->add_class("flat");
style->add_class("launcher");

button.signal_clicked().connect([=] () { launch(); });
btn_sig = button.signal_clicked().connect([=] () { launch(); });

update_icon();

Expand All @@ -74,7 +75,9 @@ void WfLauncherButton::launch()
WfLauncherButton::WfLauncherButton()
{}
WfLauncherButton::~WfLauncherButton()
{}
{
btn_sig.disconnect();
}

static bool begins_with(const std::string& string, const std::string& prefix)
{
Expand Down
Loading
Loading