|
|
bb3dc4 |
From 3edf6664432fd65ad68b7e5b91de65eef7fcdb09 Mon Sep 17 00:00:00 2001
|
|
|
bb3dc4 |
From: Robert Roth <robert.roth.off@gmail.com>
|
|
|
bb3dc4 |
Date: Thu, 4 Oct 2018 23:41:03 +0300
|
|
|
bb3dc4 |
Subject: [PATCH 4/5] Conversion ui improvements (#72)
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
---
|
|
|
bb3dc4 |
src/math-converter.ui | 9 +++++++--
|
|
|
bb3dc4 |
src/math-converter.vala | 45 +++++++++++++++++++++++++++--------------
|
|
|
bb3dc4 |
src/math-display.vala | 12 ++++-------
|
|
|
bb3dc4 |
3 files changed, 41 insertions(+), 25 deletions(-)
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
diff --git a/src/math-converter.ui b/src/math-converter.ui
|
|
|
bb3dc4 |
index 8172ede3..9ec03820 100644
|
|
|
bb3dc4 |
--- a/src/math-converter.ui
|
|
|
bb3dc4 |
+++ b/src/math-converter.ui
|
|
|
bb3dc4 |
@@ -1,59 +1,63 @@
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
<interface>
|
|
|
bb3dc4 |
<requires lib="gtk+" version="3.16"/>
|
|
|
bb3dc4 |
<template class="MathConverter" parent="GtkGrid">
|
|
|
bb3dc4 |
<property name="visible">False</property>
|
|
|
bb3dc4 |
<property name="can_focus">False</property>
|
|
|
bb3dc4 |
<property name="row_spacing">6</property>
|
|
|
bb3dc4 |
<property name="column_spacing">6</property>
|
|
|
bb3dc4 |
<child>
|
|
|
bb3dc4 |
<object class="GtkButton" id="swap_button">
|
|
|
bb3dc4 |
<property name="label">⇆</property>
|
|
|
bb3dc4 |
<property name="visible">True</property>
|
|
|
bb3dc4 |
<property name="can_focus">False</property>
|
|
|
bb3dc4 |
<property name="receives_default">False</property>
|
|
|
bb3dc4 |
<property name="tooltip_text" translatable="yes">Switch conversion units</property>
|
|
|
bb3dc4 |
<property name="relief">none</property>
|
|
|
bb3dc4 |
<signal name="clicked" handler="swap_button_clicked_cb" swapped="no"/>
|
|
|
bb3dc4 |
</object>
|
|
|
bb3dc4 |
<packing>
|
|
|
bb3dc4 |
<property name="left_attach">3</property>
|
|
|
bb3dc4 |
<property name="top_attach">0</property>
|
|
|
bb3dc4 |
</packing>
|
|
|
bb3dc4 |
</child>
|
|
|
bb3dc4 |
<child>
|
|
|
bb3dc4 |
- <object class="GtkLabel" id="in_label">
|
|
|
bb3dc4 |
+ <object class="GtkButton" id="in_button">
|
|
|
bb3dc4 |
<property name="visible">True</property>
|
|
|
bb3dc4 |
<property name="can_focus">False</property>
|
|
|
bb3dc4 |
- <property name="label" translatable="yes"> in </property>
|
|
|
bb3dc4 |
+ <property name="label" translatable="yes"> to </property>
|
|
|
bb3dc4 |
+ <signal name="clicked" handler="convert_button_clicked_cb" swapped="no"/>
|
|
|
bb3dc4 |
+ <style>
|
|
|
bb3dc4 |
+ <class name="flat"/>
|
|
|
bb3dc4 |
+ </style>
|
|
|
bb3dc4 |
</object>
|
|
|
bb3dc4 |
<packing>
|
|
|
bb3dc4 |
<property name="left_attach">1</property>
|
|
|
bb3dc4 |
<property name="top_attach">0</property>
|
|
|
bb3dc4 |
</packing>
|
|
|
bb3dc4 |
</child>
|
|
|
bb3dc4 |
<child>
|
|
|
bb3dc4 |
<object class="GtkComboBox" id="from_combo">
|
|
|
bb3dc4 |
<property name="visible">True</property>
|
|
|
bb3dc4 |
<property name="can_focus">False</property>
|
|
|
bb3dc4 |
<signal name="changed" handler="from_combobox_changed_cb" swapped="no"/>
|
|
|
bb3dc4 |
<child>
|
|
|
bb3dc4 |
<object class="GtkCellRendererText" id="from_renderer"/>
|
|
|
bb3dc4 |
<attributes>
|
|
|
bb3dc4 |
<attribute name="text">0</attribute>
|
|
|
bb3dc4 |
</attributes>
|
|
|
bb3dc4 |
</child>
|
|
|
bb3dc4 |
</object>
|
|
|
bb3dc4 |
<packing>
|
|
|
bb3dc4 |
<property name="left_attach">0</property>
|
|
|
bb3dc4 |
<property name="top_attach">0</property>
|
|
|
bb3dc4 |
</packing>
|
|
|
bb3dc4 |
</child>
|
|
|
bb3dc4 |
<child>
|
|
|
bb3dc4 |
<object class="GtkComboBox" id="to_combo">
|
|
|
bb3dc4 |
<property name="visible">True</property>
|
|
|
bb3dc4 |
<property name="can_focus">False</property>
|
|
|
bb3dc4 |
<property name="opacity">0.88</property>
|
|
|
bb3dc4 |
<signal name="changed" handler="to_combobox_changed_cb" swapped="no"/>
|
|
|
bb3dc4 |
<child>
|
|
|
bb3dc4 |
@@ -103,30 +107,31 @@
|
|
|
bb3dc4 |
<property name="hexpand">False</property>
|
|
|
bb3dc4 |
<property name="vexpand">False</property>
|
|
|
bb3dc4 |
<property name="justify">center</property>
|
|
|
bb3dc4 |
<property name="xalign">0</property>
|
|
|
bb3dc4 |
<property name="yalign">0</property>
|
|
|
bb3dc4 |
<property name="label" translatable="yes" context="convertion equals label">=</property>
|
|
|
bb3dc4 |
</object>
|
|
|
bb3dc4 |
</child>
|
|
|
bb3dc4 |
<child>
|
|
|
bb3dc4 |
<object class="GtkLabel" id="to_label">
|
|
|
bb3dc4 |
<property name="visible">True</property>
|
|
|
bb3dc4 |
<property name="sensitive">True</property>
|
|
|
bb3dc4 |
<property name="can_focus">False</property>
|
|
|
bb3dc4 |
<property name="halign">end</property>
|
|
|
bb3dc4 |
<property name="valign">center</property>
|
|
|
bb3dc4 |
<property name="hexpand">True</property>
|
|
|
bb3dc4 |
<property name="vexpand">False</property>
|
|
|
bb3dc4 |
<property name="justify">center</property>
|
|
|
bb3dc4 |
<property name="xalign">0</property>
|
|
|
bb3dc4 |
<property name="yalign">0</property>
|
|
|
bb3dc4 |
</object>
|
|
|
bb3dc4 |
<packing>
|
|
|
bb3dc4 |
<property name="expand">false</property>
|
|
|
bb3dc4 |
<property name="fill">true</property>
|
|
|
bb3dc4 |
</packing>
|
|
|
bb3dc4 |
</child>
|
|
|
bb3dc4 |
</object>
|
|
|
bb3dc4 |
</child>
|
|
|
bb3dc4 |
</template>
|
|
|
bb3dc4 |
</interface>
|
|
|
bb3dc4 |
+
|
|
|
bb3dc4 |
diff --git a/src/math-converter.vala b/src/math-converter.vala
|
|
|
bb3dc4 |
index 0cf90ac5..a83dea24 100644
|
|
|
bb3dc4 |
--- a/src/math-converter.vala
|
|
|
bb3dc4 |
+++ b/src/math-converter.vala
|
|
|
bb3dc4 |
@@ -75,66 +75,64 @@ public class MathConverter : Gtk.Grid
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
Gtk.TreeIter child_iter;
|
|
|
bb3dc4 |
while (model.iter_children (out child_iter, iter))
|
|
|
bb3dc4 |
iter = child_iter;
|
|
|
bb3dc4 |
from_combo.set_active_iter (iter);
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
return;
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
set_active_unit (from_combo, null, ua);
|
|
|
bb3dc4 |
set_active_unit (to_combo, null, ub);
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
public void get_conversion (out Unit from_unit, out Unit to_unit)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
Gtk.TreeIter from_iter, to_iter;
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
from_combo.get_active_iter (out from_iter);
|
|
|
bb3dc4 |
to_combo.get_active_iter (out to_iter);
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
from_combo.get_model ().get (from_iter, 2, out from_unit, -1);
|
|
|
bb3dc4 |
to_combo.get_model ().get (to_iter, 2, out to_unit, -1);
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
private void update_result_label ()
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
var x = equation.number;
|
|
|
bb3dc4 |
if (x == null)
|
|
|
bb3dc4 |
return;
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
- var z = convert_equation (x);
|
|
|
bb3dc4 |
+ Unit source_unit, target_unit;
|
|
|
bb3dc4 |
+ var z = convert_equation (x, out source_unit, out target_unit);
|
|
|
bb3dc4 |
if (z != null)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
- Unit source_unit, target_unit;
|
|
|
bb3dc4 |
- get_conversion (out source_unit, out target_unit);
|
|
|
bb3dc4 |
-
|
|
|
bb3dc4 |
var source_text = source_unit.format (x);
|
|
|
bb3dc4 |
var target_text = target_unit.format (z);
|
|
|
bb3dc4 |
from_label.set_text (source_text);
|
|
|
bb3dc4 |
to_label.set_text (target_text);
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
private void update_from_model ()
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
var from_model = new Gtk.TreeStore (3, typeof (string), typeof (UnitCategory), typeof (Unit));
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
if (category == null)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
var categories = UnitManager.get_default ().get_categories ();
|
|
|
bb3dc4 |
foreach (var category in categories)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
Gtk.TreeIter parent;
|
|
|
bb3dc4 |
from_model.append (out parent, null);
|
|
|
bb3dc4 |
from_model.set (parent, 0, category.display_name, 1, category, -1);
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
foreach (var unit in category.get_units ())
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
Gtk.TreeIter iter;
|
|
|
bb3dc4 |
from_model.append (out iter, parent);
|
|
|
bb3dc4 |
from_model.set (iter, 0, unit.display_name, 1, category, 2, unit, -1);
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
else
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
@@ -201,62 +199,79 @@ public class MathConverter : Gtk.Grid
|
|
|
bb3dc4 |
/* Set the to combobox to be the list of units can be converted to */
|
|
|
bb3dc4 |
to_model = new Gtk.ListStore (3, typeof (string), typeof (UnitCategory), typeof (Unit));
|
|
|
bb3dc4 |
foreach (var u in category.get_units ())
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
to_model.append (out iter);
|
|
|
bb3dc4 |
to_model.set (iter, 0, u.display_name, 1, category, 2, u, -1);
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
to_combo.model = to_model;
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
/* Select the first possible unit */
|
|
|
bb3dc4 |
to_combo.set_active (0);
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
[GtkCallback]
|
|
|
bb3dc4 |
private void to_combobox_changed_cb ()
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
/* Conversion must have changed */
|
|
|
bb3dc4 |
update_result_label ();
|
|
|
bb3dc4 |
changed ();
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
private void from_cell_data_func (Gtk.CellLayout cell_layout, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
cell.set ("sensitive", !tree_model.iter_has_child (iter));
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
[GtkCallback]
|
|
|
bb3dc4 |
private void swap_button_clicked_cb ()
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
+ Unit? from_unit, to_unit;
|
|
|
bb3dc4 |
+ get_conversion (out from_unit, out to_unit);
|
|
|
bb3dc4 |
+
|
|
|
bb3dc4 |
+ set_active_unit (from_combo, null, to_unit);
|
|
|
bb3dc4 |
+ set_active_unit (to_combo, null, from_unit);
|
|
|
bb3dc4 |
+
|
|
|
bb3dc4 |
+ do_convert(out from_unit, out to_unit);
|
|
|
bb3dc4 |
+
|
|
|
bb3dc4 |
+ update_result_label ();
|
|
|
bb3dc4 |
+ }
|
|
|
bb3dc4 |
+
|
|
|
bb3dc4 |
+ private void do_convert (out Unit? from_unit, out Unit? to_unit) {
|
|
|
bb3dc4 |
var x = equation.number;
|
|
|
bb3dc4 |
if (x != null)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
- var z = convert_equation (x);
|
|
|
bb3dc4 |
- if (z != null)
|
|
|
bb3dc4 |
- equation.set_number (z);
|
|
|
bb3dc4 |
+ var z = convert_equation (x, out from_unit, out to_unit);
|
|
|
bb3dc4 |
+ if (z != null && from_unit != null && to_unit != null)
|
|
|
bb3dc4 |
+ {
|
|
|
bb3dc4 |
+ equation.set ("%s %s %s %s".printf(equation.serializer.to_string (x), from_unit.display_name, _("in"), to_unit.display_name));
|
|
|
bb3dc4 |
+ equation.solve ();
|
|
|
bb3dc4 |
+ }
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
+ }
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
- Unit from_unit, to_unit;
|
|
|
bb3dc4 |
- get_conversion (out from_unit, out to_unit);
|
|
|
bb3dc4 |
- set_active_unit (from_combo, null, to_unit);
|
|
|
bb3dc4 |
- set_active_unit (to_combo, null, from_unit);
|
|
|
bb3dc4 |
+ [GtkCallback]
|
|
|
bb3dc4 |
+ private void convert_button_clicked_cb ()
|
|
|
bb3dc4 |
+ {
|
|
|
bb3dc4 |
+ Unit? from_unit, to_unit;
|
|
|
bb3dc4 |
+ do_convert (out from_unit, out to_unit);
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
update_result_label ();
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
- private Number? convert_equation (Number x)
|
|
|
bb3dc4 |
+ private Number? convert_equation (Number x,
|
|
|
bb3dc4 |
+ out Unit? source_unit,
|
|
|
bb3dc4 |
+ out Unit? target_unit)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
Gtk.TreeIter from_iter, to_iter;
|
|
|
bb3dc4 |
if (!from_combo.get_active_iter (out from_iter))
|
|
|
bb3dc4 |
return null;
|
|
|
bb3dc4 |
if (!to_combo.get_active_iter (out to_iter))
|
|
|
bb3dc4 |
return null;
|
|
|
bb3dc4 |
-
|
|
|
bb3dc4 |
UnitCategory category;
|
|
|
bb3dc4 |
- Unit source_unit, target_unit;
|
|
|
bb3dc4 |
from_combo.model.get (from_iter, 1, out category, 2, out source_unit, -1);
|
|
|
bb3dc4 |
to_combo.model.get (to_iter, 2, out target_unit, -1);
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
return category.convert (x, source_unit, target_unit);
|
|
|
bb3dc4 |
- }
|
|
|
bb3dc4 |
+ }
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
diff --git a/src/math-display.vala b/src/math-display.vala
|
|
|
bb3dc4 |
index 4b1a17c8..01156b0c 100644
|
|
|
bb3dc4 |
--- a/src/math-display.vala
|
|
|
bb3dc4 |
+++ b/src/math-display.vala
|
|
|
bb3dc4 |
@@ -1,60 +1,60 @@
|
|
|
bb3dc4 |
/*
|
|
|
bb3dc4 |
* Copyright (C) 2008-2012 Robert Ancell
|
|
|
bb3dc4 |
*
|
|
|
bb3dc4 |
* This program is free software: you can redistribute it and/or modify it under
|
|
|
bb3dc4 |
* the terms of the GNU General Public License as published by the Free Software
|
|
|
bb3dc4 |
* Foundation, either version 3 of the License, or (at your option) any later
|
|
|
bb3dc4 |
* version. See http://www.gnu.org/copyleft/gpl.html the full text of the
|
|
|
bb3dc4 |
* license.
|
|
|
bb3dc4 |
*/
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
public class MathDisplay : Gtk.Viewport
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
/* Equation being displayed */
|
|
|
bb3dc4 |
private MathEquation _equation;
|
|
|
bb3dc4 |
public MathEquation equation { get { return _equation; } }
|
|
|
bb3dc4 |
private HistoryView history;
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
/* Display widget */
|
|
|
bb3dc4 |
Gtk.SourceView source_view;
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
/* Buffer that shows errors etc */
|
|
|
bb3dc4 |
Gtk.TextBuffer info_buffer;
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
/* Spinner widget that shows if we're calculating a response */
|
|
|
bb3dc4 |
Gtk.Spinner spinner;
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
public MathDisplay (MathEquation equation)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
_equation = equation;
|
|
|
bb3dc4 |
- _equation.history_signal.connect (this.handler);
|
|
|
bb3dc4 |
+ _equation.history_signal.connect (this.update_history);
|
|
|
bb3dc4 |
var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
|
|
|
bb3dc4 |
add (main_box);
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
history = new HistoryView ();
|
|
|
bb3dc4 |
history.answer_clicked.connect ((ans) => { insert_text (ans); });
|
|
|
bb3dc4 |
history.equation_clicked.connect ((eq) => { display_text (eq); });
|
|
|
bb3dc4 |
main_box.add (history);
|
|
|
bb3dc4 |
main_box.show_all ();
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
var scrolled_window = new Gtk.ScrolledWindow (null, null);
|
|
|
bb3dc4 |
var style_context = scrolled_window.get_style_context ();
|
|
|
bb3dc4 |
style_context.add_class ("display-scrolled");
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
scrolled_window.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER);
|
|
|
bb3dc4 |
source_view = new Gtk.SourceView.with_buffer (equation);
|
|
|
bb3dc4 |
source_view.set_accepts_tab (false);
|
|
|
bb3dc4 |
source_view.set_left_margin (14);
|
|
|
bb3dc4 |
source_view.set_pixels_above_lines (8);
|
|
|
bb3dc4 |
source_view.set_pixels_below_lines (2);
|
|
|
bb3dc4 |
source_view.set_justification (Gtk.Justification.LEFT);
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
source_view.set_name ("displayitem");
|
|
|
bb3dc4 |
source_view.set_size_request (20, 20);
|
|
|
bb3dc4 |
source_view.get_accessible ().set_role (Atk.Role.EDITBAR);
|
|
|
bb3dc4 |
//FIXME:<property name="AtkObject::accessible-description" translatable="yes" comments="Accessible description for the area in which results are displayed">Result Region</property>
|
|
|
bb3dc4 |
source_view.key_press_event.connect (key_press_cb);
|
|
|
bb3dc4 |
create_autocompletion ();
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
main_box.pack_start (scrolled_window, false, false, 0);
|
|
|
bb3dc4 |
scrolled_window.add (source_view); /* Adds ScrolledWindow to source_view for displaying long equations */
|
|
|
bb3dc4 |
@@ -67,75 +67,71 @@ public class MathDisplay : Gtk.Viewport
|
|
|
bb3dc4 |
info_view.set_wrap_mode (Gtk.WrapMode.WORD);
|
|
|
bb3dc4 |
info_view.set_can_focus (false);
|
|
|
bb3dc4 |
info_view.set_editable (false);
|
|
|
bb3dc4 |
info_view.set_left_margin (12);
|
|
|
bb3dc4 |
info_view.set_right_margin (12);
|
|
|
bb3dc4 |
info_box.pack_start (info_view, true, true, 0);
|
|
|
bb3dc4 |
info_buffer = info_view.get_buffer ();
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
style_context = info_view.get_style_context ();
|
|
|
bb3dc4 |
style_context.add_class ("info-view");
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
spinner = new Gtk.Spinner ();
|
|
|
bb3dc4 |
info_box.pack_end (spinner, false, false, 0);
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
info_box.show ();
|
|
|
bb3dc4 |
info_view.show ();
|
|
|
bb3dc4 |
source_view.show ();
|
|
|
bb3dc4 |
main_box.show ();
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
equation.notify["status"].connect ((pspec) => { status_changed_cb (); });
|
|
|
bb3dc4 |
status_changed_cb ();
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
equation.notify["error-token-end"].connect ((pspec) => { error_status_changed_cb (); });
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
public void grabfocus () /* Editbar grabs focus when an instance of gnome-calculator is created */
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
source_view.grab_focus ();
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
- public void handler (string answer, Number number, int number_base, uint representation_base)
|
|
|
bb3dc4 |
+ public void update_history (string answer, Number number, int number_base, uint representation_base)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
- this.update_history (answer, number, number_base, representation_base); /* Recieves signal emitted by a MathEquation object for updating history-view */
|
|
|
bb3dc4 |
+ /* Recieves signal emitted by a MathEquation object for updating history-view */
|
|
|
bb3dc4 |
+ history.insert_entry (answer, number, number_base, representation_base); /* Sends current equation and answer for updating History-View */
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
public void display_text (string prev_eq)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
_equation.display_selected (prev_eq);
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
- public void update_history (string answer, Number number, int number_base, uint representation_base)
|
|
|
bb3dc4 |
- {
|
|
|
bb3dc4 |
- history.insert_entry (answer, number, number_base, representation_base); /* Sends current equation and answer for updating History-View */
|
|
|
bb3dc4 |
- }
|
|
|
bb3dc4 |
-
|
|
|
bb3dc4 |
public void clear_history ()
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
history.clear ();
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
public void insert_text (string answer)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
_equation.insert_selected (answer);
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
private void create_autocompletion ()
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
Gtk.SourceCompletion completion = source_view.get_completion ();
|
|
|
bb3dc4 |
try
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
completion.add_provider (new FunctionCompletionProvider ());
|
|
|
bb3dc4 |
completion.add_provider (new VariableCompletionProvider (equation));
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
catch (Error e)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
warning ("Could not add CompletionProvider to source-view");
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
}
|
|
|
bb3dc4 |
|
|
|
bb3dc4 |
private bool function_completion_window_visible ()
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
unowned List<Gtk.SourceCompletionProvider> providers_list = source_view.get_completion ().get_providers ();
|
|
|
bb3dc4 |
if (providers_list.length () > 0)
|
|
|
bb3dc4 |
{
|
|
|
bb3dc4 |
MathFunction[] functions = FunctionCompletionProvider.get_matches_for_completion_at_cursor (equation);
|
|
|
bb3dc4 |
--
|
|
|
bb3dc4 |
2.31.1
|
|
|
bb3dc4 |
|