[gnome-subtitles: 2/6] Code improvement: don't initialize translations
- From: Pedro Castro <pcastro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-subtitles: 2/6] Code improvement: don't initialize translations
- Date: Tue, 14 May 2019 07:44:25 +0000 (UTC)
commit 2128e6a28530e7df785425c66f21a9931dbd7f9a
Author: Pedro Castro <pedro gnomesubtitles org>
Date: Sat May 4 19:41:47 2019 +0100
Code improvement: don't initialize translations
Check if translations are initialized so we don't inadvertently
initialize them when rendering the TextView.
src/GnomeSubtitles/Ui/View/SubtitleView.cs | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/src/GnomeSubtitles/Ui/View/SubtitleView.cs b/src/GnomeSubtitles/Ui/View/SubtitleView.cs
index 868ac5f..c1b381a 100644
--- a/src/GnomeSubtitles/Ui/View/SubtitleView.cs
+++ b/src/GnomeSubtitles/Ui/View/SubtitleView.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2006-2018 Pedro Castro
+ * Copyright (C) 2006-2019 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,6 @@
*/
using GnomeSubtitles.Core;
-using GnomeSubtitles.Ui.View;
using Gtk;
using Mono.Unix;
using System;
@@ -336,14 +335,18 @@ public class SubtitleView {
private void RenderTranslationTextCell (TreeViewColumn column, CellRenderer cell, ITreeModel
treeModel, TreeIter iter) {
Subtitle subtitle = subtitles[iter];
- RenderTextCell(cell as CellRendererText, iter, subtitle.Translation, subtitle.Style);
+ if (subtitle.HasTranslation) {
+ RenderTextCell(cell as CellRendererText, iter, subtitle.Translation, subtitle.Style);
+ } else {
+ RenderEmptyTextCell(cell as CellRendererText);
+ }
}
-
+
private void RenderTextCell (CellRendererText renderer, TreeIter iter, SubtitleText subtitleText,
SubLib.Core.Domain.Style subtitleStyle) {
/* If there's no text, return empty text without line count */
if (subtitleText.IsEmpty) {
- renderer.Text = String.Empty;
+ RenderEmptyTextCell(renderer);
return;
}
@@ -362,6 +365,10 @@ public class SubtitleView {
renderer.Markup = textMarkup;
}
+
+ private void RenderEmptyTextCell (CellRendererText renderer) {
+ renderer.Text = String.Empty;
+ }
private void GetStyleMarkup (SubLib.Core.Domain.Style subtitleStyle, ref string prefix, ref string
suffix) {
if (subtitleStyle.Italic) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]