Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions data/com.github.subhadeepjasu.pebbles.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
<summary>Choose the number system</summary>
<description>Select the number system.</description>
</key>
<key name="calculus-mode" type="b">
<default>false</default>
<summary>Calculus Mode: Derivative/Definite Integral</summary>
<description>True if Definite Integral mode, False if Derivative mode</description>
</key>
<key name="last-input-scientific" type="s">
<default>"0"</default>
<summary>Last input in Scientific View</summary>
Expand All @@ -117,6 +122,21 @@
<summary>Last input in Calculator View</summary>
<description>Last input in Calculator View</description>
</key>
<key name="last-input-calculus-upper-lim" type="s">
<default>""</default>
<summary>Last input upper limit in Calculus View</summary>
<description>Last input upper limit for definite integral in Calculus View</description>
</key>
<key name="last-input-calculus-lower-lim" type="s">
<default>""</default>
<summary>Last input lower limit in Calculus View</summary>
<description>Last input lower limit for definite integral in Calculus View</description>
</key>
<key name="last-input-calculus-x" type="s">
<default>""</default>
<summary>Last input x limit in Calculus View</summary>
<description>Last input x limit for derivative in Calculus View</description>
</key>
<key name="last-input-graphing" type="as">
<default>[]</default>
<summary>Last input equations in Graphing View</summary>
Expand Down
8 changes: 4 additions & 4 deletions data/com.github.subhadeepjasu.pebbles.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<categories>
<category>Calculator</category>
</categories>
<developer id="com.github.SubhadeepJasu">
<developer id="com.github.subhadeepjasu">
<name>Subhadeep Jasu</name>
</developer>
<url type="homepage">https://subhadeepjasu.github.io/#/project/pebbles</url>
Expand All @@ -61,18 +61,18 @@
</custom>
<branding>
<color type="primary" scheme_preference="light">#84AEAA</color>
<color type="primary" scheme_preference="dark">rgb(39,40,99)</color>
<color type="primary" scheme_preference="dark">#272863</color>
</branding>
<translation type="gettext" source_locale="en_US">com.github.subhadeepjasu.pebbles</translation>
<launchable type="desktop-id">com.github.subhadeepjasu.pebbles.desktop</launchable>
<screenshots>
<screenshot type="default" environment="pantheon">
<caption>Scientific Mode</caption>
<image>https://raw.githubusercontent.com/SubhadeepJasu/pebbles/master/screenshots/ScreenshotScientific.png</image>
<image>https://raw.githubusercontent.com/SubhadeepJasu/pebbles/master/screenshots/ScientificMode.png</image>
</screenshot>
<screenshot environment="pantheon:dark">
<caption>Scientific Mode</caption>
<image>https://raw.githubusercontent.com/SubhadeepJasu/pebbles/master/screenshots/ScreenshotScientificDark.png</image>
<image>https://raw.githubusercontent.com/SubhadeepJasu/pebbles/master/screenshots/ScientificModeDark.png</image>
</screenshot>
</screenshots>
<content_rating type="oars-1.1">
Expand Down
1 change: 0 additions & 1 deletion data/ui/date_view.blp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2026 Subhadeep Jasu <subhadeep107@proton.me>
using Gtk 4.0;
using Adw 1;

