Unified tray tooltip handling so GTK3 uses the tooltip-text property while GTK2 keeps the legacy API behind guards, and wired fe_tray_set_tooltip to the shared helper.

Centralized embedded-state checks through a GTK3-safe helper in the tray notification callback, avoiding GTK2-only calls under GTK3.
This commit is contained in:
2026-01-30 19:33:56 -07:00
parent dec2aff37d
commit 907211a733

View File

@@ -188,16 +188,21 @@ tray_set_custom_icon_state (TrayCustomIcon icon, TrayIconState state)
tray_icon_state = state;
}
#if HAVE_GTK3
static void
tray_set_tooltip_text (GtkStatusIcon *icon, const char *text)
{
#if HAVE_GTK3
g_object_set (G_OBJECT (icon), "tooltip-text", text, NULL);
#endif
#if !HAVE_GTK3
gtk_status_icon_set_tooltip_text (icon, text);
#endif
}
static gboolean
tray_is_embedded (GtkStatusIcon *icon)
{
#if HAVE_GTK3
GObjectClass *klass;
gboolean embedded = TRUE;
@@ -209,19 +214,17 @@ tray_is_embedded (GtkStatusIcon *icon)
g_object_get (G_OBJECT (icon), "embedded", &embedded, NULL);
return embedded;
}
#endif
#if !HAVE_GTK3
return gtk_status_icon_is_embedded (icon);
#endif
}
void
fe_tray_set_tooltip (const char *text)
{
if (sticon)
#if HAVE_GTK3
tray_set_tooltip_text (sticon, text);
#endif
#if !HAVE_GTK3
gtk_status_icon_set_tooltip_text (sticon, text);
#endif
}
static void
@@ -461,12 +464,7 @@ tray_menu_notify_cb (GObject *tray, GParamSpec *pspec, gpointer user_data)
{
if (sticon)
{
#if HAVE_GTK3
if (!tray_is_embedded (sticon))
#endif
#if !HAVE_GTK3
if (!gtk_status_icon_is_embedded (sticon))
#endif
{
tray_restore_timer = g_timeout_add(500, (GSourceFunc)tray_menu_try_restore, NULL);
}