Overlay for link destination should be opaque: Closes #6847

The Gtk.Overlay's background color is set to the background color
of the main window when it's realized and when the window's
style changes.
This commit is contained in:
Andreas Obergrusberger 2013-09-26 13:51:11 -07:00 committed by Jim Nelson
parent 29ae18b3f0
commit ad344b6c6b

View file

@ -1893,9 +1893,41 @@ public class ConversationViewer : Gtk.Box {
message_overlay_label.ellipsize = Pango.EllipsizeMode.MIDDLE;
message_overlay_label.halign = Gtk.Align.START;
message_overlay_label.valign = Gtk.Align.END;
message_overlay_label.realize.connect(on_message_overlay_label_realize);
message_overlay.add_overlay(message_overlay_label);
}
// This ensures the overlay's background color matches the background color of the
// main window
private void update_message_overlay_label_style() {
Gtk.Window main_window = GearyApplication.instance.controller.main_window;
Gdk.RGBA window_background = main_window.get_style_context()
.get_background_color(Gtk.StateFlags.NORMAL);
Gdk.RGBA label_background = message_overlay_label.get_style_context()
.get_background_color(Gtk.StateFlags.NORMAL);
// To prevent an event loop situation, only update the background if it actually changed.
if (label_background == window_background)
return;
message_overlay_label.get_style_context().changed.disconnect(
on_message_overlay_label_style_changed);
message_overlay_label.override_background_color(Gtk.StateFlags.NORMAL, window_background);
message_overlay_label.get_style_context().changed.connect(
on_message_overlay_label_style_changed);
}
private void on_message_overlay_label_realize() {
update_message_overlay_label_style();
}
private void on_message_overlay_label_style_changed() {
// The Gtk theme has probably changed - update the label background.
update_message_overlay_label_style();
}
private void on_hovering_over_link(string? title, string? url) {
// Copy the link the user is hovering over. Note that when the user mouses-out,
// this signal is called again with null for both parameters.