From 6bfa70fc7045669be435d3757456e1da7d341927 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Fri, 29 Jul 2022 19:54:54 +0200 Subject: [PATCH] Disable tooltips for GTK 4.6.4 - 4.6.6 A bug in GTK caused the application to crash in some tooltip-related conditions https://gitlab.gnome.org/GNOME/gtk/-/issues/4941 --- main/data/chat_input.ui | 1 - main/data/conversation_list_titlebar.ui | 1 - main/data/conversation_list_titlebar_csd.ui | 1 - main/src/ui/add_conversation/list_row.vala | 4 ++-- main/src/ui/chat_input/view.vala | 2 ++ .../conversation_item_skeleton.vala | 4 ++-- main/src/ui/conversation_list_titlebar.vala | 2 ++ .../conversation_selector_row.vala | 8 ++++---- main/src/ui/conversation_titlebar/menu_entry.vala | 4 ++-- .../ui/conversation_titlebar/occupants_entry.vala | 2 +- main/src/ui/conversation_titlebar/search_entry.vala | 2 +- main/src/ui/util/helper.vala | 12 ++++++++++++ 12 files changed, 28 insertions(+), 15 deletions(-) diff --git a/main/data/chat_input.ui b/main/data/chat_input.ui index 12d104ad..99b087aa 100644 --- a/main/data/chat_input.ui +++ b/main/data/chat_input.ui @@ -16,7 +16,6 @@ mail-attachment-symbolic - Send a file 2 start - Start Conversation list-add-symbolic diff --git a/main/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala index a25ecbd3..5b3ec49a 100644 --- a/main/src/ui/add_conversation/list_row.vala +++ b/main/src/ui/add_conversation/list_row.vala @@ -37,8 +37,8 @@ public class ListRow : Widget { string display_name = Util.get_conversation_display_name(stream_interactor, conv); if (show_account && stream_interactor.get_accounts().size > 1) { via_label.label = @"via $(account.bare_jid)"; - this.has_tooltip = true; - set_tooltip_text(jid.to_string()); + this.has_tooltip = Util.use_tooltips(); + set_tooltip_text(Util.string_if_tooltips_active(jid.to_string())); } else if (display_name != jid.bare_jid.to_string()){ via_label.label = jid.bare_jid.to_string(); } else { diff --git a/main/src/ui/chat_input/view.vala b/main/src/ui/chat_input/view.vala index 81f2bd0f..3de060c6 100644 --- a/main/src/ui/chat_input/view.vala +++ b/main/src/ui/chat_input/view.vala @@ -41,6 +41,8 @@ public class View : Box { }); emoji_button.set_popover(chooser); + file_button.tooltip_text = Util.string_if_tooltips_active(_("Send a file")); + Util.force_css(frame, "* { border-radius: 3px; }"); return this; diff --git a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala index b4b99a77..14fcd536 100644 --- a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala +++ b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala @@ -145,7 +145,7 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, if (item.encryption == Encryption.NONE) { if (conversation.encryption != Encryption.NONE) { encryption_image.icon_name = "dino-changes-allowed-symbolic"; - encryption_image.tooltip_text = _("Unencrypted"); + encryption_image.tooltip_text = Util.string_if_tooltips_active(_("Unencrypted")); Util.force_error_color(encryption_image); encryption_image.visible = true; } else if (conversation.encryption == Encryption.NONE) { @@ -177,7 +177,7 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, received_image.icon_name = "dialog-warning-symbolic"; Util.force_error_color(received_image); Util.force_error_color(time_label); - string error_text = _("Unable to send message"); + string error_text = Util.string_if_tooltips_active(_("Unable to send message")); received_image.tooltip_text = error_text; time_label.tooltip_text = error_text; break; diff --git a/main/src/ui/conversation_list_titlebar.vala b/main/src/ui/conversation_list_titlebar.vala index 692ac680..9cbb6aec 100644 --- a/main/src/ui/conversation_list_titlebar.vala +++ b/main/src/ui/conversation_list_titlebar.vala @@ -24,6 +24,8 @@ public static HeaderBar get_conversation_list_titlebar_csd() { } private static void create_add_menu(MenuButton add_button, MenuButton menu_button) { + add_button.tooltip_text = Util.string_if_tooltips_active(_("Start Conversation")); + Builder add_builder = new Builder.from_resource("/im/dino/Dino/menu_add.ui"); MenuModel add_menu_model = add_builder.get_object("menu_add") as MenuModel; add_button.set_menu_model(add_menu_model); diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala index 76cbabb3..a2588d9a 100644 --- a/main/src/ui/conversation_selector/conversation_selector_row.vala +++ b/main/src/ui/conversation_selector/conversation_selector_row.vala @@ -70,15 +70,15 @@ public class ConversationSelectorRow : ListBoxRow { // Set tooltip switch (conversation.type_) { case Conversation.Type.CHAT: - has_tooltip = true; + has_tooltip = Util.use_tooltips(); query_tooltip.connect ((x, y, keyboard_tooltip, tooltip) => { - tooltip.set_custom(generate_tooltip()); + tooltip.set_custom(Util.widget_if_tooltips_active(generate_tooltip())); return true; }); break; case Conversation.Type.GROUPCHAT: - has_tooltip = true; - set_tooltip_text(conversation.counterpart.bare_jid.to_string()); + has_tooltip = Util.use_tooltips(); + set_tooltip_text(Util.string_if_tooltips_active(conversation.counterpart.bare_jid.to_string())); break; case Conversation.Type.GROUPCHAT_PM: break; diff --git a/main/src/ui/conversation_titlebar/menu_entry.vala b/main/src/ui/conversation_titlebar/menu_entry.vala index 28a06c24..7b484219 100644 --- a/main/src/ui/conversation_titlebar/menu_entry.vala +++ b/main/src/ui/conversation_titlebar/menu_entry.vala @@ -23,9 +23,9 @@ class MenuEntry : Plugins.ConversationTitlebarEntry, Object { button.sensitive = true; this.conversation = conversation; if (conversation.type_ == Conversation.Type.GROUPCHAT) { - button.tooltip_text = "Channel details"; + button.tooltip_text = Util.string_if_tooltips_active("Channel details"); } else { - button.tooltip_text = "Conversation details"; + button.tooltip_text = Util.string_if_tooltips_active("Conversation details"); } } diff --git a/main/src/ui/conversation_titlebar/occupants_entry.vala b/main/src/ui/conversation_titlebar/occupants_entry.vala index 5c0da99b..a71cf05e 100644 --- a/main/src/ui/conversation_titlebar/occupants_entry.vala +++ b/main/src/ui/conversation_titlebar/occupants_entry.vala @@ -11,7 +11,7 @@ class OccupantsEntry : Plugins.ConversationTitlebarEntry, Object { StreamInteractor stream_interactor; private Conversation? conversation; - private MenuButton button = new MenuButton() { icon_name="system-users-symbolic", tooltip_text=_("Members") }; + private MenuButton button = new MenuButton() { icon_name="system-users-symbolic", tooltip_text=Util.string_if_tooltips_active(_("Members")) }; private OccupantMenu.View menu = null; diff --git a/main/src/ui/conversation_titlebar/search_entry.vala b/main/src/ui/conversation_titlebar/search_entry.vala index a51d7d43..b479ff78 100644 --- a/main/src/ui/conversation_titlebar/search_entry.vala +++ b/main/src/ui/conversation_titlebar/search_entry.vala @@ -9,7 +9,7 @@ public class SearchMenuEntry : Plugins.ConversationTitlebarEntry, Object { public string id { get { return "search"; } } public double order { get { return 1; } } - public ToggleButton button = new ToggleButton() { tooltip_text=_("Search messages") }; + public ToggleButton button = new ToggleButton() { tooltip_text=Util.string_if_tooltips_active(_("Search messages")) }; public SearchMenuEntry() { button.set_icon_name("system-search-symbolic"); diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index 98abb48e..df7438b1 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -440,4 +440,16 @@ public bool use_csd() { return ((Application) GLib.Application.get_default()).use_csd(); } +public Widget? widget_if_tooltips_active(Widget w) { + return use_tooltips() ? w : null; +} + +public string? string_if_tooltips_active(string s) { + return use_tooltips() ? s : null; +} + +public bool use_tooltips() { + return Gtk.MINOR_VERSION != 6 || (Gtk.MICRO_VERSION < 4 || Gtk.MICRO_VERSION > 6); +} + }