xeco23 / WasIstLos

An unofficial WhatsApp desktop application for Linux.
GNU General Public License v3.0
1.03k stars 106 forks source link

Attention tray icon never shows up #105

Closed spbisc97 closed 3 years ago

spbisc97 commented 3 years ago

Description Attention tray icon never shows up

Expected behavior I would expect the tray icon to switch to the 'attention' one when a message arrives or when i have not read messages

Environment

xeco23 commented 3 years ago

Hi @spbisc97. Currently, it is shown while the notification is alive, and if that's not the case we should do something. There is no way to tell if there are some unread messages since we cannot have access to the Whatsapp API.

spbisc97 commented 3 years ago

Thank you so much! Maybe also i can contribute to this project, is anywhere possible to add some javascrit code to detect the properties of the displayed page? in this way inspecting the cells we could notice if there is a notifification icon or not. This is a simple and probebly stupid idea, but could be tried. Thanks for the awesome project!

xeco23 commented 3 years ago

We use those signals to show the attention icon: https://webkitgtk.org/reference/webkit2gtk/stable/webkit2gtk-4.0-The-title-for-the-notification..html#WebKitNotification-clicked. Maybe removing closed signal and having only clicked would solve this issue...

spbisc97 commented 3 years ago

Thanks, just removing closed seems to do not work, but more I am having issues also with just visualizing the right icon. Anyway thanks for your help and for your project! I hope to have the possibility to contribute as soon as possible

spbisc97 commented 3 years ago

After trying to add functions to change the icon on the go, I tried to change the icons with others with different colors recompiling all, especially resources.c where as I have understood there are saved the two png icons. Now I have changed the colors of the icons (to yellow)

convert tray/icon.png +level-colors red, tray/icon.png

and recompiled, but I still see the old green icon, strange. If you have time would be great to have this clarified, otherwise, i'll try to get this on my own!

Seems to change as I change the icon in hicolor folder like the app is taking that icon and not the desired one, could it be?

Thanks for your awesome project!!

xeco23 commented 3 years ago

After trying to add functions to change the icon on the go, I tried to change the icons with others with different colors recompiling all, especially resources.c where as I have understood there are saved the two png icons. Now I have changed the colors of the icons (to yellow)

convert tray/icon.png +level-colors red, tray/icon.png

and recompiled, but I still see the old green icon, strange. If you have time would be great to have this clarified, otherwise, i'll try to get this on my own!

Seems to change as I change the icon in hicolor folder like the app is taking that icon and not the desired one, could it be?

Thanks for your awesome project!!

Yes, that is the icon for the tray. You need to recompile Resources.h if something is changed in ui resources and maybe it doesn't recompile because of the make cache. Try cleaning and rebuilding from scratch again.

spbisc97 commented 3 years ago

Yes, after changing the color and some code I made some clean, both with make clean, by removing Resources.c and also trying to recompile with glib-compile-resources, but not working properly..

I changed some code just to understand how was it working

TrayIcon::TrayIcon()
    : m_appIndicator{app_indicator_new("com.github.whatsapp-for-linux.tray", "whatsapp-active", APP_INDICATOR_CATEGORY_COMMUNICATIONS)} //whatsapp-for-linux-tray-
    , m_popupMenu{}
    , m_signalOpen{}
    , m_signalAbout{}
    , m_signalQuit{}
{
    auto const activePixbuf = Gdk::Pixbuf::create_from_resource("/main/image/tray/active.png");
    auto const attentionPixbuf = Gdk::Pixbuf::create_from_resource("/main/image/tray/attention.png");
    Gtk::IconTheme::get_default()->add_builtin_icon("whatsapp-active", Gtk::ICON_SIZE_MENU, activePixbuf);
    Gtk::IconTheme::get_default()->add_builtin_icon("whatsapp-attention", Gtk::ICON_SIZE_MENU, attentionPixbuf);

    //gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(),"/main/image/tray");

    bool info= Gtk::IconTheme::get_default()->has_icon("whatsapp-for-linux-tray-active");
    printf("%d\n", info);     // i get 0
    info= Gtk::IconTheme::get_default()->has_icon("whatsapp-for-linux-tray-attention");
    printf("%d\n", info);    //i get 0
    info= Gtk::IconTheme::get_default()->has_icon("whatsapp-attention");
    printf("%d\n", info);   // i get 1
    info= Gtk::IconTheme::get_default()->has_icon("whatsapp-active");
    printf("%d\n", info);   // i get 1

    app_indicator_set_attention_icon(m_appIndicator, "whatsapp-attention"); 

changed name and added print to "debug" but only when i set original whatsapp-for-linux-tray- the icon shows up for real like if libappindicator was falling back to hicolor icons...

void TrayIcon::setAttention(bool attention)
{
    if (!visible())
    {
        return;
    }

    app_indicator_set_status(m_appIndicator, (attention ? APP_INDICATOR_STATUS_ATTENTION : APP_INDICATOR_STATUS_ACTIVE));
    if(attention){
        printf("Set Icon To Attention");
    }else{
        printf("Set Icon To Active\n");
    }
}

and added a "flip flop" icon that is used with setAttention function.. but i see the change only if one icon is called whatsapp-for-linux-tray- and the other is whatsapp- and the difference is that the second one is a "icon not fount" icon

i also have used

sudo update-icon-caches /usr/share/icons/* 

and if i use the full name whatsapp-for-linux-tray- having a different color of active and attention icon (blue on tray icons, and red on hicolor/app icons) i see only red icons everywhere

Thanks for your support and sorry for my probably stupid questions!

spbisc97 commented 3 years ago

PS. I thought that probably could be an issue of gnome-shell, I'm on pop_os with gnome 3.38 I don't have the AppIndicator Extension and for now I cannot install it

xeco23 commented 3 years ago

Ah, don't you see the regular icon also? What do you see in the system tray, three dots?

spbisc97 commented 3 years ago

Yes, I see three dots if the name is different from whatsapp-for-linux- otherwise is the same as the icon in the launcher (hicolor/app icon)

xeco23 commented 3 years ago

Alright, we are discussing that issue in #98. Please take a look and close this if neccessary.

spbisc97 commented 3 years ago

But if I check if the icon exists it responds that the icon exists, anyway I call it!

info= Gtk::IconTheme::get_default()->has_icon(<anyway i call it>)
xeco23 commented 3 years ago

Yes, but in this case, Gnome's AppIndicator is failing to find the icon we added to the default theme. It somehow searches by appending -panel at the end which I don't understand. Let's see, maybe there is a reason for that so that we can redefine our naming.

xeco23 commented 3 years ago

PS. I thought that probably could be an issue of gnome-shell, I'm on pop_os with gnome 3.38 I don't have the AppIndicator Extension and for now I cannot install it

Sorry, I didn't see this one. What does it use then to show tray icons? Also, could you please try to see system log messages with journalctl to see any related logs to tray icons?

xeco23 commented 3 years ago

Well, overall if your normal tray icon doesn't show up, it's no surprise that the attention doesn't.

xeco23 commented 3 years ago

Closing this due to being part of the #98