template $PebblesDateView: $PebblesView {
selected_view: bind date_stack.visible-child-name;
Expand Down
25 changes: 25 additions & 0 deletions src/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Pebbles {
public const string KEY_DECIMAL_PLACES = "decimal-places";
public const string KEY_INTEGRATION_RESOLUTION = "integration-resolution";
public const string KEY_DERIVATIVE_ACCURACY = "derivative-accuracy";
public const string KEY_CALCULUS_MODE = "calculus-mode";
public const string KEY_FOREX_API_KEY = "forex-api-key";
public const string KEY_FOREX_API_TIMESTAMP = "forex-timestamp";
public const string KEY_FOREX_RATES_CACHE = "forex-rates-cache";
Expand All @@ -32,6 +33,9 @@ namespace Pebbles {
public const string KEY_LAST_INPUT_SCIENTIFIC = "last-input-scientific";
public const string KEY_LAST_INPUT_PROGRAMMER = "last-input-programmer";
public const string KEY_LAST_INPUT_CALCULUS = "last-input-calculus";
public const string KEY_LAST_INPUT_CALCULUS_X = "last-input-calculus-x";
public const string KEY_LAST_INPUT_CALCULUS_UPPER_LIM = "last-input-calculus-upper-lim";
public const string KEY_LAST_INPUT_CALCULUS_LOWER_LIM = "last-input-calculus-lower-lim";
public const string KEY_LAST_INPUT_GRAPHING = "last-input-graphing";
public const string KEY_DATE_DIFF_FROM = "date-diff-from";
public const string KEY_DATE_DIFF_TO = "date-diff-to";
Expand Down Expand Up @@ -60,6 +64,7 @@ namespace Pebbles {
keys.append (KEY_GLOBAL_ANGLE_UNIT);
keys.append (KEY_GLOBAL_WORD_LENGTH);
keys.append (KEY_NUMBER_SYSTEM);
keys.append (KEY_CALCULUS_MODE);
keys.append (KEY_LAST_INPUT_SCIENTIFIC);
keys.append (KEY_LAST_INPUT_PROGRAMMER);
keys.append (KEY_LAST_INPUT_CALCULUS);
Expand Down Expand Up @@ -181,6 +186,11 @@ namespace Pebbles {
set { set_enum (KEY_NUMBER_SYSTEM, value); }
}

public bool calculus_mode {
get { return get_boolean (KEY_CALCULUS_MODE); }
set { set_boolean (KEY_CALCULUS_MODE, value); }
}

public string last_input_scientific {
owned get { return get_string (KEY_LAST_INPUT_SCIENTIFIC); }
set { set_string (KEY_LAST_INPUT_SCIENTIFIC, value); }
Expand All @@ -196,6 +206,21 @@ namespace Pebbles {
set { set_string (KEY_LAST_INPUT_CALCULUS, value); }
}

public string last_input_calculus_x {
owned get { return get_string (KEY_LAST_INPUT_CALCULUS_X); }
set { set_string (KEY_LAST_INPUT_CALCULUS_X, value); }
}

public string last_input_calculus_upper_lim {
owned get { return get_string (KEY_LAST_INPUT_CALCULUS_UPPER_LIM); }
set { set_string (KEY_LAST_INPUT_CALCULUS_UPPER_LIM, value); }
}

public string last_input_calculus_lower_lim {
owned get { return get_string (KEY_LAST_INPUT_CALCULUS_LOWER_LIM); }
set { set_string (KEY_LAST_INPUT_CALCULUS_LOWER_LIM, value); }
}

public string[] last_input_graphing {
owned get { return get_strv (KEY_LAST_INPUT_GRAPHING); }
set { set_strv (KEY_LAST_INPUT_GRAPHING, value); }
Expand Down
38 changes: 35 additions & 3 deletions src/shell/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ namespace Pebbles {
public Gtk.Stack date_header_box_stack;
public Gtk.Switch diff_mode_switch;
public Gtk.Switch add_mode_switch;
public Granite.ModeSwitch calculus_mode_button;
[GtkChild]
private unowned Gtk.Box currency_header_box;
[GtkChild]
Expand Down Expand Up @@ -274,12 +275,14 @@ namespace Pebbles {
on_change_mode ();
});

var calculus_mode_button = new Granite.ModeSwitch.from_icon_name (
calculus_mode_button = new Granite.ModeSwitch.from_icon_name (
"derivative-mode-symbolic",
"integral-mode-symbolic"
);
calculus_header_box.append (calculus_mode_button);

if (settings.load_last_session) {
calculus_mode_button.active = settings.calculus_mode;
}
calculus_mode_button.notify["active"].connect (() => {
calculus_view.integral_mode = calculus_mode_button.active;
});
Expand Down Expand Up @@ -682,6 +685,14 @@ namespace Pebbles {
on_memory_clear (global ? "global" : Context.SCIENTIFIC);
});

calculus_view.on_memory_recall.connect ((global) => {
return on_memory_recall (global ? "global" : Context.CALCULUS);
});

calculus_view.on_memory_clear.connect ((global) => {
on_memory_clear (global ? "global" : Context.CALCULUS);
});

statistics_view.on_memory_recall.connect ((global) => {
return on_memory_recall (global ? "global" : Context.STATISTICS);
});
Expand Down Expand Up @@ -939,7 +950,6 @@ namespace Pebbles {
protected void history_recall (HistoryModel _history) {
switch (_history.context) {
case Context.SCIENTIFIC:
case Context.CALCULUS:
case Context.GRAPHING:
settings.global_angle_unit = (GlobalAngleUnit) _history.metadata.metadata_1;
switch (settings.global_angle_unit) {
Expand All @@ -960,6 +970,28 @@ namespace Pebbles {
break;
}
break;
case Context.CALCULUS:
settings.global_angle_unit = (GlobalAngleUnit) _history.metadata.metadata_1;
switch (settings.global_angle_unit) {
case RAD:
angle_mode.label_text = "RAD";
graph_angle_mode.label_text = "RAD";
calculus_angle_mode.label_text = "RAD";
break;
case GRAD:
angle_mode.label_text = "GRA";
graph_angle_mode.label_text = "GRA";
calculus_angle_mode.label_text = "GRA";
break;
case DEG:
angle_mode.label_text = "DEG";
graph_angle_mode.label_text = "DEG";
calculus_angle_mode.label_text = "DEG";
break;
}
settings.calculus_mode = _history.metadata.metadata_2 == 1;
calculus_mode_button.active = settings.calculus_mode;
break;
case Context.PROGRAMMER:
settings.global_word_length = (GlobalWordLength) _history.metadata.metadata_1;
switch (settings.global_word_length) {
Expand Down
10 changes: 8 additions & 2 deletions src/shell/views/CalculusView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ namespace Pebbles {
protected string constant_label { get; private set; default = "C"; }
protected string constant_desc { get; private set; default = ""; }

private Settings settings;

public signal void on_evaluate (
string input,
bool integral_mode,
Expand All @@ -80,6 +82,7 @@ namespace Pebbles {
public signal void on_memory_clear (bool global);

construct {
settings = Pebbles.Settings.get_default ();
display.on_input.connect ((text) => {
on_evaluate (
text,
Expand All @@ -89,6 +92,10 @@ namespace Pebbles {
);
});

if (settings.load_last_session) {
integral_mode = settings.calculus_mode;
}

load_constant_button ();
Settings.get_default ().changed.connect ((key) => {
if (key == "constant-key-value1" || key == "constant-key-value2") {
Expand All @@ -99,6 +106,7 @@ namespace Pebbles {

public void show_result (string result) {
display.show_result (result);
settings.calculus_mode = integral_mode;
}

[GtkCallback]
Expand Down Expand Up @@ -244,8 +252,6 @@ namespace Pebbles {
}

private void load_constant_button () {
var settings = Pebbles.Settings.get_default ();

var key = shift_button.active ? settings.constant_key_value2 : settings.constant_key_value1;
switch (key) {
case ARCHIMEDES:
Expand Down
15 changes: 15 additions & 0 deletions src/shell/widgets/displays/CalculusDisplay.vala
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ namespace Pebbles {

});

if (settings.load_last_session) {
limit_entry_a.text = settings.last_input_calculus_lower_lim;
limit_entry_b.text = settings.last_input_calculus_upper_lim;
limit_entry_der.text = settings.last_input_calculus_x;
}

focus_controller_main = new Gtk.EventControllerFocus ();
focus_controller_main.enter.connect (() => {
focused_entry = main_entry;
Expand Down Expand Up @@ -120,16 +126,19 @@ namespace Pebbles {
[GtkCallback]
public void set_limit_a (Gtk.Editable entry) {
limit_a = double.parse (entry.text);
settings.last_input_calculus_lower_lim = entry.text;
}

[GtkCallback]
public void set_limit_b (Gtk.Editable entry) {
limit_b = double.parse (entry.text);
settings.last_input_calculus_upper_lim = entry.text;
}

[GtkCallback]
public void set_limit_x (Gtk.Editable entry) {
limit_x = double.parse (entry.text);
settings.last_input_calculus_x = entry.text;
}

[GtkCallback]
Expand All @@ -148,6 +157,12 @@ namespace Pebbles {
main_entry.set_text (data.input);
main_entry.set_position ((int) main_entry.text_length);
main_label.set_text (data.result);
if (data.metadata.metadata_2 == 1) {
limit_entry_a.text = data.metadata.metadata_3;
limit_entry_b.text = data.metadata.metadata_4;
} else {
limit_entry_der.text = data.metadata.metadata_3;
}
}

public void show_result (string result) {
Expand Down