From dbd8dc65936ed02a1bde93ac7b4bf9a8a0cddb23 Mon Sep 17 00:00:00 2001 From: Alain M Date: Thu, 28 Mar 2019 14:31:44 -0500 Subject: [PATCH] Fix #21 --- ...com.github.alainm23.planner.appdata.xml.in | 17 +- .../com.github.alainm23.planner.gresource.xml | 3 +- data/credits.json | 21 ++ data/resources/planner-paypal.svg | 1 + meson.build | 2 +- src/Application.vala | 2 +- src/Dialogs/PreferencesDialog.vala | 238 ++++++++++++++---- src/Widgets/ProjectsList.vala | 20 ++ src/Widgets/TaskNew.vala | 97 ++++++- src/Widgets/TaskRow.vala | 69 +++-- 10 files changed, 365 insertions(+), 105 deletions(-) create mode 100644 data/resources/planner-paypal.svg diff --git a/data/com.github.alainm23.planner.appdata.xml.in b/data/com.github.alainm23.planner.appdata.xml.in index 497a09b80..884a7bf8a 100644 --- a/data/com.github.alainm23.planner.appdata.xml.in +++ b/data/com.github.alainm23.planner.appdata.xml.in @@ -29,6 +29,21 @@ com.github.alainm23.planner + + +
    +
  • Stability and performance improvements
  • +
  • New view "All tasks" and "Tasks completed"
  • +
  • Markdown support
  • +
  • Improved quick search
  • +
+

Translations:

+
    +
  • Dutch (Heimen Stoffels)
  • +
  • Brazilian (Raphael Cabral)
  • +
+
+

New features:

