[gnome-calculator] mathwindow:Moved history view from MathDisplay to MathWindow
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] mathwindow:Moved history view from MathDisplay to MathWindow
- Date: Wed, 24 Nov 2021 17:38:23 +0000 (UTC)
commit 3b55d253be5df37e9726d2a872c2f945f506c568
Author: Robert Roth <robert roth off gmail com>
Date: Wed Nov 24 19:37:38 2021 +0200
mathwindow:Moved history view from MathDisplay to MathWindow
src/math-display.vala | 24 ++----------------------
src/math-window.vala | 22 ++++++++++++++++++++--
src/ui/calculator.css | 21 +++++++++++++++------
3 files changed, 37 insertions(+), 30 deletions(-)
---
diff --git a/src/math-display.vala b/src/math-display.vala
index 69a1a1ac..bd9f7b71 100644
--- a/src/math-display.vala
+++ b/src/math-display.vala
@@ -13,7 +13,6 @@ public class MathDisplay : Gtk.Box
/* Equation being displayed */
private MathEquation _equation;
public MathEquation equation { get { return _equation; } }
- private HistoryView history;
/* Display widget */
Gtk.SourceView source_view;
@@ -38,16 +37,8 @@ public class MathDisplay : Gtk.Box
public MathDisplay (MathEquation equation)
{
_equation = equation;
- _equation.history_signal.connect (this.update_history);
orientation = Gtk.Orientation.VERTICAL;
- history = new HistoryView ();
- history.answer_clicked.connect ((ans) => { insert_text (ans); });
- history.equation_clicked.connect ((eq) => { display_text (eq); });
- history.set_serializer (equation.serializer);
- _equation.display_changed.connect (history.set_serializer);
- append (history);
-
var scrolled_window = new Gtk.ScrolledWindow ();
scrolled_window.add_css_class ("display-scrolled");
@@ -107,22 +98,11 @@ public class MathDisplay : Gtk.Box
source_view.grab_focus ();
}
- public void update_history (string answer, Number number, int number_base, uint representation_base)
- {
- /* Recieves signal emitted by a MathEquation object for updating history-view */
- history.insert_entry (answer, number, number_base, representation_base); /* Sends current equation
and answer for updating History-View */
- }
-
public void display_text (string prev_eq)
{
_equation.display_selected (prev_eq);
}
- public void clear_history ()
- {
- history.clear ();
- }
-
public void insert_text (string answer)
{
_equation.insert_selected (answer);
@@ -159,7 +139,7 @@ public class MathDisplay : Gtk.Box
return true;
} else if (state == Gdk.ModifierType.ALT_MASK && (keyval == Gdk.Key.Left || keyval == Gdk.Key.Right))
{
- switch (keyval)
+ /*switch (keyval)
{
case Gdk.Key.Left:
history.current -= 1;
@@ -173,7 +153,7 @@ public class MathDisplay : Gtk.Box
equation.clear();
insert_text (entry.answer_label.get_text ());
}
- return true;
+ return true;*/
}
/* Ignore keypresses while calculating */
diff --git a/src/math-window.vala b/src/math-window.vala
index e01adea0..05e4dec3 100644
--- a/src/math-window.vala
+++ b/src/math-window.vala
@@ -15,6 +15,8 @@ public class MathWindow : Adw.ApplicationWindow
private MathEquation _equation;
public MathEquation equation { get { return _equation; } }
+ private HistoryView history;
+
private MathDisplay _display;
public MathDisplay math_display { get { return _display; } }
private MathButtons _buttons;
@@ -61,10 +63,19 @@ public class MathWindow : Adw.ApplicationWindow
event_controller.key_pressed.connect (key_press_cb);
_display = new MathDisplay (equation);
- grid.attach (_display, 0, 1, 1, 1);
+ grid.attach (_display, 0, 2, 1, 1);
_display.show ();
_display.grabfocus ();
+ history = new HistoryView ();
+ history.answer_clicked.connect ((ans) => { _display.insert_text (ans); });
+ history.equation_clicked.connect ((eq) => { _display.display_text (eq); });
+ history.set_serializer (_display.equation.serializer);
+ grid.attach (history, 0, 1, 1, 1);
+
+ _display.equation.display_changed.connect (history.set_serializer);
+ _display.equation.history_signal.connect (this.update_history);
+
_buttons = new MathButtons (equation, this);
grid.attach_next_to(_buttons, _display, Gtk.PositionType.BOTTOM);
@@ -80,7 +91,7 @@ public class MathWindow : Adw.ApplicationWindow
private void clear_cb ()
{
- _display.clear_history ();
+ history.clear ();
}
private void mode_changed_cb ()
@@ -241,4 +252,11 @@ public class MathWindow : Adw.ApplicationWindow
buttons.mode = mode;
}
+
+ public void update_history (string answer, Number number, int number_base, uint representation_base)
+ {
+ /* Recieves signal emitted by a MathEquation object for updating history-view */
+ history.insert_entry (answer, number, number_base, representation_base); /* Sends current equation
and answer for updating History-View */
+ }
+
}
diff --git a/src/ui/calculator.css b/src/ui/calculator.css
index f2101741..e3edeec0 100644
--- a/src/ui/calculator.css
+++ b/src/ui/calculator.css
@@ -17,6 +17,7 @@
mathdisplay {
border: solid @borders 1px;
+ border-top-width: 0px;
margin: 6px 12px 0 12px;
transition: 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@@ -27,14 +28,10 @@ mathdisplay:last-child {
clamp > grid.small mathdisplay {
border-width: 1px 0;
+ border-top-width: 0px;
margin: 6px 0 0 0;
}
-clamp > grid.small mathdisplay:first-child {
- border-top-width: 0;
- margin: 0;
-}
-
clamp > grid.small mathdisplay:last-child {
border-bottom-width: 0;
}
@@ -130,8 +127,16 @@ clamp > .small .bit-panel button {
margin: 0 12px;
}
+clamp > grid.small > widget > .history-view {
+ border-width: 0px 0px;
+ margin: 0px 0 0 0;
+}
+
.history-view {
- border-width: 0 0 1px 0;
+ border: solid @borders 1px;
+ border-top-width: 0px;
+ margin: 0px 12px 0 12px;
+ transition: 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.history-view, .history-entry {
@@ -148,6 +153,10 @@ clamp > .small .bit-panel button {
font-size: 1.3em;
}
+.history-entry :first-child{
+ border-top-width: 0px;
+}
+
.history-entry .equation-label {
/* word-spacing: 2px; Doesn't work (yet) in GTK */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]