[gnome-calculator/wip/cdavis/hdywindow] Use HdyWindow and HdyHeaderBar




commit adc182725205b26f1f085da1e84302df8e60b4c9
Author: Christopher Davis <brainblasted disroot org>
Date:   Sat Dec 26 22:29:14 2020 -0800

    Use HdyWindow and HdyHeaderBar
    
    Use HdyWindow and HdyHeaderBar for nice bottom
    rounded corners.

 meson.build               |   3 +-
 src/gnome-calculator.vala |   2 +
 src/math-window.vala      |   2 +-
 src/meson.build           |   1 +
 src/ui/calculator.css     |  10 +--
 src/ui/math-window.ui     | 151 ++++++++++++++++++++++++----------------------
 6 files changed, 90 insertions(+), 79 deletions(-)
---
diff --git a/meson.build b/meson.build
index c2a5a3ab..47b8626a 100644
--- a/meson.build
+++ b/meson.build
@@ -63,7 +63,8 @@ meson.add_install_script('meson_post_install.py')
 subdir('vapi')
 subdir('gcalc')
 if not get_option ('disable-ui')
-gtk = dependency('gtk+-3.0', version: '>= 3.19.3')
+gtk = dependency('gtk+-3.0', version: '>= 3.24.1')
+libhandy = dependency('libhandy-1', version: '>= 1.0.0')
 subdir('gci')
 gtksourceview = dependency('gtksourceview-4', version: '>= 4.0.2')
 subdir('data')
diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala
index 6edf4c8b..6490af2d 100644
--- a/src/gnome-calculator.vala
+++ b/src/gnome-calculator.vala
@@ -116,6 +116,8 @@ public class Calculator : Gtk.Application
     {
         base.startup ();
 
+        Hdy.init ();
+
         settings = new Settings ("org.gnome.calculator");
         settings.delay ();
         last_opened_window = create_new_window (settings);
diff --git a/src/math-window.vala b/src/math-window.vala
index c1d00dbb..b50c6e41 100644
--- a/src/math-window.vala
+++ b/src/math-window.vala
@@ -10,7 +10,7 @@
  */
 
 [GtkTemplate (ui = "/org/gnome/calculator/math-window.ui")]
-public class MathWindow : Gtk.ApplicationWindow
+public class MathWindow : Hdy.ApplicationWindow
 {
     private MathEquation _equation;
     public MathEquation equation { get { return _equation; } }
diff --git a/src/meson.build b/src/meson.build
index 825cff8b..d4ee5ffc 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -24,6 +24,7 @@ gnome_calculator_deps = [
   gobject,
   gtk,
   gtksourceview,
+  libhandy,
   mpc,
   mpfr,
   posix,
diff --git a/src/ui/calculator.css b/src/ui/calculator.css
index 3291cae5..cbec632a 100644
--- a/src/ui/calculator.css
+++ b/src/ui/calculator.css
@@ -15,29 +15,29 @@
   padding: 0px 12px;
 }
 
-window > grid > .frame {
+window > deck > box > grid > .frame {
   border-left-width: 0;
   border-right-width: 0;
 }
 
 /* It isn't first in keyboard mode */
-window > grid > .frame:first-child {
+window > deck > box > grid > .frame:first-child {
   border-top-width: 0;
 }
 
 /* It is last in keyboard mode */
-window > grid > .frame:last-child {
+window > deck > box > grid > .frame:last-child {
   border-bottom-width: 0;
 }
 
-window > grid > box {
+window > deck > box > grid > box {
   padding-left: 12px;
   padding-right: 12px;
   padding-bottom: 12px;
 }
 
 /* This affects the keyboard mode */
-window > grid > mathconverter {
+window > deck > box > grid > mathconverter {
   padding-left: 12px;
   padding-right: 12px;
   padding-top: 12px;
diff --git a/src/ui/math-window.ui b/src/ui/math-window.ui
index d2e233df..f9e0f00e 100644
--- a/src/ui/math-window.ui
+++ b/src/ui/math-window.ui
@@ -103,113 +103,120 @@
       </item>
     </section>
   </menu>
-  <template class="MathWindow" parent="GtkApplicationWindow">
+  <template class="MathWindow" parent="HdyApplicationWindow">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Calculator</property>
     <property name="role">gnome-calculator</property>
     <property name="resizable">True</property>
     <property name="show_menubar">False</property>
     <child>
-      <object class="GtkGrid" id="grid">
+      <object class="GtkBox">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="vexpand">True</property>
-        <property name="border_width">0</property>
         <property name="orientation">vertical</property>
-        <property name="row_spacing">6</property>
         <child>
-          <placeholder/>
-        </child>
-        <child>
-          <object class="MathConverter" id="converter">
-            <property name="visible">False</property>
-          </object>
-          <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">0</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <child type="titlebar">
-      <object class="GtkHeaderBar" id="headerbar">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="show_close_button">True</property>
-        <child type="title">
-          <object class="GtkMenuButton" id="menu_button">
+          <object class="HdyHeaderBar" id="headerbar">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="relief">none</property>
-            <property name="menu_model">window_menu</property>
-            <child internal-child="accessible">
-              <object class="AtkObject">
-                <property name="accessible-name" translatable="yes">Mode selection</property>
+            <property name="can_focus">False</property>
+            <property name="show_close_button">True</property>
+            <child type="title">
+              <object class="GtkMenuButton" id="menu_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="relief">none</property>
+                <property name="menu_model">window_menu</property>
+                <child internal-child="accessible">
+                  <object class="AtkObject">
+                    <property name="accessible-name" translatable="yes">Mode selection</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkGrid" id="grid1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="valign">center</property>
+                    <property name="column_spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="mode_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkArrow" id="arrow">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="arrow_type">down</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+                <style>
+                  <class name="title"/>
+                  <class name="text-button"/>
+                </style>
               </object>
             </child>
             <child>
-              <object class="GtkGrid" id="grid1">
+              <object class="GtkMenuButton" id="primary_menu_button">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="valign">center</property>
-                <property name="column_spacing">6</property>
-                <child>
-                  <object class="GtkLabel" id="mode_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                <property name="receives_default">False</property>
+                <property name="menu_model">primary_menu</property>
+                <accelerator key="F10" signal="clicked"/>
+                <child internal-child="accessible">
+                  <object class="AtkObject">
+                    <property name="accessible-name" translatable="yes">Primary menu</property>
                   </object>
-                  <packing>
-                    <property name="left_attach">0</property>
-                    <property name="top_attach">0</property>
-                  </packing>
                 </child>
                 <child>
-                  <object class="GtkArrow" id="arrow">
+                  <object class="GtkImage">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="arrow_type">down</property>
+                    <property name="icon_name">open-menu-symbolic</property>
+                    <property name="icon_size">1</property>
                   </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="top_attach">0</property>
-                  </packing>
                 </child>
+                <style>
+                  <class name="image-button"/>
+                </style>
               </object>
+              <packing>
+                <property name="pack_type">end</property>
+              </packing>
             </child>
-            <style>
-              <class name="title"/>
-              <class name="text-button"/>
-            </style>
           </object>
         </child>
         <child>
-          <object class="GtkMenuButton" id="primary_menu_button">
+          <object class="GtkGrid" id="grid">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="receives_default">False</property>
-            <property name="menu_model">primary_menu</property>
-            <accelerator key="F10" signal="clicked"/>
-            <child internal-child="accessible">
-              <object class="AtkObject">
-                <property name="accessible-name" translatable="yes">Primary menu</property>
-              </object>
+            <property name="vexpand">True</property>
+            <property name="border_width">0</property>
+            <property name="orientation">vertical</property>
+            <property name="row_spacing">6</property>
+            <child>
+              <placeholder/>
             </child>
             <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="icon_name">open-menu-symbolic</property>
-                <property name="icon_size">1</property>
+              <object class="MathConverter" id="converter">
+                <property name="visible">False</property>
               </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
             </child>
-            <style>
-              <class name="image-button"/>
-            </style>
           </object>
-          <packing>
-            <property name="pack_type">end</property>
-          </packing>
         </child>
       </object>
     </child>


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