aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/conversation_summary/merged_message_item.vala16
-rw-r--r--main/src/ui/conversation_summary/view.vala17
-rw-r--r--main/src/ui/util.vala16
3 files changed, 20 insertions, 29 deletions
diff --git a/main/src/ui/conversation_summary/merged_message_item.vala b/main/src/ui/conversation_summary/merged_message_item.vala
index 0270ef42..ec6b4f7b 100644
--- a/main/src/ui/conversation_summary/merged_message_item.vala
+++ b/main/src/ui/conversation_summary/merged_message_item.vala
@@ -42,20 +42,12 @@ public class MergedMessageItem : Grid {
name_label.label = Util.get_message_display_name(stream_interactor, message, conversation.account);
update_display_style();
- message_text_view.style_updated.connect(style_changed);
- }
-
- private void style_changed() {
- lock(message_text_view) {
- message_text_view.style_updated.disconnect(style_changed);
- update_display_style();
- message_text_view.style_updated.connect(style_changed);
- }
+ Util.force_base_background(message_text_view, "textview, text:not(:selected)");
+ message_text_view.style_updated.connect(update_display_style);
}
private void update_display_style() {
- TextView tmp = new TextView();
- RGBA bg = tmp.get_style_context().get_background_color(StateFlags.NORMAL);
+ RGBA bg = get_style_context().get_background_color(StateFlags.NORMAL);
bool dark_theme = (bg.red < 0.5 && bg.green < 0.5 && bg.blue < 0.5);
string display_name = Util.get_message_display_name(stream_interactor, messages[0], conversation.account);
@@ -64,8 +56,6 @@ public class MergedMessageItem : Grid {
LinkButton lnk = new LinkButton("http://example.com");
RGBA link_color = lnk.get_style_context().get_color(StateFlags.LINK);
link_tag.foreground_rgba = link_color;
-
- message_text_view.override_background_color(0, {0,0,0,0});
}
public void update() {
diff --git a/main/src/ui/conversation_summary/view.vala b/main/src/ui/conversation_summary/view.vala
index 87c553c5..2cf695b2 100644
--- a/main/src/ui/conversation_summary/view.vala
+++ b/main/src/ui/conversation_summary/view.vala
@@ -50,22 +50,7 @@ public class View : Box {
return true;
});
- update_background_color();
- this.style_updated.connect(style_changed);
- }
-
- private void update_background_color() {
- TextView tmp = new TextView();
- this.override_background_color(0, tmp.get_style_context().get_background_color(0));
- main.override_background_color(0, tmp.get_style_context().get_background_color(0));
- }
-
- private void style_changed() {
- lock (main) {
- this.style_updated.disconnect(style_changed);
- update_background_color();
- this.style_updated.connect(style_changed);
- }
+ Util.force_base_background(this);
}
public void initialize_for_conversation(Conversation? conversation) {
diff --git a/main/src/ui/util.vala b/main/src/ui/util.vala
index aad0817d..ec09609a 100644
--- a/main/src/ui/util.vala
+++ b/main/src/ui/util.vala
@@ -74,6 +74,22 @@ public class Util : Object {
if (scale == 0) scale = image.get_scale_factor();
image.set_from_surface(Gdk.cairo_surface_create_from_pixbuf(pixbuf, scale, image.get_window()));
}
+
+ private const string force_background_css = "%s { background-color: %s; }";
+
+ public static void force_background(Gtk.Widget widget, string color, string selector = "*") {
+ var p = new Gtk.CssProvider();
+ try {
+ p.load_from_data(force_background_css.printf(selector, color));
+ widget.get_style_context().add_provider(p, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ } catch (GLib.Error err) {
+ // handle err
+ }
+ }
+
+ public static void force_base_background(Gtk.Widget widget, string selector = "*") {
+ force_background(widget, "@theme_base_color", selector);
+ }
}
} \ No newline at end of file