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
This commit is contained in:
fiaxh 2022-07-29 19:54:54 +02:00
parent 517363dfc9
commit 6bfa70fc70
12 changed files with 28 additions and 15 deletions

View file

@ -16,7 +16,6 @@
<child> <child>
<object class="GtkButton" id="file_button"> <object class="GtkButton" id="file_button">
<property name="icon-name">mail-attachment-symbolic</property> <property name="icon-name">mail-attachment-symbolic</property>
<property name="tooltip-text" translatable="1">Send a file</property>
<property name="margin-top">2</property> <property name="margin-top">2</property>
<property name="valign">start</property> <property name="valign">start</property>
<style> <style>

View file

@ -15,7 +15,6 @@
<property name="hexpand">1</property> <property name="hexpand">1</property>
<child> <child>
<object class="GtkMenuButton" id="add_button"> <object class="GtkMenuButton" id="add_button">
<property name="tooltip_text" translatable="1">Start Conversation</property>
<property name="has-frame">False</property> <property name="has-frame">False</property>
<child> <child>
<object class="GtkImage"> <object class="GtkImage">

View file

@ -8,7 +8,6 @@
</style> </style>
<child> <child>
<object class="GtkMenuButton" id="add_button"> <object class="GtkMenuButton" id="add_button">
<property name="tooltip_text" translatable="True">Start Conversation</property>
<child> <child>
<object class="GtkImage"> <object class="GtkImage">
<property name="icon-name">list-add-symbolic</property> <property name="icon-name">list-add-symbolic</property>

View file

@ -37,8 +37,8 @@ public class ListRow : Widget {
string display_name = Util.get_conversation_display_name(stream_interactor, conv); string display_name = Util.get_conversation_display_name(stream_interactor, conv);
if (show_account && stream_interactor.get_accounts().size > 1) { if (show_account && stream_interactor.get_accounts().size > 1) {
via_label.label = @"via $(account.bare_jid)"; via_label.label = @"via $(account.bare_jid)";
this.has_tooltip = true; this.has_tooltip = Util.use_tooltips();
set_tooltip_text(jid.to_string()); set_tooltip_text(Util.string_if_tooltips_active(jid.to_string()));
} else if (display_name != jid.bare_jid.to_string()){ } else if (display_name != jid.bare_jid.to_string()){
via_label.label = jid.bare_jid.to_string(); via_label.label = jid.bare_jid.to_string();
} else { } else {

View file

@ -41,6 +41,8 @@ public class View : Box {
}); });
emoji_button.set_popover(chooser); emoji_button.set_popover(chooser);
file_button.tooltip_text = Util.string_if_tooltips_active(_("Send a file"));
Util.force_css(frame, "* { border-radius: 3px; }"); Util.force_css(frame, "* { border-radius: 3px; }");
return this; return this;

View file

@ -145,7 +145,7 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
if (item.encryption == Encryption.NONE) { if (item.encryption == Encryption.NONE) {
if (conversation.encryption != Encryption.NONE) { if (conversation.encryption != Encryption.NONE) {
encryption_image.icon_name = "dino-changes-allowed-symbolic"; 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); Util.force_error_color(encryption_image);
encryption_image.visible = true; encryption_image.visible = true;
} else if (conversation.encryption == Encryption.NONE) { } else if (conversation.encryption == Encryption.NONE) {
@ -177,7 +177,7 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
received_image.icon_name = "dialog-warning-symbolic"; received_image.icon_name = "dialog-warning-symbolic";
Util.force_error_color(received_image); Util.force_error_color(received_image);
Util.force_error_color(time_label); 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; received_image.tooltip_text = error_text;
time_label.tooltip_text = error_text; time_label.tooltip_text = error_text;
break; break;

View file

@ -24,6 +24,8 @@ public static HeaderBar get_conversation_list_titlebar_csd() {
} }
private static void create_add_menu(MenuButton add_button, MenuButton menu_button) { 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"); 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; MenuModel add_menu_model = add_builder.get_object("menu_add") as MenuModel;
add_button.set_menu_model(add_menu_model); add_button.set_menu_model(add_menu_model);

View file

@ -70,15 +70,15 @@ public class ConversationSelectorRow : ListBoxRow {
// Set tooltip // Set tooltip
switch (conversation.type_) { switch (conversation.type_) {
case Conversation.Type.CHAT: case Conversation.Type.CHAT:
has_tooltip = true; has_tooltip = Util.use_tooltips();
query_tooltip.connect ((x, y, keyboard_tooltip, tooltip) => { 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; return true;
}); });
break; break;
case Conversation.Type.GROUPCHAT: case Conversation.Type.GROUPCHAT:
has_tooltip = true; has_tooltip = Util.use_tooltips();
set_tooltip_text(conversation.counterpart.bare_jid.to_string()); set_tooltip_text(Util.string_if_tooltips_active(conversation.counterpart.bare_jid.to_string()));
break; break;
case Conversation.Type.GROUPCHAT_PM: case Conversation.Type.GROUPCHAT_PM:
break; break;

View file

@ -23,9 +23,9 @@ class MenuEntry : Plugins.ConversationTitlebarEntry, Object {
button.sensitive = true; button.sensitive = true;
this.conversation = conversation; this.conversation = conversation;
if (conversation.type_ == Conversation.Type.GROUPCHAT) { if (conversation.type_ == Conversation.Type.GROUPCHAT) {
button.tooltip_text = "Channel details"; button.tooltip_text = Util.string_if_tooltips_active("Channel details");
} else { } else {
button.tooltip_text = "Conversation details"; button.tooltip_text = Util.string_if_tooltips_active("Conversation details");
} }
} }

View file

@ -11,7 +11,7 @@ class OccupantsEntry : Plugins.ConversationTitlebarEntry, Object {
StreamInteractor stream_interactor; StreamInteractor stream_interactor;
private Conversation? conversation; 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; private OccupantMenu.View menu = null;

View file

@ -9,7 +9,7 @@ public class SearchMenuEntry : Plugins.ConversationTitlebarEntry, Object {
public string id { get { return "search"; } } public string id { get { return "search"; } }
public double order { get { return 1; } } 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() { public SearchMenuEntry() {
button.set_icon_name("system-search-symbolic"); button.set_icon_name("system-search-symbolic");

View file

@ -440,4 +440,16 @@ public bool use_csd() {
return ((Application) GLib.Application.get_default()).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);
}
} }