[gtranslator: 1/2] gtrl-dl-teams, gtr-application: Add libhandy widgets




commit d000d632d9fe0e0654769fe19333a0f0e4013b26
Author: Amanda Shafack <shafack likhene gmail com>
Date:   Thu Oct 22 16:53:09 2020 +0000

    gtrl-dl-teams, gtr-application: Add libhandy widgets
    
    When you click on the "load from DL" button with the window in
    full screen, the form takes the whole width. It will be good if the
    form has a maximum width.
    
    Use libhandy to extend Gtk so as to make the form smoothly grow to a
    maximum width and automatically adapt its size to that of it's parent.
    
    Closes: https://gitlab.gnome.org/GNOME/gtranslator/-/issues/122

 build-aux/flatpak/org.gnome.Gtranslator.json |  15 +++
 meson.build                                  |   2 +
 src/gtr-application.c                        |   2 +
 src/gtr-dl-teams.h                           |   1 +
 src/gtr-dl-teams.ui                          | 163 +++++++++++++++------------
 5 files changed, 109 insertions(+), 74 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Gtranslator.json b/build-aux/flatpak/org.gnome.Gtranslator.json
index 7a649617a..65cb50823 100644
--- a/build-aux/flatpak/org.gnome.Gtranslator.json
+++ b/build-aux/flatpak/org.gnome.Gtranslator.json
@@ -110,6 +110,21 @@
                 "/share/doc"
             ]
         },
+        {
+            "name": "libhandy",
+            "buildsystem": "meson",
+            "builddir": true,
+            "config-opts": [
+                "-Dexamples=false",
+                "-Dtests=false"
+            ],
+            "sources": [
+                {
+                    "type": "git",
+                    "url": "https://gitlab.gnome.org/GNOME/libhandy.git";
+                }
+            ]
+        },
         {
             "name" : "gtranslator",
             "buildsystem" : "meson",
diff --git a/meson.build b/meson.build
index 81457ad30..fdc9b7d9a 100644
--- a/meson.build
+++ b/meson.build
@@ -103,10 +103,12 @@ src_dir = join_paths(meson.source_root(), 'src')
 
 glib_dep = dependency('glib-2.0', version: '>= 2.36.0')
 gtk_dep = dependency('gtk+-3.0', version: '>= 3.22.20')
+libhandy_dep = dependency('libhandy-1', version: '>= 1.0.0')
 
 gtr_deps = [
   glib_dep,
   gtk_dep,
+  libhandy_dep,
   dependency('libdazzle-1.0', version: '>= 3.33.90'),
   dependency('libgda-5.0'),
   dependency('gio-2.0', version: '>= 2.36.0'),
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 771b296e2..2612733fc 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -42,6 +42,7 @@
 #include <gio/gio.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#include <libhandy-1/handy.h>
 
 #ifdef ENABLE_INTROSPECTION
 #include <girepository.h>
@@ -642,6 +643,7 @@ gtr_application_startup (GApplication *application)
 
   G_APPLICATION_CLASS (gtr_application_parent_class)->startup (application);
 
+  hdy_init();
   g_set_application_name (_("Translation Editor"));
   gtk_window_set_default_icon_name (PACKAGE_APPID);
 
diff --git a/src/gtr-dl-teams.h b/src/gtr-dl-teams.h
index 7437a677e..25ac83e64 100644
--- a/src/gtr-dl-teams.h
+++ b/src/gtr-dl-teams.h
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <gtk/gtk.h>
+#include "libhandy-1/handy.h"
 
 G_BEGIN_DECLS
 
diff --git a/src/gtr-dl-teams.ui b/src/gtr-dl-teams.ui
index 254699ce8..2601aa5ff 100644
--- a/src/gtr-dl-teams.ui
+++ b/src/gtr-dl-teams.ui
@@ -1,37 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
+  <requires lib="gtk+" version="3.20"/>
+  <requires lib="libhandy" version="1.0"/>
   <template class="GtrDlTeams" parent="GtkBin">
     <child>
-      <object class="GtkBox" id="main_box">
-        <property name="margin_start">134</property>
-        <property name="margin_end">134</property>
+      <object class="HdyClamp">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="margin_top">24</property>
-        <property name="margin_bottom">24</property>
-        <property name="vexpand">False</property>
-        <property name="valign">center</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">14</property>
-
-        <child>
-          <object class="GtkImage">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="pixel_size">60</property>
-            <property name="icon_name">view-restore-symbolic</property>
-            <property name="icon_size">6</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
+        <property name="halign">fill</property>
+        <property name="valign">fill</property>
+        <property name="margin-bottom">32</property>
+        <property name="margin-start">16</property>
+        <property name="margin-end">16</property>
+        <property name="margin-top">32</property>
+        <property name="expand">True</property>
+        <property name="maximum-size">600</property>
+        <property name="tightening-threshold">400</property>
         <child>
-          <object class="GtkBox" id="select_box">
-            <property name="margin_start">0</property>
-            <property name="margin_end">0</property>
+          <object class="GtkBox" id="main_box">
+            <property name="margin_start">134</property>
+            <property name="margin_end">134</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="margin_top">24</property>
@@ -40,54 +28,82 @@
             <property name="valign">center</property>
             <property name="orientation">vertical</property>
             <property name="spacing">14</property>
+
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="pixel_size">48</property>
+                <property name="icon_name">view-restore-symbolic</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="select_box">
+                <property name="margin_start">0</property>
+                <property name="margin_end">0</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_top">24</property>
+                <property name="margin_bottom">24</property>
+                <property name="vexpand">False</property>
+                <property name="valign">center</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">14</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="file_label">
+                <property name="visible">False</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">4</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="instructions">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Select team, module, branch and domain to get the 
translation file.</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">5</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="stats_label">
+                <property name="visible">False</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">5</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="load_button">
+                <property name="label" translatable="yes">Load file</property>
+                <property name="visible">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">6</property>
+              </packing>
+            </child>
+
           </object>
         </child>
-        <child>
-          <object class="GtkLabel" id="file_label">
-            <property name="visible">False</property>
-            <property name="can_focus">False</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">4</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="instructions">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Select team, module, branch and domain to get the 
translation file.</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">5</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="stats_label">
-            <property name="visible">False</property>
-            <property name="can_focus">False</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">5</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="load_button">
-            <property name="label" translatable="yes">Load file</property>
-            <property name="visible">False</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">6</property>
-          </packing>
-        </child>
-
       </object>
     </child>
   </template>
@@ -239,4 +255,3 @@
   </object>
 
 </interface>
-


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