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
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v6

- name: Lint
run: io.elementary.vala-lint -d .
Expand All @@ -24,7 +24,7 @@ jobs:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
Expand Down
5 changes: 5 additions & 0 deletions data/com.github.subhadeepjasu.pebbles.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<summary>Result Flow</summary>
<description>Whether result action would replace input with result</description>
</key>
<key name="delete-all-clear" type="b">
<default>false</default>
<summary>All Clear using Delete</summary>
<description>Whether to clear all values when delete is pressed</description>
</key>
<key name="constant-key-value1" enum="@SCHEMA_ID@.constant-key-index">
<default>"euler"</default>
<summary>Choose Constant 1</summary>
Expand Down
2 changes: 0 additions & 2 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ foreach b : blueprint_files
bfs += meson.current_source_dir () / b
endforeach

run_command ('blueprint-compiler', 'batch-compile', meson.project_build_root () / 'data/ui', meson.current_source_dir () / 'ui', bfs, check: true)

blueprints = custom_target ('blueprints',
input: files (blueprint_files),
output: '.',
Expand Down
2 changes: 1 addition & 1 deletion data/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $LCD_FG_COLOR: #272863bb;
0 0 0 1px #0006,
inset 0 1px 0 #fff4,
inset 0 -1px 0 #fff2,
0 12px 24px #545e5473;
0 12px 24px #aec3ae73;

color: $LCD_FG_COLOR;
padding-top: 8px;
Expand Down
4 changes: 2 additions & 2 deletions data/ui/calculus_view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ template $PebblesCalculusView: $PebblesView {
$PebblesButton all_clear_button {
label_text: _("AC");
tooltip_desc: _("All Clear");
accel_markup: "<Shift>BackSpace";
accel_markup: bind template.all_clear_key;
focus-on-click: false;
key: "<Shift>BackSpace";
key: bind template.all_clear_key;

styles [
"destructive-action",
Expand Down
4 changes: 2 additions & 2 deletions data/ui/converter_view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ template $PebblesConverterView: $PebblesView {
$PebblesButton all_clear_button {
label_text: _("AC");
tooltip_desc: _("All Clear");
accel_markup: "<Shift>BackSpace";
accel_markup: bind template.all_clear_key;
focus-on-click: false;
key: "<Shift>BackSpace";
key: bind template.all_clear_key;

styles [
"destructive-action",
Expand Down
4 changes: 2 additions & 2 deletions data/ui/graphing_view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ template $PebblesGraphingView: $PebblesView {
$PebblesButton all_clear_button {
label_text: _("AC");
tooltip_desc: _("All Clear");
accel_markup: "Delete";
accel_markup: bind template.all_clear_key;
focus-on-click: false;
key: "delete";
key: bind template.all_clear_key;

styles [
"destructive-action",
Expand Down
9 changes: 9 additions & 0 deletions data/ui/preferences_dialog.blp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ template $PebblesPreferencesDialog: Adw.PreferencesDialog {
notify::active => $load_session_notify_active_cb();
}

Adw.SwitchRow {
title: _("All Clear On [Delete] Key");
subtitle: _("Clear all values when delete is pressed");
focus-on-click: false;
focusable: false;
active: bind template.settings as <$PebblesSettings>.delete_all_clear;
notify::active => $delete_all_clear_notify_active_cb();
}

Adw.ActionRow decimal_places {
title: _("Decimal Places");
subtitle: _("Number of decimal places after radix symbol");
Expand Down
4 changes: 2 additions & 2 deletions data/ui/programmer_view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ template $PebblesProgrammerView: $PebblesView {
$PebblesButton all_clear_button {
label_text: _("AC");
tooltip_desc: _("All Clear");
accel_markup: "<Shift>BackSpace";
accel_markup: bind template.all_clear_key;
focus-on-click: false;
key: "<Shift>BackSpace";
key: bind template.all_clear_key;

styles [
"destructive-action",
Expand Down
4 changes: 2 additions & 2 deletions data/ui/scientific_view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ template $PebblesScientificView: $PebblesView {
$PebblesButton all_clear_button {
label_text: _("AC");
tooltip_desc: _("All Clear");
accel_markup: "<Shift>BackSpace";
accel_markup: bind template.all_clear_key;
focus-on-click: false;
key: "<Shift>BackSpace";
key: bind template.all_clear_key;

styles [
"destructive-action",
Expand Down
4 changes: 2 additions & 2 deletions data/ui/statistics_view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ template $PebblesStatisticsView: $PebblesView {
$PebblesButton all_clear_button {
label_text: _("AC");
tooltip_desc: _("All Clear");
accel_markup: "<Shift>BackSpace";
accel_markup: bind template.all_clear_key;
focus-on-click: false;
key: "<Shift>BackSpace";
key: bind template.all_clear_key;

styles [
"destructive-action",
Expand Down
6 changes: 6 additions & 0 deletions src/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Pebbles {
public const string KEY_VERSION = "version";
public const string KEY_LOAD_LAST_SESSION = "load-last-session";
public const string KEY_RESULT_FLOW = "result-flow";
public const string KEY_DELETE_ALL_CLEAR = "delete-all-clear";
public const string KEY_THEME = "theme";
public const string KEY_CONSTANT_KEY_VALUE1 = "constant-key-value1";
public const string KEY_CONSTANT_KEY_VALUE2 = "constant-key-value2";
Expand Down Expand Up @@ -125,6 +126,11 @@ namespace Pebbles {
set { set_boolean (KEY_RESULT_FLOW, value); }
}

public bool delete_all_clear {
get { return get_boolean (KEY_DELETE_ALL_CLEAR); }
set { set_boolean (KEY_DELETE_ALL_CLEAR, value); }
}

public string theme {
owned get { return get_string (KEY_THEME); }
set { set_string (KEY_THEME, value); }
Expand Down
105 changes: 58 additions & 47 deletions src/core/graphing_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def set_plot_params_and_plot(self, payload):
'yMax': payload.get_y_max(),
'xScaling': payload.get_x_scaling(),
'yScaling': payload.get_y_scaling(),
'darkMode': payload.get_dark_mode()
'darkMode': payload.get_dark_mode(),
'fidelity': payload.get_fidelity_mode()
}

self.start_plotting()
Expand Down Expand Up @@ -99,64 +100,74 @@ def start_plotting(self):
def _plot(self, path=''):
try:
with self.plot_lock:
steps = [6, 5, 4, 3, 1]
fidelity_mode = self.plot_params['fidelity']
step_size = 1 if fidelity_mode or path != '' else 6
palette = Pebbles.get_palette(self.plot_params['darkMode'])
dpi = self.plot_params['dpi']
width = self.plot_params['width']
height = self.plot_params['height']
plt.tight_layout(pad=4 / dpi)

for step_size in steps:
if self.cancel_event.is_set():
return

fig, ax = self._setup_plot(width, height, dpi, step_size)
x_values = self._generate_plot_x_values(
self.plot_params['xScaling'],
width,
step_size
)

if self.plot_params['yScaling'] == 1:
x_values = x_values[x_values != 0]

t_values = np.linspace(
0, 2*np.pi, width // (step_size ** 2)
)
for pro in self.calculators:
pro['calc'].set_substitute_value('A',
self.plot_params['a'], zero_limit=True)
pro['calc'].set_substitute_value('B',
self.plot_params['b'], zero_limit=True)
pro['calc'].set_substitute_value('C',
self.plot_params['c'], zero_limit=True)
pro['calc'].set_substitute_value('M',
self.plot_params['m'], zero_limit=True)
if pro['eq'].get_radial_coord_mode():
self._plot_radial(ax, pro, palette, (t_values, step_size))
else:
self._plot_cartesian(
ax, pro, palette,
(
x_values,
step_size,
self.plot_params['xScaling'],
self.plot_params['yScaling']
)
if self.cancel_event.is_set():
return

fig, ax = self._setup_plot(width, height, dpi, step_size)
x_values = self._generate_plot_x_values(
self.plot_params['xScaling'],
width,
step_size
)

if self.plot_params['yScaling'] == 1:
x_values = x_values[x_values != 0]

t_values = np.linspace(
0, 2 * np.pi, width // (step_size ** 2)
)
for pro in self.calculators:
pro['calc'].set_substitute_value('A',
self.plot_params['a'], zero_limit=True)
pro['calc'].set_substitute_value('B',
self.plot_params['b'], zero_limit=True)
pro['calc'].set_substitute_value('C',
self.plot_params['c'], zero_limit=True)
pro['calc'].set_substitute_value('M',
self.plot_params['m'], zero_limit=True)
if pro['eq'].get_radial_coord_mode():
self._plot_radial(ax, pro, palette, (t_values, step_size))
else:
self._plot_cartesian(
ax, pro, palette,
(
x_values,
step_size,
self.plot_params['xScaling'],
self.plot_params['yScaling']
)
)

if step_size == 1:
if path == '':
if fidelity_mode:
self._draw_legend(ax)
self._configure_labels(ax)

if path != '':
Utils.fig_save_path = path
Utils.plot_to_image(plt, fig, (width, height), dpi, step_size)
pixbuf_f = Utils.plot_to_pixbuf(plt, fig, (width, height), dpi, step_size)
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.get_legend().remove()
pixbuf_i = Utils.plot_to_pixbuf(plt, fig, (width, height), dpi, step_size)
if self.on_plot_ready:
self.on_plot_ready(pixbuf_i, pixbuf_f, True)
else:
pixbuf = Utils.plot_to_pixbuf(plt, fig, (width, height), dpi, step_size)

ax.set_xticklabels([])
ax.set_yticklabels([])
pixbuf_f = Utils.plot_to_pixbuf(plt, fig, (width, height), dpi, step_size)
if self.on_plot_ready:
self.on_plot_ready(pixbuf, True)
self.on_plot_ready(None, pixbuf_f, True)
else:
self._draw_legend(ax)
self._configure_labels(ax)
Utils.fig_save_path = path
Utils.plot_to_image(plt, fig, (width, height), dpi, step_size)

except RuntimeError:
pass
Expand Down
3 changes: 2 additions & 1 deletion src/models/GraphPayload.Model.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ namespace Pebbles {
public int height { get; set; }
public double dpi { get; set; }
public bool dark_mode { get; set; }
public bool fidelity_mode { get; set; }

public bool contains_equations () {
return equations != null;
return equations != null && equations.length > 0;
}
}
}
15 changes: 5 additions & 10 deletions src/shell/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,9 @@ namespace Pebbles {
set_shift_on (!lock_on);
}

if (keyval == Gdk.Key.BackSpace && (modifier & Gdk.ModifierType.SHIFT_MASK) != 0) {
if (settings.delete_all_clear && keyval == Gdk.Key.Delete) {
on_all_clear (view_stack.visible_child_name);
} else if (keyval == Gdk.Key.BackSpace && (modifier & Gdk.ModifierType.SHIFT_MASK) != 0) {
on_all_clear (view_stack.visible_child_name);
}

Expand Down Expand Up @@ -717,13 +719,6 @@ namespace Pebbles {
}

private void load_settings () {
// Check if the version is new
if (settings.version != Config.VERSION) {
settings.version = Config.VERSION;

// Show some kind of What's New dialog?
}

if (settings.load_last_session) {
switch (settings.global_angle_unit) {
case DEG:
Expand Down Expand Up @@ -902,8 +897,8 @@ namespace Pebbles {
statistics_view.plot (figure, valid);
}

protected void on_render_ready (Gdk.Pixbuf? figure, bool valid) {
graphing_view.render_graph (figure, valid);
protected void on_render_ready (Gdk.Pixbuf? figure_i, Gdk.Pixbuf? figure_f, bool valid) {
graphing_view.render_graph (figure_i, figure_f, valid);
}

protected void on_memory_change (string context, bool present) {
Expand Down
5 changes: 5 additions & 0 deletions src/shell/dialogs/PreferencesDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ namespace Pebbles {
settings.load_last_session = (obj as Adw.SwitchRow)?.active;
}

[GtkCallback]
protected void delete_all_clear_notify_active_cb (Object obj, ParamSpec params) {
settings.delete_all_clear = (obj as Adw.SwitchRow)?.active;
}

[GtkCallback]
protected void result_flow_notify_active_cb (Object obj, ParamSpec params) {
settings.result_flow = (obj as Adw.SwitchRow)?.active;
Expand Down
Loading
Loading