Codebase list xapp / 40a01f5
xapp-sn-watcher: Add an app list to flag items that should have their tooltip replaced by the application name. qBittorrent puts html in its tooltip, which qt5's xembed tray supports, but StatusNotifier does not. Until this gets sorted, just show the program name as a tooltip. Normalize the sort name and app lists - the lists should be all lower, and the sort names will be lowercased also. Onboard had changed from Onboard to onboard, and was no longer allowing left-click activation. Michael Webster 3 years ago
3 changed file(s) with 50 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
55
66 <schema id="org.x.apps.statusicon" path="/org/x/apps/statusicon/">
77 <key name="left-click-activate-apps" type="as">
8 <default>["Onboard"]</default>
8 <default>["onboard"]</default>
99 <summary>A list of appindicator-based apps where left-click should trigger the 'secondary activation' action, rather than open the menu.</summary>
1010 <description>The name to be put here will be the icon's "Name" (not icon name). You can see what name to use by running xapp-sn-watcher from a terminal (or in .xsession-properties in some DEs).
1111 </description>
2020 <default>false</default>
2121 <summary>Print debug messages for the xapp-sn-watcher service</summary>
2222 </key>
23 <key name="sn-watcher-replace-tooltip" type="as">
24 <default>["qbittorrent"]</default>
25 <summary>Use the Title property in place of the Tooltip for programs with these IDs.</summary>
26 </key>
2327 </schema>
2428
2529 </schemalist>
4242 gint current_icon_id;
4343 gchar *sortable_name;
4444
45 gboolean should_activate;
46 gboolean should_replace_tooltip;
4547 gboolean is_ai;
4648 };
4749
6264
6365 should = g_strv_contains ((const gchar * const *) whitelist, item->sortable_name);
6466 g_strfreev (whitelist);
67
68 return should;
69 }
70
71 static gboolean
72 should_replace_tooltip (SnItem *item)
73 {
74 gboolean should;
75
76 gchar **ids = g_settings_get_strv (xapp_settings,
77 REPLACE_TOOLTIP_KEY);
78
79 should = g_strv_contains ((const gchar * const *) ids, item->sortable_name);
80 g_strfreev (ids);
6581
6682 return should;
6783 }
549565 item->menu = GTK_WIDGET (dbusmenu_gtkmenu_new ((gchar *) g_dbus_proxy_get_name (item->sn_item_proxy), menu_path));
550566 g_object_ref_sink (item->menu);
551567
552 if (item->is_ai && !should_activate (item))
568 if (item->is_ai && !item->should_activate)
553569 {
554570 xapp_status_icon_set_primary_menu (item->status_icon, GTK_MENU (item->menu));
555571 }
585601 static void
586602 update_tooltip (SnItem *item)
587603 {
588 g_autoptr(GVariant) tt_var;
589
590 tt_var = get_property (item, "ToolTip");
604 g_autoptr(GVariant) tt_var = NULL;
605
606 if (!item->should_replace_tooltip)
607 {
608 tt_var = get_property (item, "ToolTip");
609 }
591610
592611 if (tt_var)
593612 {
738757 {
739758 if (item->is_ai)
740759 {
741 if (should_activate (item))
760 if (item->should_activate)
742761 {
743762 sn_item_interface_call_secondary_activate (SN_ITEM_INTERFACE (item->sn_item_proxy), x, y, NULL, NULL, NULL);
744763 return;
816835 assign_sortable_name (SnItem *item,
817836 XAppStatusIcon *status_icon)
818837 {
819 gchar *sortable_name;
820
821 sortable_name = sn_item_interface_dup_id (SN_ITEM_INTERFACE (item->sn_item_proxy));
822
823 if (sortable_name == NULL)
824 {
825 sortable_name = get_string_property (item, "Title");
826 }
838 gchar *init_name, *normalized, *sortable_name;
839
840 init_name = sn_item_interface_dup_id (SN_ITEM_INTERFACE (item->sn_item_proxy));
841
842 if (init_name == NULL)
843 {
844 init_name = get_string_property (item, "Title");
845 }
846
847 normalized = g_utf8_normalize (init_name,
848 -1,
849 G_NORMALIZE_DEFAULT);
850
851 sortable_name = g_utf8_strdown (normalized, -1);
827852
828853 g_debug ("Sort name for %s is '%s'", g_dbus_proxy_get_name (G_DBUS_PROXY (item->sn_item_proxy)), sortable_name);
829854 xapp_status_icon_set_name (status_icon, sortable_name);
830855
831856 item->sortable_name = sortable_name;
857
858 g_free (init_name);
859 g_free (normalized);
832860 }
833861
834862 static void
867895 g_signal_connect (item->status_icon, "state-changed", G_CALLBACK (xapp_icon_state_changed), item);
868896
869897 assign_sortable_name (item, item->status_icon);
898
899 item->should_activate = should_activate (item);
900 item->should_replace_tooltip = should_replace_tooltip (item);
870901
871902 update_status (item);
872903 update_menu (item);
1818 #define WHITELIST_KEY "left-click-activate-apps"
1919 #define VALID_XDG_DESKTOPS_KEY "status-notifier-enabled-desktops"
2020 #define DEBUG_KEY "sn-watcher-debug"
21 #define REPLACE_TOOLTIP_KEY "sn-watcher-replace-tooltip"
2122 extern GSettings *xapp_settings;
2223
2324 G_END_DECLS