aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-09-10 19:11:41 +0200
committerfiaxh <fiaxh@users.noreply.github.com>2019-09-10 19:36:11 +0200
commitbd7fde99af3df59c5ec96184b2649b4308250b24 (patch)
tree49f67c73f6ecc69bb949ea81b49814c90a13f0bd /main
parentd5d305193ce527f1cc3022c406de35d9a85d4ccb (diff)
downloaddino-bd7fde99af3df59c5ec96184b2649b4308250b24.tar.gz
dino-bd7fde99af3df59c5ec96184b2649b4308250b24.zip
fixup Fix some warnings
Diffstat (limited to 'main')
-rw-r--r--main/src/ui/conversation_selector/conversation_selector_row.vala6
-rw-r--r--main/src/ui/global_search.vala22
-rw-r--r--main/src/ui/unified_window_controller.vala12
-rw-r--r--main/src/ui/util/helper.vala8
4 files changed, 22 insertions, 26 deletions
diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala
index 46f6c1a8..6ffefc94 100644
--- a/main/src/ui/conversation_selector/conversation_selector_row.vala
+++ b/main/src/ui/conversation_selector/conversation_selector_row.vala
@@ -136,11 +136,7 @@ public class ConversationSelectorRow : ListBoxRow {
nick_label.label = last_message.direction == Message.DIRECTION_SENT ? _("Me") + ": " : "";
}
- try {
- message_label.label = Markup.escape_text((/\s+/).replace_literal(last_message.body, -1, 0, " "));
- } catch (RegexError e) {
- assert_not_reached();
- }
+ message_label.label = Util.summarize_whitespaces_to_space(last_message.body);
break;
case FileItem.TYPE:
FileItem file_item = last_content_item as FileItem;
diff --git a/main/src/ui/global_search.vala b/main/src/ui/global_search.vala
index db7dbc0f..74e96999 100644
--- a/main/src/ui/global_search.vala
+++ b/main/src/ui/global_search.vala
@@ -205,8 +205,8 @@ public class GlobalSearch : Overlay {
regex_str += ")";
// Color the keywords
- int elongated_by = 0;
try {
+ int elongated_by = 0;
Regex highlight_regex = new Regex(regex_str);
MatchInfo match_info;
string markup_text_bak = markup_text.down();
@@ -218,19 +218,19 @@ public class GlobalSearch : Overlay {
elongated_by += "<span bgcolor=\"yellow\">".length + "</span>".length;
}
markup_text_bak += ""; // We need markup_text_bak to live until here because url_regex.match does not copy the string
-
- label.label = markup_text;
- grid.attach(label, 1, 1, 1, 1);
-
- Button button = new Button() { relief=ReliefStyle.NONE, visible=true };
- button.clicked.connect(() => {
- selected_item(item);
- });
- button.add(grid);
- return button;
} catch (RegexError e) {
assert_not_reached();
}
+
+ label.label = markup_text;
+ grid.attach(label, 1, 1, 1, 1);
+
+ Button button = new Button() { relief=ReliefStyle.NONE, visible=true };
+ button.clicked.connect(() => {
+ selected_item(item);
+ });
+ button.add(grid);
+ return button;
}
private Grid get_context_message_widget(MessageItem item) {
diff --git a/main/src/ui/unified_window_controller.vala b/main/src/ui/unified_window_controller.vala
index 21725574..2fd8eb0d 100644
--- a/main/src/ui/unified_window_controller.vala
+++ b/main/src/ui/unified_window_controller.vala
@@ -153,19 +153,11 @@ public class UnifiedWindowController : Object {
private void update_conversation_topic(string? subtitle = null) {
if (subtitle != null) {
- try {
- conversation_topic = (/\s+/).replace_literal(subtitle, -1, 0, " ");
- } catch (RegexError e) {
- assert_not_reached();
- }
+ conversation_topic = Util.summarize_whitespaces_to_space(subtitle);
} else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
string? subject = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account);
if (subject != null) {
- try {
- conversation_topic = (/\s+/).replace_literal(subject, -1, 0, " ");
- } catch (RegexError e) {
- assert_not_reached();
- }
+ conversation_topic = Util.summarize_whitespaces_to_space(subject);
} else {
conversation_topic = null;
}
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala
index c3353fb6..4e5fbb41 100644
--- a/main/src/ui/util/helper.vala
+++ b/main/src/ui/util/helper.vala
@@ -272,6 +272,14 @@ public int get_only_emoji_count(string markup_text) {
return emoji_no;
}
+public string summarize_whitespaces_to_space(string s) {
+ try {
+ return (/\s+/).replace_literal(s, -1, 0, " ");
+ } catch (RegexError e) {
+ assert_not_reached();
+ }
+}
+
public bool use_csd() {
return (GLib.Application.get_default() as Application).use_csd();
}