commit
baaeda0ab7
|
@ -46,7 +46,12 @@ 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 = false;
|
/**
|
||||||
|
* ItemIsMenu flag means that the item only supports the context menu.
|
||||||
|
* Default value is true because libappindicator supports neither ItemIsMenu nor Activate method
|
||||||
|
* while compliant SNI implementation would always reset the flag to desired value.
|
||||||
|
*/
|
||||||
|
bool item_is_menu = true;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
|
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
|
||||||
|
@ -60,7 +65,7 @@ class Item : public sigc::trackable {
|
||||||
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, GObject* old_menu_pointer);
|
static void onMenuDestroyed(Item* self, GObject* old_menu_pointer);
|
||||||
void makeMenu(GdkEventButton* const& ev);
|
void makeMenu();
|
||||||
bool handleClick(GdkEventButton* const& /*ev*/);
|
bool handleClick(GdkEventButton* const& /*ev*/);
|
||||||
|
|
||||||
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
|
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
|
||||||
|
|
|
@ -128,6 +128,7 @@ void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) {
|
||||||
}
|
}
|
||||||
} else if (name == "Menu") {
|
} else if (name == "Menu") {
|
||||||
menu = get_variant<std::string>(value);
|
menu = get_variant<std::string>(value);
|
||||||
|
makeMenu();
|
||||||
} else if (name == "ItemIsMenu") {
|
} else if (name == "ItemIsMenu") {
|
||||||
item_is_menu = get_variant<bool>(value);
|
item_is_menu = get_variant<bool>(value);
|
||||||
}
|
}
|
||||||
|
@ -319,7 +320,7 @@ void Item::onMenuDestroyed(Item* self, GObject* old_menu_pointer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item::makeMenu(GdkEventButton* const& ev) {
|
void Item::makeMenu() {
|
||||||
if (gtk_menu == nullptr && !menu.empty()) {
|
if (gtk_menu == nullptr && !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) {
|
||||||
|
@ -334,8 +335,8 @@ void Item::makeMenu(GdkEventButton* const& ev) {
|
||||||
bool Item::handleClick(GdkEventButton* const& ev) {
|
bool Item::handleClick(GdkEventButton* const& ev) {
|
||||||
auto parameters = Glib::VariantContainerBase::create_tuple(
|
auto parameters = Glib::VariantContainerBase::create_tuple(
|
||||||
{Glib::Variant<int>::create(ev->x), Glib::Variant<int>::create(ev->y)});
|
{Glib::Variant<int>::create(ev->x), Glib::Variant<int>::create(ev->y)});
|
||||||
if ((ev->button == 1 && (item_is_menu || !menu.empty())) || ev->button == 3) {
|
if ((ev->button == 1 && item_is_menu) || ev->button == 3) {
|
||||||
makeMenu(ev);
|
makeMenu();
|
||||||
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));
|
||||||
|
|
Loading…
Reference in New Issue