[gnome-calculator] math-display: Simplify the class
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] math-display: Simplify the class
- Date: Mon, 29 Mar 2021 17:34:54 +0000 (UTC)
commit 618e77fc70dcc71bc0d2d6c980264228df90cfd1
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Mar 18 12:02:42 2021 +0100
math-display: Simplify the class
This makes the class a GtkBox directly to make the widget a bit simpler,
implements the frame via CSS, and gives the class a proper CSS node name
to make the CSS easier to read.
src/math-display.vala | 18 ++++++++++--------
src/ui/calculator.css | 7 ++++---
2 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/math-display.vala b/src/math-display.vala
index 75d1f943..e19f4f39 100644
--- a/src/math-display.vala
+++ b/src/math-display.vala
@@ -8,7 +8,7 @@
* license.
*/
-public class MathDisplay : Gtk.Viewport
+public class MathDisplay : Gtk.Box
{
/* Equation being displayed */
private MathEquation _equation;
@@ -28,20 +28,23 @@ public class MathDisplay : Gtk.Viewport
Regex only_variable_name = /^_*\p{L}+(_|\p{L})*$/;
+ static construct {
+ set_css_name ("mathdisplay");
+ }
+
public MathDisplay (MathEquation equation)
{
_equation = equation;
_equation.history_signal.connect (this.update_history);
- var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
- add (main_box);
+ 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);
- main_box.add (history);
- main_box.show_all ();
+ add (history);
+ show_all ();
var scrolled_window = new Gtk.ScrolledWindow (null, null);
var style_context = scrolled_window.get_style_context ();
@@ -64,12 +67,12 @@ public class MathDisplay : Gtk.Viewport
completion_visible = false;
completion_selected = false;
- main_box.pack_start (scrolled_window, false, false, 0);
+ pack_start (scrolled_window, false, false, 0);
scrolled_window.add (source_view); /* Adds ScrolledWindow to source_view for displaying long
equations */
scrolled_window.show ();
var info_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
- main_box.pack_start (info_box, false, true, 0);
+ pack_start (info_box, false, true, 0);
var info_view = new Gtk.TextView ();
info_view.set_wrap_mode (Gtk.WrapMode.WORD);
@@ -89,7 +92,6 @@ public class MathDisplay : Gtk.Viewport
info_box.show ();
info_view.show ();
source_view.show ();
- main_box.show ();
equation.notify["status"].connect ((pspec) => { status_changed_cb (); });
status_changed_cb ();
diff --git a/src/ui/calculator.css b/src/ui/calculator.css
index 5439f0aa..30493877 100644
--- a/src/ui/calculator.css
+++ b/src/ui/calculator.css
@@ -15,18 +15,19 @@
padding: 0px 12px;
}
-window > deck > box > grid > .frame {
+mathdisplay {
+ border: solid @borders 1px;
border-left-width: 0;
border-right-width: 0;
}
/* It isn't first in keyboard mode */
-window > deck > box > grid > .frame:first-child {
+mathdisplay:first-child {
border-top-width: 0;
}
/* It is last in keyboard mode */
-window > deck > box > grid > .frame:last-child {
+mathdisplay:last-child {
border-bottom-width: 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]