fix: uninitialized bool
This commit is contained in:
parent
d8be72e4b6
commit
d2d9db23b5
|
@ -46,7 +46,7 @@ class Item : public sigc::trackable {
|
||||||
std::string menu;
|
std::string menu;
|
||||||
DbusmenuGtkMenu* dbus_menu = nullptr;
|
DbusmenuGtkMenu* dbus_menu = nullptr;
|
||||||
Gtk::Menu* gtk_menu = nullptr;
|
Gtk::Menu* gtk_menu = nullptr;
|
||||||
bool item_is_menu;
|
bool item_is_menu = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
|
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
|
||||||
|
@ -59,8 +59,8 @@ class Item : public sigc::trackable {
|
||||||
void updateImage();
|
void updateImage();
|
||||||
Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant* variant);
|
Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant* variant);
|
||||||
Glib::RefPtr<Gdk::Pixbuf> getIconByName(const std::string& name, int size);
|
Glib::RefPtr<Gdk::Pixbuf> getIconByName(const std::string& name, int size);
|
||||||
static void onMenuDestroyed(Item* self);
|
static void onMenuDestroyed(Item* self, GObject* old_menu_pointer);
|
||||||
bool makeMenu(GdkEventButton* const& ev);
|
void makeMenu(GdkEventButton* const& ev);
|
||||||
bool handleClick(GdkEventButton* const& /*ev*/);
|
bool handleClick(GdkEventButton* const& /*ev*/);
|
||||||
|
|
||||||
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
|
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
|
||||||
|
|
|
@ -276,14 +276,15 @@ Glib::RefPtr<Gdk::Pixbuf> Item::getIconByName(const std::string& name, int reque
|
||||||
name.c_str(), tmp_size, Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE);
|
name.c_str(), tmp_size, Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item::onMenuDestroyed(Item* self) {
|
void Item::onMenuDestroyed(Item* self, GObject* old_menu_pointer) {
|
||||||
|
if (old_menu_pointer == reinterpret_cast<GObject*>(self->dbus_menu)) {
|
||||||
self->gtk_menu = nullptr;
|
self->gtk_menu = nullptr;
|
||||||
self->dbus_menu = nullptr;
|
self->dbus_menu = nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Item::makeMenu(GdkEventButton* const& ev) {
|
void Item::makeMenu(GdkEventButton* const& ev) {
|
||||||
if (gtk_menu == nullptr) {
|
if (gtk_menu == nullptr && !menu.empty()) {
|
||||||
if (!menu.empty()) {
|
|
||||||
dbus_menu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
|
dbus_menu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
|
||||||
if (dbus_menu != nullptr) {
|
if (dbus_menu != nullptr) {
|
||||||
g_object_ref_sink(G_OBJECT(dbus_menu));
|
g_object_ref_sink(G_OBJECT(dbus_menu));
|
||||||
|
@ -293,6 +294,12 @@ bool Item::makeMenu(GdkEventButton* const& ev) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
makeMenu(ev);
|
||||||
if (gtk_menu != nullptr) {
|
if (gtk_menu != nullptr) {
|
||||||
#if GTK_CHECK_VERSION(3, 22, 0)
|
#if GTK_CHECK_VERSION(3, 22, 0)
|
||||||
gtk_menu->popup_at_pointer(reinterpret_cast<GdkEvent*>(ev));
|
gtk_menu->popup_at_pointer(reinterpret_cast<GdkEvent*>(ev));
|
||||||
|
@ -300,15 +307,7 @@ bool Item::makeMenu(GdkEventButton* const& ev) {
|
||||||
gtk_menu->popup(ev->button, ev->time);
|
gtk_menu->popup(ev->button, ev->time);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
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)) {
|
|
||||||
proxy_->call("ContextMenu", parameters);
|
proxy_->call("ContextMenu", parameters);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue