[gnome-calculator/wip/glade: 2/4] WIP: porting main window to GLADE



commit 14f76a75b612f18cf753883cb478b9a89fb9fb60
Author: Alberto Ruiz <aruiz gnome org>
Date:   Sun Jan 10 20:03:34 2016 +0000

    WIP: porting main window to GLADE

 data/Makefile.am                    |    1 +
 data/gnome-calculator.gresource.xml |    1 +
 data/math-window.ui                 |   40 +++++++++++++++++++++++++++++++++++
 gnome-calculator.doap               |    2 +-
 po/POTFILES.in                      |    1 +
 src/math-window.vala                |   31 ++++++++++++--------------
 6 files changed, 58 insertions(+), 18 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 76fa087..957a555 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -19,6 +19,7 @@ EXTRA_DIST = \
        buttons-financial.ui \
        buttons-programming.ui \
        math-converter.ui \
+       math-window.ui \
        menu.ui \
        calculator.css \
        gnome-calculator.gresource.xml \
diff --git a/data/gnome-calculator.gresource.xml b/data/gnome-calculator.gresource.xml
index b68e708..30630d9 100644
--- a/data/gnome-calculator.gresource.xml
+++ b/data/gnome-calculator.gresource.xml
@@ -6,6 +6,7 @@
     <file preprocess="xml-stripblanks">buttons-financial.ui</file>
     <file preprocess="xml-stripblanks">buttons-programming.ui</file>
     <file preprocess="xml-stripblanks">math-converter.ui</file>
+    <file preprocess="xml-stripblanks">math-window.ui</file>
     <file preprocess="xml-stripblanks">menu.ui</file>
     <file>calculator.css</file>
   </gresource>
diff --git a/data/math-window.ui b/data/math-window.ui
new file mode 100644
index 0000000..bb8dbd4
--- /dev/null
+++ b/data/math-window.ui
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.19.0 -->
+<interface>
+  <requires lib="gtk+" version="3.16"/>
+  <template class="MathWindow" parent="GtkApplicationWindow">
+    <property name="can_focus">False</property>
+    <property name="role">gnome-calculator</property>
+    <property name="show_menubar">False</property>
+    <child>
+      <object class="GtkGrid" id="grid">
+      </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">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="relief">none</property>
+            <child>
+              <object class="GtkGrid" id="grid">
+                <child>
+                  <object class="GtkLabel" id="mode_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes"></property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/gnome-calculator.doap b/gnome-calculator.doap
index 90d320e..66de213 100644
--- a/gnome-calculator.doap
+++ b/gnome-calculator.doap
@@ -4,7 +4,7 @@
          xmlns:gnome="http://api.gnome.org/doap-extensions#";
          xmlns="http://usefulinc.com/ns/doap#";>
 
-  <name xml:lang="en">gnome-calculator</name>
+  <name xml:lang="en">GNOME Calculator/name>
   <shortdesc xml:lang="en">Desktop calculator</shortdesc>
   <homepage rdf:resource="https://wiki.gnome.org/Apps/Calculator"; />
   <mailing-list rdf:resource="https://mail.gnome.org/mailman/listinfo/gcalctool-list"; />
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4124820..f0d867a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -8,6 +8,7 @@
 data/gnome-calculator.desktop.in
 data/gnome-calculator.appdata.xml.in
 data/math-converter.ui
+data/math-window.ui
 [type: gettext/glade]data/menu.ui
 data/org.gnome.calculator.gschema.xml
 lib/currency.vala
diff --git a/src/math-window.vala b/src/math-window.vala
index c6c32f7..a567ab0 100644
--- a/src/math-window.vala
+++ b/src/math-window.vala
@@ -9,6 +9,7 @@
  * license.
  */
 
+[GtkTemplate (ui = "/org/gnome/calculator/math-window.ui")]
 public class MathWindow : Gtk.ApplicationWindow
 {
     private MathEquation _equation;
@@ -21,10 +22,10 @@ public class MathWindow : Gtk.ApplicationWindow
     public MathButtons buttons { get { return _buttons; } }
     private bool right_aligned;
     private bool remove_buttons;
-    private Gtk.MenuButton menu_button;
 
-    private Gtk.HeaderBar headerbar;
-    private Gtk.Box vbox;
+    [GtkChild]
+    private Gtk.MenuButton menu_button;
+    [GtkChild]
     private Gtk.Label mode_label;
 
     private const ActionEntry[] window_entries =
@@ -40,9 +41,10 @@ public class MathWindow : Gtk.ApplicationWindow
     {
         Object (application: app);
         _equation = equation;
-        set_title (/* Title of main window */
-                   _("Calculator"));
-
+        return;
+//        set_title (/* Title of main window */
+//                   _("Calculator"));
+/*
         role = "gnome-calculator";
         resizable = false;
         converter = new MathConverter (_equation);
@@ -60,11 +62,6 @@ public class MathWindow : Gtk.ApplicationWindow
             error ("Error loading menu UI: %s", e.message);
         }
 
-        mode_label = new Gtk.Label (null);
-        mode_label.show ();
-
-        var arrow = new Gtk.Arrow (Gtk.ArrowType.DOWN, Gtk.ShadowType.NONE);
-        arrow.show ();
 
         var menu_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
         menu_box.pack_start (mode_label);
@@ -114,16 +111,16 @@ public class MathWindow : Gtk.ApplicationWindow
         _buttons = new MathButtons (equation);
 
         if (_buttons.mode != ButtonMode.KEYBOARD) /* Checks if the calculator is in Keyboard mode or not */
-        {
+/*        {
             vbox.pack_start (buttons, true, true, 0); /* Packs buttons if not in keyboard mode. */
-            remove_buttons = false;
+/*            remove_buttons = false;
             converter.set_visible (false);
         }
         else
         {
             remove_buttons = true;
             converter.set_visible (true); /* Unpacks buttons if in keyboard mode */
-            resizable = true;
+/*            resizable = true;
         }
 
         buttons.show ();
@@ -142,7 +139,7 @@ public class MathWindow : Gtk.ApplicationWindow
         catch (Error e)
         {
             warning ("Error while loading css: %s", e.message);
-        }
+        }*/
     }
 
     private void mode_changed_cb ()
@@ -180,14 +177,14 @@ public class MathWindow : Gtk.ApplicationWindow
 
         if (remove_buttons ==  true && buttons.mode != ButtonMode.KEYBOARD)
         {
-            vbox.pack_start (buttons, true, true, 0); /* Packs buttons when calculator is switched from 
keyboard mode to any other mode */
+            //vbox.pack_start (buttons, true, true, 0); /* Packs buttons when calculator is switched from 
keyboard mode to any other mode */
             remove_buttons = false;
             converter.set_visible (false);
             resizable = false;
         }
         else if (remove_buttons == false && buttons.mode == ButtonMode.KEYBOARD)
         {
-            vbox.remove (vbox.get_children ().nth_data (2)); /* Unpacks buttons when switched to keyboard 
mode */
+            //vbox.remove (vbox.get_children ().nth_data (2)); /* Unpacks buttons when switched to keyboard 
mode */
             remove_buttons = true;
             converter.set_visible (true); /* Converter above the display window is set to visible. */
             resizable = true;


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