summaryrefslogtreecommitdiff
path: root/src/math-equation.c
diff options
context:
space:
mode:
authormbkma <[email protected]>2020-02-13 22:24:23 +0100
committerlukefromdc <[email protected]>2020-02-27 05:50:08 +0000
commit8de77e33ab168df33b2a4bc7a7fe45aed75e9040 (patch)
tree379e6ad7924cd65ffad2f7d0a8a2464618772940 /src/math-equation.c
parent432a684f6139ec0029eff6469e2873c11cb9adc4 (diff)
downloadmate-calc-8de77e33ab168df33b2a4bc7a7fe45aed75e9040.tar.bz2
mate-calc-8de77e33ab168df33b2a4bc7a7fe45aed75e9040.tar.xz
add history view to show recent calculations.
add option to enable/disable history (disabled by default). add possibility to resize mate-calc if history is enabled.
Diffstat (limited to 'src/math-equation.c')
-rw-r--r--src/math-equation.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/math-equation.c b/src/math-equation.c
index 3b0e4d8..1d349e2 100644
--- a/src/math-equation.c
+++ b/src/math-equation.c
@@ -975,10 +975,15 @@ math_equation_set_number(MathEquation *equation, const MPNumber *x)
{
char *text;
GtkTextIter start, end;
+ MathEquationState *state;
g_return_if_fail(equation != NULL);
g_return_if_fail(x != NULL);
+ /* Notify history */
+ state = get_current_state(equation);
+ g_signal_emit_by_name(equation, "history", state->expression, x, mp_serializer_get_base(equation->priv->serializer));
+
/* Show the number in the user chosen format */
text = mp_serializer_to_string(equation->priv->serializer, x);
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(equation), text, -1);
@@ -1788,8 +1793,19 @@ math_equation_class_init(MathEquationClass *klass)
"Serializer",
MP_TYPE_SERIALIZER,
G_PARAM_READABLE));
-}
+ GType param_types[3] = {G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INT};
+ g_signal_newv("history",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ G_TYPE_NONE,
+ 3,
+ param_types);
+}
static void
pre_insert_text_cb(MathEquation *equation,