[gnome-calculator/wip/glade: 3/4] WIP progress
- From: Alberto Ruiz <aruiz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator/wip/glade: 3/4] WIP progress
- Date: Tue, 12 Jan 2016 02:15:01 +0000 (UTC)
commit e1e3f1a495747fa434364523263a36d2949a78b1
Author: Alberto Ruiz <aruiz gnome org>
Date: Tue Jan 12 01:36:55 2016 +0000
WIP progress
data/math-window.ui | 65 +++++++++++++++++++++++++++++++++++++++++++-
src/math-window.vala | 72 ++++++++++++--------------------------------------
2 files changed, 80 insertions(+), 57 deletions(-)
---
diff --git a/data/math-window.ui b/data/math-window.ui
index bb8dbd4..b9f2b25 100644
--- a/data/math-window.ui
+++ b/data/math-window.ui
@@ -2,12 +2,51 @@
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
+ <object class="GtkAdjustment" id="hadjustment">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="vadjustment">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ <signal name="changed" handler="scroll_changed_cb" swapped="no"/>
+ <signal name="value-changed" handler="scroll_value_changed_cb" swapped="no"/>
+ </object>
<template class="MathWindow" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
+ <property name="title" translatable="yes">Calculator</property>
<property name="role">gnome-calculator</property>
<property name="show_menubar">False</property>
<child>
<object class="GtkGrid" id="grid">
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ <property name="border_width">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolled_window">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hadjustment">hadjustment</property>
+ <property name="vadjustment">vadjustment</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
</child>
<child type="titlebar">
@@ -22,16 +61,38 @@
<property name="receives_default">True</property>
<property name="relief">none</property>
<child>
- <object class="GtkGrid" id="grid">
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="mode_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes"></property>
+ <property name="halign">baseline</property>
+ <property name="hexpand">True</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>
</object>
diff --git a/src/math-window.vala b/src/math-window.vala
index a567ab0..72008cd 100644
--- a/src/math-window.vala
+++ b/src/math-window.vala
@@ -27,6 +27,8 @@ public class MathWindow : Gtk.ApplicationWindow
private Gtk.MenuButton menu_button;
[GtkChild]
private Gtk.Label mode_label;
+ [GtkChild]
+ private Gtk.ScrolledWindow scrolled_window;
private const ActionEntry[] window_entries =
{
@@ -41,16 +43,7 @@ public class MathWindow : Gtk.ApplicationWindow
{
Object (application: app);
_equation = equation;
- return;
-// set_title (/* Title of main window */
-// _("Calculator"));
-/*
- role = "gnome-calculator";
- resizable = false;
- converter = new MathConverter (_equation);
- converter.set_category (null);
- converter.set_conversion (equation.source_units, equation.target_units);
- add_action_entries (window_entries, this);
+ right_aligned = true;
var builder = new Gtk.Builder ();
try
@@ -62,46 +55,12 @@ public class MathWindow : Gtk.ApplicationWindow
error ("Error loading menu UI: %s", e.message);
}
-
- var menu_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
- menu_box.pack_start (mode_label);
- menu_box.pack_start (arrow);
- menu_box.show ();
-
- menu_button = new Gtk.MenuButton ();
- menu_button.add (menu_box);
menu_button.menu_model = (MenuModel) builder.get_object ("window-menu");
- menu_button.get_style_context ().add_class ("title");
- menu_button.get_style_context ().add_class ("text-button");
- menu_button.use_popover = true;
- menu_button.relief = Gtk.ReliefStyle.NONE;
- menu_button.show ();
-
- headerbar = new Gtk.HeaderBar ();
- headerbar.show_close_button = true;
- headerbar.custom_title = menu_button;
- headerbar.show ();
- set_titlebar (headerbar);
-
- var main_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
- add (main_vbox);
- main_vbox.show ();
-
- vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
- vbox.border_width = 6;
- vbox.set_vexpand (true);
- vbox.pack_start (converter, false, true, 0);
- main_vbox.pack_start (vbox, true, true, 0);
- vbox.show ();
-
- var scrolled_window = new Gtk.ScrolledWindow (null, null);
- scrolled_window.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER);
- scrolled_window.set_shadow_type (Gtk.ShadowType.IN);
- vbox.pack_start (scrolled_window, false, true, 0);
- scrolled_window.get_hadjustment ().changed.connect (scroll_changed_cb);
- scrolled_window.get_hadjustment ().value_changed.connect (scroll_value_changed_cb);
- right_aligned = true;
- scrolled_window.show ();
+ add_action_entries (window_entries, this);
+
+ converter = new MathConverter (_equation);
+ converter.set_category (null);
+ converter.set_conversion (equation.source_units, equation.target_units);
_display = new MathDisplay (equation);
scrolled_window.add (_display);
@@ -111,16 +70,17 @@ 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;
+ {
+ buttons.set_visible (true);
+ remove_buttons = false;
converter.set_visible (false);
}
else
{
+ buttons.set_visible(false);
remove_buttons = true;
converter.set_visible (true); /* Unpacks buttons if in keyboard mode */
-/* resizable = true;
+ resizable = true;
}
buttons.show ();
@@ -139,7 +99,7 @@ public class MathWindow : Gtk.ApplicationWindow
catch (Error e)
{
warning ("Error while loading css: %s", e.message);
- }*/
+ }
}
private void mode_changed_cb ()
@@ -177,14 +137,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 */
+ buttons.set_visible (true);
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 */
+ buttons.set_visible (false);
remove_buttons = true;
converter.set_visible (true); /* Converter above the display window is set to visible. */
resizable = true;
@@ -235,12 +195,14 @@ public class MathWindow : Gtk.ApplicationWindow
return result;
}
+ [GtkCallback]
private void scroll_changed_cb (Gtk.Adjustment adjustment)
{
if (right_aligned)
adjustment.set_value (adjustment.get_upper () - adjustment.get_page_size ());
}
+ [GtkCallback]
private void scroll_value_changed_cb (Gtk.Adjustment adjustment)
{
if (adjustment.get_value () == adjustment.get_upper () - adjustment.get_page_size ())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]