mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix: uninitialized bool
This commit is contained in:
parent
d8be72e4b6
commit
d2d9db23b5
@ -46,7 +46,7 @@ class Item : public sigc::trackable {
|
||||
std::string menu;
|
||||
DbusmenuGtkMenu* dbus_menu = nullptr;
|
||||
Gtk::Menu* gtk_menu = nullptr;
|
||||
bool item_is_menu;
|
||||
bool item_is_menu = false;
|
||||
|
||||
private:
|
||||
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
|
||||
@ -59,8 +59,8 @@ class Item : public sigc::trackable {
|
||||
void updateImage();
|
||||
Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant* variant);
|
||||
Glib::RefPtr<Gdk::Pixbuf> getIconByName(const std::string& name, int size);
|
||||
static void onMenuDestroyed(Item* self);
|
||||
bool makeMenu(GdkEventButton* const& ev);
|
||||
static void onMenuDestroyed(Item* self, GObject* old_menu_pointer);
|
||||
void makeMenu(GdkEventButton* const& ev);
|
||||
bool handleClick(GdkEventButton* const& /*ev*/);
|
||||
|
||||
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
|
||||
|
@ -276,39 +276,38 @@ Glib::RefPtr<Gdk::Pixbuf> Item::getIconByName(const std::string& name, int reque
|
||||
name.c_str(), tmp_size, Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE);
|
||||
}
|
||||
|
||||
void Item::onMenuDestroyed(Item* self) {
|
||||
self->gtk_menu = nullptr;
|
||||
self->dbus_menu = nullptr;
|
||||
void Item::onMenuDestroyed(Item* self, GObject* old_menu_pointer) {
|
||||
if (old_menu_pointer == reinterpret_cast<GObject*>(self->dbus_menu)) {
|
||||
self->gtk_menu = nullptr;
|
||||
self->dbus_menu = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Item::makeMenu(GdkEventButton* const& ev) {
|
||||
if (gtk_menu == nullptr) {
|
||||
if (!menu.empty()) {
|
||||
dbus_menu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
|
||||
if (dbus_menu != nullptr) {
|
||||
g_object_ref_sink(G_OBJECT(dbus_menu));
|
||||
g_object_weak_ref(G_OBJECT(dbus_menu), (GWeakNotify)onMenuDestroyed, this);
|
||||
gtk_menu = Glib::wrap(GTK_MENU(dbus_menu));
|
||||
gtk_menu->attach_to_widget(event_box);
|
||||
}
|
||||
void Item::makeMenu(GdkEventButton* const& ev) {
|
||||
if (gtk_menu == nullptr && !menu.empty()) {
|
||||
dbus_menu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
|
||||
if (dbus_menu != nullptr) {
|
||||
g_object_ref_sink(G_OBJECT(dbus_menu));
|
||||
g_object_weak_ref(G_OBJECT(dbus_menu), (GWeakNotify)onMenuDestroyed, this);
|
||||
gtk_menu = Glib::wrap(GTK_MENU(dbus_menu));
|
||||
gtk_menu->attach_to_widget(event_box);
|
||||
}
|
||||
}
|
||||
if (gtk_menu != nullptr) {
|
||||
#if GTK_CHECK_VERSION(3, 22, 0)
|
||||
gtk_menu->popup_at_pointer(reinterpret_cast<GdkEvent*>(ev));
|
||||
#else
|
||||
gtk_menu->popup(ev->button, ev->time);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Item::handleClick(GdkEventButton* const& ev) {
|
||||
auto parameters = Glib::VariantContainerBase::create_tuple(
|
||||
{Glib::Variant<int>::create(ev->x), Glib::Variant<int>::create(ev->y)});
|
||||
if ((ev->button == 1 && item_is_menu) || ev->button == 3) {
|
||||
if (!makeMenu(ev)) {
|
||||
makeMenu(ev);
|
||||
if (gtk_menu != nullptr) {
|
||||
#if GTK_CHECK_VERSION(3, 22, 0)
|
||||
gtk_menu->popup_at_pointer(reinterpret_cast<GdkEvent*>(ev));
|
||||
#else
|
||||
gtk_menu->popup(ev->button, ev->time);
|
||||
#endif
|
||||
return true;
|
||||
} else {
|
||||
proxy_->call("ContextMenu", parameters);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user