diff options
-rw-r--r-- | main/src/ui/conversation_content_view/message_widget.vala | 10 | ||||
-rw-r--r-- | main/src/ui/util/helper.vala | 36 |
2 files changed, 29 insertions, 17 deletions
diff --git a/main/src/ui/conversation_content_view/message_widget.vala b/main/src/ui/conversation_content_view/message_widget.vala index 2b5fd793..ead9a570 100644 --- a/main/src/ui/conversation_content_view/message_widget.vala +++ b/main/src/ui/conversation_content_view/message_widget.vala @@ -198,9 +198,9 @@ public class MessageItemWidget : SizeRequestBin { } if (conversation.type_ == Conversation.Type.GROUPCHAT) { - markup_text = Util.parse_add_markup(markup_text, conversation.nickname, true, true); + markup_text = Util.parse_add_markup_theme(markup_text, conversation.nickname, true, true, Util.is_dark_theme(this), ref theme_dependent); } else { - markup_text = Util.parse_add_markup(markup_text, null, true, true); + markup_text = Util.parse_add_markup_theme(markup_text, null, true, true, Util.is_dark_theme(this), ref theme_dependent); } if (message.body.has_prefix("/me ")) { @@ -216,8 +216,10 @@ public class MessageItemWidget : SizeRequestBin { markup_text = @"<span size=\'$size_str\'>" + markup_text + "</span>"; } + string dim_color = Util.is_dark_theme(this) ? "#BDBDBD" : "#707070"; + if (message.edit_to != null) { - markup_text += " <span size='small' alpha='70%'>(%s)</span>".printf(_("edited")); + markup_text += @" <span size='small' color='$dim_color'>(%s)</span>".printf(_("edited")); theme_dependent = true; } @@ -226,7 +228,7 @@ public class MessageItemWidget : SizeRequestBin { if (message.direction == Message.DIRECTION_SENT && (message.marked == Message.Marked.SENDING || message.marked == Message.Marked.UNSENT)) { // Append "pending..." iff message has not been sent yet if (message.time.compare(new DateTime.now_utc().add_seconds(-10)) < 0) { - markup_text += " <span size='small' alpha='70%'>%s</span>".printf(_("pending…")); + markup_text += @" <span size='small' color='$dim_color'>%s</span>".printf(_("pending…")); theme_dependent = true; additional_info = AdditionalInfo.PENDING; } else { diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index f533ffad..2e1dc023 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -237,7 +237,12 @@ public static Map<unichar, unichar> get_matching_chars() { return MATCHING_CHARS; } -public static string parse_add_markup(string s_, string? highlight_word, bool parse_links, bool parse_text_markup, bool already_escaped_ = false) { +public static string parse_add_markup(string s_, string? highlight_word, bool parse_links, bool parse_text_markup) { + bool ignore_out_var = false; + return parse_add_markup_theme(s_, highlight_word, parse_links, parse_text_markup, false, ref ignore_out_var); +} + +public static string parse_add_markup_theme(string s_, string? highlight_word, bool parse_links, bool parse_text_markup, bool dark_theme, ref bool theme_dependent, bool already_escaped_ = false) { string s = s_; bool already_escaped = already_escaped_; @@ -281,9 +286,11 @@ public static string parse_add_markup(string s_, string? highlight_word, bool pa } } - return parse_add_markup(s[0:start], highlight_word, parse_links, parse_text_markup, already_escaped) + - "<a href=\"" + Markup.escape_text(link) + "\">" + parse_add_markup(link, highlight_word, false, false, already_escaped) + "</a>" + - parse_add_markup(s[end:s.length], highlight_word, parse_links, parse_text_markup, already_escaped); + return parse_add_markup_theme(s[0:start], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + + "<a href=\"" + Markup.escape_text(link) + "\">" + + parse_add_markup_theme(link, highlight_word, false, false, dark_theme, ref theme_dependent, already_escaped) + + "</a>" + + parse_add_markup_theme(s[end:s.length], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped); } match_info.next(); } @@ -302,9 +309,9 @@ public static string parse_add_markup(string s_, string? highlight_word, bool pa if (match_info.matches()) { int start, end; match_info.fetch_pos(0, out start, out end); - return parse_add_markup(s[0:start], highlight_word, parse_links, parse_text_markup, already_escaped) + + return parse_add_markup_theme(s[0:start], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + "<b>" + s[start:end] + "</b>" + - parse_add_markup(s[end:s.length], highlight_word, parse_links, parse_text_markup, already_escaped); + parse_add_markup_theme(s[end:s.length], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped); } } catch (RegexError e) { assert_not_reached(); @@ -318,10 +325,13 @@ public static string parse_add_markup(string s_, string? highlight_word, bool pa if (quote_match_info.matches()) { int start, end; + string dim_color = dark_theme ? "#BDBDBD": "#707070"; + + theme_dependent = true; quote_match_info.fetch_pos(0, out start, out end); - return parse_add_markup(s[0:start], highlight_word, parse_links, parse_text_markup, already_escaped) + - "<span fgalpha='70%'>" + s[start:end] + "</span>" + - parse_add_markup(s[end:s.length], highlight_word, parse_links, parse_text_markup, already_escaped); + return parse_add_markup_theme(s[0:start], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + + @"<span color='$dim_color'>> " + parse_add_markup_theme(s[start + "> ".len():end], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + "</span>" + + parse_add_markup_theme(s[end:s.length], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped); } string[] markup_string = new string[]{"`", "_", "*", "~"}; @@ -336,11 +346,11 @@ public static string parse_add_markup(string s_, string? highlight_word, bool pa if (match_info.matches()) { int start, end; match_info.fetch_pos(2, out start, out end); - return parse_add_markup(s[0:start-1], highlight_word, parse_links, parse_text_markup, already_escaped) + - "<span alpha='50%'>" + s[start-1:start] + "</span>" + + return parse_add_markup_theme(s[0:start-1], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + + "<span color='#9E9E9E'>" + s[start-1:start] + "</span>" + @"<$(convenience_tag[i])>" + s[start:end] + @"</$(convenience_tag[i])>" + - "<span alpha='50%'>" + s[end:end+1] + "</span>" + - parse_add_markup(s[end+1:s.length], highlight_word, parse_links, parse_text_markup, already_escaped); + "<span color='#9E9E9E'>" + s[end:end+1] + "</span>" + + parse_add_markup_theme(s[end+1:s.length], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped); } } catch (RegexError e) { assert_not_reached(); |