diff --git a/src/Config.vala b/src/Config.vala index 9e24414..bed375b 100644 --- a/src/Config.vala +++ b/src/Config.vala @@ -17,20 +17,20 @@ */ namespace Constants { - public const string DATADIR = "/usr/share"; - public const string PKG_DATADIR = "/usr/share/com.github.tomatoers.tomato"; - public const string GETTEXT_PACKAGE = "com.github.tomatoers.tomato"; - public const string RELEASE_NAME = "Stupice"; - public const string VERSION = "2.0.2"; - public const string VERSION_INFO = "Release"; - public const string INSTALL_PREFIX = "/usr"; + public const string DATADIR = "/usr/share"; + public const string PKG_DATADIR = "/usr/share/com.github.tomatoers.tomato"; + public const string GETTEXT_PACKAGE = "com.github.tomatoers.tomato"; + public const string RELEASE_NAME = "Stupice"; + public const string VERSION = "2.0.2"; + public const string VERSION_INFO = "Release"; + public const string INSTALL_PREFIX = "/usr"; public const string APP_NAME = "Tomato"; - public const string EXEC_NAME = "com.github.tomatoers.tomato"; - public const string ICON_NAME = "com.github.tomatoers.tomato"; + public const string EXEC_NAME = "com.github.tomatoers.tomato"; + public const string ICON_NAME = "com.github.tomatoers.tomato"; } namespace Default { - public const int POMODORO_DURATION = 25; + public const int POMODORO_DURATION = 25; public const int SHORT_BREAK_DURATION = 5; public const int LONG_BREAK_DURATION = 15; public const int LONG_BREAK_DELAY = 4; diff --git a/src/Tomato.vala b/src/Tomato.vala index 9817ce4..669c54a 100644 --- a/src/Tomato.vala +++ b/src/Tomato.vala @@ -148,7 +148,10 @@ namespace Tomato { if (stop_countdown == -1) { on_stop_clicked (); stop_countdown = 14; - notification.show (_("Pomodoro was interrupted"), _("Tomato was paused for a long time. You might have lost focus. Try a new pomodoro!")); + notification.show ( + _("Pomodoro was interrupted"), + _("Tomato was paused for a long time. You might have lost focus. Try a new pomodoro!") + ); } } return paused; } @@ -308,8 +311,8 @@ namespace Tomato { } } - public static void main(string[] args) { - Gtk.init(ref args); + public static void main (string[] args) { + Gtk.init (ref args); TomatoApp app = new TomatoApp (); app.run (args); diff --git a/src/Widgets/Screen.vala b/src/Widgets/Screen.vala index 919fb55..c5d33e0 100644 --- a/src/Widgets/Screen.vala +++ b/src/Widgets/Screen.vala @@ -58,7 +58,7 @@ namespace Tomato.Widget { public void add_controls (Gtk.Widget[] controls) { foreach (Gtk.Widget control in controls) { - add_control (control); + add_control (control); } } @@ -78,7 +78,7 @@ namespace Tomato.Widget { private void setup_control_box () { control_box.set_layout (Gtk.ButtonBoxStyle.CENTER); control_box.set_spacing (6); - control_box.set_valign (Gtk.Align.END); + control_box.set_valign (Gtk.Align.END); control_box.set_margin_bottom (15); } } diff --git a/src/Widgets/Slide.vala b/src/Widgets/Slide.vala index 61b5e98..51828a3 100644 --- a/src/Widgets/Slide.vala +++ b/src/Widgets/Slide.vala @@ -22,12 +22,12 @@ namespace Tomato.Widget { private List screens; - public signal void changed (Screen s); + public signal void changed (Screen s); public Slide () { screens = new List (); set_transition_duration (500); - this.expand = true; + this.expand = true; } public void add_screen (Screen screen) { @@ -35,10 +35,13 @@ namespace Tomato.Widget { screens.append (screen); } - public void set_visible_screen (string name, Gtk.StackTransitionType transition = Gtk.StackTransitionType.SLIDE_LEFT) { + public void set_visible_screen ( + string name, + Gtk.StackTransitionType transition = Gtk.StackTransitionType.SLIDE_LEFT + ) { set_visible_child_full (name, transition); - message (name); - changed (find_screen (name)); + message (name); + changed (find_screen (name)); } public Screen? get_visible_screen () { diff --git a/src/Windows/MainWindow.vala b/src/Windows/MainWindow.vala index 87d42c3..e69a275 100644 --- a/src/Windows/MainWindow.vala +++ b/src/Windows/MainWindow.vala @@ -19,7 +19,7 @@ namespace Tomato.Window { public class MainWindow : Gtk.Dialog { - private const string COLOR_PRIMARY = """ + private const string COLOR_PRIMARY = """ @define-color colorPrimary %s; .main-window.background, @@ -40,11 +40,11 @@ namespace Tomato.Window { private TomatoApp app; - private Gtk.HeaderBar headerbar; + private Gtk.HeaderBar headerbar; private Gtk.MenuButton appmenu; private Gtk.MenuItem preferences; private Widget.Slide slide; - private Gtk.Box content; + private Gtk.Box content; private Gtk.Label countdown_label; private Gtk.Label total_time_label; @@ -56,7 +56,7 @@ namespace Tomato.Window { // constructor public MainWindow (TomatoApp app) { - Object (use_header_bar: 1); + Object (use_header_bar: 1); this.app = app; this.title = Constants.APP_NAME; @@ -75,8 +75,8 @@ namespace Tomato.Window { stop = new Gtk.Button.with_label (_("Stop")); skip = new Gtk.Button.with_label (_("Skip")); - content = this.get_content_area (); - headerbar = this.get_header_bar () as Gtk.HeaderBar; + content = this.get_content_area (); + headerbar = this.get_header_bar () as Gtk.HeaderBar; setup_layout (); setup_style (); @@ -87,16 +87,16 @@ namespace Tomato.Window { next_status (Gtk.StackTransitionType.NONE); - /** - * Allow moving the window - */ - this.button_press_event.connect ((e) => { - if (e.button == Gdk.BUTTON_PRIMARY) { - this.begin_move_drag ((int) e.button, (int) e.x_root, (int) e.y_root, e.time); - return true; - } - return false; - }); + /** + * Allow moving the window + */ + this.button_press_event.connect ((e) => { + if (e.button == Gdk.BUTTON_PRIMARY) { + this.begin_move_drag ((int) e.button, (int) e.x_root, (int) e.y_root, e.time); + return true; + } + return false; + }); } public void set_pause (bool topause = true) { @@ -115,7 +115,7 @@ namespace Tomato.Window { if (saved.status == Status.START) { slide.set_visible_screen ("start", transition); - this.set_title ("Pomodoro %d".printf(saved.pomodoro_count+1)); + this.set_title ("Pomodoro %d".printf (saved.pomodoro_count + 1)); appmenu.set_sensitive (true); } else if (saved.status == Status.SHORT_BREAK) { slide.set_visible_screen ("break", transition); @@ -127,7 +127,7 @@ namespace Tomato.Window { appmenu.set_sensitive (true); } else { slide.set_visible_screen ("pomodoro", transition); - this.set_title ("Pomodoro %d".printf(saved.pomodoro_count+1)); + this.set_title ("Pomodoro %d".printf (saved.pomodoro_count + 1)); appmenu.set_sensitive (false); } @@ -156,7 +156,10 @@ namespace Tomato.Window { } public void update_total_time () { - if ((saved.status == Status.START || saved.status == Status.SHORT_BREAK || saved.status == Status.LONG_BREAK || paused) && saved.total_time != 0) { + if ((saved.status == Status.START || saved.status == Status.SHORT_BREAK + || saved.status == Status.LONG_BREAK || paused) + && saved.total_time != 0 + ) { total_time_label.set_label (work.formatted_total_time () + _(" of work")); } else { total_time_label.set_label (""); @@ -176,13 +179,13 @@ namespace Tomato.Window { appmenu.set_image (menu_icon); appmenu.popup = menu; - appmenu.valign = Gtk.Align.CENTER; + appmenu.valign = Gtk.Align.CENTER; - appmenu.get_style_context ().add_class ("close"); - appmenu.get_style_context ().add_class ("titlebutton"); - appmenu.get_style_context ().remove_class ("image-button"); + appmenu.get_style_context ().add_class ("close"); + appmenu.get_style_context ().add_class ("titlebutton"); + appmenu.get_style_context ().remove_class ("image-button"); - headerbar.pack_end (appmenu); + headerbar.pack_end (appmenu); } private void setup_stack () { @@ -203,7 +206,7 @@ namespace Tomato.Window { private void setup_layout () { setup_headerbar (); setup_stack (); - content.add (slide); + content.add (slide); } private void setup_style () { @@ -227,12 +230,12 @@ namespace Tomato.Window { resume.get_style_context ().add_class ("pomodoro-button"); pause.get_style_context ().add_class ("pomodoro-button"); stop.get_style_context ().add_class ("pomodoro-button"); - start.get_style_context ().add_class ("pomodoro-button"); + start.get_style_context ().add_class ("pomodoro-button"); - headerbar.get_style_context ().add_class ("compact"); - headerbar.get_style_context ().add_class ("main-window"); + headerbar.get_style_context ().add_class ("compact"); + headerbar.get_style_context ().add_class ("main-window"); - this.get_style_context ().add_class ("main-window"); + this.get_style_context ().add_class ("main-window"); } private void connect_signals () { @@ -243,45 +246,49 @@ namespace Tomato.Window { skip.clicked.connect (() => {skip_clicked ();}); preferences.activate.connect (() => {preferences_clicked ();}); - this.slide.changed.connect ((s) => { - string color_primary; - - switch (s.get_name ()) { - case "start": - color_primary = "#8ea5af"; - break; - case "pomodoro": - color_primary = "#df4b4b"; - break; - case "break": - color_primary = "#05B560"; - break; - default: - color_primary = "#8ea5af"; - break; - } - - var provider = new Gtk.CssProvider (); - try { - var colored_css = COLOR_PRIMARY.printf (color_primary); - provider.load_from_data (colored_css, colored_css.length); - - Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - } catch (GLib.Error e) { - critical (e.message); - } - }); + this.slide.changed.connect ((s) => { + string color_primary; + + switch (s.get_name ()) { + case "start": + color_primary = "#8ea5af"; + break; + case "pomodoro": + color_primary = "#df4b4b"; + break; + case "break": + color_primary = "#05B560"; + break; + default: + color_primary = "#8ea5af"; + break; + } + + var provider = new Gtk.CssProvider (); + try { + var colored_css = COLOR_PRIMARY.printf (color_primary); + provider.load_from_data (colored_css, colored_css.length); + + Gtk.StyleContext.add_provider_for_screen ( + Gdk.Screen.get_default (), + provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + } catch (GLib.Error e) { + critical (e.message); + } + }); this.delete_event.connect (quit); } - private bool quit () { - if (!paused) { - hide (); - return true; - } - Gtk.main_quit (); - return false; - } + private bool quit () { + if (!paused) { + hide (); + return true; + } + Gtk.main_quit (); + return false; + } } } diff --git a/src/Windows/PreferencesDialog.vala b/src/Windows/PreferencesDialog.vala index 8531966..630ea78 100644 --- a/src/Windows/PreferencesDialog.vala +++ b/src/Windows/PreferencesDialog.vala @@ -21,7 +21,7 @@ namespace Tomato.Window { public class PreferencesDialog : Gtk.Dialog { //stacks - private Gtk.Stack stack; + private Gtk.Stack stack; private Gtk.StackSwitcher stackswitcher; //options - scales @@ -80,39 +80,50 @@ namespace Tomato.Window { /* ** options - scales ** */ //pomodoro_scale = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 5, 60, 1); pomodoro_scale = new Widget.ValueRange (5, 60, 1, _("minute"), _("minutes")); - settings.schema.bind ("pomodoro-duration", pomodoro_scale, "current-value", SettingsBindFlags.DEFAULT); + settings.schema.bind ("pomodoro-duration", pomodoro_scale, + "current-value", SettingsBindFlags.DEFAULT); short_break_scale = new Widget.ValueRange (1, 10, 1, _("minute"), _("minutes")); - settings.schema.bind ("short-break-duration", short_break_scale, "current-value", SettingsBindFlags.DEFAULT); + settings.schema.bind ("short-break-duration", short_break_scale, + "current-value", SettingsBindFlags.DEFAULT); long_break_scale = new Widget.ValueRange (10, 30, 1, _("minute"), _("minutes")); - settings.schema.bind ("long-break-duration", long_break_scale, "current-value", SettingsBindFlags.DEFAULT); + settings.schema.bind ("long-break-duration", long_break_scale, + "current-value", SettingsBindFlags.DEFAULT); long_break_delay_scale = new Widget.ValueRange (2, 8, 1, _("pomodoro"), _("pomodoros")); - settings.schema.bind ("long-break-delay", long_break_delay_scale, "current-value", SettingsBindFlags.DEFAULT); + settings.schema.bind ("long-break-delay", long_break_delay_scale, + "current-value", SettingsBindFlags.DEFAULT); /* ** options - switches ** */ reset_work_everyday = new Gtk.Switch (); - preferences.schema.bind ("reset-work-everyday", reset_work_everyday, "active", SettingsBindFlags.DEFAULT); + preferences.schema.bind ("reset-work-everyday", reset_work_everyday, + "active", SettingsBindFlags.DEFAULT); pause_after_break = new Gtk.Switch (); - preferences.schema.bind ("pause-after-break", pause_after_break, "active", SettingsBindFlags.DEFAULT); + preferences.schema.bind ("pause-after-break", pause_after_break, + "active", SettingsBindFlags.DEFAULT); auto_stop_enabled = new Gtk.Switch (); - preferences.schema.bind ("auto-stop", auto_stop_enabled, "active", SettingsBindFlags.DEFAULT); + preferences.schema.bind ("auto-stop", auto_stop_enabled, + "active", SettingsBindFlags.DEFAULT); pomodoro_sound_enabled = new Gtk.Switch (); - preferences.schema.bind ("pomodoro-sound-enabled", pomodoro_sound_enabled, "active", SettingsBindFlags.DEFAULT); + preferences.schema.bind ("pomodoro-sound-enabled", pomodoro_sound_enabled, + "active", SettingsBindFlags.DEFAULT); if (preferences.debug_mode) { pomodoro_scale = new Widget.ValueRange (1, 60, 1, _("minute"), _("minutes")); - settings.schema.bind ("pomodoro-duration", pomodoro_scale, "current-value", SettingsBindFlags.DEFAULT); + settings.schema.bind ("pomodoro-duration", pomodoro_scale, + "current-value", SettingsBindFlags.DEFAULT); long_break_scale = new Widget.ValueRange (2, 30, 1, _("minute"), _("minutes")); - settings.schema.bind ("long-break-duration", long_break_scale, "current-value", SettingsBindFlags.DEFAULT); + settings.schema.bind ("long-break-duration", long_break_scale, + "current-value", SettingsBindFlags.DEFAULT); debug_switch = new Gtk.Switch (); - preferences.schema.bind ("debug-mode", debug_switch, "active", SettingsBindFlags.DEFAULT); + preferences.schema.bind ("debug-mode", debug_switch, + "active", SettingsBindFlags.DEFAULT); } /* ** options - buttons ** */ @@ -240,7 +251,7 @@ namespace Tomato.Window { sensitive = true; } else if (long_break_scale.current_value != Default.LONG_BREAK_DURATION) { sensitive = true; - } else if (long_break_delay_scale.current_value != Default.LONG_BREAK_DELAY) { + } else if (long_break_delay_scale.current_value != Default.LONG_BREAK_DELAY) { sensitive = true; } reset_timings.sensitive = sensitive; @@ -268,7 +279,13 @@ namespace Tomato.Window { row++; //add one to row } - private void add_option (Gtk.Grid grid, Gtk.Widget label, Gtk.Widget switcher, ref int row, int margin_top = 0) { + private void add_option ( + Gtk.Grid grid, + Gtk.Widget label, + Gtk.Widget switcher, + ref int row, + int margin_top = 0 + ) { label.hexpand = true; label.halign = Gtk.Align.END; if (switcher is Gtk.Scale || switcher is Widget.ValueRange) label.valign = Gtk.Align.END;