@@ -168,6 +183,6 @@ #ffe16b #000 - 15 + 9 \ No newline at end of file diff --git a/data/com.github.alainm23.planner.gresource.xml b/data/com.github.alainm23.planner.gresource.xml index fda458170..84f42c8b4 100644 --- a/data/com.github.alainm23.planner.gresource.xml +++ b/data/com.github.alainm23.planner.gresource.xml @@ -53,7 +53,8 @@ resources/planner-github.svg resources/planner-repository.svg resources/planner-todoist.svg - + resources/planner-paypal.svg + resources/planner-banana-theme.svg resources/planner-black-theme.svg resources/planner-blueberry-theme.svg diff --git a/data/credits.json b/data/credits.json index 2a6486143..559219760 100644 --- a/data/credits.json +++ b/data/credits.json @@ -73,6 +73,20 @@ "username": "", "avatar": "https://avatars0.githubusercontent.com/u/28876465?s=400&v=4", "profile_url": "https://github.com/welaq" + }, + { + "id": "13441032", + "name": "Raphael Cabral", + "username": "brcmesquita", + "avatar": "https://avatars0.githubusercontent.com/u/13441032?s=400&v=4", + "profile_url": "https://github.com/brcmesquita" + }, + { + "id": "1716229", + "name": "Heimen Stoffels", + "username": "Vistaus", + "avatar": "https://avatars0.githubusercontent.com/u/1716229?s=400&v=4", + "profile_url": "https://github.com/Vistaus" } ], "support" : [ @@ -110,6 +124,13 @@ "username": "", "avatar": "https://avatars3.githubusercontent.com/u/33732772?s=400&v=4", "profile_url": "https://github.com/ArthurS1" + }, + { + "id": "48254041", + "name": "Ilya Egorov", + "username": "ie900", + "avatar": "https://avatars2.githubusercontent.com/u/48254041?s=400&v=4", + "profile_url": "https://github.com/ie900" } ] } diff --git a/data/resources/planner-paypal.svg b/data/resources/planner-paypal.svg new file mode 100644 index 000000000..28eecebfd --- /dev/null +++ b/data/resources/planner-paypal.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/meson.build b/meson.build index 018b1df1c..497466ee2 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('com.github.alainm23.planner', 'vala', 'c', - version: '1.2.1') + version: '1.2.4') gnome = import('gnome') i18n = import('i18n') diff --git a/src/Application.vala b/src/Application.vala index f17eb7081..b45411f70 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -58,7 +58,7 @@ public class Application : Gtk.Application { github = new Services.Github (); share = new Services.Share (); - APP_VERSION = "1.2.3"; + APP_VERSION = "1.2.4"; } public static Application _instance = null; diff --git a/src/Dialogs/PreferencesDialog.vala b/src/Dialogs/PreferencesDialog.vala index 0ee4c16be..8bb848a67 100644 --- a/src/Dialogs/PreferencesDialog.vala +++ b/src/Dialogs/PreferencesDialog.vala @@ -40,6 +40,8 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { private Granite.Widgets.Avatar profile_image; private Gtk.Label username_label; + private string oauth_open_url; + public signal void on_close (); public PreferencesDialog (Gtk.Window parent) { @@ -56,8 +58,10 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { construct { title = _("Preferences"); - height_request = 550; - width_request = 650; + height_request = 500; + width_request = 600; + + oauth_open_url = "https://todoist.com/oauth/authorize?client_id=b0dd7d3714314b1dbbdab9ee03b6b432&scope=data:read&state=XE3K-4BBL-4XLG-UDS8"; var mode_button = new Granite.Widgets.ModeButton (); mode_button.hexpand = true; @@ -89,6 +93,7 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { main_stack.add_named (get_items_widget (), "items"); main_stack.add_named (get_credist_widget (), "credits"); main_stack.add_named (get_todoist_login_widget (), "todoist_login"); + main_stack.add_named (get_support_widget (), "support"); main_stack.visible_child_name = "general"; @@ -141,6 +146,65 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { add_action_widget (close_button, 0); } + private Gtk.Widget get_support_widget () { + var back_button = new Gtk.Button.with_label (_("Back")); + back_button.can_focus = false; + back_button.valign = Gtk.Align.CENTER; + back_button.get_style_context ().add_class (Granite.STYLE_CLASS_BACK_BUTTON); + + var title_label = new Gtk.Label ("%s".printf (_("Support"))); + title_label.use_markup = true; + + var top_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + top_box.margin = 6; + top_box.hexpand = true; + top_box.pack_start (back_button, false, false, 0); + top_box.set_center_widget (title_label); + + var label = new Gtk.Label (_("Thank you very much for using Planner. At the moment the method of payment by AppCenter is not available in my country. If you like Planner and want to support their development, consider donating via:")); + label.get_style_context ().add_class ("h3"); + label.wrap = true; + + var paypal_button = new Gtk.Button.from_icon_name ("planner-paypal", Gtk.IconSize.DIALOG); + paypal_button.can_focus = false; + + var grid = new Gtk.Grid (); + grid.margin = 12; + grid.row_spacing = 12; + grid.orientation = Gtk.Orientation.VERTICAL; + grid.add (label); + grid.add (paypal_button); + + var scrolled = new Gtk.ScrolledWindow (null, null); + scrolled.expand = true; + scrolled.add (grid); + + var main_grid = new Gtk.Grid (); + main_grid.orientation = Gtk.Orientation.VERTICAL; + main_grid.add (top_box); + main_grid.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); + main_grid.add (scrolled); + + var main_frame = new Gtk.Frame (null); + main_frame.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); + main_frame.add (main_grid); + + back_button.clicked.connect (() => { + check_quick_save_preview (); + main_stack.visible_child_name = "about"; + }); + + paypal_button.clicked.connect (() => { + try { + Gtk.show_uri (null, "https://www.paypal.me/alainm23", 1000); + } catch (Error e) { + stderr.printf ("Error open the uri\n"); + } + }); + + return main_frame; + } + private Gtk.Widget get_accounts_widget () { // Github var github_icon = new Gtk.Image (); @@ -195,8 +259,8 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { main_grid.orientation = Gtk.Orientation.VERTICAL; main_grid.add (github_eventbox); - main_grid.add (s_1); - main_grid.add (todoist_eventbox); + //main_grid.add (s_1); + //main_grid.add (todoist_eventbox); main_grid.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); var scrolled = new Gtk.ScrolledWindow (null, null); @@ -221,6 +285,7 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { todoist_eventbox.event.connect ((event) => { if (event.type == Gdk.EventType.BUTTON_PRESS) { main_stack.visible_child_name = "todoist_login"; + webview.load_uri (oauth_open_url); } return false; @@ -254,25 +319,30 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { webview = new WebKit.WebView (); webview.expand = true; - webview.load_uri ("https://todoist.com/oauth/authorize?client_id=b0dd7d3714314b1dbbdab9ee03b6b432&scope=data:read&state=XE3K-4BBL-4XLG-UDS8"); - WebKit.WebContext.get_default ().set_preferred_languages (GLib.Intl.get_language_names ()); - webview.load_changed.connect (on_webview_load); - - /* - webview.load_failed.connect (); - */ - var scrolled = new Gtk.ScrolledWindow (null, null); scrolled.add (webview); + var alert_view = new Granite.Widgets.AlertView ( + _("Network Is Not Available"), + _("Connect to the Internet to connect with Todoist"), + "network-error" + ); + + var stack = new Gtk.Stack (); + stack.expand = true; + stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; + + stack.add_named (scrolled, "web_view"); + stack.add_named (alert_view, "error_view"); + var main_grid = new Gtk.Grid (); main_grid.orientation = Gtk.Orientation.VERTICAL; main_grid.add (header_box); main_grid.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); - main_grid.add (scrolled); + main_grid.add (stack); var main_frame = new Gtk.Frame (null); main_frame.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); @@ -282,37 +352,62 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { main_stack.visible_child_name = "accounts"; }); - return main_frame; - } + webview.load_changed.connect ((load_event) => { + var redirect_uri = webview.get_uri (); - private void on_webview_load (WebKit.LoadEvent load_event) { - var redirect_uri = webview.get_uri (); + //if (redirect_uri == null || !redirect_uri.has_prefix ("https://github.com/alainm23/planner?state=XE3K-4BBL-4XLG-UDS8&code=")) { + if (load_event == WebKit.LoadEvent.FINISHED) { + info_label.label = _("Please enter your credentials…"); + spinner.stop (); + spinner.hide (); + stack.visible_child_name = "web_view"; + + return; + } + //} + + if (load_event == WebKit.LoadEvent.STARTED) { + info_label.label = _("Loading…"); + spinner.start (); + spinner.show (); - - if (load_event == WebKit.LoadEvent.FINISHED) { - info_label.label = _("Please enter your credentials…"); - spinner.stop (); - spinner.hide (); + return; + } - if (redirect_uri.has_prefix ("https://github.com/alainm23/planner?state=XE3K-4BBL-4XLG-UDS8&code=")) { + /* + if (redirect_uri != null || redirect_uri.has_prefix ("https://github.com/alainm23/planner?state=XE3K-4BBL-4XLG-UDS8&code=")) { get_todoist_token (redirect_uri); } - + */ + return; - } + }); - if (load_event == WebKit.LoadEvent.STARTED) { - info_label.label = _("Loading…"); - spinner.start (); - spinner.show (); + webview.load_failed.connect ((load_event, failing_uri, _error) => { + var error = (GLib.Error)_error; + warning ("Loading uri '%s' failed, error : %s", failing_uri, error.message); + if (GLib.strcmp (failing_uri, oauth_open_url) == 0) { + stack.visible_child_name = "error_view"; + } - return; - } - - return; + return true; + }); + + return main_frame; } private void get_todoist_token (string url) { + var message_dialog = new Granite.MessageDialog.with_image_from_icon_name ( + "URL", + url, + "applications-development", + Gtk.ButtonsType.CLOSE + ); + + message_dialog.run (); + message_dialog.destroy (); + + /* string code = url.split ("=") [2]; string response = ""; @@ -330,18 +425,11 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { var root_oa = parser.get_root ().get_object (); var token = root_oa.get_string_member ("access_token"); - var message_dialog = new Granite.MessageDialog.with_image_from_icon_name ( - "Access Token", - token, - "applications-development", - Gtk.ButtonsType.CLOSE - ); - - message_dialog.run (); - message_dialog.destroy (); + Application.todoist.get_user (token); } catch (Error e) { debug (e.message); } + */ } private Gtk.Widget get_github_login_widget () { @@ -478,6 +566,21 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { } private Gtk.Widget get_github_widget () { + var back_button = new Gtk.Button.with_label (_("Back")); + back_button.margin = 6; + back_button.can_focus = false; + back_button.valign = Gtk.Align.CENTER; + back_button.get_style_context ().add_class (Granite.STYLE_CLASS_BACK_BUTTON); + + var title_label = new Gtk.Label ("%s".printf (_("Github Account"))); + title_label.use_markup = true; + + var top_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + top_box.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); + top_box.hexpand = true; + top_box.pack_start (back_button, false, false, 0); + top_box.set_center_widget (title_label); + var user = Application.database.get_user (); var image_path = GLib.Path.build_filename (Application.utils.PROFILE_FOLDER, ("profile-%i.jpg").printf ((int) user.id)); @@ -558,6 +661,8 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { var main_grid = new Gtk.Grid (); main_grid.orientation = Gtk.Orientation.VERTICAL; + main_grid.add (top_box); + main_grid.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); main_grid.add (profile_overlay); main_grid.add (username_label); main_grid.add (subtitle_label); @@ -577,7 +682,7 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { scrolled.add (main_grid); var main_frame = new Gtk.Frame (null); - //main_frame.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); + main_frame.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); main_frame.add (scrolled); Application.database.adden_new_repository.connect ((repo) => { @@ -641,6 +746,10 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { } }); + back_button.clicked.connect (() => { + main_stack.visible_child_name = "accounts"; + }); + return main_frame; } @@ -929,27 +1038,32 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { inbox_check.get_style_context ().add_class ("h3"); inbox_check.margin_start = 12; inbox_check.margin_top = 6; + inbox_check.active = Application.settings.get_boolean ("show-inbox"); var today_check = new Gtk.CheckButton.with_label (_("Today")); today_check.get_style_context ().add_class ("h3"); today_check.margin_start = 12; today_check.margin_top = 3; + today_check.active = Application.settings.get_boolean ("show-today"); var upcoming_check = new Gtk.CheckButton.with_label (_("Upcoming")); upcoming_check.get_style_context ().add_class ("h3"); upcoming_check.margin_start = 12; upcoming_check.margin_top = 3; + upcoming_check.active = Application.settings.get_boolean ("show-upcoming"); var all_tasks_check = new Gtk.CheckButton.with_label (_("All Tasks")); all_tasks_check.get_style_context ().add_class ("h3"); all_tasks_check.margin_start = 12; all_tasks_check.margin_top = 3; + all_tasks_check.active = Application.settings.get_boolean ("show-all-tasks"); var completed_check = new Gtk.CheckButton.with_label (_("Completed Tasks")); completed_check.get_style_context ().add_class ("h3"); completed_check.margin_start = 12; completed_check.margin_top = 3; completed_check.margin_bottom = 6; + completed_check.active = Application.settings.get_boolean ("show-completed-tasks"); var grid = new Gtk.Grid (); grid.orientation = Gtk.Orientation.VERTICAL; @@ -979,6 +1093,26 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { main_stack.visible_child_name = "general"; }); + inbox_check.toggled.connect (() => { + Application.settings.set_boolean ("show-inbox", inbox_check.active); + }); + + today_check.toggled.connect (() => { + Application.settings.set_boolean ("show-today", today_check.active); + }); + + upcoming_check.toggled.connect (() => { + Application.settings.set_boolean ("show-upcoming", upcoming_check.active); + }); + + all_tasks_check.toggled.connect (() => { + Application.settings.set_boolean ("show-all-tasks", all_tasks_check.active); + }); + + completed_check.toggled.connect (() => { + Application.settings.set_boolean ("show-completed-tasks", completed_check.active); + }); + return main_frame; } @@ -1478,10 +1612,11 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { planner_icon.halign = Gtk.Align.CENTER; planner_icon.hexpand = true; - var planner_label = new Gtk.Label ("Planner %s".printf (Application.APP_VERSION)); + var planner_label = new Gtk.Label ("Planner %s".printf ("" + Application.APP_VERSION + "")); planner_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL); planner_label.halign = Gtk.Align.CENTER; planner_label.hexpand = true; + planner_label.use_markup = true; var planner_developer = new Gtk.Label ("Alain M."); planner_developer.margin_bottom = 12; @@ -1492,7 +1627,7 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { // Home Button var home_icon = new Gtk.Image (); - home_icon.gicon = new ThemedIcon ("com.github.alainm23.planner"); + home_icon.gicon = new ThemedIcon ("internet-web-browser"); home_icon.pixel_size = 24; var home_label = new Gtk.Label (_("Home Page")); @@ -1634,6 +1769,7 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { scrolled.add (main_grid); var main_frame = new Gtk.Frame (null); + main_frame.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); main_frame.add (scrolled); home_eventbox.event.connect ((event) => { @@ -1674,11 +1810,7 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { donation_eventbox.event.connect ((event) => { if (event.type == Gdk.EventType.BUTTON_PRESS) { - try { - Gtk.show_uri (null, "https://www.paypal.me/alainm23", 1000); - } catch (Error e) { - stderr.printf ("Error open the uri\n"); - } + main_stack.visible_child_name = "support"; } return false; @@ -1912,8 +2044,8 @@ public class Dialogs.PreferencesDialog : Gtk.Dialog { main_grid.add (s_4); main_grid.add (calendar_eventbox); main_grid.add (s_5); - //main_grid.add (items_eventbox); - //main_grid.add (s_6); + main_grid.add (items_eventbox); + main_grid.add (s_6); main_grid.add (run_background_eventbox); main_grid.add (s_7); main_grid.add (launch_eventbox); @@ -2240,4 +2372,4 @@ public class PerfilRow : Gtk.ListBoxRow { add (box); } -} +} \ No newline at end of file diff --git a/src/Widgets/ProjectsList.vala b/src/Widgets/ProjectsList.vala index 5ea2d9711..a0c60e595 100644 --- a/src/Widgets/ProjectsList.vala +++ b/src/Widgets/ProjectsList.vala @@ -42,19 +42,25 @@ public class Widgets.ProjectsList : Gtk.Grid { inbox_item = new Widgets.ItemRow (_("Inbox"), "planner-inbox", "inbox"); inbox_item.primary_text = Application.database.get_inbox_number ().to_string (); + inbox_item.reveal_child = Application.settings.get_boolean ("show-inbox"); today_item = new Widgets.ItemRow (_("Today"), "planner-today-" + new GLib.DateTime.now_local ().get_day_of_month ().to_string (), "today"); today_item.primary_text = Application.database.get_today_number ().to_string (); + today_item.reveal_child = Application.settings.get_boolean ("show-today"); upcoming_item = new Widgets.ItemRow (_("Upcoming"), "planner-upcoming", "upcoming"); + upcoming_item.primary_text = Application.database.get_upcoming_number ().to_string (); + upcoming_item.reveal_child = Application.settings.get_boolean ("show-upcoming"); all_tasks_item = new Widgets.ItemRow (_("All Tasks"), "user-bookmarks", "all"); all_tasks_item.primary_text = Application.database.get_all_tasks_number ().to_string (); all_tasks_item.reveal_child = false; + all_tasks_item.reveal_child = Application.settings.get_boolean ("show-all-tasks"); completed_item = new Widgets.ItemRow (_("Completed Tasks"), "emblem-default", "completed"); completed_item.primary_text = Application.database.get_completed_number ().to_string (); completed_item.reveal_child = false; + completed_item.reveal_child = Application.settings.get_boolean ("show-completed-tasks"); check_number_labels (); @@ -212,6 +218,20 @@ public class Widgets.ProjectsList : Gtk.Grid { return true; }); }); + + Application.settings.changed.connect (key => { + if (key == "show-inbox") { + inbox_item.reveal_child = Application.settings.get_boolean ("show-inbox"); + } else if (key == "show-today") { + today_item.reveal_child = Application.settings.get_boolean ("show-today"); + } else if (key == "show-upcoming") { + upcoming_item.reveal_child = Application.settings.get_boolean ("show-upcoming"); + } else if (key == "show-all-tasks") { + all_tasks_item.reveal_child = Application.settings.get_boolean ("show-all-tasks"); + } else if (key == "show-completed-tasks") { + completed_item.reveal_child = Application.settings.get_boolean ("show-completed-tasks"); + } + }); } private void check_number_labels () { diff --git a/src/Widgets/TaskNew.vala b/src/Widgets/TaskNew.vala index 5f961a2e6..c300c3ce2 100644 --- a/src/Widgets/TaskNew.vala +++ b/src/Widgets/TaskNew.vala @@ -29,6 +29,8 @@ public class Widgets.TaskNew : Gtk.Revealer { public bool is_inbox { get; construct; } public int project_id { get; construct; } + + private Objects.Task task; public GLib.DateTime when_datetime { set { when_button.set_date (value, false, new GLib.DateTime.now_local ()); @@ -48,6 +50,8 @@ public class Widgets.TaskNew : Gtk.Revealer { } construct { + task = new Objects.Task (); + name_entry = new Gtk.Entry (); name_entry.margin_start = 12; name_entry.margin_end = 6; @@ -67,18 +71,93 @@ public class Widgets.TaskNew : Gtk.Revealer { close_button.valign = Gtk.Align.START; close_button.halign = Gtk.Align.START; - note_view = new Gtk.TextView (); - note_view.opacity = 0.7; - note_view.margin_start = 15; - note_view.margin_end = 12; + /* Note */ + var source_buffer = new Gtk.SourceBuffer (null); + source_buffer.highlight_syntax = true; + source_buffer.language = Gtk.SourceLanguageManager.get_default ().get_language ("markdown"); + + if (Application.settings.get_boolean ("prefer-dark-style")) { + source_buffer.style_scheme = new Gtk.SourceStyleSchemeManager ().get_scheme ("solarized-dark"); + } else { + source_buffer.style_scheme = new Gtk.SourceStyleSchemeManager ().get_scheme ("solarized-light"); + } + + Application.settings.changed.connect ((key) => { + if (key == "prefer-dark-style") { + if (Application.settings.get_boolean ("prefer-dark-style")) { + source_buffer.style_scheme = new Gtk.SourceStyleSchemeManager ().get_scheme ("solarized-dark"); + } else { + source_buffer.style_scheme = new Gtk.SourceStyleSchemeManager ().get_scheme ("solarized-light"); + } + } + }); + + note_view = new Gtk.SourceView (); + note_view.expand = true; + note_view.wrap_mode = Gtk.WrapMode.WORD; note_view.height_request = 50; - note_view.set_wrap_mode (Gtk.WrapMode.WORD_CHAR); - note_view.get_style_context ().add_class ("note-view"); + note_view.margin_start = 12; + note_view.margin_top = 6; + note_view.margin_end = 12; + note_view.monospace = true; + note_view.buffer = source_buffer; + note_view.get_style_context ().add_class ("note-view"); + var note_view_placeholder_label = new Gtk.Label (_("Note")); note_view_placeholder_label.opacity = 0.65; note_view.add (note_view_placeholder_label); + if (note_view.buffer.text != "") { + note_view_placeholder_label.visible = false; + note_view_placeholder_label.no_show_all = true; + } + + var note_eventbox = new Gtk.EventBox (); + note_eventbox.add (note_view); + + /* + var preview_view = new Gtk.ScrolledWindow (null, null); + preview_view.expand = true; + + var preview_view_content = new Widgets.WebView (task); + preview_view.add (preview_view_content); + + var note_stack = new Gtk.Stack (); + note_stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; + note_stack.expand = true; + + note_stack.add_named (note_eventbox, "note_edit"); + note_stack.add_named (preview_view, "note_view"); + + var mode_button = new Granite.Widgets.ModeButton (); + mode_button.get_style_context ().add_class ("format-bar"); + mode_button.hexpand = true; + mode_button.margin_end = 24; + mode_button.halign = Gtk.Align.END; + mode_button.valign = Gtk.Align.START; + + mode_button.append_icon ("planner-text-symbolic", Gtk.IconSize.MENU); + mode_button.append_icon ("planner-markdown-symbolic", Gtk.IconSize.MENU); + + mode_button.selected = 0; + + var note_view_overlay = new Gtk.Overlay (); + note_view_overlay.add_overlay (mode_button); + note_view_overlay.add (note_stack); + + mode_button.mode_changed.connect ((widget) => { + if (mode_button.selected == 0) { + note_stack.visible_child_name = "note_edit"; + preview_view.height_request = -1; + } else if (mode_button.selected == 1){ + preview_view.height_request = 200; + preview_view_content.update_note (note_view.buffer.text); + note_stack.visible_child_name = "note_view"; + } + }); + */ + checklist = new Gtk.ListBox (); checklist.activate_on_single_click = true; checklist.get_style_context ().add_class ("view"); @@ -145,7 +224,7 @@ public class Widgets.TaskNew : Gtk.Revealer { main_grid.orientation = Gtk.Orientation.VERTICAL; main_grid.add (name_entry); - main_grid.add (note_view); + main_grid.add (note_eventbox); main_grid.add (checklist_grid); main_grid.add (labels_flowbox_revealer); main_grid.add (bottom_box); @@ -289,8 +368,6 @@ public class Widgets.TaskNew : Gtk.Revealer { private void add_task () { if (name_entry.text != "") { - var task = new Objects.Task (); - task.project_id = project_id; task.content = name_entry.text; task.note = note_view.buffer.text; @@ -363,4 +440,4 @@ public class Widgets.TaskNew : Gtk.Revealer { } } } -} +} \ No newline at end of file diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 8755d0d56..2ad0f97af 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -52,7 +52,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { private Gtk.ListBox checklist; private Gtk.Box top_box; - //private Gtk.Revealer remove_revealer; + private Gtk.Revealer remove_revealer; private Gtk.Revealer close_revealer; public Gtk.Box project_box; @@ -229,8 +229,8 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { note_view.margin_end = 12; note_view.monospace = true; note_view.buffer = source_buffer; - note_view.get_style_context ().add_class ("note-view"); + note_view_placeholder_label = new Gtk.Label (_("Note")); note_view_placeholder_label.opacity = 0.65; note_view.add (note_view_placeholder_label); @@ -241,8 +241,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { } var note_scrolled = new Gtk.ScrolledWindow (null, null); - note_scrolled.min_content_height = 200; - note_scrolled.max_content_height = 200; + note_scrolled.vscrollbar_policy = Gtk.PolicyType.NEVER; note_scrolled.add (note_view); var note_eventbox = new Gtk.EventBox (); @@ -342,13 +341,11 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { } when_button = new Widgets.WhenButton (); - if (task.when_date_utc.length != 0) { - when_button.set_date ( - new GLib.DateTime.from_iso8601 (task.when_date_utc, new GLib.TimeZone.local ()), - has_reminder, - new GLib.DateTime.from_iso8601 (task.reminder_time, new GLib.TimeZone.local ()) - ); - } + when_button.set_date ( + new GLib.DateTime.from_iso8601 (task.when_date_utc, new GLib.TimeZone.local ()), + has_reminder, + new GLib.DateTime.from_iso8601 (task.reminder_time, new GLib.TimeZone.local ()) + ); var labels = new Widgets.LabelButton (); @@ -514,7 +511,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { close_button.clicked.connect (() => { close_revealer.reveal_child = false; - //remove_revealer.reveal_child = false; + remove_revealer.reveal_child = false; check_task_completed (); hide_content (); @@ -562,7 +559,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { remove_button.clicked.connect (() => { close_revealer.reveal_child = false; - //remove_revealer.reveal_child = false; + remove_revealer.reveal_child = false; var message_dialog = new Granite.MessageDialog.with_image_from_icon_name ( _("Are you sure you want to delete this task?"), @@ -642,7 +639,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { main_eventbox.enter_notify_event.connect ((event) => { if (bottom_box_revealer.reveal_child == true) { close_revealer.reveal_child = true; - //remove_revealer.reveal_child = true; + remove_revealer.reveal_child = true; } return false; @@ -654,7 +651,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { } close_revealer.reveal_child = false; - //remove_revealer.reveal_child = false; + remove_revealer.reveal_child = false; return false; }); @@ -759,20 +756,18 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { string[] checklist_array = task.checklist.split (";"); foreach (string str in checklist_array) { - if (str.length > 0) { - string check_name = str.substring (1, -1); - bool check_active = false; + string check_name = str.substring (1, -1); + bool check_active = false; - if (str.length > 0 && str.substring (0, 1) == "0") { - check_active = false; - } else { - check_active = true; - } + if (str.substring (0, 1) == "0") { + check_active = false; + } else { + check_active = true; + } - var row = new Widgets.CheckRow (check_name, check_active); + var row = new Widgets.CheckRow (check_name, check_active); - checklist.add (row); - } + checklist.add (row); } checklist.show_all (); @@ -826,7 +821,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { int completed = 0; foreach (string str in checklist_array) { - if (str.length > 0 && str.substring (0, 1) == "1") { + if (str.substring (0, 1) == "1") { completed = completed + 1; } @@ -903,7 +898,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { main_grid.margin_start = 5; top_box.margin_top = 6; top_box.margin_start = 12; - //project_box.margin_end = 6; + project_box.margin_end = 6; name_entry.visible = true; name_eventbox.visible = false; @@ -922,7 +917,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { main_grid.margin_start = 0; top_box.margin_top = 0; top_box.margin_start = 0; - //project_box.margin_end = 0; + project_box.margin_end = 0; name_entry.visible = false; name_eventbox.visible = true; @@ -998,13 +993,11 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { has_reminder = true; } - if (task.when_date_utc.length != 0) { - when_button.set_date ( - new GLib.DateTime.from_iso8601 (task.when_date_utc, new GLib.TimeZone.local ()), - has_reminder, - new GLib.DateTime.from_iso8601 (task.reminder_time, new GLib.TimeZone.local ()) - ); - } + when_button.set_date ( + new GLib.DateTime.from_iso8601 (task.when_date_utc, new GLib.TimeZone.local ()), + has_reminder, + new GLib.DateTime.from_iso8601 (task.reminder_time, new GLib.TimeZone.local ()) + ); check_note_preview_icon (); check_checklist_progress (); @@ -1050,7 +1043,7 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { when_preview_label.no_show_all = true; } - if (when_button.reminder_datetime != null && when_button.reminder_datetime.to_string () != task.reminder_time) { + if (when_button.reminder_datetime.to_string () != task.reminder_time) { task.was_notified = 0; if (when_button.has_reminder) { @@ -1118,4 +1111,4 @@ public class Widgets.TaskRow : Gtk.ListBoxRow { show_all (); } } - } + } \ No newline at end of file