Skip to content

Commit

Permalink
Add preferences dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhadeepJasu committed Jan 11, 2025
1 parent 6592ef1 commit 8068b9b
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 14 deletions.
1 change: 1 addition & 0 deletions data/com.github.subhadeepjasu.pebbles.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<gresource prefix="/com/github/subhadeepjasu/pebbles">
<file alias="style.css" compressed="true">style.css</file>
<file compressed="true" preprocess="xml-stripblanks">ui/main_window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/preferences_dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/button.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/popover_menu_item.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/display.ui</file>
Expand Down
4 changes: 2 additions & 2 deletions data/com.github.subhadeepjasu.pebbles.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<enum id="@[email protected]">
<value nick="euler" value="0" />
<value nick="archimedes" value="1" />
<value nick="imaginary" value="2" />
<value nick="golden_ratio" value="3" />
<value nick="golden_ratio" value="2" />
<value nick="imaginary" value="3" />
<value nick="euler_masch" value="4" />
<value nick="conway" value="5" />
<value nick="khinchin" value="6" />
Expand Down
13 changes: 7 additions & 6 deletions data/icons/scalable/emblems/currency-conv-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions data/icons/scalable/emblems/volume-conv-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ stylesheet_deps = custom_target(

blueprint_files = [
'ui/main_window.blp',
'ui/preferences_dialog.blp',
'ui/button.blp',
'ui/popover_menu_item.blp',
'ui/display.blp',
Expand Down
14 changes: 14 additions & 0 deletions data/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,17 @@ button.pressed {
}
}
}

.preferences-group {
margin: 8px;

.heading {
font-weight: bold;
margin-bottom: 8px;
}

.combo {
background: #0000000a;
border-top: 1px solid #0002;
}
}
14 changes: 14 additions & 0 deletions data/ui/main_window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ template $PebblesMainWindow: Adw.ApplicationWindow {
navigation_headerbar.show-back-button: true;
main_headerbar.show-start-title-buttons: true;
main_headerbar.show-title: false;
history_button.visible: false;
history_item.visible: true;
}
}

Expand Down Expand Up @@ -525,6 +527,12 @@ template $PebblesMainWindow: Adw.ApplicationWindow {
orientation: horizontal;
}

$PebblesPopoverMenuItem history_item {
text: _("History");
action_name: "win.history";
visible: false;
}

$PebblesPopoverMenuItem controls_item {
text: _("Controls");
accel: "F1";
Expand Down Expand Up @@ -558,6 +566,12 @@ template $PebblesMainWindow: Adw.ApplicationWindow {
focusable: false;
focus-on-click: false;
tooltip-text: _("History");
action-name: "win.history";
}

[end]
Box spinner_box {
Spinner spinner {}
}
}

Expand Down
97 changes: 97 additions & 0 deletions data/ui/preferences_dialog.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2024 Subhadeep Jasu <[email protected]>
using Gtk 4.0;
using Adw 1;

