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,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);
|
||||
}
|
||||
|
||||
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->dbus_menu = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Item::makeMenu(GdkEventButton* const& ev) {
|
||||
if (gtk_menu == nullptr) {
|
||||
if (!menu.empty()) {
|
||||
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));
|
||||
|
@ -292,7 +293,13 @@ bool Item::makeMenu(GdkEventButton* const& ev) {
|
|||
gtk_menu->attach_to_widget(event_box);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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_CHECK_VERSION(3, 22, 0)
|
||||
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);
|
||||
#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)) {
|
||||
} else {
|
||||
proxy_->call("ContextMenu", parameters);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue