commit quilter for openSUSE:Factory
Hello community, here is the log from the commit of package quilter for openSUSE:Factory checked in at 2018-01-31 19:54:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/quilter (Old) and /work/SRC/openSUSE:Factory/.quilter.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "quilter" Wed Jan 31 19:54:11 2018 rev:4 rq:571348 version:1.4.8 Changes: -------- --- /work/SRC/openSUSE:Factory/quilter/quilter.changes 2018-01-24 15:29:08.994163135 +0100 +++ /work/SRC/openSUSE:Factory/.quilter.new/quilter.changes 2018-01-31 19:54:14.970898353 +0100 @@ -1,0 +2,8 @@ +Tue Jan 30 20:02:52 UTC 2018 - avvissu@yandex.by + +- Update to 1.4.8: + * Autosave works properly / Fixed Focus Mode highlight + preferences + * change screenshot in readme + +------------------------------------------------------------------- Old: ---- quilter-1.4.6.tar.gz New: ---- quilter-1.4.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ quilter.spec ++++++ --- /var/tmp/diff_new_pack.Xa9cAx/_old 2018-01-31 19:54:15.638867289 +0100 +++ /var/tmp/diff_new_pack.Xa9cAx/_new 2018-01-31 19:54:15.642867103 +0100 @@ -17,7 +17,7 @@ Name: quilter -Version: 1.4.6 +Version: 1.4.8 Release: 0 Summary: Writing application License: GPL-3.0 ++++++ quilter-1.4.6.tar.gz -> quilter-1.4.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/README.md new/quilter-1.4.8/README.md --- old/quilter-1.4.6/README.md 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/README.md 2018-01-22 22:09:20.000000000 +0100 @@ -7,7 +7,7 @@ [![Build Status](https://travis-ci.org/lainsce/quilter.svg?branch=master)](https://travis-ci.org/lainsce/quilter) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0) -![Screenshot](data/images/shot-preview.png) +![Screenshot](data/images/shot.png) ## License diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/data/com.github.lainsce.quilter.appdata.xml new/quilter-1.4.8/data/com.github.lainsce.quilter.appdata.xml --- old/quilter-1.4.6/data/com.github.lainsce.quilter.appdata.xml 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/data/com.github.lainsce.quilter.appdata.xml 2018-01-22 22:09:20.000000000 +0100 @@ -24,6 +24,17 @@ <url type="homepage">https://github.com/lainsce/quilter/</url> <url type="bugtracker">https://github.com/lainsce/quilter/issues</url> <releases> + <release version="1.4.6" date="2018-01-26"> + <description> + <p>Release: New Menu & Fries</p> + <ul> + <li>The main menu now houses the Dark/Focus Mode buttons previously shown on the statusbar.</li> + <li>The statusbar now shows number of lines, deprecating the toggle in the preferences to show line numbers.</li> + <li>Preferences Dialog had a reorganization of items.</li> + <li>Disabling autosaving in preferences will make you save files manually now with the Save button.</li> + </ul> + </description> + </release> <release version="1.4.5" date="2018-01-13"> <description> <p>Release: Focus Mode with a Glasses Push-up</p> @@ -132,10 +143,6 @@ <caption>Focus Mode</caption> <image>https://raw.githubusercontent.com/lainsce/quilter/master/data/images/shot-focused.png</image> </screenshot> - <screenshot> - <caption>Preview Mode</caption> - <image>https://raw.githubusercontent.com/lainsce/quilter/master/data/images/shot-preview.png</image> - </screenshot> </screenshots> <custom> <value key="x-appcenter-color-primary">#b8d2e2</value> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/data/com.github.lainsce.quilter.gschema.xml new/quilter-1.4.8/data/com.github.lainsce.quilter.gschema.xml --- old/quilter-1.4.6/data/com.github.lainsce.quilter.gschema.xml 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/data/com.github.lainsce.quilter.gschema.xml 2018-01-22 22:09:20.000000000 +0100 @@ -35,11 +35,11 @@ <summary>Use system font</summary> <description>Whether Quilter should use the default system font</description> </key> - <key name="show-save-button" type="b"> - <default>false</default> - <summary>Show save button</summary> - <description>Whether Quilter should show a save button on the Toolbar</description> - </key> + <key name="autosave" type="b"> + <default>true</default> + <summary>Autosave edited files</summary> + <description>Autosave edited files.</description> + </key> <key name="font" type="s"> <default>'PT Mono 11'</default> <summary>Preferred Font</summary> Binary files old/quilter-1.4.6/data/images/shot-dark.png and new/quilter-1.4.8/data/images/shot-dark.png differ Binary files old/quilter-1.4.6/data/images/shot-focused.png and new/quilter-1.4.8/data/images/shot-focused.png differ Binary files old/quilter-1.4.6/data/images/shot-preview.png and new/quilter-1.4.8/data/images/shot-preview.png differ Binary files old/quilter-1.4.6/data/images/shot.png and new/quilter-1.4.8/data/images/shot.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/debian/changelog new/quilter-1.4.8/debian/changelog --- old/quilter-1.4.6/debian/changelog 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/debian/changelog 2018-01-22 22:09:20.000000000 +0100 @@ -1,4 +1,13 @@ -com.github.lainsce.quilter (1.4.4) xenial; urgency=low +com.github.lainsce.quilter (1.4.6) xenial; urgency=low + + * The main menu now houses the Dark/Focus Mode buttons previously shown on the statusbar. + * The statusbar now shows number of lines, deprecating the toggle in the preferences to show line numbers. + * Preferences Dialog had a reorganization of items. + * Disabling autosaving in preferences will make you save files manually now with the Save button. + + -- Lains <lainsce@airmail.cc> Fri, 26 Jan 2018 12:40:00 -0300 + +com.github.lainsce.quilter (1.4.5) xenial; urgency=low * In the Preferences, select if you want Focus Mode to highlight the sentence or the paragraph. (Contributed by Michał "wyhasany" Rowicki) * Add Polish translation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/meson.build new/quilter-1.4.8/meson.build --- old/quilter-1.4.6/meson.build 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/meson.build 2018-01-22 22:09:20.000000000 +0100 @@ -1,6 +1,6 @@ # Name our project project('com.github.lainsce.quilter', ['vala', 'c'], - version: '1.4.5' + version: '1.4.6' ) # Import main lib files @@ -47,6 +47,8 @@ endif # Let's define our executable +add_project_arguments(['--vapidir', join_paths(meson.current_source_dir(), 'vapi')], language: 'vala') + executable( meson.project_name(), 'src/Application.vala', @@ -75,8 +77,7 @@ ], vala_args: [ meson.source_root() + '/vapi/config.vapi', - meson.source_root() + '/vapi/libmarkdown.vapi', - '--vapidir=' + meson.source_root() + '/vapi/', + meson.source_root() + '/vapi/libmarkdown.vapi' ], install : true ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/src/Constants/AppSettings.vala new/quilter-1.4.8/src/Constants/AppSettings.vala --- old/quilter-1.4.6/src/Constants/AppSettings.vala 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/src/Constants/AppSettings.vala 2018-01-22 22:09:20.000000000 +0100 @@ -21,7 +21,7 @@ public bool focus_mode { get; set; } public bool fullscreen { get; set; } public bool show_num_lines { get; set; } - public bool show_save_button { get; set; } + public bool autosave { get; set; } public bool spellcheck { get; set; } public bool statusbar { get; set; } public bool use_system_font { get; set; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/src/MainWindow.vala new/quilter-1.4.8/src/MainWindow.vala --- old/quilter-1.4.6/src/MainWindow.vala 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/src/MainWindow.vala 2018-01-22 22:09:20.000000000 +0100 @@ -27,7 +27,6 @@ public Widgets.WebView preview_view_content; public Widgets.StatusBar statusbar; - private Gtk.Menu menu; private Gtk.Button new_button; private Gtk.Button open_button; private Gtk.Button save_button; @@ -38,8 +37,6 @@ private Gtk.ScrolledWindow edit_view; private Gtk.ScrolledWindow preview_view; private Gtk.Grid grid; - private Widgets.Preferences preferences_dialog; - private Widgets.Cheatsheet cheatsheet_dialog; private bool timer_scheduled = false; /* @@ -47,6 +44,19 @@ */ private const int TIME_TO_REFRESH = 100; + public SimpleActionGroup actions { get; construct; } + + public const string ACTION_PREFIX = "win."; + public const string ACTION_CHEATSHEET = "action_cheatsheet"; + public const string ACTION_PREFS = "action_preferences"; + + public static Gee.MultiMap<string, string> action_accelerators = new Gee.HashMultiMap<string, string> (); + + private const GLib.ActionEntry[] action_entries = { + { ACTION_CHEATSHEET, action_cheatsheet }, + { ACTION_PREFS, action_preferences } + }; + public bool is_fullscreen { get { var settings = AppSettings.get_default (); @@ -73,6 +83,7 @@ schedule_timer (); statusbar.update_wordcount (); + statusbar.update_linecount (); statusbar.update_readtimecount (); show_statusbar (); focus_mode_toolbar (); @@ -86,6 +97,7 @@ edit_view_content.changed.connect (() => { schedule_timer (); statusbar.update_wordcount (); + statusbar.update_linecount (); statusbar.update_readtimecount (); }); @@ -148,6 +160,10 @@ } construct { + actions = new SimpleActionGroup (); + actions.add_action_entries (action_entries, this); + insert_action_group ("win", actions); + toolbar = new Gtk.HeaderBar (); toolbar.title = title; var settings = AppSettings.get_default (); @@ -159,7 +175,7 @@ toolbar.subtitle = "New Document"; } - var header_context = toolbar.get_style_context (); + var header_context = toolbar.get_style_context (); header_context.add_class (Gtk.STYLE_CLASS_FLAT); header_context.add_class ("quilter-toolbar"); @@ -212,34 +228,76 @@ toolbar.subtitle = settings.subtitle; }); - menu_button = new Gtk.MenuButton (); - menu_button.has_tooltip = true; - menu_button.tooltip_text = (_("Settings")); - - menu = new Gtk.Menu (); - - var cheatsheet = new Gtk.MenuItem.with_label (_("Markdown Cheatsheet")); - cheatsheet.activate.connect (() => { - debug ("Cheatsheet button pressed."); - cheatsheet_dialog = new Widgets.Cheatsheet (this); - cheatsheet_dialog.show_all (); - }); + var cheatsheet = new Gtk.ModelButton (); + cheatsheet.text = (_("Markdown Cheatsheet")); + cheatsheet.action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_CHEATSHEET; + + var preferences = new Gtk.ModelButton (); + preferences.text = (_("Preferences")); + preferences.action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_PREFS; + + var darkmode_button = new Gtk.ToggleButton.with_label ((_("Dark Mode"))); + darkmode_button.set_image (new Gtk.Image.from_icon_name ("weather-clear-night-symbolic", Gtk.IconSize.SMALL_TOOLBAR)); + darkmode_button.set_always_show_image (true); + + if (settings.dark_mode == false) { + darkmode_button.set_active (false); + } else { + darkmode_button.set_active (settings.dark_mode); + } - var preferences = new Gtk.MenuItem.with_label (_("Preferences")); - preferences.activate.connect (() => { - debug ("Prefs button pressed."); - preferences_dialog = new Widgets.Preferences (this); - preferences_dialog.show_all (); - }); + darkmode_button.toggled.connect (() => { + if (darkmode_button.active) { + settings.dark_mode = true; + } else { + settings.dark_mode = false; + } + + }); + + var focusmode_button = new Gtk.ToggleButton.with_label ((_("Focus Mode"))); + focusmode_button.set_image (new Gtk.Image.from_icon_name ("zoom-fit-best-symbolic", Gtk.IconSize.SMALL_TOOLBAR)); + focusmode_button.set_always_show_image (true); + + if (settings.focus_mode == false) { + focusmode_button.set_active (false); + } else { + focusmode_button.set_active (settings.focus_mode); + } - var separator = new Gtk.SeparatorMenuItem (); + focusmode_button.toggled.connect (() => { + if (focusmode_button.active) { + settings.focus_mode = true; + } else { + settings.focus_mode = false; + } + + }); + + var buttonbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); + buttonbox.pack_start (darkmode_button, false, true, 0); + buttonbox.pack_start (focusmode_button, false, true, 0); + + var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL); + + var menu_grid = new Gtk.Grid (); + menu_grid.margin = 6; + menu_grid.row_spacing = 6; + menu_grid.column_spacing = 12; + menu_grid.orientation = Gtk.Orientation.VERTICAL; + menu_grid.add (buttonbox); + menu_grid.add (separator); + menu_grid.add (cheatsheet); + menu_grid.add (preferences); + menu_grid.show_all (); - menu.add (cheatsheet); - menu.add (separator); - menu.add (preferences); - menu.show_all (); + var menu = new Gtk.Popover (null); + menu.add (menu_grid); - menu_button.popup = menu; + menu_button = new Gtk.MenuButton (); + menu_button.has_tooltip = true; + menu_button.tooltip_text = (_("Settings")); + menu_button.popover = menu; edit_view = new Gtk.ScrolledWindow (null, null); edit_view_content = new Widgets.SourceView (); @@ -275,11 +333,11 @@ // This makes the save button show or not, and it's necessary as-is. settings.changed.connect (() => { - if (settings.show_save_button) { + if (settings.autosave) { + save_button.visible = false; + } else { toolbar.pack_start (save_button); save_button.visible = true; - } else { - save_button.visible = false; } }); @@ -339,6 +397,18 @@ return false; } + private void action_preferences () { + var dialog = new Widgets.Preferences (this); + dialog.set_modal (true); + dialog.show_all (); + } + + private void action_cheatsheet () { + var dialog = new Widgets.Cheatsheet (this); + dialog.set_modal (true); + dialog.show_all (); + } + private void schedule_timer () { if (!timer_scheduled) { Timeout.add (TIME_TO_REFRESH, render_func); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/src/Widgets/Preferences.vala new/quilter-1.4.8/src/Widgets/Preferences.vala --- old/quilter-1.4.6/src/Widgets/Preferences.vala 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/src/Widgets/Preferences.vala 2018-01-22 22:09:20.000000000 +0100 @@ -65,8 +65,6 @@ editor_grid.column_spacing = 12; var editor_header = new Granite.HeaderLabel (_("Editor")); - var num_lines_label = new SettingsLabel (_("Show Line Numbers:")); - var num_lines_button = new SettingsSwitch ("show-num-lines"); var spellcheck_label = new Gtk.Label (_("Enable Spellchecking:")); spellcheck_label.set_halign (Gtk.Align.END); var spellcheck = new SettingsSwitch ("spellcheck"); @@ -152,11 +150,15 @@ } }); + var save_button_label = new SettingsLabel (_("Save files when changed:")); + var save_button = new SettingsSwitch ("autosave"); + editor_grid.attach (editor_header, 0, 1, 3, 1); - editor_grid.attach (num_lines_label, 0, 2, 1, 1); - editor_grid.attach (num_lines_button, 1, 2, 1, 1); - editor_grid.attach (spellcheck_label, 0, 3, 1, 1); - editor_grid.attach (spellcheck, 1, 3, 1, 1); + editor_grid.attach (spellcheck_label, 0, 2, 1, 1); + editor_grid.attach (spellcheck, 1, 2, 1, 1); + editor_grid.attach (save_button_label, 0, 3, 1, 1); + editor_grid.attach (save_button, 1, 3, 1, 1); + editor_grid.attach (geo_header, 0, 4, 3, 1); editor_grid.attach (spacing_label, 0, 5, 1, 1); @@ -173,15 +175,12 @@ interface_grid.row_spacing = 6; interface_grid.column_spacing = 12; - var ui_header = new Granite.HeaderLabel (_("Interface")); - var save_button_label = new SettingsLabel (_("Show the Save Button:")); - var save_button = new SettingsSwitch ("show-save-button"); - var mode_header = new Granite.HeaderLabel (_("Mode")); var focus_mode_label = new SettingsLabel (_("Enable Focus Mode:")); var focus_mode = new SettingsSwitch ("focus-mode"); var dark_mode_label = new SettingsLabel (_("Enable Dark Mode:")); var dark_mode = new SettingsSwitch ("dark-mode"); + var focus_mode_type_label = new SettingsLabel (_("Type of Focus Mode:")); var focus_mode_type_size = new Granite.Widgets.ModeButton (); focus_mode_type_size.append_text (_("Paragraph")); @@ -226,31 +225,30 @@ main_settings.schema.bind ("font", select_font, "font-name", SettingsBindFlags.DEFAULT); main_settings.schema.bind ("use-system-font", select_font, "sensitive", SettingsBindFlags.INVERT_BOOLEAN); + var custom_font_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); + custom_font_box.pack_start (use_custom_font, false, true, 0); + custom_font_box.pack_start (select_font, false, true, 0); + var statusbar_header = new Granite.HeaderLabel (_("Statusbar")); var statusbar_label = new Gtk.Label (_("Show Statusbar:")); statusbar_label.set_halign (Gtk.Align.END); var statusbar = new SettingsSwitch ("statusbar"); - interface_grid.attach (ui_header, 0, 1, 3, 1); - interface_grid.attach (save_button_label, 0, 2, 1, 1); - interface_grid.attach (save_button, 1, 2, 1, 1); - - interface_grid.attach (mode_header, 0, 4, 3, 1); - interface_grid.attach (focus_mode_label, 0, 5, 1, 1); - interface_grid.attach (focus_mode, 1, 5, 1, 1); - interface_grid.attach (dark_mode_label, 0, 6, 1, 1); - interface_grid.attach (dark_mode, 1, 6, 1, 1); - interface_grid.attach (focus_mode_type_label, 0, 7, 1, 1); - interface_grid.attach (focus_mode_type_size, 1, 7, 1, 1); - - interface_grid.attach (font_header, 0, 8, 3, 1); - interface_grid.attach (use_custom_font_label , 0, 9, 1, 1); - interface_grid.attach (use_custom_font, 1, 9, 1, 1); - interface_grid.attach (select_font, 2, 9, 1, 1); - - interface_grid.attach (statusbar_header, 0, 10, 1, 1); - interface_grid.attach (statusbar_label, 0, 11, 1, 1); - interface_grid.attach (statusbar, 1, 11, 1, 1); + interface_grid.attach (mode_header, 0, 1, 3, 1); + interface_grid.attach (focus_mode_label, 0, 2, 1, 1); + interface_grid.attach (focus_mode, 1, 2, 1, 1); + interface_grid.attach (dark_mode_label, 0, 3, 1, 1); + interface_grid.attach (dark_mode, 1, 3, 1, 1); + interface_grid.attach (focus_mode_type_label, 0, 4, 1, 1); + interface_grid.attach (focus_mode_type_size, 1, 4, 1, 1); + + interface_grid.attach (font_header, 0, 5, 3, 1); + interface_grid.attach (use_custom_font_label, 0, 6, 1, 1); + interface_grid.attach (custom_font_box, 1, 6, 1, 1); + + interface_grid.attach (statusbar_header, 0, 7, 1, 1); + interface_grid.attach (statusbar_label, 0, 8, 1, 1); + interface_grid.attach (statusbar, 1, 8, 1, 1); return interface_grid; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/src/Widgets/SourceView.vala new/quilter-1.4.8/src/Widgets/SourceView.vala --- old/quilter-1.4.6/src/Widgets/SourceView.vala 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/src/Widgets/SourceView.vala 2018-01-22 22:09:20.000000000 +0100 @@ -118,10 +118,13 @@ whitefont = buffer.create_tag(null, "foreground", "#FFF"); is_modified = false; - Timeout.add_seconds (20, () => { - on_text_modified (); - return true; - }); + + if (settings.autosave = true) { + Timeout.add_seconds (20, () => { + on_text_modified (); + return true; + }); + } this.set_buffer (buffer); this.set_wrap_mode (Gtk.WrapMode.WORD); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/quilter-1.4.6/src/Widgets/StatusBar.vala new/quilter-1.4.8/src/Widgets/StatusBar.vala --- old/quilter-1.4.6/src/Widgets/StatusBar.vala 2018-01-13 16:31:11.000000000 +0100 +++ new/quilter-1.4.8/src/Widgets/StatusBar.vala 2018-01-22 22:09:20.000000000 +0100 @@ -21,6 +21,7 @@ namespace Quilter { public class Widgets.StatusBar : Gtk.Revealer { public Gtk.Label wordcount_label; + public Gtk.Label linecount_label; public Gtk.Label readtimecount_label; public MainWindow window; public Gtk.ActionBar actionbar; @@ -31,9 +32,8 @@ public StatusBar () { actionbar = new Gtk.ActionBar (); wordcount_item (); + linecount_item (); readtimecount_item (); - darkmode_item (); - focusmode_item (); this.transition_type = Gtk.RevealerTransitionType.SLIDE_UP; this.add (actionbar); @@ -41,7 +41,7 @@ public void wordcount_item () { wordcount_label = new Gtk.Label(""); - wordcount_label.set_width_chars (12); + wordcount_label.set_width_chars (10); update_wordcount (); actionbar.pack_start (wordcount_label); } @@ -51,6 +51,18 @@ wordcount_label.set_text((_("Words: ")) + wc.words.to_string()); } + public void linecount_item () { + linecount_label = new Gtk.Label(""); + linecount_label.set_width_chars (10); + update_linecount (); + actionbar.pack_start (linecount_label); + } + + public void update_linecount () { + var lc = get_count(); + linecount_label.set_text((_("Lines: ")) + lc.lines.to_string()); + } + public void readtimecount_item () { readtimecount_label = new Gtk.Label(""); readtimecount_label.set_width_chars (12); @@ -59,78 +71,36 @@ } public void update_readtimecount () { - var wc = get_count(); - int rtc = (wc.words / WPM); - readtimecount_label.set_text((_("Reading Time: ")) + rtc.to_string() + "m"); - } - - public void darkmode_item () { - var darkmode_button = new Gtk.ToggleButton.with_label ((_("Dark Mode"))); - darkmode_button.set_image (new Gtk.Image.from_icon_name ("weather-clear-night-symbolic", Gtk.IconSize.SMALL_TOOLBAR)); - darkmode_button.set_always_show_image (true); - - var settings = AppSettings.get_default (); - if (settings.dark_mode == false) { - darkmode_button.set_active (false); - } else { - darkmode_button.set_active (settings.dark_mode); - } - - darkmode_button.toggled.connect (() => { - if (darkmode_button.active) { - settings.dark_mode = true; - } else { - settings.dark_mode = false; - } - - }); - - actionbar.pack_end (darkmode_button); - } - - public void focusmode_item () { - var focusmode_button = new Gtk.ToggleButton.with_label ((_("Focus Mode"))); - focusmode_button.set_image (new Gtk.Image.from_icon_name ("zoom-fit-best-symbolic", Gtk.IconSize.SMALL_TOOLBAR)); - focusmode_button.set_always_show_image (true); - - var settings = AppSettings.get_default (); - if (settings.focus_mode == false) { - focusmode_button.set_active (false); - } else { - focusmode_button.set_active (settings.focus_mode); - } - - focusmode_button.toggled.connect (() => { - if (focusmode_button.active) { - settings.focus_mode = true; - } else { - settings.focus_mode = false; - } - - }); - - actionbar.pack_end (focusmode_button); + var rtc = get_count(); + int rt = (rtc.words / WPM); + readtimecount_label.set_text((_("Reading Time: ")) + rt.to_string() + "m"); } public WordCount get_count() { try { var reg = new Regex("[\\s\\W]+", RegexCompileFlags.OPTIMIZE); - string text = Widgets.SourceView.buffer.text; + var buffer = Widgets.SourceView.buffer; + + string text = buffer.text; string result = reg.replace (text, text.length, 0, " "); - return new WordCount(result.strip().split(" ").length, result.length); + var lines = buffer.get_line_count (); + + return new WordCount(result.strip().split(" ").length, lines, result.length); } catch (Error e) { - return new WordCount(0, 0); + return new WordCount(0, 0, 0); } } } public class Widgets.WordCount { public int words { get; private set; } + public int lines { get; private set; } public int chars { get; private set; } - public WordCount(int words, int chars) { + public WordCount(int words, int lines, int chars) { this.words = words; + this.lines = lines; this.chars = chars; } }
participants (1)
-
root@hilbert.suse.de