template $PebblesPreferencesDialog: Adw.PreferencesDialog {
Adw.PreferencesPage {
Adw.PreferencesGroup {
title: _("General");
styles ["preferences-group"]

Adw.SwitchRow {
title: _("Save State");
subtitle: _("Load last session on startup");
focus-on-click: false;
focusable: false;
}

Adw.ActionRow float_accuracy {
title: _("Precision");
subtitle: _("Number of decimal places");
focus-on-click: false;
focusable: false;

SpinButton {
width-request: 100;
adjustment: Adjustment {
lower: 0;
upper: 9;
step-increment: 1;
};
focus-on-click: false;
focusable: false;
can-focus: false;
}
}

Adw.ExpanderRow {
title: _("Scientific Constants Button");
subtitle: _("The scientific constants to insert when the 'Constants' button is clicked");
focus-on-click: false;
focusable: false;
can-focus: false;

Adw.ComboRow constants_select_1 {
title: _("Constants Button Default");
use-subtitle: true;
model: bind template.constant_button_model;
focus-on-click: false;
focusable: false;
}

Adw.ComboRow constants_select_2 {
title: _("Constants Button Shifted");
use-subtitle: true;
model: bind template.constant_button_model;
focus-on-click: false;
focusable: false;
}
}
}

Adw.PreferencesGroup {
title: _("Calculus");
styles ["preferences-group"]

Adw.ActionRow {
title: _("Integration Resolution");
subtitle: _("Higher resolution means more time to process");
focus-on-click: false;
focusable: false;

Scale {
width-request: 200;
adjustment: Adjustment {
lower: 0;
upper: 9;
step-increment: 1;
};
focus-on-click: false;
focusable: false;
}
}
}

Adw.PreferencesGroup {
title: _("Converters");
styles ["preferences-group"]

Adw.EntryRow {
title: _("Currency Converter API Key");
focus-on-click: false;
focusable: false;
}
}
}
}
20 changes: 20 additions & 0 deletions data/ui/scientific_view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ template $PebblesScientificView: Gtk.Grid {
accel_markup: "Return";
visible: bind template.collapsed;
focus-on-click: false;
key: "=, Return";

styles [
"suggested-action",
Expand Down Expand Up @@ -533,6 +534,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("x raised to the power y");
accel_markup: "Q";
focus-on-click: false;
key: "q";

styles [
"special-action",
Expand All @@ -553,6 +555,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("10 raised to the power x");
accel_markup: "Z";
focus-on-click: false;
key: "z";

styles [
"special-action",
Expand All @@ -572,6 +575,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Add it to the value in Memory");
accel_markup: "F3";
focus-on-click: false;
key: "F3";

styles [
"memory-action",
Expand All @@ -592,6 +596,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Sine");
accel_markup: "S";
focus-on-click: false;
key: "s";

styles [
"special-action",
Expand All @@ -612,6 +617,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Hyberbolic Sine");
accel_markup: "H";
focus-on-click: false;
key: "h";

styles [
"special-action",
Expand All @@ -632,6 +638,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Log base 10");
accel_markup: "L";
focus-on-click: false;
key: "l";

styles [
"special-action",
Expand All @@ -651,6 +658,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Subtract it from the value in Memory");
accel_markup: "F4";
focus-on-click: false;
key: "F4";

styles [
"memory-action",
Expand All @@ -671,6 +679,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Cosine");
accel_markup: "C";
focus-on-click: false;
key: "c";

styles [
"special-action",
Expand All @@ -691,6 +700,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Hyberbolic Cosine");
accel_markup: "O";
focus-on-click: false;
key: "o";

styles [
"special-action",
Expand All @@ -711,6 +721,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Modulus");
accel_markup: "M";
focus-on-click: false;
key: "m";

styles [
"special-action",
Expand All @@ -730,6 +741,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Recall value from Memory");
accel_markup: "F5";
focus-on-click: false;
key: "F5";

styles [
"memory-action",
Expand All @@ -750,6 +762,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Tangent");
accel_markup: "T";
focus-on-click: false;
key: "t";

styles [
"special-action",
Expand All @@ -770,6 +783,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Hyberbolic Tangent");
accel_markup: "A";
focus-on-click: false;
key: "a";

styles [
"special-action",
Expand All @@ -790,6 +804,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Permutations");
accel_markup: "P";
focus-on-click: false;
key: "p";

styles [
"special-action",
Expand All @@ -809,6 +824,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Memory Clear");
accel_markup: "F6";
focus-on-click: false;
key: "F6";

styles [
"memory-action",
Expand All @@ -829,6 +845,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Factorial");
accel_markup: "F";
focus-on-click: false;
key: "f";

styles [
"special-action",
Expand All @@ -848,6 +865,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: bind template.constant_desc;
accel_markup: "R";
focus-on-click: false;
key: "r";

styles [
"special-action",
Expand All @@ -867,6 +885,7 @@ template $PebblesScientificView: Gtk.Grid {
tooltip_desc: _("Insert last answer");
accel_markup: "F7";
focus-on-click: false;
key: "F7";

styles [
"special-action",
Expand All @@ -887,6 +906,7 @@ template $PebblesScientificView: Gtk.Grid {
accel_markup: "Return";
visible: bind template.show_hide_fx_btn;
focus-on-click: false;
key: "Return";

styles [
"suggested-action",
Expand Down
2 changes: 1 addition & 1 deletion src/Common.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace Pebbles {
public enum ConstantKeyIndex {
EULER,
ARCHIMEDES,
IMAGINARY,
GOLDEN_RATIO,
IMAGINARY,
EULER_MASCH,
CONWAY,
KHINCHIN,
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pebbles_lib = shared_library('pebbles',
'Application.vala',
'Settings.vala',
'shell/MainWindow.vala',
'shell/dialogs/PreferencesDialog.vala',
'shell/widgets/Button.vala',
'shell/widgets/PopoverMenuItem.vala',
'shell/widgets/Display.vala',
Expand Down
Loading

0 comments on commit 8068b9b

Please sign in to comment.