[chronojump] tweaks for new products load image on windows



commit f00687ad6f9c55e6058970778b5fdca35d82adcd
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jan 22 20:29:04 2021 +0100

    tweaks for new products load image on windows

 glade/app1.glade     |  1 +
 src/gui/app1/news.cs |  9 +++++++--
 src/json/json.cs     | 12 +++++++++---
 3 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index f3b73ef0..94846efd 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -43032,6 +43032,7 @@ then click this button.</property>
                                                             <child>
                                                             <widget class="GtkLabel" 
id="label_news_description_and_link">
                                                             <property name="width_request">300</property>
+                                                            <property name="height_request">300</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="wrap">True</property>
diff --git a/src/gui/app1/news.cs b/src/gui/app1/news.cs
index dd93c362..0c9f0c91 100644
--- a/src/gui/app1/news.cs
+++ b/src/gui/app1/news.cs
@@ -232,7 +232,10 @@ public partial class ChronoJumpWindow
        {
                label_news_title.Text = "<b>" + news.GetTitle(langEs) + "</b>";
                label_news_title.UseMarkup = true;
+
+               label_news_description_and_link.Visible = false;
                label_news_description_and_link.Text = news.GetDescription(langEs) + "\n\n" + 
news.GetLink(langEs);
+               label_news_description_and_link.Visible = true;
        }
 
        private void news_loadImage(News news)
@@ -249,9 +252,11 @@ public partial class ChronoJumpWindow
                LogB.Information("news image filename: " + filename);
                if(File.Exists(filename))
                {
-                       Pixbuf pixbuf = new Pixbuf (filename);
-                       image_news.Pixbuf = pixbuf;
                        LogB.Information("exists");
+                       //Pixbuf pixbuf = new Pixbuf (filename);
+                       //image_news.Pixbuf = pixbuf;
+                       image_news.Pixbuf = UtilGtk.OpenPixbufSafe(filename, image_news.Pixbuf);
+                       LogB.Information("opened");
                }
        }
 
diff --git a/src/json/json.cs b/src/json/json.cs
index c362524d..a4241e3e 100644
--- a/src/json/json.cs
+++ b/src/json/json.cs
@@ -286,7 +286,10 @@ public class Json
                        else if (Util.IsPng(linkServerImage))
                                extension = ".png";
 
-                       string copyTo = Path.Combine(News.GetNewsDir(), code.ToString() + extension);
+                       //for windows specially, better download to temp and later copy to desired place,
+                       //if download directly, it could create a 0 bytes file
+                       string copyToTemp = Path.Combine(Path.GetTempPath(), code.ToString() + extension);
+                       string copyToNewsDir = Path.Combine(News.GetNewsDir(), code.ToString() + extension);
 
                        /*
                         * download the image if (1 version has changed OR 2 linkServerImage has changed OR 3 
image does not exists locally)
@@ -302,9 +305,12 @@ public class Json
                                        needToDownloadImage = true;
 
                        if(needToDownloadImage ||
-                                       ! File.Exists(copyTo)                                                 
  // 3
+                                       ! File.Exists(copyToNewsDir)                                          
          // 3
                                        )
-                               downloadNewsImage(linkServerImage, copyTo);
+                       {
+                               if(downloadNewsImage(linkServerImage, copyToTemp))
+                                       File.Copy(copyToTemp, copyToNewsDir, true);
+                       }
                }
 
                return news_l;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]