-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from colinkiama/zero-startup-option
- Loading branch information
Showing
21 changed files
with
301 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,15 @@ | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Authored by: Subhadeep Jasu <[email protected]> | ||
* Saunak Biswas <[email protected]> | ||
*/ | ||
|
||
|
||
namespace Pebbles { | ||
namespace Pebbles { | ||
public class PreferencesOverlay : Gtk.Window { | ||
Pebbles.Settings settings; | ||
Gtk.SpinButton precision_entry; | ||
|
@@ -29,15 +29,24 @@ namespace Pebbles { | |
Gtk.ComboBoxText constants_select_1; | ||
Gtk.ComboBoxText constants_select_2; | ||
Gtk.Scale accuracy_scale; | ||
Gtk.Switch load_last_session_switch; | ||
|
||
public signal void update_settings (); | ||
|
||
public PreferencesOverlay () { | ||
settings = Pebbles.Settings.get_default (); | ||
|
||
var scrolled_window = new Gtk.ScrolledWindow (null, null); | ||
|
||
var main_grid = new Gtk.Grid (); | ||
main_grid.halign = Gtk.Align.CENTER; | ||
main_grid.row_spacing = 8; | ||
|
||
|
||
var load_last_session_label = new Gtk.Label (_("Load Last Session on Startup:")); | ||
load_last_session_label.halign = Gtk.Align.START; | ||
load_last_session_label.get_style_context ().add_class ("h4"); | ||
load_last_session_switch = new Gtk.Switch (); | ||
load_last_session_switch.halign = Gtk.Align.START; | ||
|
||
var precision_label = new Gtk.Label (_("Number of decimal places:")); | ||
precision_label.get_style_context ().add_class ("h4"); | ||
|
@@ -95,15 +104,17 @@ namespace Pebbles { | |
return false; | ||
}); | ||
|
||
main_grid.attach (precision_label, 0, 0, 1, 1); | ||
main_grid.attach (precision_entry, 0, 1, 1, 1); | ||
main_grid.attach (accuracy_label, 0, 2, 1, 1); | ||
main_grid.attach (accuracy_scale, 0, 3, 1, 1); | ||
main_grid.attach (constant_button_label, 0, 4, 1, 1); | ||
main_grid.attach (constant_label1, 0, 5, 1, 1); | ||
main_grid.attach (constants_select_1, 0, 6, 1, 1); | ||
main_grid.attach (constant_label2, 0, 7, 1, 1); | ||
main_grid.attach (constants_select_2, 0, 8, 1, 1); | ||
main_grid.attach (load_last_session_label, 0, 0, 1, 1); | ||
main_grid.attach (load_last_session_switch, 0, 1, 1,1); | ||
main_grid.attach (precision_label, 0, 2, 1, 1); | ||
main_grid.attach (precision_entry, 0, 3, 1, 1); | ||
main_grid.attach (accuracy_label, 0, 4, 1, 1); | ||
main_grid.attach (accuracy_scale, 0, 5, 1, 1); | ||
main_grid.attach (constant_button_label, 0, 6, 1, 1); | ||
main_grid.attach (constant_label1, 0, 7, 1, 1); | ||
main_grid.attach (constants_select_1, 0, 8, 1, 1); | ||
main_grid.attach (constant_label2, 0, 9, 1, 1); | ||
main_grid.attach (constants_select_2, 0, 10, 1, 1); | ||
|
||
var forex_label = new Gtk.Label (_("Currency Converter API Key")); | ||
forex_label.halign = Gtk.Align.START; | ||
|
@@ -113,13 +124,15 @@ namespace Pebbles { | |
forex_api_key.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY,"edit-undo-symbolic"); | ||
forex_api_key.set_icon_tooltip_markup (Gtk.EntryIconPosition.SECONDARY, _("Reset")); | ||
forex_api_key.placeholder_text = "03eb97e97cbf3fa3e228"; | ||
|
||
main_grid.attach (forex_label, 0, 9, 1, 1); | ||
main_grid.attach (forex_api_key, 0, 10, 1, 1); | ||
main_grid.attach (forex_api_link, 0, 11, 1, 1); | ||
|
||
this.add (main_grid); | ||
main_grid.margin_bottom = 8; | ||
main_grid.attach (forex_label, 0, 11, 1, 1); | ||
main_grid.attach (forex_api_key, 0, 12, 1, 1); | ||
main_grid.attach (forex_api_link, 0, 13, 1, 1); | ||
|
||
scrolled_window.add (main_grid); | ||
|
||
this.add (scrolled_window); | ||
main_grid.margin_bottom = 16; | ||
|
||
var headerbar = new Gtk.HeaderBar (); | ||
headerbar.has_subtitle = false; | ||
|
@@ -145,6 +158,7 @@ namespace Pebbles { | |
} | ||
|
||
private void save_settings () { | ||
settings.load_last_session = load_last_session_switch.get_active (); | ||
if (precision_entry.get_value_as_int () != 0) { | ||
settings.decimal_places = precision_entry.get_value_as_int (); | ||
} | ||
|
@@ -155,12 +169,13 @@ namespace Pebbles { | |
settings.forex_api_key = forex_api_key.get_text (); | ||
else | ||
settings.forex_api_key = "03eb97e97cbf3fa3e228"; | ||
|
||
settings.integration_accuracy = (int)(accuracy_scale.get_value ()); | ||
this.update_settings (); | ||
} | ||
|
||
private void load_settings () { | ||
load_last_session_switch.set_active (settings.load_last_session); | ||
precision_entry.set_value ((double)settings.decimal_places); | ||
load_constant_button_settings (); | ||
forex_api_key.set_text (settings.forex_api_key); | ||
|
@@ -240,6 +255,7 @@ namespace Pebbles { | |
} | ||
return false; | ||
}); | ||
|
||
this.forex_api_key.icon_release.connect ((pos, event) => { | ||
settings.forex_api_key = "03eb97e97cbf3fa3e228"; | ||
this.forex_api_key.set_text ("03eb97e97cbf3fa3e228"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Authored by: Subhadeep Jasu <[email protected]> | ||
|
@@ -85,7 +85,7 @@ namespace Pebbles { | |
public int integration_accuracy {get; set;} | ||
public string sci_input_text {get; set;} | ||
public string sci_output_text {get; set;} | ||
public string sci_memory_value {get; set;} | ||
public string sci_memory_value {get; set;} | ||
public string prog_input_text {get; set;} | ||
public string prog_output_text {get; set;} | ||
public string cal_input_text {get; set;} | ||
|
@@ -132,11 +132,12 @@ namespace Pebbles { | |
public string date_year_entry {get; set;} | ||
public string forex_api_key {get; set;} | ||
public string saved_history {get; set;} | ||
|
||
public bool load_last_session {get; set;} | ||
|
||
private Settings () { | ||
base ("com.github.subhadeepjasu.pebbles"); | ||
} | ||
|
||
public void switch_angle_unit () { | ||
switch (settings.global_angle_unit) { | ||
case GlobalAngleUnit.RAD: | ||
|
@@ -150,7 +151,7 @@ namespace Pebbles { | |
break; | ||
} | ||
} | ||
|
||
public void switch_word_length () { | ||
switch (settings.global_word_length) { | ||
case GlobalWordLength.DWD: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Authored by: Subhadeep Jasu <[email protected]> | ||
|
@@ -57,17 +57,17 @@ namespace Pebbles { | |
|
||
conv = new Converter (unit_multipliers); | ||
keypad = new CommonKeyPadConverter (); | ||
|
||
// Make Header Label | ||
var header_title = new Gtk.Label (_("Angle")); | ||
header_title.get_style_context ().add_class ("h2"); | ||
header_title.set_justify (Gtk.Justification.LEFT); | ||
header_title.halign = Gtk.Align.START; | ||
header_title.margin_start = 8; | ||
|
||
// Make Upper Unit Box | ||
from_entry = new Gtk.Entry (); | ||
from_entry.set_text (settings.conv_angle_from_entry); | ||
from_entry.set_text (settings.load_last_session ? settings.conv_angle_from_entry : "0"); | ||
from_entry.get_style_context ().add_class ("Pebbles_Conversion_Text_Box"); | ||
from_entry.max_width_chars = 35; | ||
from_unit = new Gtk.ComboBoxText (); | ||
|
@@ -78,15 +78,15 @@ namespace Pebbles { | |
|
||
// Make Lower Unit Box | ||
to_entry = new Gtk.Entry (); | ||
to_entry.set_text (settings.conv_angle_to_entry); | ||
to_entry.set_text (settings.load_last_session ? settings.conv_angle_to_entry : "0"); | ||
to_entry.get_style_context ().add_class ("Pebbles_Conversion_Text_Box"); | ||
to_entry.max_width_chars = 35; | ||
to_unit = new Gtk.ComboBoxText (); | ||
for (int i = 0; i < units.length; i++) { | ||
to_unit.append_text (units [i]); | ||
} | ||
to_unit.active = 1; | ||
|
||
// Create Conversion active section | ||
interchange_button = new Gtk.Button (); | ||
var up_button = new Gtk.Image.from_icon_name ("go-up-symbolic", Gtk.IconSize.BUTTON); | ||
|
@@ -101,7 +101,7 @@ namespace Pebbles { | |
interchange_button.margin_bottom = 8; | ||
interchange_button.margin_start = 100; | ||
interchange_button.margin_end = 100; | ||
|
||
Gtk.Grid conversion_grid = new Gtk.Grid (); | ||
conversion_grid.attach (from_unit, 0, 0, 1, 1); | ||
conversion_grid.attach (from_entry, 0, 1, 1, 1); | ||
|
@@ -116,12 +116,12 @@ namespace Pebbles { | |
conversion_grid.margin_end = 8; | ||
conversion_grid.valign = Gtk.Align.CENTER; | ||
conversion_grid.row_spacing = 8; | ||
|
||
ResponsiveBox wrapbox = new ResponsiveBox (8); | ||
wrapbox.margin_bottom = 8; | ||
wrapbox.pack_end (keypad, true, true, 0); | ||
wrapbox.pack_start (conversion_grid, true, true, 0); | ||
|
||
halign = Gtk.Align.FILL; | ||
valign = Gtk.Align.CENTER; | ||
attach (header_title, 0, 0, 1, 1); | ||
|
@@ -229,7 +229,7 @@ namespace Pebbles { | |
interchange_button.clicked.connect (() => { | ||
interchange_entries (); | ||
}); | ||
|
||
keypad.button_clicked.connect ((val) => { | ||
if (from_to == 0) { | ||
if (val == "C") { | ||
|
@@ -280,7 +280,7 @@ namespace Pebbles { | |
|
||
public void grab_focus_on_view_switch () { | ||
switch (from_to) { | ||
case 0: | ||
case 0: | ||
this.from_entry.grab_focus_without_selecting (); | ||
break; | ||
case 1: | ||
|
@@ -302,7 +302,7 @@ namespace Pebbles { | |
} else { | ||
string last_answer = from_entry.get_text().replace(Utils.get_local_separator_symbol(), ""); | ||
clipboard.set_text (last_answer, -1); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Authored by: Subhadeep Jasu <[email protected]> | ||
|
@@ -65,17 +65,17 @@ namespace Pebbles { | |
|
||
conv = new Converter (unit_multipliers); | ||
keypad = new CommonKeyPadConverter (); | ||
|
||
// Make Header Label | ||
var header_title = new Gtk.Label (_("Area")); | ||
header_title.get_style_context ().add_class ("h2"); | ||
header_title.set_justify (Gtk.Justification.LEFT); | ||
header_title.halign = Gtk.Align.START; | ||
header_title.margin_start = 8; | ||
|
||
// Make Upper Unit Box | ||
from_entry = new Gtk.Entry (); | ||
from_entry.set_text (settings.conv_area_from_entry); | ||
from_entry.set_text (settings.load_last_session ? settings.conv_area_from_entry : "0"); | ||
from_entry.get_style_context ().add_class ("Pebbles_Conversion_Text_Box"); | ||
from_entry.max_width_chars = 35; | ||
from_unit = new Gtk.ComboBoxText (); | ||
|
@@ -86,15 +86,15 @@ namespace Pebbles { | |
|
||
// Make Lower Unit Box | ||
to_entry = new Gtk.Entry (); | ||
to_entry.set_text (settings.conv_area_to_entry); | ||
to_entry.set_text (settings.load_last_session ? settings.conv_area_to_entry : "0"); | ||
to_entry.get_style_context ().add_class ("Pebbles_Conversion_Text_Box"); | ||
to_entry.max_width_chars = 35; | ||
to_unit = new Gtk.ComboBoxText (); | ||
for (int i = 0; i < units.length; i++) { | ||
to_unit.append_text (units [i]); | ||
} | ||
to_unit.active = 1; | ||
|
||
// Create Conversion active section | ||
interchange_button = new Gtk.Button (); | ||
var up_button = new Gtk.Image.from_icon_name ("go-up-symbolic", Gtk.IconSize.BUTTON); | ||
|
@@ -109,7 +109,7 @@ namespace Pebbles { | |
interchange_button.margin_bottom = 8; | ||
interchange_button.margin_start = 100; | ||
interchange_button.margin_end = 100; | ||
|
||
Gtk.Grid conversion_grid = new Gtk.Grid (); | ||
conversion_grid.attach (from_unit, 0, 0, 1, 1); | ||
conversion_grid.attach (from_entry, 0, 1, 1, 1); | ||
|
@@ -124,12 +124,12 @@ namespace Pebbles { | |
conversion_grid.margin_end = 8; | ||
conversion_grid.valign = Gtk.Align.CENTER; | ||
conversion_grid.row_spacing = 8; | ||
|
||
ResponsiveBox wrapbox = new ResponsiveBox (8); | ||
wrapbox.margin_bottom = 8; | ||
wrapbox.pack_end (keypad, true, true, 0); | ||
wrapbox.pack_start (conversion_grid, true, true, 0); | ||
|
||
halign = Gtk.Align.FILL; | ||
valign = Gtk.Align.CENTER; | ||
attach (header_title, 0, 0, 1, 1); | ||
|
@@ -243,7 +243,7 @@ namespace Pebbles { | |
to_entry.set_text (result); | ||
allow_change = true; | ||
}); | ||
|
||
keypad.button_clicked.connect ((val) => { | ||
if (from_to == 0) { | ||
if (val == "C") { | ||
|
@@ -294,7 +294,7 @@ namespace Pebbles { | |
|
||
public void grab_focus_on_view_switch () { | ||
switch (from_to) { | ||
case 0: | ||
case 0: | ||
this.from_entry.grab_focus_without_selecting (); | ||
break; | ||
case 1: | ||
|
@@ -307,7 +307,7 @@ namespace Pebbles { | |
settings.conv_area_from_entry = from_entry.get_text (); | ||
settings.conv_area_to_entry = to_entry.get_text (); | ||
} | ||
|
||
public void write_answer_to_clipboard () { | ||
Gdk.Display display = this.get_display (); | ||
Gtk.Clipboard clipboard = Gtk.Clipboard.get_for_display (display, Gdk.SELECTION_CLIPBOARD); | ||
|
@@ -317,7 +317,7 @@ namespace Pebbles { | |
} else { | ||
string last_answer = from_entry.get_text().replace(Utils.get_local_separator_symbol(), ""); | ||
clipboard.set_text (last_answer, -1); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.