[chronojump] Better gui size for dialog_image_test, and solve better no img file found



commit e5f3a69d10bed23bb41af4f6cd3b1a8f8adc9175
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jul 13 14:29:36 2018 +0200

    Better gui size for dialog_image_test, and solve better no img file found

 glade/dialog_image_test.glade |  2 --
 src/gui/dialogImageTest.cs    | 27 +++++++++++++++++----------
 2 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/glade/dialog_image_test.glade b/glade/dialog_image_test.glade
index 4b6fe130..df7e2876 100644
--- a/glade/dialog_image_test.glade
+++ b/glade/dialog_image_test.glade
@@ -3,8 +3,6 @@
   <!-- interface-requires gtk+ 3.0 -->
   <!-- interface-naming-policy toplevel-contextual -->
   <widget class="GtkDialog" id="dialog_image_test">
-    <property name="width_request">640</property>
-    <property name="height_request">480</property>
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="border_width">8</property>
diff --git a/src/gui/dialogImageTest.cs b/src/gui/dialogImageTest.cs
index b2f341d3..300b6d0e 100644
--- a/src/gui/dialogImageTest.cs
+++ b/src/gui/dialogImageTest.cs
@@ -56,6 +56,9 @@ public class DialogImageTest
                        Pixbuf pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
myEventType.ImageFileName);
                        image_test.Pixbuf = pixbuf;
                }
+
+               dialog_image_test.WidthRequest = 640;
+               dialog_image_test.HeightRequest = 480;
        }
 
        public enum ArchiveType { FILE, ASSEMBLY }
@@ -63,6 +66,12 @@ public class DialogImageTest
        //in a future do a DialogImage class (with this). And the inherit to DialogImageTest
        public DialogImageTest (string title, string imagePath, ArchiveType archiveType)
        {
+               if(archiveType == ArchiveType.FILE && ! File.Exists(imagePath))
+               {
+                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.MultimediaFileNoExists);
+                       return;
+               }
+
                Glade.XML gladeXML;
                gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "dialog_image_test.glade", 
"dialog_image_test", "chronojump");
                gladeXML.Autoconnect(this);
@@ -75,17 +84,15 @@ public class DialogImageTest
 
                scrolledwindow28.Hide();
        
-               if(archiveType == ArchiveType.FILE) {
-                       if(File.Exists(imagePath)) {
-                               Pixbuf pixbuf = new Pixbuf (imagePath);
-                               image_test.Pixbuf = pixbuf;
-                       } else 
-                               new DialogMessage(Constants.MessageTypes.WARNING, 
Constants.MultimediaFileNoExists);
-               } else { //ASSEMBLY
-                       Pixbuf pixbuf = new Pixbuf (null, imagePath);
-                       image_test.Pixbuf = pixbuf;
-               }
+               Pixbuf pixbuf;
+               if(archiveType == ArchiveType.FILE)
+                       pixbuf = new Pixbuf (imagePath);
+               else //ASSEMBLY
+                       pixbuf = new Pixbuf (null, imagePath);
 
+               image_test.Pixbuf = pixbuf;
+               dialog_image_test.WidthRequest = pixbuf.Width + 40; //allocate vertical scrollbar if needed
+               dialog_image_test.HeightRequest = pixbuf.Height + 85; //allocate button close
        }
                                
        public void on_close_button_clicked (object obj, EventArgs args) {


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